Re: glade-3 integration for gtkmm-widgets (was: Reverse-wrapping gtkmm widgets to gtk+ (for glade3))



> What needs work
> (1) properties do not get set by libglade on widget instantiation.

ok, this one seems to be solved.
in glade_module_register_widgets(), we do a

  glade_register_widget(simpledraw_get_type(), simpledraw_glade_new,
NULL, NULL);

with the following function:

// ---------------------------------------------------------
static GtkWidget *simpledraw_glade_new(GladeXML *xml, GType widget_type,
				     GladeWidgetInfo *info)
{
  SimpleDraw *sd = manage(new SimpleDraw);
  GtkWidget *w = GTK_WIDGET(sd->gobj());

  GObjectClass *oclass = G_OBJECT_GET_CLASS(w);

  for (int i=0; i<info->n_properties; i++) {
    const gchar *name = info->properties[i].name;
    const gchar *value = info->properties[i].value;
    GParamSpec *pspec;

    pspec = g_object_class_find_property (oclass, name);
    if (pspec) {
      GValue gvalue = { 0 };

      if (glade_xml_set_value_from_string(xml, pspec, value, &gvalue)) {
        g_object_set_property(G_OBJECT(w), name, &gvalue);
        g_value_unset(&gvalue);
      }
    }
  }

  return w;
}
// ---------------------------------------------------------

this could be written as a template to serve all the widgets in a glade
module.

it is not extensively tested so i would appreciate other users testing
it with their own widgets. (look at the previous post in thread for the
simpledraw example or write me if you can't get your widgets into glade3)

TIA!

however, glade still does not correctly apply property values when
loading a glade file. will do this next ;-)

  --o
-- 
Oliver Nittka
ESEM Grünau GmbH & Co. KG
Dornierstraße 6, 88677 Markdorf/Germany
phone: +49 7544 9583-25, fax: +49 7544 9583-60



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