【发布时间】:2013-09-08 15:20:08
【问题描述】:
在我的应用中,我有首选项对话框(模式到主),可以在 GTK_LIST_STORE[GTK_TREE_VIEW] 中插入值。
此条目作为菜单选择发送到 GTK_COMBO_BOX_TEXT。
当按下按钮打开首选项对话框以编辑值时,我希望 GTK_TREE_VIEW 自动滚动到 main 中选择的单元格引用。
主要(GTK_COMBO_BOX_TEXT)
首选项对话框 (GTK_TREE_VIEW)
例如:
如果我在主窗口中打开首选项对话框时选择黄色,则在黄色行中抓取焦点小部件
谢谢
更新:
添加新条目时我使用:
ps = malloc(sizeof(preset));
ps->name = g_strdup(_("unnamed"));
ps->value = rint(gtk_adjustment_get_value(adj)) / STEPS;
settings.presets = g_list_append(settings.presets, (gpointer) ps);
buffer = g_strdup_printf("%.2f", ps->value);
gtk_list_store_append(list_store, &iter);
gtk_list_store_set(GTK_LIST_STORE(list_store), &iter, 0, ps->name, 1, buffer, -1);
g_free(buffer);
gtk_tree_selection_unselect_all(selection);
v_scb = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(list_view));
gtk_adjustment_set_value(v_scb, gtk_adjustment_get_upper(v_scb));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(preset_combo), ps->name);
【问题讨论】: