diff src/prefs.c @ 5422:af62169c74fd

[gaim-migrate @ 5801] Not to be too LSchieresque, but: <SeanEgan> Which should I do? Finish writing sorting code or commit sorting code? <Robot101> the latter, then the former. This is my incomplete buddy list sorting code. Sorting methods are modular, a plugin can add its own if it wanted to. Included are four sorting methods: None - this will be perceived as no sorting. It sorts the list in the order specified in blist.xml Alphabetical - duh. By status - this isn't really written yet, but I'm going to fix it right now. This will sort using idle time, away status, and online status when it's written By log file size - this puts the people you talk to the most at the top of your list. Pretty keen, eh? Of course this is replete with Sean Egan Hacks (TM). Now I'm going to go eat some weird "golden crunch" cereal from nestle. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 18 May 2003 03:41:31 +0000
parents c54cb8f8655f
children 19224d2ab31e
line wrap: on
line diff
--- a/src/prefs.c	Sun May 18 02:50:49 2003 +0000
+++ b/src/prefs.c	Sun May 18 03:41:31 2003 +0000
@@ -573,8 +573,27 @@
 	GtkWidget *ret;
 	GtkWidget *vbox;
 	GtkWidget *button, *b2;
+	int r = 0;
+	gboolean fnd = FALSE;
+	GList *l= NULL;
+	GSList *sl = gaim_gtk_blist_sort_methods;
 	ret = gtk_vbox_new(FALSE, 18);
 	gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
+	
+	
+	vbox = make_frame (ret, _("Buddy List Sorting"));
+	while (sl) {
+		l = g_list_append(l, ((struct gaim_gtk_blist_sort_method*)sl->data)->name);
+		l = g_list_append(l, ((struct gaim_gtk_blist_sort_method*)sl->data)->name);
+		if (!fnd && !gaim_utf8_strcasecmp(((struct gaim_gtk_blist_sort_method*)sl->data)->name, sort_method))
+			fnd = TRUE;
+			sl = sl->next;
+		if (!fnd) r++;
+	}
+	gaim_dropdown_from_list(vbox, _("Sorting:"),
+				(int*)&sort_method, r, l);
+	
+	g_list_free(l);
 
 	vbox = make_frame (ret, _("Buddy List Toolbar"));
 	gaim_dropdown(vbox, _("Show _buttons as:"), &blist_options, OPT_BLIST_SHOW_BUTTON_XPM | OPT_BLIST_NO_BUTTON_TEXT,
@@ -2300,6 +2319,12 @@
 	int opt = GPOINTER_TO_INT(g_object_get_data(w, "value"));
 	int clear = GPOINTER_TO_INT(g_object_get_data(w, "clear"));
 
+	if (option == (int*)&sort_method) {
+		/* Hack city -- Population: Sean Egan */
+		char *name = (char*)opt;
+		 gaim_gtk_blist_sort_method_set(name);
+		 return;
+	}		
 	if (clear != -1) {
 		*option = *option & ~clear;
 		*option = *option | opt;
@@ -2340,7 +2365,7 @@
 		//    set_blist_tab();
 	} else if (option == (int *)&conv_placement_option) {
 		gaim_conv_placement_set_active(conv_placement_option);
-	}
+	} 
 }
 
 static GtkWidget *gaim_dropdown(GtkWidget *box, const gchar *title, int *option, int clear, ...)
@@ -2409,7 +2434,10 @@
 		gtk_widget_show(opt);
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
 
-		if (((clear > -1) && ((*option & clear) == value)) || *option == value) {
+		if (option == (int*)sort_method) {
+			/* Now Entering Hacksville, Estd. May 17, 2003 */
+			gtk_menu_set_active(GTK_MENU(menu), clear);
+		} else if (((clear > -1) && ((*option & clear) == value)) || *option == value) {
 			gtk_menu_set_active(GTK_MENU(menu), o);
 		}
 		o++;