Re: Adjustment problem



Murray,

From what I can tell, these are being implemented twice.

The following is from  gtk+/gtk/gtkadjustment.h and .c

struct _GtkAdjustment
{
 GtkObject parent_instance;

 gdouble lower;
 gdouble upper;
 gdouble value;
 gdouble step_increment;
 gdouble page_increment;
 gdouble page_size;
};

 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;
}

void
gtk_adjustment_set_value (GtkAdjustment        *adjustment,
             gdouble               value)
{
 g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));

 value = CLAMP (value, adjustment->lower, adjustment->upper);

 if (value != adjustment->value)
   {
     adjustment->value = value;

     gtk_adjustment_value_changed (adjustment);
   }
}

So, what I think I'm looking at is this:

gtk_adjustment_new() is using the property api for storing value et al.

Ie, it'd work if we did something like:

g_object_get_property( adj->gobj(), "value", &value ) ;

But, the get/set functions are using the structure variables.

Ie, gtk has two places it wants to store value, one is in the gobject
property, and the second is in the structure member.

Gtk::Adjustment doesn't wrap properties. As near as I can tell, Gtkmm
only looks at the structure members, except at instantiation, when it
passes the values just to the properties.

So I patched it to also initialize the structure members.

If thats totally incomprehensible, let me know.

Paul

On 10/31/06, Murray Cumming <murrayc murrayc com> wrote:
On Tue, 2006-10-31 at 14:24 -0600, Paul Davis wrote:
> Ie, the value, lower, upper, et al values are stored as *both*
> properties and structure member variables.

Properties must be implemented somehow. Most of the time that's done by
getting/setting struct member variables in the get_property() and
set_property() vfunc implementations. If these properties are not being
properly set then it should be fairly easy to investigate why not.

--
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]