Getting the model column for cell renderer attribute
John Delaney <[email protected]>
| Newsgroups | gmane.comp.gnome.glade.user |
|---|---|
| Message-ID | <CANnQzPL4n_KHWBBbNoHpSiVoqtihcdzgbbbr8CNaT6bp0L7erQ@mail.gmail.com> |
For the current project that I'm working on, which unfortunately needs to target Gtk+ 2.12, I have designed several GtkBuilder UIs using the Win32 build of Glade 3.6.7. For most of the tree views in the project, I would like the tree view columns to be able to set their sort column ID dynamically, based on which column of the model the cell renderer gets the "text" attribute from (if any), rather than having to remember to add a new gtk_tree_view_column_set_sort_column_id() line every time I add a new column to a tree view. However, there is no complement "get" function for gtk_cell_layout_set_attributes(), so I'm struggling to work out if it can be done without parsing the XML. I can't set it in Glade because the sort_column_id property isn't supported until Gtk+ 2.18. I've attached a highly simplified version of my UI and code to illustrate what I mean, the two lines that I've commented out are where I'm stuck. In this simplified example I could just use a loop counter variable, but obviously it's not quite so simple in the actual project code. John _______________________________________________ Glade-users maillist - [email protected] http://lists.ximian.com/mailman/listinfo/glade-users
test.glade
(application/x-glade, 3.6 KB) - not displayed
test.c
(text/x-csrc, 1.1 KB)
#include <gtk/gtk.h>
void on_window_destroy(GtkObject *object, gpointer user_data)
{
gtk_main_quit();
}
int main(int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window, *treeview;
GList *column_list, *renderers;
GtkTreeViewColumn *column;
gint model_text_col;
gtk_init(&argc, &argv);
builder = gtk_builder_new ();
gtk_builder_add_from_file(builder, "test.glade", NULL);
window = GTK_WIDGET (gtk_builder_get_object(builder, "window1"));
treeview = GTK_WIDGET (gtk_builder_get_object(builder, "treeview1"));
column_list = gtk_tree_view_get_columns(GTK_TREE_VIEW (treeview));
do
{
column = GTK_TREE_VIEW_COLUMN (column_list->data);
renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
/*model_text_col = ???;
gtk_tree_view_column_set_sort_column_id(column, model_text_col);*/
g_list_free(renderers);
} while ((column_list = g_list_next(column_list)));
g_list_free(column_list);
gtk_builder_connect_signals(builder, NULL);
g_object_unref(G_OBJECT (builder));
gtk_widget_show(window);
gtk_main();
return 0;
}