Re: [gtk-list] Changing Buttons in a hbox?



On Wed, 28 Apr 1999 10:12:21 +0200 (METDST), gtk-list@redhat.com (Andreas Tille) wrote:
> 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);
>   }
> }

The simplest solution is to use gtk_widget_set_sensitive() on the buttons
you want to grey out.

The somewhat more difficult solution is to use a GtkNotebook without tabs
(use gtk_notebook_set_show_tabs()) with two pages: one containing the
three buttons, and one containing the single button. Use
gtk_notebook_set_page() to go to the page with the correct set of buttons.


Erik

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2785859  Fax: +31-15-2781843  Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/




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