Re: Patch: Bug 50278



Mike Kestner <mkestner ameritech net> writes:

> Owen Taylor wrote:
> 
> > And since you'll almost certainly need to adjust the value in
> > more code, there is little advantage to putting the value in
> > the constructor.
> 
> I think providing a hardcoded page=10*step is consistent with the goal
> of this helper API, but value cannot be defaulted meaningfully.  Some
> spins start at min.  Some start at 50%. In my random sampling analysis
> of lxr, I don't recall any situations where the initial value provided
> in the gtk_adjustment_new call was altered outside of callback code.  If
> we don't provide the value parameter, we are back to a two call
> construction paradigm, which isn't significantly more compact than the
> existing mechanism.

The point is, generally you have somewhat separate code to:

 construct your interface

and to:

 set the values in the interface

So, including setting the value in the constructor buys you
little or nothing and is inconsistent with the rest of GTK+
where the initial value of a user editable control is not
in the constructor. 

While there may be no sensible default for the value,
it's frequently the case that you don't care what the
value is because you are setting it later, so if you
force people to supply it, they'll have to make something
random up.


And I don't think the idea here is as much reducing the number
of calls to a minimum but making them sensible and easy to 
remember

 adjustment = gtk_adjustment_new (5, 0.0, 10.0, 0.1, 1.0, 0)
 spinbutton = gtk_spin_button_new (adjustment, 0.01, 1);

Is just black obscure magic, while:

 spinbutton = gtk_spin_button_new_with_range (0.0, 10.0, 0.1);
 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton), 5);

Has a meaning that can be guessed at inspection and there
is no problem remembering the order of arguments. 

Adding a fourth argument with new_with_range() makes remembering the
order significantly harder


Finally, the more arguments that spin_button_new_with_range()
has beyond the range, the harder it is to justify the
name ;-)

Regards,
                                        Owen




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