Re: Is it possible having different GtkAdjustment values in GtkTreeView

Thanks for your help.

The key point was GTK_TYPE_TREE_MODEL!
But it doesn't still work properly with G_TYPE_INTERFACE.

Your example code was very useful.
And thanks again! :-D

2008/12/9 Tadej Borovšak <tadeboro gmail com>

I forgot to explain why G_TYPE_OBJECT does not work in this situation.
The GtkTreeModel is just an interface for GtkList/TreeStore objects
and is not derived from GObject but from GInterface. So it is
perfectly legal to use G_TYPE_INTERFACE instead GTK_TYPE_TREE_MODEL in
my code.

Another key function call to getting GtkCellRendererCombo working is
g_object_set, which sets "editable" property to TRUE, so you can edit
your renderer.

2008/12/9 Tadej Borovšak <tadeboro gmail com>:

I've created a simple app that demonstrates some G(TK)_TYPE macro magic;)

#include <gtk/gtk.h>


static GtkTreeModel *
create_and_fill_model (void)
   GtkListStore  *store;
   GtkListStore  *model;
   GtkTreeIter    iter;

   model = gtk_list_store_new( 1, G_TYPE_STRING );
   gtk_list_store_append( model, &iter );
   gtk_list_store_set( model, &iter, 0, "String1", -1 );
   gtk_list_store_append( model, &iter );
   gtk_list_store_set( model, &iter, 0, "String2", -1 );
   gtk_list_store_append( model, &iter );
   gtk_list_store_set( model, &iter, 0, "String3", -1 );
   gtk_list_store_append( model, &iter );
   gtk_list_store_set( model, &iter, 0, "String3", -1 );
   gtk_list_store_append( model, &iter );
   gtk_list_store_set( model, &iter, 0, "String4", -1 );
   gtk_list_store_append( model, &iter );
   gtk_list_store_set( model, &iter, 0, "String5", -1 );

   store = gtk_list_store_new( NO_COLS, GTK_TYPE_TREE_MODEL );
   gtk_list_store_append( store, &iter );
   gtk_list_store_set( store, &iter, MODEL_COL, GTK_TREE_MODEL( model ),
-1 );

   return GTK_TREE_MODEL(store);

main( int    argc,
     char **argv )
   GtkWidget         *window;
   GtkWidget         *pop_window;
   GtkWidget         *treeview;
   GtkWidget         *label;
   GtkTreeModel      *model;
   GtkTreeIter        parent;
   GtkTreeIter        child;
   GtkCellRenderer   *renderer;
   GtkTreeViewColumn *col;
   GtkTreeSelection  *sel;

   gtk_init( &argc, &argv );

   window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
   g_signal_connect( G_OBJECT( window ), "destroy",
                     G_CALLBACK( gtk_main_quit ), NULL );

   model = create_and_fill_model();
   treeview = gtk_tree_view_new_with_model( GTK_TREE_MODEL( model ) );
   g_object_unref( G_OBJECT( model ) );

   col = gtk_tree_view_column_new();
   renderer = gtk_cell_renderer_combo_new();
   g_object_set( G_OBJECT( renderer ), "editable", TRUE, NULL );
   g_object_set( G_OBJECT( renderer ), "text_column", 0, NULL );
   gtk_tree_view_column_pack_start(col, renderer, TRUE);
   gtk_tree_view_column_set_attributes(col, renderer, "model",

   gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), col);

   gtk_tree_view_expand_all( GTK_TREE_VIEW( treeview ) );
   gtk_container_add( GTK_CONTAINER( window ), treeview );
   gtk_widget_show_all( window );


   return( 0);

2008/12/9 Keedi Kim <keedi perl kr>:
Hi, guys.

I have one more question about GtkTreeView.

In my GtkTreeView, another column use GtkCellRenderCombo,
and I tried store the GtkListStore (for GtkCellRenderCombo) using
and set it up as an attribute ("model" -> list_store).

But this doesn't seem work properly and warning occurs.

[W] unable to set property `model' of type `GtkTreeModel' from value of

the warning disappears but tree view does not work.

Is there something different when using GtkCellRenderCombo in this case?

Thanks, :-)

2008/12/9 Keedi Kim <keedi perl kr>

Tadej, Tristan, Thanks!

In fact I misunderstood about attributes and GtkCellRenderSpin,
and I thought each column's spin cell renderer could have only one
but it was not true. :-)

As you were mentioned,
I use tree model to store adjustment for each row of columns,
and connect them using attributes, then everything works great!

Thanks again! :-)

2008/12/9 Tristan Van Berkom <tvb gnome org>

On Mon, Dec 8, 2008 at 6:02 AM, Keedi Kim <keedi perl kr> wrote:
Hi! :-)

I have some question about GtkTreeView and GtkCellRenderer.
Is it possible to have different GtkAdjustment values for each
column(renderer?) in GtkTreeView?

Is there any reason you cant just store the adjustment in the model
and set it up as an attribute ? or am I missing what you want to
accomplish ?


Best regards,

Keedi Kim

Best regards,

Keedi Kim
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

Best regards,

Keedi Kim

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