changeset 23263:6c4db8059e91

merge of 'adc233c42c586b7fae877a688cd39532eaca23a0' and 'dff9129288f4ec49e17c74372f1f52405fdf94bf'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 01 Jun 2008 21:36:43 +0000
parents 9c79e86e6f2b (current diff) 07aa8e4a262a (diff)
children 2b997b690500
files
diffstat 5 files changed, 58 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Sun Jun 01 20:05:06 2008 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Sun Jun 01 21:36:43 2008 +0000
@@ -824,7 +824,7 @@
 		}		
 		if(jbr) {
 			char *purdy = NULL;
-			char *status_name = jabber_buddy_state_get_name(jbr->state);
+			const char *status_name = jabber_buddy_state_get_name(jbr->state);
 			if(jbr->status)
 				purdy = purple_strdup_withhtml(jbr->status);
 			if(status_name && purdy && !strcmp(status_name, purdy))
@@ -967,8 +967,9 @@
 		gboolean multiple_resources = jbi->jb->resources && (g_list_length(jbi->jb->resources) > 1);
 
 		for(resources = jbi->jb->resources; resources; resources = resources->next) {
-			char *purdy = NULL, *status_name = NULL;
-			
+			char *purdy = NULL;
+			const char *status_name = NULL;
+
 			jbr = resources->data;
 
 			if(jbr->client.name) {
--- a/libpurple/protocols/jabber/chat.c	Sun Jun 01 20:05:06 2008 +0000
+++ b/libpurple/protocols/jabber/chat.c	Sun Jun 01 21:36:43 2008 +0000
@@ -308,7 +308,7 @@
 
 	jabber_chat_part(chat, NULL);
 
-	chat->conv = NULL;
+	chat->left = TRUE;
 }
 
 void jabber_chat_destroy(JabberChat *chat)
--- a/libpurple/protocols/jabber/chat.h	Sun Jun 01 20:05:06 2008 +0000
+++ b/libpurple/protocols/jabber/chat.h	Sun Jun 01 21:36:43 2008 +0000
@@ -49,6 +49,7 @@
 	PurpleRequestType config_dialog_type;
 	void *config_dialog_handle;
 	GHashTable *members;
+	gboolean left;
 } JabberChat;
 
 GList *jabber_chat_info(PurpleConnection *gc);
--- a/libpurple/protocols/jabber/presence.c	Sun Jun 01 20:05:06 2008 +0000
+++ b/libpurple/protocols/jabber/presence.c	Sun Jun 01 21:36:43 2008 +0000
@@ -49,7 +49,7 @@
 	xmlnode *presence = user_data;
 	char *chat_full_jid;
 
-	if(!chat->conv)
+	if(!chat->conv || chat->left)
 		return;
 
 	chat_full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server,
@@ -581,13 +581,13 @@
 		if(state == JABBER_BUDDY_STATE_ERROR) {
 			char *title, *msg = jabber_parse_error(js, packet, NULL);
 
-			if(chat->conv) {
+			if (!chat->conv) {
+				title = g_strdup_printf(_("Error joining chat %s"), from);
+				purple_serv_got_join_chat_failed(js->gc, chat->components);
+			} else {
 				title = g_strdup_printf(_("Error in chat %s"), from);
 				if (g_hash_table_size(chat->members) == 0)
 					serv_got_chat_left(js->gc, chat->id);
-			} else {
-				title = g_strdup_printf(_("Error joining chat %s"), from);
-				purple_serv_got_join_chat_failed(js->gc, chat->components);
 			}
 			purple_notify_error(js->gc, title, title, msg);
 			g_free(title);
@@ -609,8 +609,9 @@
 
 			/* If we haven't joined the chat yet, we don't care that someone
 			 * left, or it was us leaving after we closed the chat */
-			if(!chat->conv) {
-				if(jid->resource && chat->handle && !strcmp(jid->resource, chat->handle))
+			if (!chat->conv || chat->left) {
+				if (chat->left &&
+						jid->resource && chat->handle && !strcmp(jid->resource, chat->handle))
 					jabber_chat_destroy(chat);
 				jabber_id_free(jid);
 				g_free(status);
--- a/pidgin/gtkstatusbox.c	Sun Jun 01 20:05:06 2008 +0000
+++ b/pidgin/gtkstatusbox.c	Sun Jun 01 21:36:43 2008 +0000
@@ -1706,6 +1706,48 @@
 }
 
 static void
+treeview_cursor_changed_cb(GtkTreeView *treeview, gpointer data)
+{
+	GtkTreeSelection *sel = gtk_tree_view_get_selection (treeview);
+	GtkTreeModel *model = GTK_TREE_MODEL (data);
+	GtkTreeIter iter;
+	GtkTreePath *cursor;
+	GtkTreePath *selection;
+	gint cmp;
+
+	if (gtk_tree_selection_get_selected (sel, NULL, &iter)) {
+		if ((selection = gtk_tree_model_get_path (model, &iter)) == NULL) {
+			/* Shouldn't happen, but ignore anyway */
+			return;
+		}
+	} else {
+		/* I don't think this can happen, but we'll just ignore it */
+		return;
+	}
+
+	gtk_tree_view_get_cursor (treeview, &cursor, NULL);
+	if (cursor == NULL) {
+		/* Probably won't happen in a 'cursor-changed' event? */
+		gtk_tree_path_free (selection);
+		return;
+	}
+
+	cmp = gtk_tree_path_compare (cursor, selection);
+	if (cmp < 0) {
+		/* The cursor moved up without moving the selection, so move it up again */
+		gtk_tree_path_prev (cursor);
+		gtk_tree_view_set_cursor (treeview, cursor, NULL, FALSE);
+	} else if (cmp > 0) {
+		/* The cursor moved down without moving the selection, so move it down again */
+		gtk_tree_path_next (cursor);
+		gtk_tree_view_set_cursor (treeview, cursor, NULL, FALSE);
+	}
+
+	gtk_tree_path_free (selection);
+	gtk_tree_path_free (cursor);
+}
+
+static void
 pidgin_status_box_init (PidginStatusBox *status_box)
 {
 	GtkCellRenderer *text_rend;
@@ -1869,6 +1911,8 @@
 					G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml);
 	g_signal_connect(G_OBJECT(status_box->popup_window), "button_release_event", G_CALLBACK(treeview_button_release_cb), status_box);
 	g_signal_connect(G_OBJECT(status_box->popup_window), "key_press_event", G_CALLBACK(treeview_key_press_event), status_box);
+	g_signal_connect(G_OBJECT(status_box->tree_view), "cursor-changed",
+					 G_CALLBACK(treeview_cursor_changed_cb), status_box->dropdown_store);
 
 #if GTK_CHECK_VERSION(2,6,0)
 	gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL);