Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 19898:be8bb6f98c01
Get rid of hidden_convwin.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 05 Sep 2007 00:45:55 +0000 |
parents | 8a5d7be3e22e |
children | 25f4be036a16 bea1d9075c7e |
comparison
equal
deleted
inserted
replaced
19896:8a5d7be3e22e | 19898:be8bb6f98c01 |
---|---|
120 } InviteBuddyInfo; | 120 } InviteBuddyInfo; |
121 | 121 |
122 static GtkWidget *invite_dialog = NULL; | 122 static GtkWidget *invite_dialog = NULL; |
123 static GtkWidget *warn_close_dialog = NULL; | 123 static GtkWidget *warn_close_dialog = NULL; |
124 | 124 |
125 static PidginWindow *hidden_convwin = NULL; | |
126 static GList *window_list = NULL; | 125 static GList *window_list = NULL; |
127 | 126 |
128 /* Lists of status icons at all available sizes for use as window icons */ | 127 /* Lists of status icons at all available sizes for use as window icons */ |
129 static GList *available_list = NULL; | 128 static GList *available_list = NULL; |
130 static GList *away_list = NULL; | 129 static GList *away_list = NULL; |
2727 pidgin_conv_present_conversation(PurpleConversation *conv) | 2726 pidgin_conv_present_conversation(PurpleConversation *conv) |
2728 { | 2727 { |
2729 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); | 2728 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
2730 GdkModifierType state; | 2729 GdkModifierType state; |
2731 | 2730 |
2732 if(gtkconv->win==hidden_convwin) { | 2731 if (gtkconv == NULL) { |
2733 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); | 2732 pidgin_conv_attach_to_conversation(conv); |
2734 pidgin_conv_placement_place(gtkconv); | 2733 gtkconv = PIDGIN_CONVERSATION(conv); |
2735 } | 2734 } |
2736 | 2735 |
2737 pidgin_conv_switch_active_conversation(conv); | 2736 pidgin_conv_switch_active_conversation(conv); |
2738 /* Switch the tab only if the user initiated the event by pressing | 2737 /* Switch the tab only if the user initiated the event by pressing |
2739 * a button or hitting a key. */ | 2738 * a button or hitting a key. */ |
2762 | 2761 |
2763 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { | 2762 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { |
2764 PurpleConversation *conv = (PurpleConversation*)l->data; | 2763 PurpleConversation *conv = (PurpleConversation*)l->data; |
2765 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); | 2764 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
2766 | 2765 |
2767 if(gtkconv == NULL || gtkconv->active_conv != conv) | 2766 if (gtkconv != NULL && gtkconv->active_conv != conv) |
2768 continue; | 2767 continue; |
2769 | 2768 if (gtkconv == NULL) { |
2770 if (gtkconv->unseen_state >= min_state | 2769 if (!hidden_only) |
2771 && (!hidden_only || | 2770 continue; |
2772 (hidden_only && gtkconv->win == hidden_convwin))) { | |
2773 | |
2774 r = g_list_prepend(r, conv); | 2771 r = g_list_prepend(r, conv); |
2775 c++; | 2772 c++; |
2773 } else { | |
2774 if (gtkconv->unseen_state >= min_state && !hidden_only) { | |
2775 r = g_list_prepend(r, conv); | |
2776 c++; | |
2777 } | |
2776 } | 2778 } |
2777 } | 2779 } |
2778 | 2780 |
2779 return r; | 2781 return r; |
2780 } | 2782 } |
3074 GList *list; | 3076 GList *list; |
3075 PidginConversation *gtkconv; | 3077 PidginConversation *gtkconv; |
3076 PurpleConversation *conv; | 3078 PurpleConversation *conv; |
3077 GtkWidget *item; | 3079 GtkWidget *item; |
3078 | 3080 |
3079 if (win->window == NULL || win == hidden_convwin) | 3081 if (win->window == NULL) |
3080 return; | 3082 return; |
3081 | 3083 |
3082 gtkconv = pidgin_conv_window_get_active_gtkconv(win); | 3084 gtkconv = pidgin_conv_window_get_active_gtkconv(win); |
3083 if (gtkconv == NULL) | 3085 if (gtkconv == NULL) |
3084 return; | 3086 return; |
4915 PidginConversation *gtkconv; | 4917 PidginConversation *gtkconv; |
4916 PurpleConversationType conv_type = purple_conversation_get_type(conv); | 4918 PurpleConversationType conv_type = purple_conversation_get_type(conv); |
4917 GtkWidget *pane = NULL; | 4919 GtkWidget *pane = NULL; |
4918 GtkWidget *tab_cont; | 4920 GtkWidget *tab_cont; |
4919 | 4921 |
4922 if (hidden) | |
4923 return; | |
4924 | |
4920 if (conv_type == PURPLE_CONV_TYPE_IM && (gtkconv = pidgin_conv_find_gtkconv(conv))) { | 4925 if (conv_type == PURPLE_CONV_TYPE_IM && (gtkconv = pidgin_conv_find_gtkconv(conv))) { |
4921 conv->ui_data = gtkconv; | 4926 conv->ui_data = gtkconv; |
4922 if (!g_list_find(gtkconv->convs, conv)) | 4927 if (!g_list_find(gtkconv->convs, conv)) |
4923 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | 4928 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); |
4924 pidgin_conv_switch_active_conversation(conv); | 4929 pidgin_conv_switch_active_conversation(conv); |
5012 | 5017 |
5013 g_signal_connect_swapped(G_OBJECT(pane), "focus", | 5018 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
5014 G_CALLBACK(gtk_widget_grab_focus), | 5019 G_CALLBACK(gtk_widget_grab_focus), |
5015 gtkconv->entry); | 5020 gtkconv->entry); |
5016 | 5021 |
5017 if (hidden) | 5022 pidgin_conv_placement_place(gtkconv); |
5018 pidgin_conv_window_add_gtkconv(hidden_convwin, gtkconv); | |
5019 else | |
5020 pidgin_conv_placement_place(gtkconv); | |
5021 | 5023 |
5022 if (nick_colors == NULL) { | 5024 if (nick_colors == NULL) { |
5023 nbr_nick_colors = NUM_NICK_COLORS; | 5025 nbr_nick_colors = NUM_NICK_COLORS; |
5024 nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); | 5026 nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); |
5025 } | 5027 } |
5026 } | 5028 } |
5027 | 5029 |
5030 #if 0 | |
5028 static void | 5031 static void |
5029 pidgin_conv_new_hidden(PurpleConversation *conv) | 5032 pidgin_conv_new_hidden(PurpleConversation *conv) |
5030 { | 5033 { |
5031 private_gtkconv_new(conv, TRUE); | 5034 private_gtkconv_new(conv, TRUE); |
5032 } | 5035 } |
5036 #endif | |
5033 | 5037 |
5034 void | 5038 void |
5035 pidgin_conv_new(PurpleConversation *conv) | 5039 pidgin_conv_new(PurpleConversation *conv) |
5036 { | 5040 { |
5037 private_gtkconv_new(conv, FALSE); | 5041 private_gtkconv_new(conv, FALSE); |
7034 | 7038 |
7035 static void | 7039 static void |
7036 account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, | 7040 account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, |
7037 PurpleStatus *newstatus) | 7041 PurpleStatus *newstatus) |
7038 { | 7042 { |
7043 #if 0 | |
7039 GList *l; | 7044 GList *l; |
7040 PurpleConversation *conv = NULL; | 7045 PurpleConversation *conv = NULL; |
7041 PidginConversation *gtkconv; | 7046 PidginConversation *gtkconv; |
7042 | 7047 |
7043 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")!=0) | 7048 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")!=0) |
7044 return; | 7049 return; |
7045 | 7050 |
7046 if(purple_status_is_available(oldstatus) || !purple_status_is_available(newstatus)) | 7051 if(purple_status_is_available(oldstatus) || !purple_status_is_available(newstatus)) |
7047 return; | 7052 return; |
7048 | 7053 #endif |
7049 while ((l = hidden_convwin->gtkconvs) != NULL) | |
7050 { | |
7051 gtkconv = l->data; | |
7052 | |
7053 conv = gtkconv->active_conv; | |
7054 | |
7055 while(l && !purple_status_is_available( | |
7056 purple_account_get_active_status( | |
7057 purple_conversation_get_account(conv)))) | |
7058 l = l->next; | |
7059 if (!l) | |
7060 break; | |
7061 | |
7062 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); | |
7063 pidgin_conv_placement_place(gtkconv); | |
7064 | |
7065 /* TODO: do we need to do anything for any other conversations that are in the same gtkconv here? | |
7066 * I'm a little concerned that not doing so will cause the "pending" indicator in the gtkblist not to be cleared. -DAA*/ | |
7067 purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN); | |
7068 } | |
7069 } | 7054 } |
7070 | 7055 |
7071 static void | 7056 static void |
7072 hide_new_pref_cb(const char *name, PurplePrefType type, | 7057 hide_new_pref_cb(const char *name, PurplePrefType type, |
7073 gconstpointer value, gpointer data) | 7058 gconstpointer value, gpointer data) |
7074 { | 7059 { |
7075 GList *l; | 7060 GList *l; |
7076 PurpleConversation *conv = NULL; | |
7077 PidginConversation *gtkconv; | |
7078 gboolean when_away = FALSE; | 7061 gboolean when_away = FALSE; |
7079 | |
7080 if(!hidden_convwin) | |
7081 return; | |
7082 | 7062 |
7083 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always")==0) | 7063 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always")==0) |
7084 return; | 7064 return; |
7085 | 7065 |
7086 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")==0) | 7066 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")==0) |
7087 when_away = TRUE; | 7067 when_away = TRUE; |
7088 | 7068 |
7089 while ((l = hidden_convwin->gtkconvs) != NULL) | 7069 for (l = purple_get_conversations(); l; l = l->next) |
7090 { | 7070 { |
7091 gtkconv = l->data; | 7071 PurpleConversation *conv = l->data; |
7092 | 7072 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
7093 conv = gtkconv->active_conv; | 7073 if (gtkconv) |
7094 | 7074 continue; |
7095 if(when_away && !purple_status_is_available( | 7075 if(when_away && !purple_status_is_available( |
7096 purple_account_get_active_status( | 7076 purple_account_get_active_status( |
7097 purple_conversation_get_account(conv)))) | 7077 purple_conversation_get_account(conv)))) |
7098 continue; | 7078 continue; |
7099 | 7079 pidgin_conv_attach_to_conversation(conv); |
7100 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); | |
7101 pidgin_conv_placement_place(gtkconv); | |
7102 } | 7080 } |
7103 } | 7081 } |
7104 | 7082 |
7105 | 7083 |
7106 static void | 7084 static void |
7551 | 7529 |
7552 purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", | 7530 purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", |
7553 handle, G_CALLBACK(received_im_msg_cb), NULL); | 7531 handle, G_CALLBACK(received_im_msg_cb), NULL); |
7554 | 7532 |
7555 purple_conversations_set_ui_ops(&conversation_ui_ops); | 7533 purple_conversations_set_ui_ops(&conversation_ui_ops); |
7556 | |
7557 hidden_convwin = pidgin_conv_window_new(); | |
7558 window_list = g_list_remove(window_list, hidden_convwin); | |
7559 | 7534 |
7560 purple_signal_connect(purple_accounts_get_handle(), "account-status-changed", | 7535 purple_signal_connect(purple_accounts_get_handle(), "account-status-changed", |
7561 handle, PURPLE_CALLBACK(account_status_changed_cb), NULL); | 7536 handle, PURPLE_CALLBACK(account_status_changed_cb), NULL); |
7562 | 7537 |
7563 /* Callbacks to update a conversation */ | 7538 /* Callbacks to update a conversation */ |
7598 pidgin_conversations_uninit(void) | 7573 pidgin_conversations_uninit(void) |
7599 { | 7574 { |
7600 purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle()); | 7575 purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle()); |
7601 purple_signals_disconnect_by_handle(pidgin_conversations_get_handle()); | 7576 purple_signals_disconnect_by_handle(pidgin_conversations_get_handle()); |
7602 purple_signals_unregister_by_instance(pidgin_conversations_get_handle()); | 7577 purple_signals_unregister_by_instance(pidgin_conversations_get_handle()); |
7603 pidgin_conv_window_destroy(hidden_convwin); | |
7604 hidden_convwin=NULL; | |
7605 } | 7578 } |
7606 | 7579 |
7607 | 7580 |
7608 | 7581 |
7609 | 7582 |
9013 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | 8986 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); |
9014 | 8987 |
9015 if (win->gtkconvs && win->gtkconvs->next == NULL) | 8988 if (win->gtkconvs && win->gtkconvs->next == NULL) |
9016 pidgin_conv_tab_pack(win, win->gtkconvs->data); | 8989 pidgin_conv_tab_pack(win, win->gtkconvs->data); |
9017 | 8990 |
9018 if (!win->gtkconvs && win != hidden_convwin) | 8991 if (!win->gtkconvs) |
9019 pidgin_conv_window_destroy(win); | 8992 pidgin_conv_window_destroy(win); |
9020 } | 8993 } |
9021 | 8994 |
9022 PidginConversation * | 8995 PidginConversation * |
9023 pidgin_conv_window_get_gtkconv_at_index(const PidginWindow *win, int index) | 8996 pidgin_conv_window_get_gtkconv_at_index(const PidginWindow *win, int index) |
9552 } | 9525 } |
9553 | 9526 |
9554 gboolean | 9527 gboolean |
9555 pidgin_conv_is_hidden(PidginConversation *gtkconv) | 9528 pidgin_conv_is_hidden(PidginConversation *gtkconv) |
9556 { | 9529 { |
9557 g_return_val_if_fail(gtkconv != NULL, FALSE); | 9530 return (gtkconv == NULL); |
9558 | |
9559 return (gtkconv->win == hidden_convwin); | |
9560 } | 9531 } |
9561 | 9532 |
9562 | 9533 |
9563 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ | 9534 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
9564 static gboolean | 9535 static gboolean |