Re: Re: Re: Toggle buttons



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
 */
void 
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_TOOLBAR_ICONS);
  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));  
/*      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),
                                GTK_TOOLBAR_CHILD_RADIOBUTTON,
                                NULL,
                                NULL,
                                button[j].tooltip,
                                NULL,
                               
CreateWidgetFromXpmFile(box,button[j].widget),
                                /* NULL, */
                                (GtkSignalFunc) button[j].function,
                                button[j].data);
  }
}

Anybody know what is wrong ?

TIA

cheers,
Jim Parker

On Mon, May 06, 2002 at 02:22:17PM -0400, Jim Parker wrote:
G'Day !

I am building a toolbar(s) in a CAD application.  While I use
radio-buttons
in my menu, the UI would require a major rewite to incorporate the use
of
radio-buttons and I don't think it wold work (I am probably blinded by
convention here).


  I may misunderstand totally, but you're still describing radio
buttons. The only difference between toggle buttons and radio buttons is
that toggle buttons automatically call gtk_toggle_button_set_active()
for every buttons of its group if it is selected.

  Maybe you don't want to use radio buttons like this:
     < > choice 1
     <*> choice 2
     < > choice 3
  and you prefer a toolbox like this:
  |        |[        ]|        |
  | icon 1 |[ icon 2 ]| icon 3 |
  |        |[        ]|        |
 (sorry, if my ascii art looks ugly, I'm not an artist)

then, you can create your radiobuttons like this:
button = gtk_radio_button_new(group);
icon = gtk_pixmap_new(..., ...);
gtk_container_add(GTK_CONTAINER(button), icon);
gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
etc.

The last function prevent the < > or <*> indicator to be drawn, instead,
the radio button will be shown pressed or depressed to show its state.

        DindinX

-- 
David dindinx org



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