pidgin/gtkblist.c

changeset 21453
a90cf329cd48
parent 21233
e75de8db4f2b
parent 21440
458937dee9af
child 21456
7d52da126458
child 21503
b3cad646ba4a
equal deleted inserted replaced
21273:2f91b326b3f0 21453:a90cf329cd48
109 109
110 110
111 static GtkWidget *accountmenu = NULL; 111 static GtkWidget *accountmenu = NULL;
112 112
113 static guint visibility_manager_count = 0; 113 static guint visibility_manager_count = 0;
114 static gboolean gtk_blist_obscured = FALSE; 114 static GdkVisibilityState gtk_blist_visibility = GDK_VISIBILITY_UNOBSCURED;
115 static gboolean editing_blist = FALSE; 115 static gboolean editing_blist = FALSE;
116 116
117 static GList *pidgin_blist_sort_methods = NULL; 117 static GList *pidgin_blist_sort_methods = NULL;
118 static struct pidgin_blist_sort_method *current_sort_method = NULL; 118 static struct pidgin_blist_sort_method *current_sort_method = NULL;
119 static void sort_method_none(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter); 119 static void sort_method_none(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter);
172 /*************************************************** 172 /***************************************************
173 * Callbacks * 173 * Callbacks *
174 ***************************************************/ 174 ***************************************************/
175 static gboolean gtk_blist_visibility_cb(GtkWidget *w, GdkEventVisibility *event, gpointer data) 175 static gboolean gtk_blist_visibility_cb(GtkWidget *w, GdkEventVisibility *event, gpointer data)
176 { 176 {
177 if (event->state == GDK_VISIBILITY_FULLY_OBSCURED) 177 GdkVisibilityState old_state = gtk_blist_visibility;
178 gtk_blist_obscured = TRUE; 178 gtk_blist_visibility = event->state;
179 else if (gtk_blist_obscured) { 179
180 gtk_blist_obscured = FALSE; 180 if (gtk_blist_visibility == GDK_VISIBILITY_FULLY_OBSCURED &&
181 pidgin_blist_refresh_timer(purple_get_blist()); 181 old_state != GDK_VISIBILITY_FULLY_OBSCURED) {
182
183 /* no longer fully obscured */
184 pidgin_blist_refresh_timer(purple_get_blist());
182 } 185 }
183 186
184 /* continue to handle event normally */ 187 /* continue to handle event normally */
185 return FALSE; 188 return FALSE;
186 } 189 }
599 node = node->parent; 602 node = node->parent;
600 if (!get_iter_from_node(node, &iter)) 603 if (!get_iter_from_node(node, &iter))
601 /* Now it's definitely a bug */ 604 /* Now it's definitely a bug */
602 return; 605 return;
603 } 606 }
607
608 pidgin_blist_tooltip_destroy();
604 609
605 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); 610 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
606 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", TRUE, NULL); 611 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", TRUE, NULL);
607 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), FALSE); 612 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), FALSE);
608 gtk_widget_grab_focus(gtkblist->treeview); 613 gtk_widget_grab_focus(gtkblist->treeview);
2790 { 2795 {
2791 GtkTreePath *path; 2796 GtkTreePath *path;
2792 GtkTreeIter iter; 2797 GtkTreeIter iter;
2793 PurpleBlistNode *node; 2798 PurpleBlistNode *node;
2794 GValue val; 2799 GValue val;
2800 gboolean editable = FALSE;
2801
2802 /* If we're editing a cell (e.g. alias editing), don't show the tooltip */
2803 g_object_get(G_OBJECT(gtkblist->text_rend), "editable", &editable, NULL);
2804 if (editable)
2805 return FALSE;
2795 2806
2796 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y + (gtkblist->tip_rect.height/2), 2807 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y + (gtkblist->tip_rect.height/2),
2797 &path, NULL, NULL, NULL)) 2808 &path, NULL, NULL, NULL))
2798 return FALSE; 2809 return FALSE;
2799 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); 2810 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
3763 3774
3764 static gboolean pidgin_blist_refresh_timer(PurpleBuddyList *list) 3775 static gboolean pidgin_blist_refresh_timer(PurpleBuddyList *list)
3765 { 3776 {
3766 PurpleBlistNode *gnode, *cnode; 3777 PurpleBlistNode *gnode, *cnode;
3767 3778
3768 if (gtk_blist_obscured || !GTK_WIDGET_VISIBLE(gtkblist->window)) 3779 if (gtk_blist_visibility == GDK_VISIBILITY_FULLY_OBSCURED
3780 || !GTK_WIDGET_VISIBLE(gtkblist->window))
3769 return TRUE; 3781 return TRUE;
3770 3782
3771 for(gnode = list->root; gnode; gnode = gnode->next) { 3783 for(gnode = list->root; gnode; gnode = gnode->next) {
3772 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) 3784 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
3773 continue; 3785 continue;
3850 3862
3851 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Add Chat...")); 3863 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Add Chat..."));
3852 gtk_widget_set_sensitive(widget, pidgin_blist_joinchat_is_showable()); 3864 gtk_widget_set_sensitive(widget, pidgin_blist_joinchat_is_showable());
3853 3865
3854 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Privacy")); 3866 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Privacy"));
3855 gtk_widget_set_sensitive(widget, (purple_connections_get_all() != NULL)); 3867 gtk_widget_set_sensitive(widget, sensitive);
3856 3868
3857 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Room List")); 3869 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Room List"));
3858 gtk_widget_set_sensitive(widget, pidgin_roomlist_is_showable()); 3870 gtk_widget_set_sensitive(widget, pidgin_roomlist_is_showable());
3859 } 3871 }
3860 3872
3875 static void 3887 static void
3876 unseen_conv_menu() 3888 unseen_conv_menu()
3877 { 3889 {
3878 static GtkWidget *menu = NULL; 3890 static GtkWidget *menu = NULL;
3879 GList *convs = NULL; 3891 GList *convs = NULL;
3892 GList *chats, *ims;
3880 3893
3881 if (menu) { 3894 if (menu) {
3882 gtk_widget_destroy(menu); 3895 gtk_widget_destroy(menu);
3883 menu = NULL; 3896 menu = NULL;
3884 } 3897 }
3885 3898
3886 convs = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_ANY, PIDGIN_UNSEEN_TEXT, TRUE, 0); 3899 ims = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM,
3900 PIDGIN_UNSEEN_TEXT, FALSE, 0);
3901
3902 chats = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_CHAT,
3903 PIDGIN_UNSEEN_NICK, FALSE, 0);
3904
3905 if(ims && chats)
3906 convs = g_list_concat(ims, chats);
3907 else if(ims && !chats)
3908 convs = ims;
3909 else if(!ims && chats)
3910 convs = chats;
3911
3887 if (!convs) 3912 if (!convs)
3888 /* no conversations added, don't show the menu */ 3913 /* no conversations added, don't show the menu */
3889 return; 3914 return;
3890 3915
3891 menu = gtk_menu_new(); 3916 menu = gtk_menu_new();
3903 GList *convs; 3928 GList *convs;
3904 3929
3905 switch (event->button) { 3930 switch (event->button) {
3906 case 1: 3931 case 1:
3907 convs = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM, 3932 convs = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM,
3908 PIDGIN_UNSEEN_TEXT, TRUE, 1); 3933 PIDGIN_UNSEEN_TEXT, FALSE, 1);
3934
3935 if(!convs)
3936 convs = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_CHAT,
3937 PIDGIN_UNSEEN_NICK, FALSE, 1);
3909 if (convs) { 3938 if (convs) {
3910 purple_conversation_present((PurpleConversation*)convs->data); 3939 pidgin_conv_present_conversation((PurpleConversation*)convs->data);
3911 g_list_free(convs); 3940 g_list_free(convs);
3912 } 3941 }
3913 break; 3942 break;
3914 case 3: 3943 case 3:
3915 unseen_conv_menu(); 3944 unseen_conv_menu();
3921 static void 3950 static void
3922 conversation_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type, 3951 conversation_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type,
3923 PidginBuddyList *gtkblist) 3952 PidginBuddyList *gtkblist)
3924 { 3953 {
3925 GList *convs = NULL; 3954 GList *convs = NULL;
3955 GList *ims, *chats;
3926 GList *l = NULL; 3956 GList *l = NULL;
3927 3957
3928 if (type != PURPLE_CONV_UPDATE_UNSEEN) 3958 if (type != PURPLE_CONV_UPDATE_UNSEEN)
3929 return; 3959 return;
3930 3960
3937 if (gtkblist->menutrayicon) { 3967 if (gtkblist->menutrayicon) {
3938 gtk_widget_destroy(gtkblist->menutrayicon); 3968 gtk_widget_destroy(gtkblist->menutrayicon);
3939 gtkblist->menutrayicon = NULL; 3969 gtkblist->menutrayicon = NULL;
3940 } 3970 }
3941 3971
3942 convs = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_ANY, PIDGIN_UNSEEN_TEXT, TRUE, 0); 3972 ims = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM,
3973 PIDGIN_UNSEEN_TEXT, FALSE, 0);
3974
3975 chats = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_CHAT,
3976 PIDGIN_UNSEEN_NICK, FALSE, 0);
3977
3978 if(ims && chats)
3979 convs = g_list_concat(ims, chats);
3980 else if(ims && !chats)
3981 convs = ims;
3982 else if(!ims && chats)
3983 convs = chats;
3984
3943 if (convs) { 3985 if (convs) {
3944 GtkWidget *img = NULL; 3986 GtkWidget *img = NULL;
3945 GString *tooltip_text = NULL; 3987 GString *tooltip_text = NULL;
3946 3988
3947 tooltip_text = g_string_new(""); 3989 tooltip_text = g_string_new("");
3948 l = convs; 3990 l = convs;
3949 while (l != NULL) { 3991 while (l != NULL) {
3950 int count = GPOINTER_TO_INT(purple_conversation_get_data(l->data, "unseen-count")); 3992 int count = 0;
3993 PidginConversation *gtkconv = PIDGIN_CONVERSATION((PurpleConversation *)l->data);
3994
3995 if(gtkconv)
3996 count = gtkconv->unseen_count;
3997 else if(purple_conversation_get_data(l->data, "unseen-count"))
3998 count = GPOINTER_TO_INT(purple_conversation_get_data(l->data, "unseen-count"));
3999
3951 g_string_append_printf(tooltip_text, 4000 g_string_append_printf(tooltip_text,
3952 ngettext("%d unread message from %s\n", "%d unread messages from %s\n", count), 4001 ngettext("%d unread message from %s\n", "%d unread messages from %s\n", count),
3953 count, purple_conversation_get_name(l->data)); 4002 count, purple_conversation_get_title(l->data));
3954 l = l->next; 4003 l = l->next;
3955 } 4004 }
3956 if(tooltip_text->len > 0) { 4005 if(tooltip_text->len > 0) {
3957 /* get rid of the last newline */ 4006 /* get rid of the last newline */
3958 g_string_truncate(tooltip_text, tooltip_text->len -1); 4007 g_string_truncate(tooltip_text, tooltip_text->len -1);
6293 void 6342 void
6294 pidgin_blist_toggle_visibility() 6343 pidgin_blist_toggle_visibility()
6295 { 6344 {
6296 if (gtkblist && gtkblist->window) { 6345 if (gtkblist && gtkblist->window) {
6297 if (GTK_WIDGET_VISIBLE(gtkblist->window)) { 6346 if (GTK_WIDGET_VISIBLE(gtkblist->window)) {
6298 purple_blist_set_visible(PIDGIN_WINDOW_ICONIFIED(gtkblist->window) || gtk_blist_obscured); 6347 purple_blist_set_visible(PIDGIN_WINDOW_ICONIFIED(gtkblist->window) ||
6348 gtk_blist_visibility != GDK_VISIBILITY_UNOBSCURED);
6299 } else { 6349 } else {
6300 purple_blist_set_visible(TRUE); 6350 purple_blist_set_visible(TRUE);
6301 } 6351 }
6302 } 6352 }
6303 } 6353 }

mercurial