gossip r2757 - in trunk: . libgossip src



Author: mr
Date: Mon Mar  3 20:07:38 2008
New Revision: 2757
URL: http://svn.gnome.org/viewvc/gossip?rev=2757&view=rev

Log:
Save the chatrooms in the order they appear in the manage chatrooms window


Modified:
   trunk/ChangeLog
   trunk/libgossip/gossip-chatroom-manager.c
   trunk/libgossip/gossip-chatroom-manager.h
   trunk/src/gossip-chatrooms-window.c

Modified: trunk/libgossip/gossip-chatroom-manager.c
==============================================================================
--- trunk/libgossip/gossip-chatroom-manager.c	(original)
+++ trunk/libgossip/gossip-chatroom-manager.c	Mon Mar  3 20:07:38 2008
@@ -262,6 +262,26 @@
 	}
 }
 
+void
+gossip_chatroom_manager_set_index (GossipChatroomManager *manager,
+				   GossipChatroom        *chatroom,
+				   gint                   index)
+{
+	GossipChatroomManagerPriv *priv;
+
+	g_return_if_fail (GOSSIP_IS_CHATROOM_MANAGER (manager));
+	g_return_if_fail (GOSSIP_IS_CHATROOM (chatroom));
+
+	priv = GET_PRIV (manager);
+
+	gossip_debug (DEBUG_DOMAIN,
+		      "Indexing chatroom with name:'%s' to position %d",
+		      gossip_chatroom_get_name (chatroom), index);
+
+	priv->chatrooms = g_list_remove (priv->chatrooms, chatroom);
+	priv->chatrooms = g_list_insert (priv->chatrooms, chatroom, index);
+}
+
 static void
 chatroom_manager_chatroom_enabled_cb (GossipChatroom        *chatroom,
 				      GParamSpec            *arg1,

Modified: trunk/libgossip/gossip-chatroom-manager.h
==============================================================================
--- trunk/libgossip/gossip-chatroom-manager.h	(original)
+++ trunk/libgossip/gossip-chatroom-manager.h	Mon Mar  3 20:07:38 2008
@@ -51,6 +51,9 @@
 							 GossipChatroom        *chatroom);
 void            gossip_chatroom_manager_remove          (GossipChatroomManager *manager,
 							 GossipChatroom        *chatroom);
+void            gossip_chatroom_manager_set_index       (GossipChatroomManager *manager,
+							 GossipChatroom        *chatroom,
+							 gint                   index);
 GossipChatroom *gossip_chatroom_manager_find            (GossipChatroomManager *manager,
 							 GossipChatroomId       id);
 GList *         gossip_chatroom_manager_find_extended   (GossipChatroomManager *manager,

Modified: trunk/src/gossip-chatrooms-window.c
==============================================================================
--- trunk/src/gossip-chatrooms-window.c	(original)
+++ trunk/src/gossip-chatrooms-window.c	Mon Mar  3 20:07:38 2008
@@ -429,6 +429,45 @@
 	}
 }
 
+static gboolean
+chatrooms_window_chatroom_reordered_foreach (GtkTreeModel *model,
+					     GtkTreePath  *path,
+					     GtkTreeIter  *iter,
+					     gpointer      user_data)
+{
+	GossipChatroom        *chatroom;
+	GossipChatroomManager *manager;
+	gint                  *indices;
+
+	/* Reindex the chatrooms in the chatroom manager to make sure
+	 * we save them in the same order.
+	 */
+
+	gtk_tree_model_get (model, iter, COL_POINTER, &chatroom, -1);
+	indices = gtk_tree_path_get_indices (path);
+
+	manager = gossip_app_get_chatroom_manager ();
+	gossip_chatroom_manager_set_index (manager, chatroom, indices[0]);
+	gossip_chatroom_manager_store (manager);
+
+	g_object_unref (chatroom);
+
+	return FALSE;
+}
+
+static void
+chatrooms_window_rows_reordered_cb (GtkTreeModel          *tree_model,
+				    GtkTreePath           *path,
+				    GtkTreeIter           *iter,
+				    gpointer               arg3,
+				    GossipChatroomsWindow *window)
+{
+	gtk_tree_model_foreach (tree_model,
+				(GtkTreeModelForeachFunc)
+				chatrooms_window_chatroom_reordered_foreach,
+				NULL);
+}
+
 static void
 chatrooms_window_model_setup (GossipChatroomsWindow *window)
 {
@@ -463,6 +502,12 @@
 			  G_CALLBACK (chatrooms_window_model_selection_changed), 
 			  window);
 
+
+	/* Model */
+	g_signal_connect (GTK_TREE_MODEL (store), "rows-reordered",
+			  G_CALLBACK (chatrooms_window_rows_reordered_cb),
+			  window);
+
 	/* Columns */
 	chatrooms_window_model_add_columns (window);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]