Home GTK [转]GTK TREEVIEW相应双击的事件

在百度上搜索了很多狠多,有几遍相应的文章,用的是button-press-event,可以处理双击事件,但是,单击之后,该行没有任何变化,
也就重新定义button-press-event,导致原来singal clicked默认的聚焦于该行的功能失效了,很是郁闷。

google一下之后,才发现其实不是没有完美解决的方法,只能说中国人还是少部分人在用gtk。

在一个技术文档中http://scentric.net/tutorial/treeview-tutorial.html有很清晰的关于treeview处理双击的信号:

row-activated,及很清晰的例子。
如下:
void
view_onRowActivated (GtkTreeView *treeview,
GtkTreePath *path,
GtkTreeViewColumn *col,
gpointer userdata)
{
GtkTreeModel *model;
GtkTreeIter iter;

g_print (“A row has been double-clicked!\n”);

model = gtk_tree_view_get_model(treeview);

if (gtk_tree_model_get_iter(model, &iter, path))
{
gchar *name;

gtk_tree_model_get(model, &iter, COLUMN_NAME, &name, -1);

g_print (“Double-clicked row contains name %s\n”, name);

g_free(name);
}
}

void
create_view (void)
{
GtkWidget *view;

view = gtk_tree_view_new();

g_signal_connect(view, “row-activated”, (GCallback) view_onRowActivated, NULL);


}

打赏
0 comment

You may also like

Leave a Comment

*

code

error: Alert: Content is protected !!