patch for menu box mode in gdialog



The attached patch makes the menu box mode use an option menu, and not a
scrolled window with buttons, which looked really ugly.

Is it ok to commit?

cheers
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-utils/gdialog/ChangeLog,v
retrieving revision 1.27
diff -u -r1.27 ChangeLog
--- ChangeLog	24 Aug 2002 07:45:37 -0000	1.27
+++ ChangeLog	22 Sep 2002 16:52:54 -0000
@@ -1,3 +1,8 @@
+2002-09-22  Rodrigo Moya <rodrigo gnome-db org>
+
+	* menubox.c (dialog_menu): replaced the ugly scrolled window with
+	buttons with a nice GtkOptionMenu.
+
 2002-08-24  Archit Baweja  <bighead users sourceforge net>
 
 	* msgbox.c (dialog_msgbox): in --infobox mode, exit immediately but
Index: menubox.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gdialog/menubox.c,v
retrieving revision 1.13
diff -u -r1.13 menubox.c
--- menubox.c	29 Jul 2002 12:17:31 -0000	1.13
+++ menubox.c	22 Sep 2002 16:52:54 -0000
@@ -83,10 +83,10 @@
 	
 	if(gnome_mode) 	{
 		GtkWidget *w;
-		GtkWidget *but;
+		GtkWidget *options;
 		GtkWidget *first_button;
-		GtkWidget *butbox;
-		GtkWidget *sw;
+		GtkWidget *but;
+		GtkWidget *menu;
 
 		w = gtk_dialog_new_with_buttons (title,	NULL,
 				GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -100,26 +100,24 @@
 		label_autowrap(GTK_DIALOG(w)->vbox, prompt, width);
 
 		/*
-		 * Setup the containers.
+		 * Setup the option menu
 		 */
-		sw = gtk_scrolled_window_new (NULL, NULL);
- 		gtk_box_pack_start_defaults (
-			GTK_BOX (GTK_DIALOG (w)->vbox), sw);
-		gtk_widget_show (sw);
-
- 		butbox = gtk_vbox_new (FALSE, 0);
- 		gtk_scrolled_window_add_with_viewport (
-			GTK_SCROLLED_WINDOW (sw), butbox);
- 		gtk_widget_show (butbox);
+		options = gtk_option_menu_new ();
+ 		gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (w)->vbox), options);
+		gtk_widget_show (options);
 
-		gtk_container_set_border_width (GTK_CONTAINER (butbox),
-						GNOME_PAD);
 		/*
 		 * Add the buttons.
 		 */
 		the_items = items;
 		first_button = NULL;
-		
+		menu = gtk_option_menu_get_menu (options);
+		if (!GTK_IS_MENU (menu)) {
+			menu = gtk_menu_new ();
+			gtk_option_menu_set_menu (GTK_OPTION_MENU (options), menu);
+			gtk_widget_show (menu);
+		}
+
 		for(i=0; i< item_no; i++)
 		{
 			char *x = (char *)items[2*i];
@@ -127,21 +125,27 @@
 			char *p;
 
 			p = g_strdup_printf("%s  -   %s", x, y);
-			but=gtk_button_new_with_label(p);
+			but = gtk_menu_item_new_with_label (p);
 			g_free(p);
+			gtk_widget_show (but);
 
 			if (first_button == NULL)
 				first_button = but;
+			else
+				gtk_signal_connect(GTK_OBJECT(but), "activate",
+						   GTK_SIGNAL_FUNC(okayed), GUINT_TO_POINTER(i));
+
+			gtk_menu_shell_append (GTK_MENU_SHELL (menu), but);
 
-			gtk_box_pack_start(GTK_BOX(butbox), but, TRUE, TRUE, 0);
-			gtk_signal_connect(GTK_OBJECT(but), "clicked",
-			GTK_SIGNAL_FUNC(okayed), GUINT_TO_POINTER(i));
 		}
 
 
 		gtk_widget_show_all(w);
-		if (first_button != NULL)
-			gtk_widget_grab_focus (first_button);
+		if (first_button != NULL) {
+			gtk_menu_shell_activate_item (GTK_MENU_SHELL (menu), first_button, FALSE);
+			gtk_signal_connect(GTK_OBJECT(first_button), "activate",
+					   GTK_SIGNAL_FUNC(okayed), GUINT_TO_POINTER(0));
+		}
 		gtk_main();
 		return 0;
 	}


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