我正在编写一个使用treeview的gtk3(在C中)代码。
store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING);
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
cell = gtk_cell_renderer_text_new ();
col_pub=gtk_tree_view_column_new_with_attributes (
"Title", cell,
"text", COL_BIB_PUB,
NULL);
gtk_tree_view_column_set_sort_column_id( col_pub, ID_PUB);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), col_pub);
问题是我希望树视图的每个单元格都可以编辑,所以我需要这样的东西:
g_object_set(cell, "editable", TRUE, NULL);
但我不知道如何将编辑后的标志连接到文件/缓冲区。 如果有人亲切地表明道路,那将是非常有帮助的......一个非常简短的例子可能是。
答案 0 :(得分:0)
只需将Gtk.CellRendererText连接到信号即可。使用此渲染器的所有TreeViewColumn都将连接到信号。
g_signal_connect (G_OBJECT (cell), "edited", G_CALLBACK (cb), NULL)
void cb (GtkCellRendererText *rend, char*path, char*newtext, gpointer data)
{
// Do whatever you want with the newtext
........
// Since this signal emitted after cell being edited,
// you can use a global variable (a bool maybe) to indicate.
// gboolean switcher = 0
switcher = 1
}
如果这是你想要的,因为你的问题不明确