kconfig: improve gconfig
v3 cover kconfig: improve gconfig
This replaces just one patch in the previous submission.
"kconfig: gconf: preserve menu selection when switching view mode"
There was a corner case where the menu selection was not preserved when switching to Split view.
[Test Case]
[1] Choose Full view (default)
[2] Select "64-bit kernel"
[3] Choose Split view
In v2, the selection of "64-bit kernel" was not preserved.
This has been fixed in v3. The remaining parts are the same.
In case you are interested, I pushed the entire patchset to:
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git gconfig-v3
The code diff between v2 and v3 is very small, just as follows:
scripts/kconfig/gconf.c +3 -7
@@ -281,13 +281,9 @@ static void set_view_mode(enum view_mode mode)gtk_widget_set_sensitive (single_btn, FALSE);break ;case SPLIT_VIEW : - browsed =NULL ; -if (selected) { -if (selected->type ==M_MENU ) - browsed = selected; -else - browsed =menu_get_parent_menu (selected); - } + browsed = selected; +while (browsed && !(browsed->flags &MENU_ROOT )) + browsed = browsed->parent;gtk_tree_store_clear (tree1);display_tree (tree1, &rootmenu);gtk_tree_view_expand_all (GTK_TREE_VIEW (tree1_w));
Masahiro Yamada (1):
kconfig: gconf: preserve menu selection when switching view mode
scripts/kconfig/gconf.c | 82 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/1 kconfig: gconf: preserve menu selection when switching view mode
Preserve the current menu selection when switching to a different view mode, as it improves usability.
---
- Fix a corner case when the selection is not preserved when switching to Split view
scripts/kconfig/gconf.c | 82 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 8 deletions(-)
scripts/kconfig/gconf.c +74 -8
@@ -47,6 +47,7 @@ static GtkTreeStore *tree1, *tree2;static GtkTreeModel *model1, *model2;static struct menu *browsed;// browsed menu for SINGLE/SPLIT view +static struct menu *selected;// selected entry enum {COL_OPTION ,COL_NAME ,COL_NO ,COL_MOD ,COL_YES ,COL_VALUE ,
@@ -68,6 +69,47 @@ static void conf_changed(bool dirty)/* Utility Functions */ +static void _select_menu (GtkTreeView *view,GtkTreeModel *model, +GtkTreeIter *parent,struct menu *match) +{ +GtkTreeIter iter; +gboolean valid; + + valid =gtk_tree_model_iter_children (model, &iter, parent); +while (valid) { +struct menu *menu; + +gtk_tree_model_get (model, &iter,COL_MENU , &menu,-1 ); + +if (menu == match) { +GtkTreeSelection *selection; +GtkTreePath *path; + +/* +* Expand parents to reflect the selection, and +* scroll down to it. +*/ + path =gtk_tree_model_get_path (model, &iter); +gtk_tree_view_expand_to_path (view, path); +gtk_tree_view_scroll_to_cell (view, path,NULL , TRUE, +0.5 ,0.0 ); +gtk_tree_path_free (path); + + selection =gtk_tree_view_get_selection (view); +gtk_tree_selection_select_iter (selection, &iter); + } + +_select_menu (view, model, &iter, match); + + valid =gtk_tree_model_iter_next (model, &iter); + } +} + +static void select_menu (GtkTreeView *view,struct menu *match) +{ +_select_menu (view,gtk_tree_view_get_model (view),NULL , match); +} +static void set_view_mode (enum view_mode mode) { view_mode = mode;
@@ -89,24 +131,36 @@ static void set_view_mode(enum view_mode mode)switch (mode) {case SINGLE_VIEW : - browsed = &rootmenu; +if (selected) + browsed =menu_get_parent_menu (selected) ?: &rootmenu; +else + browsed = &rootmenu;display_tree_part (); +select_menu (GTK_TREE_VIEW (tree2_w), selected);gtk_widget_set_sensitive (single_btn, FALSE);break ;case SPLIT_VIEW : + browsed = selected; +while (browsed && !(browsed->flags &MENU_ROOT )) + browsed = browsed->parent;gtk_tree_store_clear (tree2);display_list (); +if (browsed) +display_tree (tree2, browsed); +select_menu (GTK_TREE_VIEW (tree1_w), browsed); +select_menu (GTK_TREE_VIEW (tree2_w), selected);gtk_widget_set_sensitive (split_btn, FALSE);break ;case FULL_VIEW :gtk_tree_store_clear (tree2);display_tree (tree2, &rootmenu); +select_menu (GTK_TREE_VIEW (tree2_w), selected);gtk_widget_set_sensitive (full_btn, FALSE);break ; } -if (mode !=SINGLE_VIEW ) -gtk_widget_set_sensitive (back_btn, FALSE); +gtk_widget_set_sensitive (back_btn, + mode ==SINGLE_VIEW && browsed != &rootmenu); }static void text_insert_help (struct menu *menu)
@@ -603,6 +657,8 @@ static gboolean on_treeview2_button_press_event(GtkWidget *widget,return FALSE;gtk_tree_model_get (model, &iter,COL_MENU , &menu,-1 ); + selected = menu; + col =column2index (column);if (event->type ==GDK_2BUTTON_PRESS ) {enum prop_type ptype;
@@ -712,8 +768,12 @@ static gboolean on_treeview1_button_press_event(GtkWidget *widget,if (event->type ==GDK_2BUTTON_PRESS )toggle_sym_value (menu); - browsed = menu; -display_tree_part (); + selected = menu; + +if (menu->type ==M_MENU ) { + browsed = menu; +display_tree_part (); + }gtk_tree_view_set_cursor (view, path,NULL , FALSE);gtk_widget_grab_focus (tree2_w);
@@ -1006,10 +1066,16 @@ static void _display_tree(GtkTreeStore *tree, struct menu *menu,enum prop_type ptype;GtkTreeIter iter; -if (menu == &rootmenu) - browsed = &rootmenu; -for (child = menu->list; child; child = child->next) { +/* +* REVISIT: +* menu_finalize() creates empty "if" entries. +* Do not confuse gtk_tree_model_get(), which would otherwise +* return "if" menu entry. +*/ +if (child->type ==M_IF ) +continue ; + prop = child->prompt; ptype = prop ? prop->type :P_UNKNOWN ;
Signature · 1 line
2.43.0
Hi,
Quoted 15 lines · Masahiro Yamada
This replaces just one patch in the previous submission.
"kconfig: gconf: preserve menu selection when switching view mode"
There was a corner case where the menu selection was not preserved when switching to Split view.
[Test Case]
[1] Choose Full view (default)
[2] Select "64-bit kernel"
[3] Choose Split viewIn v2, the selection of "64-bit kernel" was not preserved.
Quoted 8 lines
This has been fixed in v3. The remaining parts are the same.
In case you are interested, I pushed the entire patchset to:
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.gitgconfig-v3The code diff between v2 and v3 is very small, just as follows:
I applied this patch to the gconfig-v2 patches.
It works for me.
But I do have one question/annoyance: why does the help/message panel always switch back to:
Kernel hacking
There is no help available for this option.
Is Kernel hacking the last entry in some (menu) list?
Quoted 31 lines
scripts/kconfig/gconf.c +3
-7@@ -281,13 +281,9 @@ static void set_view_mode(enum view_mode mode)gtk_widget_set_sensitive (single_btn, FALSE);break ;case SPLIT_VIEW : - browsed =NULL ; -if (selected) { -if (selected->type ==M_MENU ) - browsed = selected; -else - browsed =menu_get_parent_menu (selected); - } + browsed = selected; +while (browsed && !(browsed->flags &MENU_ROOT )) + browsed = browsed->parent;gtk_tree_store_clear (tree1);display_tree (tree1, &rootmenu);gtk_tree_view_expand_all (GTK_TREE_VIEW (tree1_w));Masahiro Yamada (1):
kconfig: gconf: preserve menu selection when switching view modescripts/kconfig/gconf.c | 82 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 8 deletions(-)
Signature · 1 line
~Randy
Quoted 34 lines · Randy Dunlap
Hi,
Quoted 15 lines · Masahiro Yamada
This replaces just one patch in the previous submission.
"kconfig: gconf: preserve menu selection when switching view mode"
There was a corner case where the menu selection was not preserved when switching to Split view.
[Test Case]
[1] Choose Full view (default)
[2] Select "64-bit kernel"
[3] Choose Split viewIn v2, the selection of "64-bit kernel" was not preserved.
Quoted 8 lines
This has been fixed in v3. The remaining parts are the same.
In case you are interested, I pushed the entire patchset to:
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.gitgconfig-v3The code diff between v2 and v3 is very small, just as follows:
I applied this patch to the gconfig-v2 patches.
It works for me.Acked-by Randy Dunlap <[email protected]>Tested-by Randy Dunlap <[email protected]>
Quoted 7 lines
But I do have one question/annoyance: why does the help/message panel always switch back to:
Kernel hackingThere is no help available for this option.
Is Kernel hacking the last entry in some (menu) list?
Good catch.
I do not know why "Kernel hacking" is displayed, but this is a bug.
The following small diff on top of gconfig-v3 will fix the issue.
scripts/kconfig/gconf.c +1 -0
@@ -53,6 +53,7 @@ enum { COL_NUMBER }; +static void text_insert_help (struct menu *menu);static void display_tree (GtkTreeStore *store,struct menu *menu);static void recreate_tree (void );
@@ -92,6 +93,8 @@ static void _select_menu(GtkTreeView *view,
GtkTreeModel *model,
selection = gtk_tree_view_get_selection(view);
gtk_tree_selection_select_iter(selection, &iter);
+
+ text_insert_help(menu);
}
_select_menu(view, model, &iter, match);I will fix up the code locally.
--
Best Regards
Masahiro Yamada
Quoted 45 lines · Masahiro Yamada
Quoted 11 lines · Randy Dunlap
Hi,
But I do have one question/annoyance: why does the help/message panel always switch back to:
Kernel hackingThere is no help available for this option.
Is Kernel hacking the last entry in some (menu) list?
Good catch.
I do not know why "Kernel hacking" is displayed, but this is a bug.The following small diff on top of gconfig-v3 will fix the issue.
scripts/kconfig/gconf.c +3
-0@@ -53,6 +53,7 @@ enum { COL_NUMBER }; +static void text_insert_help (struct menu *menu);static void display_tree (GtkTreeStore *store,struct menu *menu);static void recreate_tree (void );@@ -92,6 +93,8 @@ static void _select_menu(GtkTreeView *view,GtkTreeModel *model, selection =gtk_tree_view_get_selection (view);gtk_tree_selection_select_iter (selection, &iter); + +text_insert_help (menu); }_select_menu(view, model, &iter, match);
Quoted 1 line
I will fix up the code locally.
Thanks.
Signature · 1 line
~Randy