diff options
author | Stu Tomlinson <nosnilmot@pidgin.im> | 2007-12-01 14:53:09 +0000 |
---|---|---|
committer | Stu Tomlinson <nosnilmot@pidgin.im> | 2007-12-01 14:53:09 +0000 |
commit | a16bb654bd85c432ae563570b50e04cf5708f0e1 (patch) | |
tree | c56a52605a14efe537b14384741f2c74cf20002f | |
parent | 0fd873802dac6a47dbb148353beaa041308e2ec7 (diff) | |
download | pidgin-a16bb654bd85c432ae563570b50e04cf5708f0e1.tar.gz |
Pluck the hidden conversation changes to ipp.2.3.1. I think this needs
careful testing.
applied changes from 806d367a737b47889afc6bc1a600745b224be73b
through af97865fc7bbf79c768ddcb673da8560cf481719
applied changes from e3e7a13ac8add4cadd65d72a3513d202baecf649
through c9f27c16e20ad158b7431974dfce2e50a300492d
applied changes from 43dd2f1b2942cac448da6cccc118014c90cbf141
through 3fe64d635336a6d7f6e520f4b2e041c3316c465d
-rw-r--r-- | pidgin/gtkconv.c | 131 |
1 files changed, 88 insertions, 43 deletions
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c index 1ff5decea0..2742dd3410 100644 --- a/pidgin/gtkconv.c +++ b/pidgin/gtkconv.c @@ -125,6 +125,7 @@ typedef struct { 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 */ @@ -1378,7 +1379,13 @@ hide_conv(PidginConversation *gtkconv, gboolean closetimer) timer = purple_timeout_add_seconds(CLOSE_CONV_TIMEOUT_SECS, close_already, conv); purple_conversation_set_data(conv, "close-timer", GINT_TO_POINTER(timer)); } +#if 0 + /* I will miss you */ purple_conversation_set_ui_ops(conv, NULL); +#else + pidgin_conv_window_remove_gtkconv(gtkconv->win, gtkconv); + pidgin_conv_window_add_gtkconv(hidden_convwin, gtkconv); +#endif } } @@ -2816,9 +2823,9 @@ pidgin_conv_present_conversation(PurpleConversation *conv) PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); GdkModifierType state; - if (gtkconv == NULL) { - pidgin_conv_attach_to_conversation(conv); - gtkconv = PIDGIN_CONVERSATION(conv); + if(gtkconv->win==hidden_convwin) { + pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); + pidgin_conv_placement_place(gtkconv); } pidgin_conv_switch_active_conversation(conv); @@ -2851,7 +2858,7 @@ pidgin_conversations_find_unseen_list(PurpleConversationType type, 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") || @@ -2860,11 +2867,6 @@ pidgin_conversations_find_unseen_list(PurpleConversationType type, continue; r = g_list_prepend(r, conv); c++; - } else { - if (gtkconv->unseen_state >= min_state && !hidden_only) { - r = g_list_prepend(r, conv); - c++; - } } } @@ -3169,7 +3171,7 @@ regenerate_plugins_items(PidginWindow *win) PurpleConversation *conv; GtkWidget *item; - if (win->window == NULL) + if (win->window == NULL || win == hidden_convwin) return; gtkconv = pidgin_conv_window_get_active_gtkconv(win); @@ -5025,9 +5027,6 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden) 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)) @@ -5126,7 +5125,10 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden) 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; @@ -5134,13 +5136,11 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden) } } -#if 0 static void pidgin_conv_new_hidden(PurpleConversation *conv) { private_gtkconv_new(conv, TRUE); } -#endif void pidgin_conv_new(PurpleConversation *conv) @@ -5156,24 +5156,30 @@ received_im_msg_cb(PurpleAccount *account, char *sender, char *message, PurpleConversation *conv, PurpleMessageFlags flags) { PurpleConversationUiOps *ui_ops = pidgin_conversations_get_conv_ui_ops(); + gboolean hide = FALSE; /* 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 */ + if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always") == 0) + hide = TRUE; + + /* 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))) + hide = TRUE; + + if (PIDGIN_IS_PIDGIN_CONVERSATION(conv) && !hide) { + PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); + if (gtkconv->win == hidden_convwin) { + pidgin_conv_window_remove_gtkconv(gtkconv->win, gtkconv); + pidgin_conv_placement_place(gtkconv); } - } else { - /* new message for an IM */ - if (conv && conv->type == PURPLE_CONV_TYPE_IM) - pidgin_conv_attach_to_conversation(conv); + return; + } + + if (hide) { + ui_ops->create_conversation = pidgin_conv_new_hidden; + purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); + ui_ops->create_conversation = pidgin_conv_new; } } @@ -7196,7 +7202,6 @@ static void account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, PurpleStatus *newstatus) { -#if 0 GList *l; PurpleConversation *conv = NULL; PidginConversation *gtkconv; @@ -7206,7 +7211,27 @@ account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, 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 @@ -7214,25 +7239,32 @@ hide_new_pref_cb(const char *name, PurplePrefType type, 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); } } @@ -7513,8 +7545,14 @@ gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) GList *list; PidginConversation *gtkconv; - if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) - return FALSE; + if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) { + gtkconv = PIDGIN_CONVERSATION(conv); + if (gtkconv->win != hidden_convwin) + return FALSE; + pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); + pidgin_conv_placement_place(gtkconv); + return TRUE; + } pidgin_conv_attach(conv); gtkconv = PIDGIN_CONVERSATION(conv); @@ -7785,6 +7823,9 @@ pidgin_conversations_init(void) 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); @@ -7832,6 +7873,8 @@ pidgin_conversations_uninit(void) purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle()); purple_signals_disconnect_by_handle(pidgin_conversations_get_handle()); purple_signals_unregister_by_instance(pidgin_conversations_get_handle()); + pidgin_conv_window_destroy(hidden_convwin); + hidden_convwin=NULL; } @@ -9285,7 +9328,7 @@ pidgin_conv_window_remove_gtkconv(PidginWindow *win, PidginConversation *gtkconv 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); } @@ -9824,7 +9867,9 @@ pidgin_conv_placement_place(PidginConversation *gtkconv) gboolean pidgin_conv_is_hidden(PidginConversation *gtkconv) { - return (gtkconv == NULL); + g_return_val_if_fail(gtkconv != NULL, FALSE); + + return (gtkconv->win == hidden_convwin); } |