Re: [gtk-list] Proper App Behaviour: Sensitivity Strategy?
- From: Havoc Pennington <hp redhat com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Proper App Behaviour: Sensitivity Strategy?
- Date: 17 Dec 1999 23:55:50 -0500
Derek Simkowiak <dereks@kd-dev.com> writes:
> I was hoping there was some way I could have the menuitem "watch"
> a particular variable, and then become insensitive automatically.
>
A GtkBoolean object?
> What about a GtkAdjustment widget? If it works for a "range" with
> scrollbars, couldn't it work for a boolean on a menuitem or button on a
> toolbar? Then I could have my "Save" callback set that GtkAdjustment to
> "FALSE" (or 0.0, whatever) and all the items that depend on that-- the
Well:
a) GtkAdjustment isn't a widget
b) 0.0 is not FALSE
So you have two rather alarming type errors there. :-)
I think emitting a signal when sensitivity should change is a very
good idea though, if you drop the GtkAdjustment part. I would either
add an appropriate signal to some relevant object already in your app,
or write a GtkBoolean object (world's heaviest way to store one bit!).
A more trivial solution:
static gboolean foo = FALSE;
static GSList* widgets = NULL;
gboolean get_foo_setting()
{
return foo;
}
void set_foo_setting(gboolean value)
{
GSList *iter;
foo = value;
iter = widgets;
while (iter != NULL) {
gtk_widget_set_sensitive(GTK_WIDGET(iter->data),
foo); /* or !foo, to taste */
iter = g_slist_next(iter);
}
}
void watch_foo_setting(GtkWidget* widget)
{
gtk_widget_set_sensitive(widget, foo);
widgets = g_slist_prepend(widgets, widget);
/* maybe on widget destroy, remove it from the list */
}
void unwatch_foo_setting(GtkWidget* iwdget)
{
widgets = g_slist_remove(widgets, widget);
}
Forgive the indentation, I'm not in cc-mode.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]