# HG changeset patch # User Sadrul Habib Chowdhury # Date 1196477812 0 # Node ID cf579f61b887667766108c1597d6ba2ef8d4c6b4 # Parent f15b22236649ab52fc02210df893df117a7ff4c3# Parent c5e55b596d1eb3197996b68f3ca17999aabc7fb0 merge of '2dee17b0fb69284b66649d32e66b473471970a43' and '7d322b254abb8cda4c3ee1ba1706b592b88f1025' diff -r f15b22236649 -r cf579f61b887 pidgin/gtkconv.c --- a/pidgin/gtkconv.c Sat Dec 01 01:46:28 2007 +0000 +++ b/pidgin/gtkconv.c Sat Dec 01 02:56:52 2007 +0000 @@ -125,6 +125,7 @@ static GtkWidget *invite_dialog = NULL; static GtkWidget *warn_close_dialog = NULL; +static PidginWindow *hidden_convwin = NULL; static GList *window_list = NULL; /* Lists of status icons at all available sizes for use as window icons */ @@ -2765,6 +2766,9 @@ if (gtkconv == NULL) { pidgin_conv_attach_to_conversation(conv); gtkconv = PIDGIN_CONVERSATION(conv); + } else if (gtkconv->win == hidden_convwin) { + pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); + pidgin_conv_placement_place(gtkconv); } pidgin_conv_switch_active_conversation(conv); @@ -2797,20 +2801,15 @@ PurpleConversation *conv = (PurpleConversation*)l->data; PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); - if (gtkconv != NULL && gtkconv->active_conv != conv) + if(gtkconv == NULL || gtkconv->active_conv != conv) continue; - if (gtkconv == NULL) { - if (!purple_conversation_get_data(conv, "unseen-count") || - !purple_conversation_get_data(conv, "unseen-state") || - GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-state"))unseen_state >= min_state + && (!hidden_only || + (hidden_only && gtkconv->win == hidden_convwin))) { + r = g_list_prepend(r, conv); c++; - } else { - if (gtkconv->unseen_state >= min_state && !hidden_only) { - r = g_list_prepend(r, conv); - c++; - } } } @@ -2853,8 +2852,8 @@ GdkPixbuf *pbuf = pidgin_conv_get_icon(conv, icon, PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC); GtkWidget *item; gchar *text = g_strdup_printf("%s (%d)", - gtkconv ? gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)) : purple_conversation_get_name(conv), - gtkconv ? gtkconv->unseen_count : GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count"))); + gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), + gtkconv->unseen_count); gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); g_object_unref(pbuf); @@ -3115,7 +3114,7 @@ PurpleConversation *conv; GtkWidget *item; - if (win->window == NULL) + if (win->window == NULL || win->window == hidden_convwin) return; gtkconv = pidgin_conv_window_get_active_gtkconv(win); @@ -4947,9 +4946,6 @@ GtkWidget *tab_cont; PurpleBlistNode *convnode; - if (hidden) - return; - if (conv_type == PURPLE_CONV_TYPE_IM && (gtkconv = pidgin_conv_find_gtkconv(conv))) { conv->ui_data = gtkconv; if (!g_list_find(gtkconv->convs, conv)) @@ -5049,7 +5045,10 @@ G_CALLBACK(gtk_widget_grab_focus), gtkconv->entry); - pidgin_conv_placement_place(gtkconv); + if (hidden) + pidgin_conv_window_add_gtkconv(hidden_convwin, gtkconv); + else + pidgin_conv_placement_place(gtkconv); if (nick_colors == NULL) { nbr_nick_colors = NUM_NICK_COLORS; @@ -5057,13 +5056,11 @@ } } -#if 0 static void pidgin_conv_new_hidden(PurpleConversation *conv) { private_gtkconv_new(conv, TRUE); } -#endif void pidgin_conv_new(PurpleConversation *conv) @@ -5081,22 +5078,22 @@ PurpleConversationUiOps *ui_ops = pidgin_conversations_get_conv_ui_ops(); /* create hidden conv if hide_new pref is always */ - /* or if hide_new pref is away and account is away */ - if ((strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always") == 0) || - (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away") == 0 && - !purple_status_is_available(purple_account_get_active_status(account)))) { - if (!conv) { - ui_ops->create_conversation = NULL; - conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); - purple_conversation_set_ui_ops(conv, NULL); - ui_ops->create_conversation = pidgin_conv_new; - } else { - /* TODO: update the unseen_state data on the conv here */ - } - } else { - /* new message for an IM */ - if (conv && conv->type == PURPLE_CONV_TYPE_IM) - pidgin_conv_attach_to_conversation(conv); + if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always") == 0) + { + ui_ops->create_conversation = pidgin_conv_new_hidden; + purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); + ui_ops->create_conversation = pidgin_conv_new; + return; + } + + /* create hidden conv if hide_new pref is away and account is away */ + if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away") == 0 && + !purple_status_is_available(purple_account_get_active_status(account))) + { + ui_ops->create_conversation = pidgin_conv_new_hidden; + purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); + ui_ops->create_conversation = pidgin_conv_new; + return; } } @@ -5105,9 +5102,6 @@ { PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); - if (!gtkconv) - return; - gtkconv->convs = g_list_remove(gtkconv->convs, conv); /* Don't destroy ourselves until all our convos are gone */ if (gtkconv->convs) { @@ -7116,7 +7110,6 @@ account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, PurpleStatus *newstatus) { -#if 0 GList *l; PurpleConversation *conv = NULL; PidginConversation *gtkconv; @@ -7126,7 +7119,27 @@ if(purple_status_is_available(oldstatus) || !purple_status_is_available(newstatus)) return; -#endif + + while ((l = hidden_convwin->gtkconvs) != NULL) + { + gtkconv = l->data; + + conv = gtkconv->active_conv; + + while(l && !purple_status_is_available( + purple_account_get_active_status( + purple_conversation_get_account(conv)))) + l = l->next; + if (!l) + break; + + pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); + pidgin_conv_placement_place(gtkconv); + + /* TODO: do we need to do anything for any other conversations that are in the same gtkconv here? + * I'm a little concerned that not doing so will cause the "pending" indicator in the gtkblist not to be cleared. -DAA*/ + purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN); + } } static void @@ -7134,25 +7147,32 @@ gconstpointer value, gpointer data) { GList *l; + PurpleConversation *conv = NULL; + PidginConversation *gtkconv; gboolean when_away = FALSE; + if(!hidden_convwin) + return; + if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always")==0) return; if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")==0) when_away = TRUE; - for (l = purple_get_conversations(); l; l = l->next) + while ((l = hidden_convwin->gtkconvs) != NULL) { - PurpleConversation *conv = l->data; - PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); - if (gtkconv) - continue; + gtkconv = l->data; + + conv = gtkconv->active_conv; + if(when_away && !purple_status_is_available( purple_account_get_active_status( purple_conversation_get_account(conv)))) continue; - pidgin_conv_attach_to_conversation(conv); + + pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); + pidgin_conv_placement_place(gtkconv); } } @@ -7704,6 +7724,9 @@ purple_conversations_set_ui_ops(&conversation_ui_ops); + hidden_convwin = pidgin_conv_window_new(); + window_list = g_list_remove(window_list, hidden_convwin); + purple_signal_connect(purple_accounts_get_handle(), "account-status-changed", handle, PURPLE_CALLBACK(account_status_changed_cb), NULL); @@ -9239,7 +9262,7 @@ if (win->gtkconvs && win->gtkconvs->next == NULL) pidgin_conv_tab_pack(win, win->gtkconvs->data); - if (!win->gtkconvs) + if (!win->gtkconvs && win != hidden_convwin) pidgin_conv_window_destroy(win); } @@ -9778,7 +9801,9 @@ gboolean pidgin_conv_is_hidden(PidginConversation *gtkconv) { - return (gtkconv == NULL); + g_return_val_if_fail(gtkconv != NULL, FALSE); + + return (gtkconv->win == hidden_convwin); } @@ -9879,5 +9904,3 @@ return colors; } - -