如何获取 GtkCellRenderer 的 GtkTreeViewColumn?
一些 gtk 源代码侦查使我相信以下代码可以获取模型中存储属性的列。
但是,要从信号处理程序到达这一点,我需要获取 GtkCellRenderer
的父 GtkTreeViewColumn
除了传递树视图列之外,我不知道如何执行此操作直接(这消除了我首先包含需要更新的模型的能力)或传递 GtkTreeView 本身,这将使我能够访问模型,但不能访问 GtkTreeViewColumn代码>
相当复杂的问题。当然,如果有人知道内置 GTK 函数可以从 GtkCellRenderer 直接转到 GtkListStore 那就更好了。
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
);
}
编辑:可能可以直接传递树视图列来获取两个所需的变量,但我在获取单元格渲染器的属性时遇到了问题。我怎样才能得到它们呢?
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 GtkCellRenderer
s 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 problems getting the cell renderer's attributes. How do I get them at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这个 API 似乎缺失了。在我的代码中我使用
,然后您可以使用
从渲染器对象获取列。
Yes this API seems to be missing. In my code i use
and then later you can use
To get the column from a renderer object.