Gobject Parent Errors
- From: snowswept <snowswept mac com>
- To: gtk-app-devel-list gnome org
- Subject: Gobject Parent Errors
- Date: 20 Jul 2002 17:21:27 -0600
All,
I am trying to make a type/widget with a parent of
GTK_TYPE_SCROLLED_WINDOW. Right after g_object_new is called I get these
errors...
(list-widget-test:2318): GLib-GObject-WARNING **: invalid cast from
(NULL) pointer to `GtkRange'
(list-widget-test:2318): Gtk-CRITICAL **: file gtkrange.c: line 438
(gtk_range_get_adjustment): assertion `GTK_IS_RANGE (range)' failed
(list-widget-test:2318): GLib-GObject-WARNING **: invalid cast from
(NULL) pointer to `GtkRange'
(list-widget-test:2318): Gtk-CRITICAL **: file gtkrange.c: line 438
(gtk_range_get_adjustment): assertion `GTK_IS_RANGE (range)' failed
(list-widget-test:2318): GLib-GObject-WARNING **: invalid cast from
(NULL) pointer to `GtkRange'
(list-widget-test:2318): Gtk-CRITICAL **: file gtkrange.c: line 438
(gtk_range_get_adjustment): assertion `GTK_IS_RANGE (range)' failed
Everything works just fine with the type/widget... these errors are just
spit out making it difficult for me to figure out where things are going
wrong. I think I get these because I am some how not initializing the
parent type right. Here are the relevant functions...
GtkType
my_list_widget_get_type (void)
{
static GtkType my_list_widget_type = 0;
if (!my_list_widget_type) {
static const GTypeInfo my_list_widget_info = {
sizeof (MyListWidgetClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) my_list_widget_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (MyListWidget),
0, /* n_preallocs */
(GInstanceInitFunc) my_list_widget_init
};
my_list_widget_type = g_type_register_static
(GTK_TYPE_SCROLLED_WINDOW, "MyListWidget",
&my_list_widget_info, 0);
}
return my_list_widget_type;
}
static void
my_list_widget_class_init (MyListWidgetClass *class)
{
GObjectClass *o_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent (class);
o_class = (GObjectClass *) class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
o_class->finalize = my_list_widget_finalize;
object_class->destroy = my_list_widget_destroy;
/* Signals. */
signals[LIST_SELECTED] = g_signal_new
("my_selected",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
}
static void
my_list_widget_init (MyListWidget *list)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
/* Create the model */
list->store = gtk_tree_store_new (N_COLUMNS, GDK_TYPE_PIXBUF,
G_TYPE_STRING);
/* Create the view */
list->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL
(list->store));
/* Create a picture column */
renderer = gtk_cell_renderer_pixbuf_new ( );
column = gtk_tree_view_column_new_with_attributes ("Picture", renderer,
"pixbuf", PICTURE_COLUMN, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (list->tree_view), column);
/* Create a text column */
renderer = gtk_cell_renderer_text_new ( );
column = gtk_tree_view_column_new_with_attributes ("Author", renderer,
"text", AUTHOR_COLUMN, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (list->tree_view), column);
gtk_container_add (GTK_CONTAINER (list), GTK_WIDGET(list->tree_view));
gtk_widget_show(GTK_WIDGET (list->tree_view));
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show(GTK_WIDGET (list));
}
GtkWidget *
my_list_widget_new (void)
{
return g_object_new (MY_TYPE_LIST_WIDGET, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]