comparison plugins/docklet/docklet.c @ 6894:c2fb9192377b

[gaim-migrate @ 7441] robot101: instead of blinking between the one with the envelope, and the one without, it's going to blink between blank and the one with the envelope committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Fri, 19 Sep 2003 23:18:40 +0000
parents 70d5122bc3ff
children 567991b90cee
comparison
equal deleted inserted replaced
6893:126e123bf065 6894:c2fb9192377b
82 { 82 {
83 gaim_accounts_auto_login(GAIM_GTK_UI); 83 gaim_accounts_auto_login(GAIM_GTK_UI);
84 } 84 }
85 85
86 #ifdef _WIN32 86 #ifdef _WIN32
87 /* This is a workaround for a bug in windows GTK+.. Clicking outside of the 87 /* This is a workaround for a bug in windows GTK+. Clicking outside of the
88 menu does not get rid of it, so instead we get rid of it as soon as the 88 menu does not get rid of it, so instead we get rid of it as soon as the
89 pointer leaves the menu. */ 89 pointer leaves the menu. */
90 static gboolean 90 static gboolean
91 docklet_menu_leave(GtkWidget *menu, GdkEventCrossing *event, void *data) 91 docklet_menu_leave(GtkWidget *menu, GdkEventCrossing *event, void *data)
92 { 92 {
195 195
196 static gboolean 196 static gboolean
197 docklet_blink_icon() 197 docklet_blink_icon()
198 { 198 {
199 static gboolean blinked = FALSE; 199 static gboolean blinked = FALSE;
200 enum docklet_status icon = status;
201 200
202 blinked = !blinked; 201 blinked = !blinked;
203 202
204 if (status == online_pending) { 203 switch (status) {
205 if (blinked) { 204 case online_pending:
206 /* last icon was the right one... let's change it */ 205 case away_pending:
207 icon = online; 206 if (blinked) {
208 } else { 207 if (ui_ops && ui_ops->blank_icon)
209 /* last icon was the wrong one, change it back */ 208 ui_ops->blank_icon();
210 icon = online_pending; 209 } else {
211 } 210 if (ui_ops && ui_ops->update_icon)
212 } else if (status == away_pending) { 211 ui_ops->update_icon(status);
213 if (blinked) { 212 }
214 /* last icon was the right one... let's change it */ 213 return TRUE; /* keep blinking */
215 icon = away; 214 break;
216 } else { 215 case offline:
217 /* last icon was the wrong one, change it back */ 216 case offline_connecting:
218 icon = away_pending; 217 case online:
219 } 218 case online_connecting:
220 } else { 219 case away:
221 /* no messages, stop blinking */ 220 blinked = FALSE;
222 blinked = FALSE; 221 return FALSE; /* no more blinking */
223 return FALSE; 222 break;
224 } 223 }
225
226 if (ui_ops->update_icon)
227 ui_ops->update_icon(icon);
228
229 return TRUE; /* keep blinking */
230 } 224 }
231 225
232 static gboolean 226 static gboolean
233 docklet_update_status() 227 docklet_update_status()
234 { 228 {
258 } 252 }
259 } 253 }
260 254
261 /* update the icon if we changed status */ 255 /* update the icon if we changed status */
262 if (status != oldstatus) { 256 if (status != oldstatus) {
263 if (ui_ops->update_icon) 257 if (ui_ops && ui_ops->update_icon)
264 ui_ops->update_icon(status); 258 ui_ops->update_icon(status);
265 259
266 /* and schedule the blinker function if messages are pending */ 260 /* and schedule the blinker function if messages are pending */
267 if (status == online_pending || status == away_pending) { 261 if (status == online_pending || status == away_pending) {
268 g_timeout_add(500, docklet_blink_icon, &handle); 262 g_timeout_add(500, docklet_blink_icon, &handle);
325 docklet_embedded() 319 docklet_embedded()
326 { 320 {
327 gaim_gtk_blist_docklet_add(); 321 gaim_gtk_blist_docklet_add();
328 322
329 docklet_update_status(); 323 docklet_update_status();
330 if (ui_ops->update_icon) 324 if (ui_ops && ui_ops->update_icon)
331 ui_ops->update_icon(status); 325 ui_ops->update_icon(status);
332 } 326 }
333 327
334 void 328 void
335 docklet_remove(gboolean visible) 329 docklet_remove(gboolean visible)
426 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin loaded\n"); 420 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin loaded\n");
427 421
428 handle = plugin; 422 handle = plugin;
429 423
430 docklet_ui_init(); 424 docklet_ui_init();
431 if (ui_ops->create) 425 if (ui_ops && ui_ops->create)
432 ui_ops->create(); 426 ui_ops->create();
433 427
434 gaim_signal_connect(conn_handle, "signed-on", 428 gaim_signal_connect(conn_handle, "signed-on",
435 plugin, GAIM_CALLBACK(gaim_signon), NULL); 429 plugin, GAIM_CALLBACK(gaim_signon), NULL);
436 gaim_signal_connect(conn_handle, "signed-off", 430 gaim_signal_connect(conn_handle, "signed-off",
453 } 447 }
454 448
455 static gboolean 449 static gboolean
456 plugin_unload(GaimPlugin *plugin) 450 plugin_unload(GaimPlugin *plugin)
457 { 451 {
458 if (ui_ops->destroy) 452 if (ui_ops && ui_ops->destroy)
459 ui_ops->destroy(); 453 ui_ops->destroy();
460 454
461 /* XXX: do this while gaim has no other way to toggle the global mute */ 455 /* XXX: do this while gaim has no other way to toggle the global mute */
462 gaim_gtk_sound_set_mute(FALSE); 456 gaim_gtk_sound_set_mute(FALSE);
463 457