libglade 0.13 does nothing with the "group" attribute of radio
menu items, so every GtkRadioMenuItem ends up in its own group.

Fortunately, libglade *does* honor the group attribute for
GtkRadioButtons.  Using the code in glade-gtk.c\radiobutton_new()
as an example, I was able to come up with (okay, cut & paste :)
a patch to glade-gtk.c\radiomenuitem_new() which lets
GtkRadioMenuItems be grouped properly.

The attached context diffs show the required changes.  Again, the
changes are for libglade 0.13, for the module glade/glade-gtk.c.

--
Mitch Chapman
[EMAIL PROTECTED]

Harry Henry Gebel wrote:
> 
> I have a set of three menu options I have set as GtkRadioMenuItem in Glade,
> I set each to have group 'search_mode'. When I run the program using
> libglade, all three are turned on as though each was in a different
> group. Am I misunderstanding how to use the 'group' entry in Glade, and if
> so how do I get these three buttons into the same group? I am currently
> using GtkCheckMenuItem and being careful to only have one set at a time,
> but I would rather use GtkRadioMenuItem .
> 
> I am using gtk v 1.2.7, pygtk 0.6.6, libglade 0.12, glade 0.5.8,
> gnome-libs 1.0.54, and pygnome 1.0.53 . I am running Mandrake 7.0 .
> 
> --
> Harry Henry Gebel, Senior Developer, Landon House SBS
> West Dover Hundred, Delaware
> -
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]


*** glade-gtk.c.new     Tue Jun 20 08:24:56 2000
--- glade-gtk.c.orig    Tue Jun 20 08:25:53 2000
***************
*** 23,29 ****
  #include "config.h"
  #endif
  
- #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <glade/glade-build.h>
--- 23,28 ----
***************
*** 1894,1901 ****
        GList *tmp;
        char *label = NULL;
        gboolean right = FALSE, active = FALSE, toggle = FALSE;
-       GSList *group = NULL;
-       char *group_name = NULL;
  
        for (tmp = info->attributes; tmp; tmp = tmp->next) {
                GladeAttribute *attr = tmp->data;
--- 1893,1898 ----
***************
*** 1908,1923 ****
                        active = attr->value[0] == 'T';
                else if (!strcmp(attr->name, "always_show_toggle"))
                        toggle = attr->value[0] == 'T';
-                 else if (!strcmp(attr->name, "group")){
-                       group_name = attr->value;
-                       group = g_hash_table_lookup (xml->priv->radio_groups,
-                                                    group_name);
-                       if (!group)
-                               group_name = g_strdup(group_name);
-                 }
        }
  
!       menuitem = gtk_radio_menu_item_new_with_label(group, "");
        if (label){
                char *s = label [0] ? _(label) : "";
                
--- 1905,1914 ----
                        active = attr->value[0] == 'T';
                else if (!strcmp(attr->name, "always_show_toggle"))
                        toggle = attr->value[0] == 'T';
        }
  
!       /* XXXX -- must do something about radio item groups ... */
!       menuitem = gtk_radio_menu_item_new_with_label(NULL, "");
        if (label){
                char *s = label [0] ? _(label) : "";
                
***************
*** 1943,1956 ****
  
        if (right)
                gtk_menu_item_right_justify(GTK_MENU_ITEM(menuitem));
-         
-       if (group_name) {
-               GtkRadioMenuItem *radio = GTK_RADIO_MENU_ITEM(menuitem);
-               
-               g_hash_table_insert (xml->priv->radio_groups,
-                                    group_name,
-                                    gtk_radio_menu_item_group (radio));
-       } 
        gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(menuitem), active);
        gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(menuitem), toggle);
  
--- 1934,1939 ----
*** glade-gtk.c.new     Tue Jun 20 08:24:56 2000
--- glade-gtk.c.orig    Tue Jun 20 08:25:53 2000
***************
*** 23,29 ****
  #include "config.h"
  #endif
  
- #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <glade/glade-build.h>
--- 23,28 ----
***************
*** 1894,1901 ****
        GList *tmp;
        char *label = NULL;
        gboolean right = FALSE, active = FALSE, toggle = FALSE;
-       GSList *group = NULL;
-       char *group_name = NULL;
  
        for (tmp = info->attributes; tmp; tmp = tmp->next) {
                GladeAttribute *attr = tmp->data;
--- 1893,1898 ----
***************
*** 1908,1923 ****
                        active = attr->value[0] == 'T';
                else if (!strcmp(attr->name, "always_show_toggle"))
                        toggle = attr->value[0] == 'T';
-                 else if (!strcmp(attr->name, "group")){
-                       group_name = attr->value;
-                       group = g_hash_table_lookup (xml->priv->radio_groups,
-                                                    group_name);
-                       if (!group)
-                               group_name = g_strdup(group_name);
-                 }
        }
  
!       menuitem = gtk_radio_menu_item_new_with_label(group, "");
        if (label){
                char *s = label [0] ? _(label) : "";
                
--- 1905,1914 ----
                        active = attr->value[0] == 'T';
                else if (!strcmp(attr->name, "always_show_toggle"))
                        toggle = attr->value[0] == 'T';
        }
  
!       /* XXXX -- must do something about radio item groups ... */
!       menuitem = gtk_radio_menu_item_new_with_label(NULL, "");
        if (label){
                char *s = label [0] ? _(label) : "";
                
***************
*** 1943,1956 ****
  
        if (right)
                gtk_menu_item_right_justify(GTK_MENU_ITEM(menuitem));
-         
-       if (group_name) {
-               GtkRadioMenuItem *radio = GTK_RADIO_MENU_ITEM(menuitem);
-               
-               g_hash_table_insert (xml->priv->radio_groups,
-                                    group_name,
-                                    gtk_radio_menu_item_group (radio));
-       } 
        gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(menuitem), active);
        gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(menuitem), toggle);
  
--- 1934,1939 ----

Reply via email to