编辑GTKCellRenderText

编辑GTKCellRenderText,c,treeview,gtk3,renderer,C,Treeview,Gtk3,Renderer,我正在编写一个使用treeview的gtk3(C)代码 store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,

我正在编写一个使用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);
问题是我希望treeview的每个单元格都是可编辑的,因此我需要如下内容:

g_object_set(cell, "editable", TRUE, NULL);
但我不知道如何将编辑标志连接到文件/缓冲区。
如果有人友好地指路,这将非常有帮助……一个非常简短的例子可能是。

只需将Gtk.cellRenderText连接到一个信号。使用此渲染器的所有TreeView列都将连接到信号

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
} 

如果这就是你想要的,因为你的问题不清楚

你需要更好地解释你想要实现的目标。同时,我建议您研究gtk3演示应用程序(随Gtk+一起提供)。有一个带有可编辑单元格的GtkListStore示例。