c - 编辑 gtkcellrenderertext

标签 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,
                                                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.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
} 

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

关于c - 编辑 gtkcellrenderertext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14490412/

相关文章:

python - 使用内存数据中的 Pygobject 和 Python 3 显示图像

blogs - GTK+ 3.0 和 GNOME 3 编程!有任何博客、书籍或教程吗?

在 GTK 中创建首选项对话框

c# - IEditableCollectionView 在 CommitEdit 上失去选择

python - 如何让 Treeview 列适合其所在的框架

c - scanf 中的分区输入

c - 在 C 标准库中转发声明实体?

wpf - 防止WPF TreeView的SelectedItemChanged事件冒泡

c - 在本地网络中读取 tcp 套接字上的完整数据

c - scanf 未读取值