subclassing a scrolled_window
- From: paolo borelli <pborelli katamail com>
- To: gtk-app-devel-list gnome org
- Subject: subclassing a scrolled_window
- Date: 11 Jun 2003 13:20:33 +0200
Hi!
I'm making a widget which is tree view wrapped into a scrolled window,
something like:
typedef struct _MyView MyView;
struct _MyView
{
GtkScrolledWindow scrolled_window;
GtkTreeStore *model; /* The model */
GtkWidget *tree_view; /* The view */
/* other things ... */
}
Then I have my instance init functions which is something like:
static void
my_view_init (GladeProjectView *view)
{
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
GtkTreeSelection *selection;
view->model = gtk_tree_store_new (N_COLUMNS, GTK_TYPE_POINTER);
glade_project_view_populate_model (view->model, view);
view->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL
(view->model));
/* the view now holds a reference, we can get rid of our own */
g_object_unref (G_OBJECT (view->model));
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Widget"),
renderer, NULL);
gtk_tree_view_column_set_cell_data_func (column, renderer,
glade_project_view_cell_function, NULL, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (view->tree_view), column);
}
And finally my my_view_new function which is:
GladeProjectView *
my_view_new (GladeProjectViewType type)
{
GladeProjectView *view = g_object_new (MY_TYPE_VIEW, NULL);
gtk_container_add (GTK_CONTAINER (view), view->tree_view);
return view;
}
This way everything works fine.
What I don't understand is why if I move the gtk_container_add() from
my_view_new() to the end of my_view_init() I get 3 assertions of this
kind:
Gtk-CRITICAL **: file gtkrange.c: line 446 (gtk_range_get_adjustment):
assertion `GTK_IS_RANGE (range)' failed
ciao
paolo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]