[PATCH] for bug-buddy



Hi,
this little patch use gtk_combo_box instead of deprecated
gtk_option_menu

Please review it

michael gossard
-- 
     \ | /
     <@ @>
--oOO-(_)-OOo---
Index: bug-buddy.glade
===================================================================
RCS file: /cvs/gnome/bug-buddy/src/bug-buddy.glade,v
retrieving revision 1.82
diff -u -p -r1.82 bug-buddy.glade
--- bug-buddy.glade	20 Nov 2004 18:04:30 -0000	1.82
+++ bug-buddy.glade	8 Apr 2005 15:31:50 -0000
@@ -358,16 +358,11 @@ The correct options should have been sel
 					  <property name="right_padding">0</property>
 
 					  <child>
-					    <widget class="GtkOptionMenu" id="gdb-option">
+					    <widget class="GtkComboBox" id="gdb-option">
 					      <property name="visible">True</property>
 					      <property name="can_focus">True</property>
-					      <property name="history">-1</property>
+					      <property name="items" translatable="no">dummy-item</property>
 
-					      <child internal-child="menu">
-						<widget class="GtkMenu" id="convertwidget1">
-						  <property name="visible">True</property>
-						</widget>
-					      </child>
 					    </widget>
 					  </child>
 					</widget>
@@ -1008,16 +1003,10 @@ The correct options should have been sel
 			      </child>
 
 			      <child>
-				<widget class="GtkOptionMenu" id="the-version-menu">
+				<widget class="GtkComboBox" id="the-version-menu">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
-				  <property name="history">-1</property>
-
-				  <child internal-child="menu">
-				    <widget class="GtkMenu" id="menu2">
-				      <property name="visible">True</property>
-				    </widget>
-				  </child>
+				  <property name="items" translatable="no">dummy-item</property>
 				</widget>
 				<packing>
 				  <property name="padding">6</property>
@@ -1048,17 +1037,12 @@ The correct options should have been sel
 			      </child>
 
 			      <child>
-				<widget class="GtkOptionMenu" id="severity-list">
+				<widget class="GtkComboBox" id="severity-list">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
-				  <property name="history">-1</property>
+				  <property name="items" translatable="no">dummy-item</property>
 
-				  <child internal-child="menu">
-				    <widget class="GtkMenu" id="convertwidget9">
-				      <property name="visible">True</property>
-				    </widget>
-				  </child>
-				</widget>
+				  </widget>
 				<packing>
 				  <property name="padding">6</property>
 				  <property name="expand">False</property>
@@ -1181,16 +1165,12 @@ If the bug is already reported, please d
 			      </child>
 
 			      <child>
-				<widget class="GtkOptionMenu" id="optionmenu1">
+				<widget class="GtkComboBox" id="optionmenu1">
 				  <property name="visible">True</property>
 				  <property name="can_focus">True</property>
-				  <property name="history">-1</property>
+				  <property name="items" translatable="no">dummy-item</property>
 
-				  <child internal-child="menu">
-				    <widget class="GtkMenu" id="convertwidget12">
-				      <property name="visible">True</property>
-				    </widget>
-				  </child>
+				 
 				</widget>
 				<packing>
 				  <property name="padding">0</property>
Index: bug-buddy.c
===================================================================
RCS file: /cvs/gnome/bug-buddy/src/bug-buddy.c,v
retrieving revision 1.118
diff -u -p -r1.118 bug-buddy.c
--- bug-buddy.c	21 Nov 2004 16:48:18 -0000	1.118
+++ bug-buddy.c	8 Apr 2005 15:31:52 -0000
@@ -41,7 +41,6 @@
 #include <libgnomevfs/gnome-vfs.h>
 #include <libgnome/libgnometypebuiltins.h>
 #include <gconf/gconf-client.h>
-#include <gtk/gtkoptionmenu.h>
 
 
 #include <libxml/tree.h>
