Re: Adjustment problem



I see that now, but here's the question.

At what point in the call to gtk_adjustment_new() does
adjustment->value get set?  The point of contention is not that it
works after instantiation, but that instantiation is incorrectly using
the gobject api to store values when instead, they should just be
placed in the structure.

I think this function:

GtkObject*
gtk_adjustment_new (gdouble value,
           gdouble lower,
           gdouble upper,
           gdouble step_increment,
           gdouble page_increment,
           gdouble page_size)
{
   return g_object_new (GTK_TYPE_ADJUSTMENT,
              "lower", lower,
              "upper", upper,
              "step-increment", step_increment,
              "page-increment", page_increment,
              "page-size", page_size,
              "value", value,
              NULL);
}

Should really look something like:

GtkAdjustment*
gtk_adjustment_new( double value, double lower, et al )
{
GObject* obj = g_object_new( GTK_TYPE_ADJUSTMENT, NULL ) ;
GtkAdjustment* adjustment = GTK_ADJUSTMENT( obj ) ;

adjustment->value = value ;
adjustment->lower = lower ;

... and so on ...

}



Paul

On 11/1/06, Murray Cumming <murrayc murrayc com> wrote:
On Tue, 2006-10-31 at 15:34 -0600, Paul Davis wrote:
> Murray,
>
> From what I can tell, these are being implemented twice.
[snip]
>   g_object_class_install_property (gobject_class,
>                                    PROP_VALUE,
>                                    g_param_spec_double ("value",
>                             P_("Value"),
>                             P_("The value of the adjustment"),
>                             -G_MAXDOUBLE,
>                             G_MAXDOUBLE,
>                             0.0,
>                             GTK_PARAM_READWRITE));
>
> And gtk_adjustment_new looks like this:
>
> GtkObject*
> gtk_adjustment_new (gdouble value,
>             gdouble lower,
>             gdouble upper,
>             gdouble step_increment,
>             gdouble page_increment,
>             gdouble page_size)
> {
>     return g_object_new (GTK_TYPE_ADJUSTMENT,
>                "lower", lower,
>                "upper", upper,
>                "step-increment", step_increment,
>                "page-increment", page_increment,
>                "page-size", page_size,
>                "value", value,
>                NULL);
> }
>
> gdouble
> gtk_adjustment_get_value (GtkAdjustment *adjustment)
> {
>   g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), 0.);
>
>   return adjustment->value;
> }

Again, if you look at get_property() you should see that it is using
adjustment->value there too.

--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com





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