Re: Re: Re: Toggle buttons


I guess I figured out..
All radio buttons that automatically interact between them must be on the same group, and from what I see 
it's not what you did.. look:

On Tue, May 07, 2002 at 09:50:38AM -0400, Jim Parker wrote:
G'Day !

Ok you are right ... radio buttons work like I want.  Thanks

I have a bug I can't figure out.  All my buttons look like they are toggled
(it actually works properly)

BTW I'm using GTK+ 1.2.10 on a Debian GNU/Linux system.

below is my code to create my toolbar.  I use an array of struct to hold
the data needed to create the toolbar buttons (works well).

/* Function: CreateRadioButton ( )
 * Test function to create groups of radio buttons for toolbars
add_toolbar_radio (GtkWidget *box, typToolButton button[5])
  GtkWidget *radio;
  GSList *group = NULL;
  guint j;

  handlebox = gtk_handle_box_new ();
  gtk_box_pack_start (GTK_BOX (box),handlebox, FALSE, FALSE, 0);
  gtk_widget_show (handlebox);

  toolbar = gtk_toolbar_new (GTK_ORIENTATION_VERTICAL,
  gtk_container_add(GTK_CONTAINER (handlebox), toolbar);
  gtk_widget_show (toolbar);
  for (j = 0;  j < NUM_ROWS;  j++)
    radio = gtk_radio_button_new(group);
    group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));  
                ^---- here
you get it's group.... and....?
you have to make a single GSList *, for all radio buttons that will be on the
same group, and as you create new buttons, you append them to the list,
like this:

     radio = gtk_radio_button_new(group);
     group = g_slist_append (group, radio);
     gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio), group);  

You don't need to update the already defined radios 'cose you're working with
the GSList, if you append an element the list header doesn't change, but
this list gets "automaticaly updated" 'cose the main node is the same for all..
Hope you undestand this.. hehe


/*      icon = gtk_pixmap_new(..., ...); */
/*      gtk_container_add(GTK_CONTAINER(button), icon); */
    gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(radio), FALSE);
/*      gtk_toggle_button_toggled (FALSE); */
    gtk_toolbar_append_element (GTK_TOOLBAR (toolbar),
                                /* NULL, */
                                (GtkSignalFunc) button[j].function,

Anybody know what is wrong ?


Jim Parker
---end quoted text---

Marcelo R Leitner <mrl netbank com br>

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