@@ -178,11 +177,12 @@ buddy_get_text_widget (GtkWidget *w)
 static gboolean
 update_crash_type (GtkWidget *w, gpointer data)
 {
-	CrashType new_type = GPOINTER_TO_INT (data);
 	GtkWidget *table, *box, *scrolled, *go;
+	CrashType new_type;
 
 	stop_gdb ();
-
+	
+	new_type = gtk_combo_box_get_active (GTK_COMBO_BOX (w));
 	druid_data.crash_type = new_type;
 	
 	table = GET_WIDGET ("gdb-binary-table");
@@ -500,7 +500,8 @@ init_gnome_version_stuff (void)
 static void
 init_ui (void)
 {
-	GtkWidget *w, *m;
+	GtkWidget *w;
+	GtkListStore *store;
 	char *s;
 	const char **sp;
 	int i;
@@ -567,19 +568,16 @@ init_ui (void)
 	}
 
         /* init some ex-radio buttons */
-	m = gtk_menu_new ();
+	w = GET_WIDGET ("gdb-option");
+	store = (GtkListStore *) gtk_combo_box_get_model (GTK_COMBO_BOX (w));
+	gtk_list_store_clear (store);
 	for (i = 0; crash_type[i]; i++) {
-		w = gtk_menu_item_new_with_label (_(crash_type[i]));
-		g_signal_connect (G_OBJECT (w), "activate",
-				  G_CALLBACK (update_crash_type),
-				  GINT_TO_POINTER (i));
-		gtk_widget_show (w);
-		gtk_menu_shell_append (GTK_MENU_SHELL (m), w);
+	  gtk_combo_box_append_text (GTK_COMBO_BOX (w), _(crash_type[i]));
 	}
-	w = GET_WIDGET ("gdb-option");
-	gtk_option_menu_set_menu (GTK_OPTION_MENU (w), m);
-	gtk_option_menu_set_history (GTK_OPTION_MENU (w), druid_data.crash_type);
-	update_crash_type (NULL, GINT_TO_POINTER (druid_data.crash_type));
+	g_signal_connect (G_OBJECT (w), "changed", 
+			  G_CALLBACK (update_crash_type), NULL);
+	gtk_combo_box_set_active (GTK_COMBO_BOX (w), druid_data.crash_type);
+	update_crash_type (w, GINT_TO_POINTER (druid_data.crash_type));
 
 	gnome_window_icon_set_from_default (GTK_WINDOW (GET_WIDGET ("druid-window")));
 
Index: bugzilla.c
===================================================================
RCS file: /cvs/gnome/bug-buddy/src/bugzilla.c,v
retrieving revision 1.69
diff -u -p -r1.69 bugzilla.c
--- bugzilla.c	15 Apr 2004 20:35:43 -0000	1.69
+++ bugzilla.c	8 Apr 2005 15:31:54 -0000
@@ -1216,31 +1216,23 @@ add_component (gpointer key, BugzillaCom
 static void
 update_severity (GtkWidget *w, gpointer data)
 {
-	druid_data.severity = (char *)data;
+	druid_data.severity = gtk_combo_box_get_active_text (GTK_COMBO_BOX (w));
 }
 
 static void
 update_version (GtkWidget *w, gpointer data)
 {
-	druid_data.version = (char *)data;
+	druid_data.version = gtk_combo_box_get_active_text (GTK_COMBO_BOX (w));
 }
 
 
 static void
-add_severity (char *s, GtkMenu *m)
+add_severity (char *s , GtkComboBox * c)
 {
-	GtkWidget *w;
-
-	w = gtk_menu_item_new_with_label (s);
-	g_signal_connect (G_OBJECT (w), "activate",
-			  G_CALLBACK (update_severity),
-			  s);
-	gtk_widget_show (w);
-	gtk_menu_shell_append (GTK_MENU_SHELL (m), w);
+	gtk_combo_box_append_text (GTK_COMBO_BOX (c), s);
 	if (!strcasecmp (s, "normal") || !strcasecmp (s, "unknown")) {
-		gtk_menu_item_activate (GTK_MENU_ITEM (w));
-		gtk_option_menu_set_history (GTK_OPTION_MENU (GET_WIDGET ("severity-list")), 
-					     g_slist_index (druid_data.product->bts->severities, s));
+		gtk_combo_box_set_active (GTK_COMBO_BOX (c),
+					  g_slist_index (druid_data.product->bts->severities, s));
 	}
 }
 
@@ -1284,22 +1276,20 @@ update_version_menu (BugzillaProduct *pr
 	GSList *versions;
 	GtkWidget *w;
 	GtkWidget *m, *c;
+	GtkListStore *store;
 
 	versions = prod->versions;
 
-	m = gtk_menu_new ();
 	c = GET_WIDGET ("the-version-menu");
-        gtk_option_menu_set_menu (GTK_OPTION_MENU (c), m);
-
+	store = (GtkListStore * ) gtk_combo_box_get_model (GTK_COMBO_BOX (c));
+	gtk_list_store_clear (store);
 	while (versions != NULL) {
-		w = gtk_menu_item_new_with_label ((gchar*)versions->data);
-		g_signal_connect (G_OBJECT (w), "activate",
-				  G_CALLBACK (update_version),
-				  versions->data);
-		gtk_widget_show (w);
-		gtk_menu_shell_append (GTK_MENU_SHELL (m), w);
+		gtk_combo_box_append_text (GTK_COMBO_BOX (c), (gchar*)versions->data);
 		versions = versions->next;
 	}
+	g_signal_connect (G_OBJECT (c), "changed",
+			  G_CALLBACK (update_version),
+			  NULL);
 }
 
 
@@ -1353,10 +1343,12 @@ bugzilla_product_add_components_to_clist
 
 	gtk_tree_view_columns_autosize (w);
 
-	m = gtk_menu_new ();
 	c = GET_WIDGET ("severity-list");
-	gtk_option_menu_set_menu (GTK_OPTION_MENU (c), m);
-	g_slist_foreach (prod->bts->severities, (GFunc)add_severity, m);
+	store = (GtkListStore *) gtk_combo_box_get_model (GTK_COMBO_BOX (c));
+	gtk_list_store_clear (store);
+	g_slist_foreach (prod->bts->severities, (GFunc)add_severity, c);
+	g_signal_connect (G_OBJECT (c), "changed",
+			  G_CALLBACK (update_severity), NULL);
 }
 
 static void
@@ -1377,7 +1369,6 @@ add_mostfreq (BugzillaBug *bug, GtkListS
 gboolean
 bugzilla_add_mostfreq (BugzillaBTS *bts)
 {
-	/* GtkWidget *m, *c; */
 	GtkTreeView *w;
 	GtkListStore *store;
 	GtkTreeSelection *selection;
Index: united-states-of-bug-buddy.c
===================================================================
RCS file: /cvs/gnome/bug-buddy/src/united-states-of-bug-buddy.c,v
retrieving revision 1.73
diff -u -p -r1.73 united-states-of-bug-buddy.c
--- united-states-of-bug-buddy.c	21 Nov 2004 16:48:18 -0000	1.73
+++ united-states-of-bug-buddy.c	8 Apr 2005 15:31:56 -0000
@@ -735,9 +735,9 @@ select_version (GSList *list, char *vers
 
 	if (version && g_slist_find_custom (list, version ,(GCompareFunc)strcmp)!=NULL) {
 		druid_data.version = strdup (version);
-		gtk_option_menu_set_history (GTK_OPTION_MENU (GET_WIDGET ("the-version-menu")),
-					     g_slist_position (list, g_slist_find_custom (list, version, 
-											  (GCompareFunc)strcmp)));
+		gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("the-version-menu")),
+					  g_slist_position (list, g_slist_find_custom (list, version,
+										       (GCompareFunc)strcmp)));
 		return;
 	}
 	 
@@ -750,18 +750,18 @@ select_version (GSList *list, char *vers
 
 		if (g_slist_find_custom (list, xversion ,(GCompareFunc)strcmp)!=NULL) {
 			druid_data.version = strdup (xversion);
-			gtk_option_menu_set_history (GTK_OPTION_MENU (GET_WIDGET ("the-version-menu")),
-						     g_slist_position (list, g_slist_find_custom (list, xversion, 
-												  (GCompareFunc)strcmp)));
+			gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("the-version-menu")),
+						  g_slist_position (list, g_slist_find_custom (list, xversion,
+											       (GCompareFunc)strcmp)));
 			g_free (xversion);
 			return;
 		}
 		g_free (xversion);
 	}
 
-	gtk_option_menu_set_history (GTK_OPTION_MENU (GET_WIDGET ("the-version-menu")),
-				     g_slist_position (list, g_slist_find_custom (list, "unspecified", 
-										  (GCompareFunc)strcmp)));
+	gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("the-version-menu")),
+				  g_slist_position (list, g_slist_find_custom (list, "unspecified", 
+									       (GCompareFunc)strcmp)));
 }
 
 static void
@@ -769,9 +769,9 @@ select_severity (GSList *list, char *sev
 {
 	if (severity && g_slist_find_custom (list, severity, (GCompareFunc)strcmp)!=NULL) {
 		druid_data.severity = strdup (severity);
-		gtk_option_menu_set_history (GTK_OPTION_MENU (GET_WIDGET ("severity-list")),
-					     g_slist_position (list, g_slist_find_custom (list, severity,
-											  (GCompareFunc)strcmp)));
+		gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("severity-list")),
+					  g_slist_position (list, g_slist_find_custom (list, severity,
+										       (GCompareFunc)strcmp)));
 	}
 }
 


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