Re: [gtk-list] Buttons...



On Sun, 1 Mar 1998, Leeman Strout wrote:

> 
> What's the easiest way to check the state of a button?  Rather than right
> callback code to set a simple variable, I would like to use a check on the
> state of the button itself.

what do you mean by "state"?

1)
if you want to know whether a button is sensitive, you can check this through

if (GTK_WIDGET_IS_SENSITIVE (button));

note that the _IS_ part of the macro is important, since there are also
the GTK_WIDGET_SENSITIVE() and GTK_WIDGET_PARENT_SENSITIVE() which are mere
internal states, and GTK_WIDGET_IS_SENSITIVE() is a combination of the two.

2)
if you want to know about the visible state of a button, you can use
switch (GTK_WIDGET_STATE (button))
{
case GTK_STATE_NORMAL:
case GTK_STATE_ACTIVE:
case GTK_STATE_PRELIGHT:
case GTK_STATE_SELECTED:
case GTK_STATE_INSENSITIVE:
}

note that GTK_WIDGET_STATE (button) == GTK_STATE_INSENSITIVE goes along
!GTK_WIDGET_IS_SENSITIVE (button).

3)
if you want to know what state a check/radio/toggle button is in, you would
want to react on

if (GTK_TOGGLE_BUTTON (my_radio_check_or_toggle_button)->active);



ok, i'm pretty sure i have covered your question with one of the above ;)


> 
> Leeman
> alaric@ct2.nai.net
> 

---
ciaoTJ



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