[PATCH] Menu factory patch #1




I'd like to resubmit this trivial patch which adds radio button support
to the menu factory. It applies cleanly over 0.99.3 & 0.99.4.

To use, simply start a menu entry with <radio> instead of <check>. All
consecutive <radio> entries will belong to the same group.


--- gtkmenufactory.c.save	Fri Jan 16 22:43:15 1998
+++ gtkmenufactory.c	Fri Jan 16 23:07:38 1998
@@ -21,6 +21,7 @@
 #include "gtkmenubar.h"
 #include "gtkmenufactory.h"
 #include "gtkmenuitem.h"
+#include "gtkradiomenuitem.h"
 #include "gtksignal.h"
 
 
@@ -28,7 +29,8 @@
 {
   CREATE  = 1 << 0,
   DESTROY = 1 << 1,
-  CHECK   = 1 << 2
+  CHECK   = 1 << 2,
+  RADIO   = 1 << 3
 };
 
 
@@ -225,7 +227,9 @@
 	}
       else
 	{
-	  if (strncmp (path, "<check>", 7) == 0)
+	  if (strncmp (path, "<radio>", 7) == 0)
+	    menu_path = gtk_menu_factory_get (parent, path + 7, CREATE | RADIO);
+	  else if (strncmp (path, "<check>", 7) == 0)
 	    menu_path = gtk_menu_factory_get (parent, path + 7, CREATE | CHECK);
 	  else
 	    menu_path = gtk_menu_factory_get (parent, path, CREATE);
@@ -419,7 +423,16 @@
       menu_path = g_new (GtkMenuPath, 1);
       menu_path->path = g_strdup (path);
 
-      if (flags & CHECK)
+      if (flags & RADIO) {
+        GSList * group;
+        GList * children = g_list_last(gtk_container_children(GTK_CONTAINER(parent)));
+       	if (children && GTK_IS_RADIO_MENU_ITEM(children->data))
+       		group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(children->data));
+       	else
+       		group = 0;
+	menu_path->widget = gtk_radio_menu_item_new_with_label (group, path);
+      }
+      else if (flags & CHECK)
 	menu_path->widget = gtk_check_menu_item_new_with_label (path);
       else
 	menu_path->widget = gtk_menu_item_new_with_label (path);


-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)




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