我想在两个TOPLEVEL GtkWindow之间进行通信。 例如,我双击GtkTreeView中的行,新的GtkWindow用于修改行的上下文。 但是,除了声明一个全局变量来传递结构之外,我没有找到解决方案。我是否可以通过巧妙的方式帮助我解决问题? 作为GTK的绿手,我将非常感谢您的帮助。
答案 0 :(得分:0)
您可以通过“行激活”信号传递数据:
this_window = gtk_window_new (mode);
that_window = gtk_window_new (mode);
tv = gtk_tree_view_new ();
g_object_connect (tv, "row_activated",
G_CALLBACK (on_row_activate), that_window);
static mode my_func_using_data (view, that_window)
{
// do something here to pass a data to view
....
....
selection = view.get_selection ()
GtkTreeModel *model;
GtkTreeIter iter;
if ( gtk_tree_selection_get_selected (selection))
{
// modify the data here with model and iter
}
}
static void on_row_activate (GtkTreeView *view,
GtkTreePath *path,
GtkTreeViewColumn *col,
gpointer that_window)
{
my_func_using_data (view, that_window)
}