[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Choosing a parent class
- From: "Brian J. Tarricone" <bjt23 cornell edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: Choosing a parent class
- Date: Tue, 11 Apr 2006 14:04:34 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 4/11/2006 2:00 PM, Andreas Kotowicz wrote:
> On Tue, 2006-04-11 at 17:02 -0400, Tristan Van Berkom wrote:
>> Andreas Kotowicz wrote:
>> [...]
>>> ok, I think I understand now. but somehow it seems that my class has
>>> some mistake in it (see attachment). I'm calling it like this in my
>>> code:
>>>
>>> ********
>>> .
>>> .
>>> window->priv->object = app_calendar_new ();
>>>
>>> gtk_box_pack_end (GTK_BOX (main_box),
>>> GTK_WIDGET(window->priv->object),
>>> TRUE,
>>> TRUE,
>>> 0);
>>> .
>>> .
>>> ********
>>>
>>> all objects before and after this code get created and displayed
>>> correctly, only my self made object refuses to show up.
>>>
>> Is it visible ? i.e. did you call gtk_widget_show() on the calendar ?
>
> sure (ok, I just realized that my attachments did get removed from my
> last email). so here's the relevant code:
>
> static void
> app_calendar_class_init (AppCalendarClass *klass)
> {
>
> GObjectClass *object_class = G_OBJECT_CLASS (klass);
>
> g_type_class_add_private (object_class, sizeof(AppCalendarPrivate));
> }
>
> static void
> app_calendar_init (AppCalendar *calendar)
> {
>
> gint i;
> calendar->priv = APP_CALENDAR_GET_PRIVATE (calendar);
>
>
> /* some widgets to test with
> the calender stuff will be inserted later on
> not using calendar-> priv here yet as things don't work */
>
> GtkWidget *main_box, *hbox, *label;
> main_box = gtk_hbox_new (FALSE, 0);
> gtk_widget_show (main_box);
Why are you creating 'main_box'? Your AppCalendar *is* the main box.
> hbox = gtk_hbox_new(TRUE, DEF_PAD);
> gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);
> gtk_widget_show (hbox);
At this point, you'd just add hbox to your AppCalendar:
gtk_box_pack_start(GTK_BOX(calendar), hbox, TRUE, TRUE, 0);
This is of course assuming that your AppCalendar is a subclass of
GtkHBox, which is I think what you want to be doing here.
> label = gtk_label_new("text from AppCalendar");
> gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
> gtk_widget_show (label);
>
> g_message("called app_calendar_init");
>
> }
>
>
> GtkWidget *
> app_calendar_new (void)
> {
> return GTK_WIDGET (g_object_new (APP_TYPE_CALENDAR, NULL));
> }
>
>
>
>> Also, where are you doing that code ? from a constructor or an instance
>> init func ?
>
> instance init func:
>
> window->priv->object = app_calendar_new ();
And don't forget to call:
gtk_widget_show(window->priv->object);
here.
> gtk_box_pack_end (GTK_BOX (main_box),
> GTK_WIDGET(window->priv->object),
> TRUE,
> TRUE,
> 0);
>
> /* this get's displayed correctly */
>
> GtkWidget *hbox, *label;
> hbox = gtk_hbox_new(TRUE, DEF_PAD);
> label = gtk_label_new("text from MainWindow");
> gtk_box_pack_end (GTK_BOX (main_box), label, TRUE, TRUE, 0);
>
>
>
> ok, I hope these were all relevant parts.
That should make it work ok.
-brian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
iD8DBQFEPBni6XyW6VEeAnsRAhi6AJ0dl0gmpWDroJ5L5/qz++PsJ18OgQCgniVD
8xN346taQS8H258E6mCpOJw=
=bGdL
-----END PGP SIGNATURE-----
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]