Changing Buttons in a hbox?



Hello,

I want to do the following:

Under certain circumstances in a GtkHbox should appear three buttons

    +----------------------------------------------------------+
    |    <button-1>       <button-2>       <button-3>          |
    +----------------------------------------------------------+

In another state of the program only one button should be visible
(and this button is different from the three above.

    +----------------------------------------------------------+
    |                  <other-button>                          |
    +----------------------------------------------------------+

The states switch depending from some user actions.  I could destroy
the GtkButton widgets and create then new after each change including
setting the appropriate callbacks.  But I think there must be a more
clever solution which only hides the buttons (or removes them from the
box and I can restore them easily when needed) which could be
stored in something like:

int SwitchButtons(int condition)
{
  static GtkWidget *button_1 = NULL, 
                   *button_2 = NULL, 
                   *button_3 = NULL, 
                   *other_button = NULL;
 
  if ( "buttons == NULL" ) {
    InitializeButtons(...);
    return;
  } 
  if ( condition ) {
    hide_other_button(other_button);
    restore_three_buttons(button_1, button_2, button_3);
  } else {
    hide_three_buttons(button_1, button_2, button_3);
    restore_other_button(other_button);
  }
}

Kind regards

      Andreas.



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