Deriving from GtkWindow



I've been learning about GType/GObject, and trying to create my own
objects.  I'm attempting to derive a new object from a GtkWindow.  While
the code compiles, I can't cast the object to a GtkWindow:

(ogcalc:14377): GLib-GObject-WARNING **: invalid uninstantiatable type
`<invalid>' in cast to `GtkWindow'
 
(ogcalc:14377): Gtk-CRITICAL **: file gtkwindow.c: line 953
(gtk_window_set_title): assertion `GTK_IS_WINDOW (window)' failed
  
(ogcalc:14377): GLib-GObject-WARNING **: invalid uninstantiatable type
`<invalid>' in cast to `GtkWindow'
   
(ogcalc:14377): Gtk-CRITICAL **: file gtkwindow.c: line 5878
(gtk_window_set_resizable): assertion `GTK_IS_WINDOW (window)' failed
    
(ogcalc:14377): GLib-GObject-WARNING **: invalid uninstantiatable
type `<invalid>' in cast to `GtkWidget'
     
(ogcalc:14377): Gtk-CRITICAL **: file gtkwidget.c: line 3409
(gtk_widget_reparent): assertion `GTK_IS_CONTAINER (new_parent)'
failed

I've attached a very small testcase which shows the problem.  What am I
doing wrong when I construct the object?  I'm doing this:

GType
ogcalc_get_type (void)
{
  static GType type = 0;

 if (type == 0)
    {
      static const GTypeInfo info =
	{
	  sizeof (OgcalcClass),
	  NULL,
	  NULL,
	  (GClassInitFunc) ogcalc_init,
	  NULL,
	  NULL,
	  sizeof (Ogcalc),
	  0,
	  NULL
	};
      type = g_type_register_static (GTK_TYPE_WINDOW,
				     "Ogcalc",
				     &info,
				     0);
    }
  return type;
}


Many thanks,
Roger

-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.

Attachment: test-gobject.tar.bz2
Description: Binary data



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