diff console/gntrequest.c @ 14059:2d1b41e3cf0d

[gaim-migrate @ 16674] Add a way to change some preferences (the preferences for the conversations do not do anything yet). I used the request-api for this, which I think is cool. But too many preferences will make the dialog long, which may not fit in the screen. It looks alright for now though. You can pop the dialog up with "/prefs" command in a converastion. And some other minor fixes. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 09 Aug 2006 03:41:45 +0000
parents 9c4bec886220
children fa8f65cd912c
line wrap: on
line diff
--- a/console/gntrequest.c	Tue Aug 08 23:20:08 2006 +0000
+++ b/console/gntrequest.c	Wed Aug 09 03:41:45 2006 +0000
@@ -251,13 +251,12 @@
 			}
 			else if (type == GAIM_REQUEST_FIELD_LIST)
 			{
-				GntWidget *tree = field->ui_data;
 				GList *list = NULL;
-
 				if (gaim_request_field_list_get_multi_select(field))
 				{
 					const GList *iter;
-					
+					GntWidget *tree = field->ui_data;
+
 					iter = gaim_request_field_list_get_items(field);
 					for (; iter; iter = iter->next)
 					{
@@ -269,7 +268,8 @@
 				}
 				else
 				{
-					gpointer data = gnt_tree_get_selection_data(GNT_TREE(tree));
+					GntWidget *combo = field->ui_data;
+					gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
 					list = g_list_append(list, data);
 				}
 
@@ -315,7 +315,9 @@
 		GList *fields = gaim_request_field_group_get_fields(group);
 		GntWidget *hbox;
 		
-		/* XXX: Do something with the title, perhaps add a bold label  */
+		gnt_box_add_widget(GNT_BOX(box),
+				gnt_label_new_with_format(gaim_request_field_group_get_title(group),
+					GNT_TEXT_FLAG_BOLD));
 
 		for (; fields ; fields = fields->next)
 		{
@@ -328,7 +330,11 @@
 			gnt_box_add_widget(GNT_BOX(box), hbox);
 			
 			if (type != GAIM_REQUEST_FIELD_BOOLEAN)
-				gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(label));
+			{
+				GntWidget *l = gnt_label_new(label);
+				gnt_widget_set_size(l, 0, 1);
+				gnt_box_add_widget(GNT_BOX(hbox), l);
+			}
 
 			if (type == GAIM_REQUEST_FIELD_BOOLEAN)
 			{
@@ -376,28 +382,38 @@
 			{
 				const GList *list;
 				gboolean multi = gaim_request_field_list_get_multi_select(field);
-				GntWidget *tree = gnt_tree_new();
-				gnt_box_add_widget(GNT_BOX(hbox), tree);
-				field->ui_data = tree;
+				if (multi)
+				{
+					GntWidget *tree = gnt_tree_new();
+					gnt_box_add_widget(GNT_BOX(hbox), tree);
+					field->ui_data = tree;
 
-				list = gaim_request_field_list_get_items(field);
-				for (; list; list = list->next)
-				{
-					const char *text = list->data;
-					gpointer key = gaim_request_field_list_get_data(field, text);
-					if (multi)
+					list = gaim_request_field_list_get_items(field);
+					for (; list; list = list->next)
 					{
+						const char *text = list->data;
+						gpointer key = gaim_request_field_list_get_data(field, text);
 						gnt_tree_add_choice(GNT_TREE(tree), key,
 								gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL);
 						if (gaim_request_field_list_is_selected(field, text))
 							gnt_tree_set_choice(GNT_TREE(tree), key, TRUE);
 					}
-					else
+				}
+				else
+				{
+					GntWidget *combo = gnt_combo_box_new();
+					gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
+					gnt_box_add_widget(GNT_BOX(hbox), combo);
+					field->ui_data = combo;
+
+					list = gaim_request_field_list_get_items(field);
+					for (; list; list = list->next)
 					{
-						gnt_tree_add_row_after(GNT_TREE(tree), key,
-								gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL);
+						const char *text = list->data;
+						gpointer key = gaim_request_field_list_get_data(field, text);
+						gnt_combo_box_add_data(GNT_COMBO_BOX(combo), key, text);
 						if (gaim_request_field_list_is_selected(field, text))
-							gnt_tree_set_selected(GNT_TREE(tree), key);
+							gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), key);
 					}
 				}
 			}
@@ -413,9 +429,9 @@
 						gnt_label_new_with_format(_("Not implemented yet."),
 							GNT_TEXT_FLAG_BOLD));
 			}
-			if (fields->next)
-				gnt_box_add_widget(GNT_BOX(box), gnt_hline_new());
 		}
+		if (list->next)
+			gnt_box_add_widget(GNT_BOX(box), gnt_hline_new());
 	}
 	gnt_box_add_widget(GNT_BOX(window), box);
 
@@ -425,7 +441,6 @@
 
 	gnt_widget_show(window);
 	
-	
 	return window;
 }