Re: ComboBox and TreeStore



Thank you for your help - that worked.  I've worked with tree views and I should have seen the similarity 
(didn't see that the combo box needed to be type cast to a cell layout).
   
  Mark
  PS - I'll make sure to stay on gtk-app-devel-list - my bad.

David Neèas (Yeti) <yeti physics muni cz> wrote:
  Date: Fri, 10 Nov 2006 00:23:46 +0100
From: David Neèas (Yeti) <yeti physics muni cz>
To: Mark Richardson <markmapo yahoo com>
Subject: Re: ComboBox and TreeStore

On Thu, Nov 09, 2006 at 02:59:18PM -0800, Mark Richardson wrote:
Thanks, I can't seem to find documentation on how to do this, so through trial and error I get a little 
closer. So if I add ...
GtkCellRenderer *myCellRenderer=gtk_cell_renderer_text_new()
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(myComboBox), myCellRenderer, FALSE);
I get a blank line in the combo box (closer to displaying, but still not right).

In a tree view, I would create a column...
GtkTreeViewColumn *myColumn=gtk_tree_view_column_new_with_attibutes("Title", myCellRenderer, "text", 0, 
NULL);

but I don't know how to associate this column with a combo box.

Since GtkCellLayout is an interface, not an object, there is
no method to create a GtkCellLayout, and therefore no method
as gtk_tree_view_column_new_with_attibutes() to create it
*and* set its attributes. So you create a combo box first:

combo = gtk_combo_box_new();

and then create the mapping between model columns and
renderer attributes using the GtkCellLayout interface:

gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), renderer,
"text", 0);

(or the same with a cell data func).

Exactly the same can be done with GtkTreeViewColumns.

GtkTreeViewColumn:
void gtk_tree_view_column_add_attribute
(GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
const gchar *attribute,
gint column);
void gtk_tree_view_column_set_cell_data_func
(GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
GtkTreeCellDataFunc func,
gpointer func_data,
GtkDestroyNotify destroy);

GtkCellLayout:
void gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
const gchar *attribute,
gint column);
void gtk_cell_layout_set_cell_data_func
(GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
GtkCellLayoutDataFunc func,
gpointer func_data,
GDestroyNotify destroy);

The similarity should be evident... In fact the
GtkTreeViewColumn's methods are simple aliases for
GtkCellLayout methods.

Yeti


--
Whatever.


 
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.


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