Commit 06f9a55c authored by Li Zefan's avatar Li Zefan Committed by Michal Marek

gconfig: add support to show hidden options that have prompts

There's a button in gconfig to "Show all options", but I think
normally we are not interested in those configs which have no
prompt and thus can't be changed, so here I add a new button to
show hidden options which have prompts.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 22c7eca6
...@@ -30,12 +30,16 @@ enum { ...@@ -30,12 +30,16 @@ enum {
SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
}; };
enum {
OPT_NORMAL, OPT_ALL, OPT_PROMPT
};
static gint view_mode = FULL_VIEW; static gint view_mode = FULL_VIEW;
static gboolean show_name = TRUE; static gboolean show_name = TRUE;
static gboolean show_range = TRUE; static gboolean show_range = TRUE;
static gboolean show_value = TRUE; static gboolean show_value = TRUE;
static gboolean show_all = FALSE;
static gboolean resizeable = FALSE; static gboolean resizeable = FALSE;
static int opt_mode = OPT_NORMAL;
GtkWidget *main_wnd = NULL; GtkWidget *main_wnd = NULL;
GtkWidget *tree1_w = NULL; // left frame GtkWidget *tree1_w = NULL; // left frame
...@@ -637,12 +641,29 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data) ...@@ -637,12 +641,29 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
void void
on_show_all_options1_activate(GtkMenuItem * menuitem, gpointer user_data) on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
opt_mode = OPT_NORMAL;
gtk_tree_store_clear(tree2);
display_tree(&rootmenu); /* instead of update_tree to speed-up */
}
void
on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
{ {
show_all = GTK_CHECK_MENU_ITEM(menuitem)->active; opt_mode = OPT_ALL;
gtk_tree_store_clear(tree2);
display_tree(&rootmenu); /* instead of update_tree to speed-up */
}
void
on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
{
opt_mode = OPT_PROMPT;
gtk_tree_store_clear(tree2); gtk_tree_store_clear(tree2);
display_tree(&rootmenu); // instead of update_tree to speed-up display_tree(&rootmenu); /* instead of update_tree to speed-up */
} }
...@@ -1095,7 +1116,10 @@ static gchar **fill_row(struct menu *menu) ...@@ -1095,7 +1116,10 @@ static gchar **fill_row(struct menu *menu)
g_strdup_printf("%s %s", _(menu_get_prompt(menu)), g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
sym && sym_has_value(sym) ? "(NEW)" : ""); sym && sym_has_value(sym) ? "(NEW)" : "");
if (show_all && !menu_is_visible(menu)) if (opt_mode == OPT_ALL && !menu_is_visible(menu))
row[COL_COLOR] = g_strdup("DarkGray");
else if (opt_mode == OPT_PROMPT &&
menu_has_prompt(menu) && !menu_is_visible(menu))
row[COL_COLOR] = g_strdup("DarkGray"); row[COL_COLOR] = g_strdup("DarkGray");
else else
row[COL_COLOR] = g_strdup("Black"); row[COL_COLOR] = g_strdup("Black");
...@@ -1318,16 +1342,19 @@ static void update_tree(struct menu *src, GtkTreeIter * dst) ...@@ -1318,16 +1342,19 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
menu2 ? menu_get_prompt(menu2) : "nil"); menu2 ? menu_get_prompt(menu2) : "nil");
#endif #endif
if (!menu_is_visible(child1) && !show_all) { // remove node if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
(opt_mode == OPT_PROMPT && !menu_has_prompt(child1))) {
/* remove node */
if (gtktree_iter_find_node(dst, menu1) != NULL) { if (gtktree_iter_find_node(dst, menu1) != NULL) {
memcpy(&tmp, child2, sizeof(GtkTreeIter)); memcpy(&tmp, child2, sizeof(GtkTreeIter));
valid = gtk_tree_model_iter_next(model2, valid = gtk_tree_model_iter_next(model2,
child2); child2);
gtk_tree_store_remove(tree2, &tmp); gtk_tree_store_remove(tree2, &tmp);
if (!valid) if (!valid)
return; // next parent return; /* next parent */
else else
goto reparse; // next child goto reparse; /* next child */
} else } else
continue; continue;
} }
...@@ -1396,7 +1423,9 @@ static void display_tree(struct menu *menu) ...@@ -1396,7 +1423,9 @@ static void display_tree(struct menu *menu)
&& (tree == tree2)) && (tree == tree2))
continue; continue;
if (menu_is_visible(child) || show_all) if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
(opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
(opt_mode == OPT_ALL))
place_node(child, fill_row(child)); place_node(child, fill_row(child));
#ifdef DEBUG #ifdef DEBUG
printf("%*c%s: ", indent, ' ', menu_get_prompt(child)); printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
......
...@@ -190,13 +190,37 @@ ...@@ -190,13 +190,37 @@
</child> </child>
<child> <child>
<widget class="GtkCheckMenuItem" id="show_all_options1"> <widget class="GtkRadioMenuItem" id="set_option_mode1">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Show normal options</property>
<property name="label" translatable="yes">Show normal options</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<signal name="activate" handler="on_set_option_mode1_activate"/>
</widget>
</child>
<child>
<widget class="GtkRadioMenuItem" id="set_option_mode2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Show all options</property> <property name="tooltip" translatable="yes">Show all options</property>
<property name="label" translatable="yes">Show all _options</property> <property name="label" translatable="yes">Show all _options</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="active">False</property> <property name="active">False</property>
<signal name="activate" handler="on_show_all_options1_activate"/> <property name="group">set_option_mode1</property>
<signal name="activate" handler="on_set_option_mode2_activate"/>
</widget>
</child>
<child>
<widget class="GtkRadioMenuItem" id="set_option_mode3">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Show all options with prompts</property>
<property name="label" translatable="yes">Show all prompt options</property>
<property name="use_underline">True</property>
<property name="active">False</property>
<property name="group">set_option_mode1</property>
<signal name="activate" handler="on_set_option_mode3_activate"/>
</widget> </widget>
</child> </child>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment