changeset 11796:b9b7a010b043

[gaim-migrate @ 14087] I need to sleep. This isn't finished. Hopefully someone will finish it before I wake up. Moved Preferences > Buddy List to Buddies menu. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 24 Oct 2005 08:06:34 +0000
parents f48e2acaa5d2
children e6bbf34b2465
files src/gtkblist.c src/gtkblist.h src/gtkprefs.c
diffstat 3 files changed, 84 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Mon Oct 24 07:46:21 2005 +0000
+++ b/src/gtkblist.c	Mon Oct 24 08:06:34 2005 +0000
@@ -101,7 +101,7 @@
 
 static GtkWidget *protomenu = NULL;
 
-GSList *gaim_gtk_blist_sort_methods = NULL;
+static GList *gaim_gtk_blist_sort_methods = NULL;
 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL;
 static GtkTreeIter sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur);
 
@@ -1310,6 +1310,12 @@
 	return handled;
 }
 
+static void gaim_gtk_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item)
+{
+	gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons",
+			    gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
+}
+
 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item)
 {
 	gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups",
@@ -2328,10 +2334,13 @@
 	{ "/Buddies/sep1", NULL, NULL, 0, "<Separator>" },
 	{ N_("/Buddies/Show _Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"},
 	{ N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>"},
+	{ N_("/Buddies/Show Buddy _Details"), NULL, gaim_gtk_blist_buddy_details_cb, 1, "<CheckItem>"},
+	{ N_("/Buddies/Sorting"), NULL, NULL, 0, "<Branch>" },
+	{ "/Buddies/sep2", NULL, NULL, 0, "<Separator>" },
 	{ N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD },
 	{ N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD },
 	{ N_("/Buddies/Add _Group..."), NULL, gaim_blist_request_add_group, 0, "<StockItem>", GTK_STOCK_ADD },
-	{ "/Buddies/sep2", NULL, NULL, 0, "<Separator>" },
+	{ "/Buddies/sep3", NULL, NULL, 0, "<Separator>" },
 	{ N_("/Buddies/_Quit"), "<CTL>Q", gaim_core_quit, 0, "<StockItem>", GTK_STOCK_QUIT },
 
 	/* Tools */
@@ -3316,12 +3325,15 @@
 			gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups"));
 	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))),
 			gaim_prefs_get_bool("/gaim/gtk/sound/mute"));
+	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))),
+                	gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"));
 	if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none"))
 		gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE);
 
 	/* Update some dynamic things */
 	update_menu_bar(gtkblist);
 	gaim_gtk_blist_update_plugin_actions();
+	gaim_gtk_blist_update_sort_methods();
 
 	/* OK... let's show this bad boy. */
 	if (gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")) {
@@ -4631,32 +4643,39 @@
  * Buddy List sorting functions                                      *
  *********************************************************************/
 
+GList *gaim_gtk_blist_get_sort_methods()
+{
+	return gaim_gtk_blist_sort_methods;
+}
+
 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func)
 {
 	struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1);
 	method->id = g_strdup(id);
 	method->name = g_strdup(name);
 	method->func = func;
-	gaim_gtk_blist_sort_methods = g_slist_append(gaim_gtk_blist_sort_methods, method);
+	gaim_gtk_blist_sort_methods = g_list_append(gaim_gtk_blist_sort_methods, method);
+	gaim_gtk_blist_update_sort_methods();
 }
 
 void gaim_gtk_blist_sort_method_unreg(const char *id){
-	GSList *l = gaim_gtk_blist_sort_methods;
+	GList *l = gaim_gtk_blist_sort_methods;
 
 	while(l) {
 		struct gaim_gtk_blist_sort_method *method = l->data;
 		if(!strcmp(method->id, id)) {
-			gaim_gtk_blist_sort_methods = g_slist_delete_link(gaim_gtk_blist_sort_methods, l);
+			gaim_gtk_blist_sort_methods = g_list_delete_link(gaim_gtk_blist_sort_methods, l);
 			g_free(method->id);
 			g_free(method->name);
 			g_free(method);
 			break;
 		}
 	}
+	gaim_gtk_blist_update_sort_methods();
 }
 
 void gaim_gtk_blist_sort_method_set(const char *id){
-	GSList *l = gaim_gtk_blist_sort_methods;
+	GList *l = gaim_gtk_blist_sort_methods;
 
 	if(!id)
 		id = "none";
@@ -5116,3 +5135,49 @@
 		
 	}
 }
+
+void sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id)
+{
+	if (gtk_check_menu_item_get_active(checkmenuitem))
+		gaim_gtk_blist_sort_method_set(id);
+}
+
+void
+gaim_gtk_blist_update_sort_methods(void)
+{
+	GtkWidget *menuitem = NULL, *activeitem = NULL;
+	GaimGtkBlistSortMethod *method = NULL;
+	GList *l;
+	GSList *sl = NULL;
+	GtkWidget *sortmenu;
+	char *m = gaim_prefs_get_string("/gaim/gtk/blist/sort_type");
+
+	if (gtkblist == NULL)
+		return;
+
+	sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sorting"));
+
+	if (sortmenu == NULL)
+		return;
+
+	/* Clear the old menu */
+	for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = l->next) {
+		menuitem = l->data;
+		gtk_widget_destroy(GTK_WIDGET(menuitem));
+	}
+	
+	for (l = gaim_gtk_blist_sort_methods; l; l = l->next) {
+		method = (GaimGtkBlistSortMethod *) l->data;
+		menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name));
+		if (!strcmp(m, method->id))
+			activeitem = menuitem;
+		sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem));
+		gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem);
+		g_signal_connect(G_OBJECT(menuitem), "toggled",
+				 G_CALLBACK(sortmethod_act), method->id);
+		gtk_widget_show(menuitem);		
+	}
+	if (activeitem)
+		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE);
+
+}
--- a/src/gtkblist.h	Mon Oct 24 07:46:21 2005 +0000
+++ b/src/gtkblist.h	Mon Oct 24 08:06:34 2005 +0000
@@ -195,7 +195,12 @@
 
 typedef GtkTreeIter (*gaim_gtk_blist_sort_function)(GaimBlistNode *new, GaimBuddyList *blist, GtkTreeIter group, GtkTreeIter *cur);
 
-extern GSList *gaim_gtk_blist_sort_methods;
+/**
+ * Gets the current list of sort methods.
+ *
+ * @return A GSlist of sort methods
+ */
+GList *gaim_gtk_blist_get_sort_methods();
 
 struct gaim_gtk_blist_sort_method {
 	char *id;
@@ -203,6 +208,8 @@
 	gaim_gtk_blist_sort_function func;
 };
 
+typedef struct gaim_gtk_blist_sort_method GaimGtkBlistSortMethod;
+
 /**
  * Registers a buddy list sorting method.
  *
@@ -243,6 +250,11 @@
 void gaim_gtk_blist_update_plugin_actions();
 
 /**
+ * Updates the Sorting menu on the GTK+ buddy list window.
+ */
+void gaim_gtk_blist_update_sort_methods();
+
+/**
  * Determines if showing the join chat dialog is a valid action.
  *
  * @return Returns TRUE if there are accounts online capable of
--- a/src/gtkprefs.c	Mon Oct 24 07:46:21 2005 +0000
+++ b/src/gtkprefs.c	Mon Oct 24 08:06:34 2005 +0000
@@ -772,40 +772,6 @@
 	gaim_prefs_set_string("/gaim/gtk/conversations/bgcolor", "");
 }
 
-static GtkWidget *
-list_page()
-{
-	GtkWidget *ret;
-	GtkWidget *vbox;
-	GList *l= NULL;
-	GSList *sl;
-	ret = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
-	gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER);
-
-
-	vbox = gaim_gtk_make_frame (ret, _("Buddy List Sorting"));
-
-	for (sl = gaim_gtk_blist_sort_methods; sl != NULL; sl = sl->next) {
-		struct gaim_gtk_blist_sort_method *method = sl->data;
-
-		l = g_list_append(l, method->name);
-		l = g_list_append(l, method->id);
-	}
-
-	gaim_gtk_prefs_dropdown_from_list(vbox, _("_Sorting:"), GAIM_PREF_STRING,
-			"/gaim/gtk/blist/sort_type", l);
-
-	g_list_free(l);
-
-	vbox = gaim_gtk_make_frame (ret, _("Buddy Display"));
-	gaim_gtk_prefs_checkbox(_("Show more buddy details"),
-			"/gaim/gtk/blist/show_buddy_icons", vbox);
-
-	gtk_widget_show_all(ret);
-
-	return ret;
-}
-
 static void
 conversation_usetabs_cb(const char *name, GaimPrefType type, gpointer value,
                           gpointer data)
@@ -1752,7 +1718,6 @@
 
 static void prefs_notebook_init() {
 	GtkTreeIter p, c, c2;
-	prefs_notebook_add_page(_("Buddy List"), NULL, list_page(), &c, &p, notebook_page++);
 	prefs_notebook_add_page(_("Conversations"), NULL, conv_page(), &c, &p, notebook_page++);
 	prefs_notebook_add_page(_("Smiley Themes"), NULL, theme_page(), &c2, &c, notebook_page++);
 	prefs_notebook_add_page(_("Sounds"), NULL, sound_page(), &c, &p, notebook_page++);