Skip to content

Commit 0e8e525

Browse files
committed
make logo
1 parent afa279e commit 0e8e525

29 files changed

+107
-56
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,6 @@
104104
"xtree": "cpp",
105105
"xutility": "cpp",
106106
"*.ipp": "cpp"
107-
}
107+
},
108+
"svg.preview.background": "transparent"
108109
}

libsimbolmudah/src/notify_icon/internal.rs

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -64,57 +64,45 @@ impl NotifyIconInternal {
6464
parent: Weak<bindings::NotifyIcon>,
6565
hookenabled: bool,
6666
) -> Result<()> {
67-
let internal_id = GLOBAL_COUNTER.next();
68-
let h_wnd = MessageWindow::new(w!("LibSimbolMudah.NotifyIcon"), Some(notify_proc))?;
69-
let h_menu = NotifyIconMenu::new(hookenabled)?;
70-
71-
let res = Self {
72-
h_wnd,
73-
internal_id,
74-
h_icon: unsafe { LoadIconW(None, IDI_WARNING) }?,
75-
h_menu: Some(h_menu),
76-
report_open_settings: DelegateStorage::new(),
77-
report_exit_app: DelegateStorage::new(),
78-
report_set_listening: DelegateStorage::new(),
79-
on_state_changed_token: EventRegistrationToken::default(),
80-
parent,
81-
};
82-
83-
res.register_notify_icon(hookenabled)?;
84-
67+
let res = Self::new(hookenabled, parent)?;
8568
INTERNAL_NOTIFYICON.set(Some(res));
8669
Ok(())
8770
}
8871

89-
fn register_notify_icon(&self, listening: bool) -> Result<()> {
72+
fn new(listening: bool, parent: Weak<bindings::NotifyIcon>) -> Result<Self> {
73+
let internal_id = GLOBAL_COUNTER.next();
74+
let h_wnd = MessageWindow::new(w!("LibSimbolMudah.NotifyIcon"), Some(notify_proc))?;
75+
let h_menu = NotifyIconMenu::new(listening)?;
76+
let h_icon = unsafe { LoadIconW(None, IDI_WARNING) }?;
77+
9078
let nid = NOTIFYICONDATAW {
9179
cbSize: std::mem::size_of::<NOTIFYICONDATAW>() as u32,
92-
hWnd: self.h_wnd.handle(),
93-
uID: self.internal_id,
80+
hWnd: h_wnd.handle(),
81+
uID: internal_id,
9482
uFlags: NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_SHOWTIP,
9583
uCallbackMessage: WM_USER_TRAYICON,
96-
hIcon: self.h_icon,
84+
hIcon: h_icon,
9785
szTip: get_tooltip(listening),
9886
Anonymous: NOTIFYICONDATAW_0 {
9987
uVersion: NOTIFYICON_VERSION_4,
10088
},
10189
..Default::default()
10290
};
10391

104-
if unsafe { Shell_NotifyIconW(NIM_ADD, &nid) }.into() {
105-
if unsafe { Shell_NotifyIconW(NIM_SETVERSION, &nid) }.into() {
106-
Ok(())
107-
} else {
108-
let _ = unsafe { Shell_NotifyIconW(NIM_DELETE, &nid) };
109-
Err(fail_message(
110-
"Failed to set notify icon version, deleting icon (Shell_NotifyIconW)",
111-
))
112-
}
113-
} else {
114-
Err(fail_message(
115-
"Failed to register notify icon (Shell_NotifyIconW)",
116-
))
117-
}
92+
unsafe { Shell_NotifyIconW(NIM_ADD, &nid) }.ok()?;
93+
unsafe { Shell_NotifyIconW(NIM_SETVERSION, &nid) }.ok()?;
94+
95+
Ok(Self {
96+
h_wnd,
97+
internal_id,
98+
h_icon,
99+
h_menu: Some(h_menu),
100+
report_open_settings: DelegateStorage::new(),
101+
report_exit_app: DelegateStorage::new(),
102+
report_set_listening: DelegateStorage::new(),
103+
on_state_changed_token: EventRegistrationToken::default(),
104+
parent,
105+
})
118106
}
119107

120108
fn update_notify_icon(&self, listening: bool) -> Result<()> {
@@ -150,13 +138,7 @@ impl NotifyIconInternal {
150138
..Default::default()
151139
};
152140

153-
if unsafe { Shell_NotifyIconW(NIM_DELETE, &nid) }.into() {
154-
Ok(())
155-
} else {
156-
Err(fail_message(
157-
"Failed to remove notify icon (Shell_NotifyIconW)",
158-
))
159-
}
141+
unsafe { Shell_NotifyIconW(NIM_DELETE, &nid) }.ok()
160142
}
161143

162144
pub(super) fn update_listening_check(&mut self, listening: bool) -> Result<()> {
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)