Doubts creating new Objects

Hi all!

I have a simple object derived from GnomeMDI:

struct _ControlApp
	GnomeMDI mdi;

In the "new" function I'm doing this:

ControlApp *
control_app_new (const gchar *appname, const gchar *title)
  ControlApp *app = gtk_type_new (control_app_get_type ());

  app = gnome_mdi_new(appname, title);

  return app;

And when compiling I get this:

warning: assignment from incompatible pointer type

I can solve it doing:

(GnomeMDI *)app = gnome_mdi_new(appname, title);

but it look ugly, and I don't know if it's the Right Way (tm).

Also, is this the correct place to do the gnome_mdi_new or should
it go in the init function of the new object.

>From now on, I must cast the new object everytime I do something
like this:

gnome_mdi_set_menubar_template(GNOME_MDI(mdi), main_menu);
gnome_mdi_set_toolbar_template(GNOME_MDI(mdi), main_toolbar);
gnome_mdi_add_child (GNOME_MDI(mdi), GNOME_MDI_CHILD (page));

so, is there an extra work? or the cast won't affect perfomance?.

How can I do to add, for example, the active_view field to my new
so it does not need the EXTRA cast.

GNOME_MDI(mdi)->active_view  ==> mdi->active_view

This all seems that is better to include a pointer to the parent object
and pass it where needed. This is:


So I can do:

gnome_mdi_add_child (MyMDI->mdi, GNOME_MDI_CHILD (page));

I would love to hear why this is bad!.

Thanks to anyone who can put my ideas in order.

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