changeset 21702:cf579f61b887

merge of '2dee17b0fb69284b66649d32e66b473471970a43' and '7d322b254abb8cda4c3ee1ba1706b592b88f1025'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 01 Dec 2007 02:56:52 +0000
parents f15b22236649 (current diff) c5e55b596d1e (diff)
children 50d1ee737a68
files libpurple/protocols/jabber/.todo libpurple/protocols/msn/msn-utils.c libpurple/protocols/msn/msn-utils.h libpurple/protocols/oscar/.todo pidgin/gtkconv.c pidgin/pixmaps/animations/16/Makefile.am pidgin/pixmaps/animations/16/Makefile.mingw pidgin/pixmaps/animations/Makefile.am pidgin/pixmaps/animations/Makefile.mingw pidgin/pixmaps/buddy_icons/Makefile.am pidgin/pixmaps/buddy_icons/Makefile.mingw pidgin/pixmaps/dialogs/16/Makefile.am pidgin/pixmaps/dialogs/16/Makefile.mingw pidgin/pixmaps/dialogs/16/scalable/Makefile.am pidgin/pixmaps/dialogs/64/Makefile.am pidgin/pixmaps/dialogs/64/Makefile.mingw pidgin/pixmaps/dialogs/64/scalable/Makefile.am pidgin/pixmaps/dialogs/Makefile.am pidgin/pixmaps/dialogs/Makefile.mingw pidgin/pixmaps/emblems/16/Makefile.am pidgin/pixmaps/emblems/16/Makefile.mingw pidgin/pixmaps/emblems/16/scalable/Makefile.am pidgin/pixmaps/emblems/Makefile.am pidgin/pixmaps/emblems/Makefile.mingw pidgin/pixmaps/emotes/Makefile.am pidgin/pixmaps/emotes/Makefile.mingw pidgin/pixmaps/emotes/default/24/scalable/Makefile.am pidgin/pixmaps/emotes/default/Makefile.am pidgin/pixmaps/emotes/default/Makefile.mingw pidgin/pixmaps/icons/16/Makefile.am pidgin/pixmaps/icons/16/Makefile.mingw pidgin/pixmaps/icons/16/pidgin.png pidgin/pixmaps/icons/16/scalable/Makefile.am pidgin/pixmaps/icons/16/scalable/pidgin.svg pidgin/pixmaps/icons/22/Makefile.am pidgin/pixmaps/icons/22/pidgin.png pidgin/pixmaps/icons/22/scalable/Makefile.am pidgin/pixmaps/icons/22/scalable/pidgin.svg pidgin/pixmaps/icons/24/Makefile.am pidgin/pixmaps/icons/24/Makefile.mingw pidgin/pixmaps/icons/24/pidgin.png pidgin/pixmaps/icons/24/scalable/Makefile.am pidgin/pixmaps/icons/24/scalable/pidgin.svg pidgin/pixmaps/icons/32/Makefile.am pidgin/pixmaps/icons/32/Makefile.mingw pidgin/pixmaps/icons/32/pidgin.png pidgin/pixmaps/icons/32/scalable/Makefile.am pidgin/pixmaps/icons/32/scalable/pidgin.svg pidgin/pixmaps/icons/48/Makefile.am pidgin/pixmaps/icons/48/Makefile.mingw pidgin/pixmaps/icons/48/pidgin.png pidgin/pixmaps/icons/48/scalable/Makefile.am pidgin/pixmaps/icons/48/scalable/pidgin.svg pidgin/pixmaps/icons/Makefile.am pidgin/pixmaps/icons/Makefile.mingw pidgin/pixmaps/protocols/16/Makefile.am pidgin/pixmaps/protocols/16/Makefile.mingw pidgin/pixmaps/protocols/16/scalable/Makefile.am pidgin/pixmaps/protocols/22/Makefile.am pidgin/pixmaps/protocols/22/Makefile.mingw pidgin/pixmaps/protocols/22/scalable/Makefile.am pidgin/pixmaps/protocols/48/Makefile.am pidgin/pixmaps/protocols/48/Makefile.mingw pidgin/pixmaps/protocols/48/scalable/Makefile.am pidgin/pixmaps/protocols/Makefile.am pidgin/pixmaps/protocols/Makefile.mingw pidgin/pixmaps/status/11/Makefile.am pidgin/pixmaps/status/11/Makefile.mingw pidgin/pixmaps/status/11/rtl/Makefile.am pidgin/pixmaps/status/11/rtl/Makefile.mingw pidgin/pixmaps/status/11/scalable/Makefile.am pidgin/pixmaps/status/16/Makefile.am pidgin/pixmaps/status/16/Makefile.mingw pidgin/pixmaps/status/16/rtl/Makefile.am pidgin/pixmaps/status/16/rtl/Makefile.mingw pidgin/pixmaps/status/16/scalable/Makefile.am pidgin/pixmaps/status/22/Makefile.am pidgin/pixmaps/status/22/Makefile.mingw pidgin/pixmaps/status/22/rtl/Makefile.am pidgin/pixmaps/status/22/rtl/Makefile.mingw pidgin/pixmaps/status/22/scalable/Makefile.am pidgin/pixmaps/status/32/Makefile.am pidgin/pixmaps/status/32/Makefile.mingw pidgin/pixmaps/status/32/rtl/Makefile.am pidgin/pixmaps/status/32/rtl/Makefile.mingw pidgin/pixmaps/status/32/scalable/Makefile.am pidgin/pixmaps/status/48/Makefile.am pidgin/pixmaps/status/48/Makefile.mingw pidgin/pixmaps/status/48/rtl/Makefile.am pidgin/pixmaps/status/48/rtl/Makefile.mingw pidgin/pixmaps/status/Makefile.am pidgin/pixmaps/status/Makefile.mingw pidgin/pixmaps/toolbar/16/Makefile.am pidgin/pixmaps/toolbar/16/Makefile.mingw pidgin/pixmaps/toolbar/16/scalable/Makefile.am pidgin/pixmaps/toolbar/22/Makefile.am pidgin/pixmaps/toolbar/22/Makefile.mingw pidgin/pixmaps/toolbar/22/scalable/Makefile.am pidgin/pixmaps/toolbar/Makefile.am pidgin/pixmaps/toolbar/Makefile.mingw pidgin/pixmaps/tray/16/Makefile.am pidgin/pixmaps/tray/16/Makefile.mingw pidgin/pixmaps/tray/16/scalable/Makefile.am pidgin/pixmaps/tray/22/Makefile.am pidgin/pixmaps/tray/22/Makefile.mingw pidgin/pixmaps/tray/22/scalable/Makefile.am pidgin/pixmaps/tray/32/Makefile.am pidgin/pixmaps/tray/32/Makefile.mingw pidgin/pixmaps/tray/48/Makefile.am pidgin/pixmaps/tray/48/Makefile.mingw pidgin/pixmaps/tray/Makefile.am pidgin/pixmaps/tray/Makefile.mingw po/sr@Latn.po share/Makefile.am share/Makefile.mingw
diffstat 1 files changed, 74 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- 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"))<min_state)
-				continue;
+
+		if (gtkconv->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;
 }
-
-