comparison src/gtkblist.c @ 12116:e75ef7aa913e

[gaim-migrate @ 14416] " This patch implements a replacement for the queuing system from 1.x. It also obsoletes a previous patch [#1338873] I submitted to prioritize the unseen states in gtk conversations. The attached envelope.png is ripped from the msgunread.png already included in gaim. It should be dropped in the pixmaps directory (Makefile.am is updated accordingly in this patch). The two separate queuing preferences from 1.x, queuing messages while away and queuing all new messages (from docklet), are replaced with a single 3-way preference for conversations. The new preference is "Hide new IM conversations". This preference can be set to never, away and always. When a gtk conversation is created, it may be placed in a hidden conversation window instead of being placed normally. This decision is based upon the preference and possibly the away state of the account the conversation is being created for. This *will* effect conversations the user explicitly requests to be created, so in these cases the caller must be sure to present the conversation to the user, using gaim_gtkconv_present_conversation(). This is done already in gtkdialogs.c which handles creating conversations requested by the user from gaim proper (menus, double-clicking on budy in blist, etc.). The main advantage to not queuing messages is that the conversations exist, the message is written to the conversation (and logged if appropriate) and the unseen state is set on the conversation. This means no additional features are needed to track whether there are queued messages or not, just use the unseen state on conversations. Since conversations may not be visible (messages "queued"), gaim proper needs some notification that there are messages waiting. I opted for a menutray icon that shows up when an im conversation has an unseen message. Clicking this icon will focus (and show if hidden) the first conversation with an unseen message. This is essentially the same behavior of the docklet in cvs right now, except that the icon is only visible when there is a conversation with an unread message. The api that is added is flexible enough to allow either the docklet or the new blist menutray icon to be visible for conversations of any/all types and for unseen messages >= any state. Currently they are set to only IM conversations and only unseen states >= TEXT (system messages and no log messages will not trigger blinking the docklet or showing the blist tray icon), but these could be made preferences relatively easily in the future. Other plugins could probably benefit as well: gaim_gtk_conversations_get_first_unseen(). There is probably some limit to comment size, so I'll stop rambling now. If anyone has more questions/comments, catch me in #gaim, here or on gaim-devel." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 16 Nov 2005 18:17:01 +0000
parents e9790eb93216
children cb77957d644c
comparison
equal deleted inserted replaced
12115:e9790eb93216 12116:e75ef7aa913e
44 #include "gtkconv.h" 44 #include "gtkconv.h"
45 #include "gtkdebug.h" 45 #include "gtkdebug.h"
46 #include "gtkdialogs.h" 46 #include "gtkdialogs.h"
47 #include "gtkft.h" 47 #include "gtkft.h"
48 #include "gtklog.h" 48 #include "gtklog.h"
49 #include "gtkmenutray.h"
49 #include "gtkpounce.h" 50 #include "gtkpounce.h"
50 #include "gtkplugin.h" 51 #include "gtkplugin.h"
51 #include "gtkprefs.h" 52 #include "gtkprefs.h"
52 #include "gtkprivacy.h" 53 #include "gtkprivacy.h"
53 #include "gtkroomlist.h" 54 #include "gtkroomlist.h"
115 static GtkTreeIter sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); 116 static GtkTreeIter sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur);
116 static GtkTreeIter sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); 117 static GtkTreeIter sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur);
117 #endif 118 #endif
118 static GaimGtkBuddyList *gtkblist = NULL; 119 static GaimGtkBuddyList *gtkblist = NULL;
119 120
121 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node);
120 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); 122 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data);
121 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node); 123 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node);
122 static char *gaim_get_tooltip_text(GaimBlistNode *node); 124 static char *gaim_get_tooltip_text(GaimBlistNode *node);
123 static char *item_factory_translate_func (const char *path, gpointer func_data); 125 static char *item_factory_translate_func (const char *path, gpointer func_data);
124 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter); 126 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter);
3119 plugin_changed_cb(GaimPlugin *p, gpointer *data) 3121 plugin_changed_cb(GaimPlugin *p, gpointer *data)
3120 { 3122 {
3121 gaim_gtk_blist_update_plugin_actions(); 3123 gaim_gtk_blist_update_plugin_actions();
3122 } 3124 }
3123 3125
3126 static gboolean
3127 menutray_press_cb(GtkWidget *widget, GdkEventButton *event)
3128 {
3129 gaim_gtkconv_present_conversation(gaim_gtk_conversations_get_first_unseen(
3130 GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT));
3131 return TRUE;
3132 }
3133
3134 static void
3135 conversation_updated_cb(GaimConversation *conv, GaimConvUpdateType type,
3136 GaimGtkBuddyList *gtkblist)
3137 {
3138 GtkWidget *img = NULL;
3139
3140 if(gtkblist->menutrayicon) {
3141 gtk_widget_destroy(gtkblist->menutrayicon);
3142 gtkblist->menutrayicon = NULL;
3143 }
3144
3145 if(gaim_gtk_conversations_get_first_unseen(GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT))
3146 img = gtk_image_new_from_stock(GAIM_STOCK_PENDING, GTK_ICON_SIZE_MENU);
3147
3148 if(img) {
3149 gtkblist->menutrayicon = gtk_event_box_new();
3150 gtk_container_add(GTK_CONTAINER(gtkblist->menutrayicon), img);
3151 gtk_widget_show(img);
3152 gtk_widget_show(gtkblist->menutrayicon);
3153 g_signal_connect(G_OBJECT(gtkblist->menutrayicon), "button-press-event", G_CALLBACK(menutray_press_cb), NULL);
3154
3155 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkblist->menutray), gtkblist->menutrayicon, NULL);
3156 }
3157 }
3158
3124 /********************************************************************************** 3159 /**********************************************************************************
3125 * Public API Functions * 3160 * Public API Functions *
3126 **********************************************************************************/ 3161 **********************************************************************************/
3127 3162
3128 static void gaim_gtk_blist_new_list(GaimBuddyList *blist) 3163 static void gaim_gtk_blist_new_list(GaimBuddyList *blist)
3327 blist_menu, NULL); 3362 blist_menu, NULL);
3328 gaim_gtk_load_accels(); 3363 gaim_gtk_load_accels();
3329 g_signal_connect(G_OBJECT(accel_group), "accel-changed", 3364 g_signal_connect(G_OBJECT(accel_group), "accel-changed",
3330 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); 3365 G_CALLBACK(gaim_gtk_save_accels_cb), NULL);
3331 menu = gtk_item_factory_get_widget(gtkblist->ift, "<GaimMain>"); 3366 menu = gtk_item_factory_get_widget(gtkblist->ift, "<GaimMain>");
3367 gtkblist->menutray = gaim_gtk_menu_tray_new();
3368 gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray);
3369 gtk_widget_show(gtkblist->menutray);
3332 gtk_widget_show(menu); 3370 gtk_widget_show(menu);
3333 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); 3371 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0);
3334 3372
3335 gtkblist->bpmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Buddy Pounce")); 3373 gtkblist->bpmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Buddy Pounce"));
3336 protomenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Account Actions")); 3374 protomenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Account Actions"));
3521 3559
3522 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load", 3560 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load",
3523 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); 3561 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL);
3524 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload", 3562 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload",
3525 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); 3563 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL);
3564
3565 gaim_signal_connect(gaim_conversations_get_handle(), "conversation-updated",
3566 gtkblist, GAIM_CALLBACK(conversation_updated_cb),
3567 gtkblist);
3526 3568
3527 /* emit our created signal */ 3569 /* emit our created signal */
3528 gaim_signal_emit(handle, "gtkblist-created", list); 3570 gaim_signal_emit(handle, "gtkblist-created", list);
3529 } 3571 }
3530 3572