Mercurial > pidgin
comparison plugins/docklet/docklet.c @ 12468:6faefbebcd24
[gaim-migrate @ 14778]
SF Patch #1372898 from charkins
"This patch updates the unseen conversation api in
gtkconv to ensure consistancy and avoid code
duplication. The ...first_unseen() function is renamed
and expanded to return a list of conversations that
match the specified criteria. A max_count parameter is
used to allow this to short circuit early (using 1
gives old behavior). An additional flag was added to
allow this function to only consider hidden
conversations (used by the buddy list). The blist is
currently inconsistant in which conversations it loops
over for showing the menu tray icon, creating the
tooltip and the unseen menu. This patch fixes that.
The ...find_unseen_list() now handles contact-aware
conversations correctly as well (based on sadrul's
patches in #1362579 which are obsoleted by this patch).
I also included the fix from #1362579 which increments
unseen_count only when state>=UNSEEN_TEXT."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 12 Dec 2005 18:59:29 +0000 |
parents | 45aa1d86428e |
children | 13f351a0096e |
comparison
equal
deleted
inserted
replaced
12467:1b57012eec7b | 12468:6faefbebcd24 |
---|---|
93 GList *l; | 93 GList *l; |
94 DockletStatus newstatus = DOCKLET_STATUS_OFFLINE; | 94 DockletStatus newstatus = DOCKLET_STATUS_OFFLINE; |
95 gboolean pending = FALSE; | 95 gboolean pending = FALSE; |
96 | 96 |
97 /* determine if any ims have unseen messages */ | 97 /* determine if any ims have unseen messages */ |
98 if(gaim_gtk_conversations_get_first_unseen(GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT)) | 98 l = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, |
99 GAIM_UNSEEN_TEXT, FALSE, 1); | |
100 if (l != NULL) { | |
99 pending = TRUE; | 101 pending = TRUE; |
102 g_list_free(l); | |
103 } | |
100 | 104 |
101 /* iterate through all accounts and determine which | 105 /* iterate through all accounts and determine which |
102 * status to show in the tray icon based on the following | 106 * status to show in the tray icon based on the following |
103 * ranks (highest encountered rank will be used): | 107 * ranks (highest encountered rank will be used): |
104 * | 108 * |
116 GaimStatus *account_status; | 120 GaimStatus *account_status; |
117 | 121 |
118 if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) | 122 if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) |
119 continue; | 123 continue; |
120 | 124 |
121 if(gaim_account_is_disconnected(account)) | 125 if (gaim_account_is_disconnected(account)) |
122 continue; | 126 continue; |
123 | 127 |
124 account_status = gaim_account_get_active_status(account); | 128 account_status = gaim_account_get_active_status(account); |
125 | 129 |
126 if(gaim_account_is_connecting(account)) { | 130 if (gaim_account_is_connecting(account)) { |
127 tmpstatus = DOCKLET_STATUS_CONNECTING; | 131 tmpstatus = DOCKLET_STATUS_CONNECTING; |
128 } | 132 } else if (gaim_status_is_online(account_status)) { |
129 else if(gaim_status_is_online(account_status)) { | 133 if (!gaim_status_is_available(account_status)) { |
130 if(!gaim_status_is_available(account_status)) { | 134 if (pending) |
131 if(pending) | |
132 tmpstatus = DOCKLET_STATUS_AWAY_PENDING; | 135 tmpstatus = DOCKLET_STATUS_AWAY_PENDING; |
133 else | 136 else |
134 tmpstatus = DOCKLET_STATUS_AWAY; | 137 tmpstatus = DOCKLET_STATUS_AWAY; |
135 } | 138 } |
136 else { | 139 else { |
137 if(pending) | 140 if (pending) |
138 tmpstatus = DOCKLET_STATUS_ONLINE_PENDING; | 141 tmpstatus = DOCKLET_STATUS_ONLINE_PENDING; |
139 else | 142 else |
140 tmpstatus = DOCKLET_STATUS_ONLINE; | 143 tmpstatus = DOCKLET_STATUS_ONLINE; |
141 } | 144 } |
142 } | 145 } |
143 | 146 |
144 if(tmpstatus>newstatus) newstatus=tmpstatus; | 147 if (tmpstatus > newstatus) |
148 newstatus = tmpstatus; | |
145 } | 149 } |
146 | 150 |
147 /* update the icon if we changed status */ | 151 /* update the icon if we changed status */ |
148 if (status != newstatus) { | 152 if (status != newstatus) { |
149 status = newstatus; | 153 status = newstatus; |
168 GList *c = NULL; | 172 GList *c = NULL; |
169 c = gaim_connections_get_all(); | 173 c = gaim_connections_get_all(); |
170 | 174 |
171 while(c!=NULL) { | 175 while(c!=NULL) { |
172 GaimConnection *gc = c->data; | 176 GaimConnection *gc = c->data; |
173 if(GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info!=NULL) | 177 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
174 return TRUE; | 178 return TRUE; |
175 c = c->next; | 179 c = c->next; |
176 } | 180 } |
177 | 181 |
178 return FALSE; | 182 return FALSE; |
200 } | 204 } |
201 | 205 |
202 static void | 206 static void |
203 docklet_conv_updated_cb(GaimConversation *conv, GaimConvUpdateType type) | 207 docklet_conv_updated_cb(GaimConversation *conv, GaimConvUpdateType type) |
204 { | 208 { |
205 if(type==GAIM_CONV_UPDATE_UNSEEN) | 209 if (type == GAIM_CONV_UPDATE_UNSEEN) |
206 docklet_update_status(); | 210 docklet_update_status(); |
207 } | 211 } |
208 | 212 |
209 static void | 213 static void |
210 docklet_signed_on_cb(GaimConnection *gc) | 214 docklet_signed_on_cb(GaimConnection *gc) |
211 { | 215 { |
212 if(!enable_join_chat) { | 216 if (!enable_join_chat) { |
213 if(GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info!=NULL) | 217 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
214 enable_join_chat = TRUE; | 218 enable_join_chat = TRUE; |
215 } | 219 } |
216 docklet_update_status(); | 220 docklet_update_status(); |
217 } | 221 } |
218 | 222 |
219 static void | 223 static void |
220 docklet_signed_off_cb(GaimConnection *gc) | 224 docklet_signed_off_cb(GaimConnection *gc) |
221 { | 225 { |
222 if(enable_join_chat) { | 226 if (enable_join_chat) { |
223 if(GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info!=NULL) | 227 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
224 enable_join_chat = online_account_supports_chat(); | 228 enable_join_chat = online_account_supports_chat(); |
225 } | 229 } |
226 docklet_update_status(); | 230 docklet_update_status(); |
227 } | 231 } |
228 | 232 |
296 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); | 300 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry); |
297 | 301 |
298 gaim_separator(menu); | 302 gaim_separator(menu); |
299 | 303 |
300 menuitem = gaim_new_item_from_stock(menu, _("New Message..."), GAIM_STOCK_IM, G_CALLBACK(gaim_gtkdialogs_im), NULL, 0, 0, NULL); | 304 menuitem = gaim_new_item_from_stock(menu, _("New Message..."), GAIM_STOCK_IM, G_CALLBACK(gaim_gtkdialogs_im), NULL, 0, 0, NULL); |
301 if(status == DOCKLET_STATUS_OFFLINE) | 305 if (status == DOCKLET_STATUS_OFFLINE) |
302 gtk_widget_set_sensitive(menuitem, FALSE); | 306 gtk_widget_set_sensitive(menuitem, FALSE); |
303 | 307 |
304 menuitem = gaim_new_item_from_stock(menu, _("Join A Chat..."), GAIM_STOCK_CHAT, G_CALLBACK(gaim_gtk_blist_joinchat_show), NULL, 0, 0, NULL); | 308 menuitem = gaim_new_item_from_stock(menu, _("Join A Chat..."), GAIM_STOCK_CHAT, G_CALLBACK(gaim_gtk_blist_joinchat_show), NULL, 0, 0, NULL); |
305 gtk_widget_set_sensitive(menuitem, enable_join_chat); | 309 gtk_widget_set_sensitive(menuitem, enable_join_chat); |
306 | 310 |
345 void | 349 void |
346 docklet_clicked(int button_type) | 350 docklet_clicked(int button_type) |
347 { | 351 { |
348 switch (button_type) { | 352 switch (button_type) { |
349 case 1: | 353 case 1: |
350 if(status==DOCKLET_STATUS_ONLINE_PENDING || status==DOCKLET_STATUS_AWAY_PENDING) | 354 if (status==DOCKLET_STATUS_ONLINE_PENDING || status==DOCKLET_STATUS_AWAY_PENDING) { |
351 gaim_gtkconv_present_conversation( | 355 GList *l = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, |
352 gaim_gtk_conversations_get_first_unseen( | 356 GAIM_UNSEEN_TEXT, FALSE, 1); |
353 GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT)); | 357 if (l != NULL) { |
354 else | 358 gaim_gtkconv_present_conversation((GaimConversation *)l->data); |
359 g_list_free(l); | |
360 } | |
361 } else { | |
355 gaim_gtk_blist_toggle_visibility(); | 362 gaim_gtk_blist_toggle_visibility(); |
363 } | |
356 break; | 364 break; |
357 case 3: | 365 case 3: |
358 docklet_menu(); | 366 docklet_menu(); |
359 break; | 367 break; |
360 } | 368 } |