Re: [gtk-list] Re: Proper App Behaviour: Sensitivity Strategy?
- From: Derek Simkowiak <dereks kd-dev com>
- To: Havoc Pennington <hp redhat com>
- cc: gtk-list redhat com, recipient list not shown: ;
- Subject: Re: [gtk-list] Re: Proper App Behaviour: Sensitivity Strategy?
- Date: Sat, 18 Dec 1999 00:14:21 -0800 (PST)
> > I was hoping there was some way I could have the menuitem "watch"
> > a particular variable, and then become insensitive automatically.
[...]
> I think emitting a signal when sensitivity should change is a very
> good idea though, if you drop the GtkAdjustment part.
[...]
> A more trivial solution:
> void set_foo_setting(gboolean value)
> {
[...snip function to automatically set all 'watching' variables to
insensitive...]
> }
So as far as application design goes, I have two options when it
comes to callback functions which affect menu-item and toolbar-button
sensitivity (i.e., "File/Save" sets "File/Save" and the "Save" toolbar
button to insensitive, or having the "Edit/Search" menu-item be
insensitive if the file length is zero...). The options are:
a) Have the callback for each widget-sensitivity-affecting-menuitem call
the function gtk_widget_set_sensitivity() multiple times (once for every
single widget which it affects).
b) When I create the menu-item or toolbar button, at that time I would
have it watch for a sensitivity signal (or add it to a linked list, as in
your prior example).
With (a), I keep the info of which application operations affect
what widgets near the operation itself. So if I create a new menu-item,
I'll need to go into all the appropriate modules and add a call to
gtk_widget_set_sensitivity() for every callback which affects that item's
sensitivity.
With (b), I keep the info of which operations affect the
sensitivity together with the widget. So if I create a new menu-item, I
would immediately (in the source code) have it "watch" all the appropriate
variables. Then, in the callbacks for the operations, I only set a single
variable (or send the right signal) and all the correct widgets are set
[in]sensitive.
It sounds like (b) is the better design, although it may not be as
immediately obvious to people browsing through the source code. Thanks
for the help. (BTW, I noticed that many apps in the CVS repository are
using the (a) method).
--Derek
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]