pidgin/gtkdocklet.c

changeset 15731
3819e5d5eeae
parent 15692
ecda27df58b9
child 15760
209681319cac
equal deleted inserted replaced
15730:428df7fada87 15731:3819e5d5eeae
65 gboolean ret = FALSE; /* by default, don't keep blinking */ 65 gboolean ret = FALSE; /* by default, don't keep blinking */
66 66
67 blinked = !blinked; 67 blinked = !blinked;
68 68
69 switch (status) { 69 switch (status) {
70 case DOCKLET_STATUS_ONLINE_PENDING: 70 case DOCKLET_STATUS_PENDING:
71 case DOCKLET_STATUS_AWAY_PENDING:
72 if (blinked) { 71 if (blinked) {
73 if (ui_ops && ui_ops->blank_icon) 72 if (ui_ops && ui_ops->blank_icon)
74 ui_ops->blank_icon(); 73 ui_ops->blank_icon();
75 } else { 74 } else {
76 if (ui_ops && ui_ops->update_icon) 75 if (ui_ops && ui_ops->update_icon)
112 static gboolean 111 static gboolean
113 docklet_update_status() 112 docklet_update_status()
114 { 113 {
115 GList *convs, *l; 114 GList *convs, *l;
116 int count; 115 int count;
116 GaimSavedStatus *saved_status;
117 GaimStatusPrimitive prim;
117 DockletStatus newstatus = DOCKLET_STATUS_OFFLINE; 118 DockletStatus newstatus = DOCKLET_STATUS_OFFLINE;
118 gboolean pending = FALSE; 119 gboolean pending = FALSE, connecting = FALSE;
119 120
120 /* determine if any ims have unseen messages */ 121 /* determine if any ims have unseen messages */
121 convs = get_pending_list(DOCKLET_TOOLTIP_LINE_LIMIT); 122 convs = get_pending_list(DOCKLET_TOOLTIP_LINE_LIMIT);
122 123
123 if (!strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"), "pending")) { 124 if (!strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"), "pending")) {
168 169
169 } else if (ui_ops->set_tooltip) { 170 } else if (ui_ops->set_tooltip) {
170 ui_ops->set_tooltip(NULL); 171 ui_ops->set_tooltip(NULL);
171 } 172 }
172 173
173 /* iterate through all accounts and determine which
174 * status to show in the tray icon based on the following
175 * ranks (highest encountered rank will be used):
176 *
177 * 1) OFFLINE
178 * 2) ONLINE
179 * 3) ONLINE_PENDING
180 * 4) AWAY
181 * 5) AWAY_PENDING
182 * 6) CONNECTING
183 */
184 for(l = gaim_accounts_get_all(); l != NULL; l = l->next) { 174 for(l = gaim_accounts_get_all(); l != NULL; l = l->next) {
185 DockletStatus tmpstatus = DOCKLET_STATUS_OFFLINE;
186 175
187 GaimAccount *account = (GaimAccount*)l->data; 176 GaimAccount *account = (GaimAccount*)l->data;
188 GaimStatus *account_status; 177 GaimStatus *account_status;
189 178
190 if (!gaim_account_get_enabled(account, PIDGIN_UI)) 179 if (!gaim_account_get_enabled(account, PIDGIN_UI))
192 181
193 if (gaim_account_is_disconnected(account)) 182 if (gaim_account_is_disconnected(account))
194 continue; 183 continue;
195 184
196 account_status = gaim_account_get_active_status(account); 185 account_status = gaim_account_get_active_status(account);
197 186 if (gaim_account_is_connecting(account))
198 if (gaim_account_is_connecting(account)) { 187 connecting = TRUE;
199 tmpstatus = DOCKLET_STATUS_CONNECTING; 188 }
200 } else if (gaim_status_is_online(account_status)) { 189
201 if (!gaim_status_is_available(account_status)) { 190 saved_status = gaim_savedstatus_get_current();
202 if (pending) 191 prim = gaim_savedstatus_get_type(saved_status);
203 tmpstatus = DOCKLET_STATUS_AWAY_PENDING; 192
204 else 193 if (connecting)
205 tmpstatus = DOCKLET_STATUS_AWAY; 194 newstatus = DOCKLET_STATUS_CONNECTING;
206 } 195 else if (prim == GAIM_STATUS_UNAVAILABLE)
207 else { 196 newstatus = DOCKLET_STATUS_BUSY;
208 if (pending) 197 else if (prim == GAIM_STATUS_AWAY)
209 tmpstatus = DOCKLET_STATUS_ONLINE_PENDING; 198 newstatus = DOCKLET_STATUS_AWAY;
210 else 199 else if (prim == GAIM_STATUS_EXTENDED_AWAY)
211 tmpstatus = DOCKLET_STATUS_ONLINE; 200 newstatus = DOCKLET_STATUS_XA;
212 } 201 else if (prim == GAIM_STATUS_OFFLINE)
213 } 202 newstatus = DOCKLET_STATUS_OFFLINE;
214 203 else
215 if (tmpstatus > newstatus) 204 newstatus = DOCKLET_STATUS_AVAILABLE;
216 newstatus = tmpstatus; 205
217 }
218
219 /* update the icon if we changed status */ 206 /* update the icon if we changed status */
220 if (status != newstatus) { 207 if (status != newstatus) {
221 status = newstatus; 208 status = newstatus;
222 209
223 if (ui_ops && ui_ops->update_icon) 210 if (ui_ops && ui_ops->update_icon)
224 ui_ops->update_icon(status); 211 ui_ops->update_icon(status);
225 212
226 /* and schedule the blinker function if messages are pending */ 213 /* and schedule the blinker function if messages are pending */
227 if (gaim_prefs_get_bool("/gaim/gtk/docklet/blink") && 214 if (gaim_prefs_get_bool("/gaim/gtk/docklet/blink") &&
228 (status == DOCKLET_STATUS_ONLINE_PENDING 215 status == DOCKLET_STATUS_PENDING
229 || status == DOCKLET_STATUS_AWAY_PENDING)
230 && docklet_blinking_timer == 0) { 216 && docklet_blinking_timer == 0) {
231 docklet_blinking_timer = g_timeout_add(500, docklet_blink_icon, NULL); 217 docklet_blinking_timer = g_timeout_add(500, docklet_blink_icon, NULL);
232 } 218 }
233 } 219 }
234 220
510 g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blist), NULL); 496 g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blist), NULL);
511 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); 497 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
512 498
513 menuitem = gtk_menu_item_new_with_label(_("Unread Messages")); 499 menuitem = gtk_menu_item_new_with_label(_("Unread Messages"));
514 500
515 if (status == DOCKLET_STATUS_ONLINE_PENDING || status == DOCKLET_STATUS_AWAY_PENDING) { 501 if (status == DOCKLET_STATUS_PENDING) {
516 GtkWidget *submenu = gtk_menu_new(); 502 GtkWidget *submenu = gtk_menu_new();
517 GList *l = get_pending_list(0); 503 GList *l = get_pending_list(0);
518 if (l == NULL) { 504 if (l == NULL) {
519 gtk_widget_set_sensitive(menuitem, FALSE); 505 gtk_widget_set_sensitive(menuitem, FALSE);
520 gaim_debug_warning("docklet", 506 gaim_debug_warning("docklet",
582 void 568 void
583 pidgin_docklet_clicked(int button_type) 569 pidgin_docklet_clicked(int button_type)
584 { 570 {
585 switch (button_type) { 571 switch (button_type) {
586 case 1: 572 case 1:
587 if (status == DOCKLET_STATUS_ONLINE_PENDING || status == DOCKLET_STATUS_AWAY_PENDING) { 573 if (status == DOCKLET_STATUS_PENDING) {
588 GList *l = get_pending_list(1); 574 GList *l = get_pending_list(1);
589 if (l != NULL) { 575 if (l != NULL) {
590 gaim_conversation_present((GaimConversation *)l->data); 576 gaim_conversation_present((GaimConversation *)l->data);
591 g_list_free(l); 577 g_list_free(l);
592 } 578 }

mercurial