1

我正在编写一个 gtk3(in 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);

但我不知道如何将编辑后的标志连接到文件/缓冲区。如果有人好心地指路,这将非常有帮助......可能是一个非常简短的例子。

4

1 回答 1

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
} 

如果那是您想要的,因为您的问题不清楚

于 2014-06-30T00:41:34.837 回答