Mercurial > pidgin
comparison plugins/docklet/docklet.c @ 6211:9fd7716068d9
[gaim-migrate @ 6697]
robot101: fairly self-explanatory
robot101: less retarded blinking code, and stop blinking correctly when away/all queues are cleared
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Fri, 18 Jul 2003 04:46:39 +0000 |
parents | 3e3ee3cba192 |
children | 6b95da075de9 |
comparison
equal
deleted
inserted
replaced
6210:a5b8abff6461 | 6211:9fd7716068d9 |
---|---|
52 /* globals */ | 52 /* globals */ |
53 | 53 |
54 GaimPlugin *handle = NULL; | 54 GaimPlugin *handle = NULL; |
55 static struct docklet_ui_ops *ui_ops = NULL; | 55 static struct docklet_ui_ops *ui_ops = NULL; |
56 static enum docklet_status status = offline; | 56 static enum docklet_status status = offline; |
57 static enum docklet_status icon = offline; | |
58 #ifdef _WIN32 | 57 #ifdef _WIN32 |
59 __declspec(dllimport) GSList *unread_message_queue; | 58 __declspec(dllimport) GSList *unread_message_queue; |
60 __declspec(dllimport) GSList *away_messages; | 59 __declspec(dllimport) GSList *away_messages; |
61 __declspec(dllimport) struct away_message *awaymessage; | 60 __declspec(dllimport) struct away_message *awaymessage; |
62 __declspec(dllimport) GSList *message_queue; | 61 __declspec(dllimport) GSList *message_queue; |
193 } | 192 } |
194 | 193 |
195 static gboolean | 194 static gboolean |
196 docklet_blink_icon() | 195 docklet_blink_icon() |
197 { | 196 { |
197 static gboolean blinked = FALSE; | |
198 enum docklet_status icon = status; | |
199 | |
200 blinked = !blinked; | |
201 | |
198 if (status == online_pending) { | 202 if (status == online_pending) { |
199 if (status == icon) { | 203 if (blinked) { |
200 /* last icon was the right one... let's change it */ | 204 /* last icon was the right one... let's change it */ |
201 icon = online; | 205 icon = online; |
202 } else { | 206 } else { |
203 /* last icon was the wrong one, change it back */ | 207 /* last icon was the wrong one, change it back */ |
204 icon = online_pending; | 208 icon = online_pending; |
205 } | 209 } |
206 } else if (status == away_pending) { | 210 } else if (status == away_pending) { |
207 if (status == icon) { | 211 if (blinked) { |
208 /* last icon was the right one... let's change it */ | 212 /* last icon was the right one... let's change it */ |
209 icon = away; | 213 icon = away; |
210 } else { | 214 } else { |
211 /* last icon was the wrong one, change it back */ | 215 /* last icon was the wrong one, change it back */ |
212 icon = away_pending; | 216 icon = away_pending; |
213 } | 217 } |
214 } else { | 218 } else { |
215 /* no messages, stop blinking */ | 219 /* no messages, stop blinking */ |
220 blinked = FALSE; | |
216 return FALSE; | 221 return FALSE; |
217 } | 222 } |
218 | 223 |
219 if (ui_ops->update_icon) | 224 if (ui_ops->update_icon) |
220 ui_ops->update_icon(icon); | 225 ui_ops->update_icon(icon); |
251 } | 256 } |
252 } | 257 } |
253 | 258 |
254 /* update the icon if we changed status */ | 259 /* update the icon if we changed status */ |
255 if (status != oldstatus) { | 260 if (status != oldstatus) { |
256 icon = status; | |
257 if (ui_ops->update_icon) | 261 if (ui_ops->update_icon) |
258 ui_ops->update_icon(icon); | 262 ui_ops->update_icon(status); |
259 | 263 |
260 /* and schedule the blinker function if messages are pending */ | 264 /* and schedule the blinker function if messages are pending */ |
261 if (status == online_pending || status == away_pending) { | 265 if (status == online_pending || status == away_pending) { |
262 g_timeout_add(500, docklet_blink_icon, NULL); | 266 g_timeout_add(500, docklet_blink_icon, NULL); |
263 } | 267 } |
293 { | 297 { |
294 switch (button_type) { | 298 switch (button_type) { |
295 case 1: | 299 case 1: |
296 if (unread_message_queue) { | 300 if (unread_message_queue) { |
297 docklet_flush_queue(); | 301 docklet_flush_queue(); |
298 g_idle_add(docklet_update_status, &handle); | |
299 } else { | 302 } else { |
300 gaim_gtk_blist_docklet_toggle(); | 303 gaim_gtk_blist_docklet_toggle(); |
301 } | 304 } |
302 break; | 305 break; |
303 case 2: | 306 case 2: |
321 { | 324 { |
322 gaim_gtk_blist_docklet_add(); | 325 gaim_gtk_blist_docklet_add(); |
323 | 326 |
324 docklet_update_status(); | 327 docklet_update_status(); |
325 if (ui_ops->update_icon) | 328 if (ui_ops->update_icon) |
326 ui_ops->update_icon(icon); | 329 ui_ops->update_icon(status); |
327 } | 330 } |
328 | 331 |
329 void | 332 void |
330 docklet_remove(gboolean visible) | 333 docklet_remove(gboolean visible) |
331 { | 334 { |
382 do this when idle so that all message processing is completed, queuing | 385 do this when idle so that all message processing is completed, queuing |
383 etc, before we run. */ | 386 etc, before we run. */ |
384 g_idle_add(docklet_update_status, &handle); | 387 g_idle_add(docklet_update_status, &handle); |
385 } | 388 } |
386 | 389 |
390 static void | |
391 gaim_new_conversation(char *who, void *data) | |
392 { | |
393 /* queue a callback here so if the queue is being | |
394 flushed, we stop flashing. thanks javabsp. */ | |
395 g_idle_add(docklet_update_status, &handle); | |
396 } | |
397 | |
387 /* static void gaim_buddy_signon(GaimConnection *gc, char *who, void *data) { | 398 /* static void gaim_buddy_signon(GaimConnection *gc, char *who, void *data) { |
388 } | 399 } |
389 | 400 |
390 static void gaim_buddy_signoff(GaimConnection *gc, char *who, void *data) { | 401 static void gaim_buddy_signoff(GaimConnection *gc, char *who, void *data) { |
391 } | 402 } |
392 | 403 |
393 static void gaim_buddy_away(GaimConnection *gc, char *who, void *data) { | 404 static void gaim_buddy_away(GaimConnection *gc, char *who, void *data) { |
394 } | 405 } |
395 | 406 |
396 static void gaim_buddy_back(GaimConnection *gc, char *who, void *data) { | 407 static void gaim_buddy_back(GaimConnection *gc, char *who, void *data) { |
397 } | |
398 | |
399 static void gaim_new_conversation(char *who, void *data) { | |
400 } */ | 408 } */ |
401 | 409 |
402 /* plugin glue */ | 410 /* plugin glue */ |
403 | 411 |
404 #define DOCKLET_PLUGIN_ID "gtk-docklet" | 412 #define DOCKLET_PLUGIN_ID "gtk-docklet" |
417 gaim_signal_connect(plugin, event_signon, gaim_signon, NULL); | 425 gaim_signal_connect(plugin, event_signon, gaim_signon, NULL); |
418 gaim_signal_connect(plugin, event_signoff, gaim_signoff, NULL); | 426 gaim_signal_connect(plugin, event_signoff, gaim_signoff, NULL); |
419 gaim_signal_connect(plugin, event_connecting, gaim_connecting, NULL); | 427 gaim_signal_connect(plugin, event_connecting, gaim_connecting, NULL); |
420 gaim_signal_connect(plugin, event_away, gaim_away, NULL); | 428 gaim_signal_connect(plugin, event_away, gaim_away, NULL); |
421 gaim_signal_connect(plugin, event_im_recv, gaim_im_recv, NULL); | 429 gaim_signal_connect(plugin, event_im_recv, gaim_im_recv, NULL); |
430 gaim_signal_connect(plugin, event_new_conversation, gaim_new_conversation, NULL); | |
422 /* gaim_signal_connect(plugin, event_buddy_signon, gaim_buddy_signon, NULL); | 431 /* gaim_signal_connect(plugin, event_buddy_signon, gaim_buddy_signon, NULL); |
423 gaim_signal_connect(plugin, event_buddy_signoff, gaim_buddy_signoff, NULL); | 432 gaim_signal_connect(plugin, event_buddy_signoff, gaim_buddy_signoff, NULL); |
424 gaim_signal_connect(plugin, event_buddy_away, gaim_buddy_away, NULL); | 433 gaim_signal_connect(plugin, event_buddy_away, gaim_buddy_away, NULL); |
425 gaim_signal_connect(plugin, event_buddy_back, gaim_buddy_back, NULL); | 434 gaim_signal_connect(plugin, event_buddy_back, gaim_buddy_back, NULL); */ |
426 gaim_signal_connect(plugin, event_new_conversation, gaim_new_conversation, NULL); */ | |
427 | 435 |
428 gaim_prefs_add_none("/plugins/gtk/docklet"); | 436 gaim_prefs_add_none("/plugins/gtk/docklet"); |
429 gaim_prefs_add_bool("/plugins/gtk/docklet/queue_messages", FALSE); | 437 gaim_prefs_add_bool("/plugins/gtk/docklet/queue_messages", FALSE); |
430 | 438 |
431 return TRUE; | 439 return TRUE; |
437 if (ui_ops->destroy) | 445 if (ui_ops->destroy) |
438 ui_ops->destroy(); | 446 ui_ops->destroy(); |
439 | 447 |
440 /* XXX: do this while gaim has no other way to toggle the global mute */ | 448 /* XXX: do this while gaim has no other way to toggle the global mute */ |
441 gaim_gtk_sound_set_mute(FALSE); | 449 gaim_gtk_sound_set_mute(FALSE); |
450 | |
442 docklet_remove_callbacks(); | 451 docklet_remove_callbacks(); |
443 | 452 |
444 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin unloaded\n"); | 453 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "plugin unloaded\n"); |
445 | 454 |
446 return TRUE; | 455 return TRUE; |