开发者

How to get a GtkCellRenderer's GtkTreeViewColumn?

Some gtk source code sleuthing has lead me to believe the following code can obtain the column in the model where an attribute is stored.

However, to get to this point from a signal handler I need to get a GtkCellRenderers parent GtkTreeViewColumn

I don't know how to do this, other than passing the treeview column directly (Which eliminates my ability to include the model that needs to be updated in the first place) or passing the GtkTreeView itself which would give me access to the model, but not the GtkTreeViewColumn

Quite a complicated problem. Of course if anyone knows a builtin GTK function to go from GtkCellRenderer straight to GtkListStore that would be much better.

void
treeview_combo_edited(GtkCellRendererCombo * widget, gchar * path, gchar * value, GtkListStore * model){
    GtkTreeIter iter;
    gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model),&iter,path);
    // How to get GtkCellRenderer's GtkTreeViewColumn to use in line below?
    GSList * attributes = g_object_get(treeviewcolumn,attributes);
    int colnumber = g_slist_nth_data(g_slist_position(g_slist_find(attributes,"text")) - 1);
    gtk_list_store_set
    (
        model,
        &iter,
        colnumber,
        value,
        -1
    );
}

Edit: It might be possible to pass the treeviewcolumn directly to get both needed variables but I've run into proble开发者_JAVA百科ms getting the cell renderer's attributes. How do I get them at all?


Yes this API seems to be missing. In my code i use

GtkTreeViewColumn *column = gtk_tree_view_column_new();
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
g_object_set_qdata_full(G_OBJECT(renderer), g_quark_from_static_string("column"), (gpointer)column, NULL);

and then later you can use

GtkTreeViewColumn* column = (g_object_get_qdata(G_OBJECT(renderer), g_quark_from_static_string("column"));

To get the column from a renderer object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