Re: ComboBoxText and constructor/new issues



On Mon, 2011-05-16 at 17:24 -0400, John Palmieri wrote:
> I thought this was fixed in Gtk+ but it might just be another object that does its setup in the wrong place.  We use g_object_new to instantiate a gobject so if the gobject does any setup code in its constructor, that never gets run.  Constructors should be convenience methods.  All objects should set sane defaults in their init method.

Ok, so it appears I understood things correctly. It might seem like
nothing, but since I've been trying to figure these things out on my own
as there is yet no documentation for PyGI, I'm quite happy to see I'm
not too far off. :)

> I would file a bug on Gtk+

Done: https://bugzilla.gnome.org/show_bug.cgi?id=650369

Looking at the Gtk+ C sources, I can see this widget has the follwoing
two methods:

static GObject * gtk_combo_box_text_constructor (
                        GType                 type,
                        guint                 n_construct_properties,
                        GObjectConstructParam *construct_properties)
{
[... snip ...]
}

static void gtk_combo_box_text_init (GtkComboBoxText *combo_box)
{
[... snip ...]
}

Could that be what you meant?

The second one is the one that creates the ListStore, which could be
what is missing in this case.

Anyway, I'm talking way past my understanding of Gtk now, so I'll
probably let the developers fix this bug. ^_^'

> and just use the new constructor for now.

The problem is that if I do that, I can't declare the GtkComboBoxText in
my GtkBuilder ui file.

So I'm using another workaround: I kept the GtkBuilder ui file intact
(it still declares the GtkComboBoxText) and then I create the ListStore,
set it as the model for the combobox and append my items to the store
rather than directly to the combobox.

Sure, I lose the advantages of the GtkComboBoxText (as I understood
them), but at least I can the workaround is contained to only one file.

Thanks a lot,


-- 
Mathieu




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