History

Merge tag 'kbuild-v6.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada: "This is the last pull request from me. I'm grateful to have been able to continue as a maintainer for eight years. From the next cycle, Nathan and Nicolas will maintain Kbuild. - Fix a shortcut key issue in menuconfig - Fix missing rebuild of kheaders - Sort the symbol dump generated by gendwarfsyms - Support zboot extraction in scripts/extract-vmlinux - Migrate gconfig to GTK 3 - Add TAR variable to allow overriding the default tar command - Hand over Kbuild maintainership" * tag 'kbuild-v6.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (92 commits) MAINTAINERS: hand over Kbuild maintenance kheaders: make it possible to override TAR kbuild: userprogs: use correct linker when mixing clang and GNU ld kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c kconfig: lxdialog: replace strcpy with snprintf in print_autowrap kconfig: gconf: refactor text_insert_help() kconfig: gconf: remove unneeded variable in text_insert_msg kconfig: gconf: use hyphens in signals kconfig: gconf: replace GtkImageMenuItem with GtkMenuItem kconfig: gconf: Fix Back button behavior kconfig: gconf: fix single view to display dependent symbols correctly scripts: add zboot support to extract-vmlinux gendwarfksyms: order -T symtypes output by name gendwarfksyms: use preferred form of sizeof for allocation kconfig: qconf: confine {begin,end}Group to constructor and destructor kconfig: qconf: fix ConfigList::updateListAllforAll() kconfig: add a function to dump all menu entries in a tree-like format kconfig: gconf: show GTK version in About dialog kconfig: gconf: replace GtkHPaned and GtkVPaned with GtkPaned kconfig: gconf: replace GdkColor with GdkRGBA ...

Linus Torvalds committed 1 year ago

Commit a530a362 parents 7881cd6 8d6841d33 files · +1218 −1334Browse files

Showing the changes to scripts (22 of 33 files). Show all

Unified · Split

22 files
  1. scripts/extract-vmlinux +6 −7
  2. scripts/gendwarfksyms/cache.c +1 −1
  3. scripts/gendwarfksyms/die.c +2 −2
  4. scripts/gendwarfksyms/dwarf.c +1 −1
  5. scripts/gendwarfksyms/kabi.c +1 −1
  6. scripts/gendwarfksyms/symbols.c +1 −1
  7. scripts/gendwarfksyms/types.c +28 −5
  8. scripts/kconfig/conf.c +1 −1
  9. scripts/kconfig/confdata.c +1 −1
  10. scripts/kconfig/gconf-cfg.sh +2 −9
  11. scripts/kconfig/gconf.c +826 −941
  12. scripts/kconfig/gconf.ui +118 −243
  13. scripts/kconfig/lkc.h +2 −0
  14. scripts/kconfig/lxdialog/inputbox.c +4 −2
  15. scripts/kconfig/lxdialog/menubox.c +1 −1
  16. scripts/kconfig/lxdialog/util.c +1 −2
  17. scripts/kconfig/menu.c +94 −0
  18. scripts/kconfig/nconf.c +2 −0
  19. scripts/kconfig/nconf.gui.c +1 −0
  20. scripts/kconfig/qconf.cc +24 −12
  21. scripts/kconfig/qconf.h +1 −0
  22. scripts/kconfig/symbol.c +4 −0
scripts/extract-vmlinux+6−7
@@ -12,13 +12,12 @@ · 11 unmodified lines
1212
1313 check_vmlinux()
1414 {
15− # Use readelf to check if it's a valid ELF
16− # TODO: find a better to way to check that it's really vmlinux
17− # and not just an elf
18− readelf -h $1 > /dev/null 2>&1 || return 1
19−
20− cat $1
21− exit 0
15+ if file "$1" | grep -q 'Linux kernel.*boot executable' ||
16+ readelf -h "$1" > /dev/null 2>&1
17+ then
18+ cat "$1"
19+ exit 0
20+ fi
2221 }
2322
2423 try_decompress()
scripts/gendwarfksyms/cache.c+1−1
@@ -15,7 +15,7 @@ void cache_set(struct cache *cache, unsigned long key, int value) · 14 unmodified lines
1515 {
1616 struct cache_item *ci;
1717
18− ci = xmalloc(sizeof(struct cache_item));
18+ ci = xmalloc(sizeof(*ci));
1919 ci->key = key;
2020 ci->value = value;
2121 hash_add(cache->cache, &ci->hash, hash_32(key));
scripts/gendwarfksyms/die.c+2−2
@@ -33,7 +33,7 @@ static struct die *create_die(Dwarf_Die *die, enum die_state state) · 32 unmodified lines
3333 {
3434 struct die *cd;
3535
36− cd = xmalloc(sizeof(struct die));
36+ cd = xmalloc(sizeof(*cd));
3737 init_die(cd);
3838 cd->addr = (uintptr_t)die->addr;
3939
@@ -123,7 +123,7 @@ static struct die_fragment *append_item(struct die *cd) · 83 unmodified lines
123123 {
124124 struct die_fragment *df;
125125
126− df = xmalloc(sizeof(struct die_fragment));
126+ df = xmalloc(sizeof(*df));
127127 df->type = FRAGMENT_EMPTY;
128128 list_add_tail(&df->list, &cd->fragments);
129129 return df;
scripts/gendwarfksyms/dwarf.c+1−1
@@ -634,7 +634,7 @@ static int get_union_kabi_status(Dwarf_Die *die, Dwarf_Die *placeholder, · 633 unmodified lines
634634 * Note that the user of this feature is responsible for ensuring
635635 * that the structure actually remains ABI compatible.
636636 */
637− memset(&state.kabi, 0, sizeof(struct kabi_state));
637+ memset(&state.kabi, 0, sizeof(state.kabi));
638638
639639 res = checkp(process_die_container(&state, NULL, die,
640640 check_union_member_kabi_status,
scripts/gendwarfksyms/kabi.c+1−1
@@ -228,7 +228,7 @@ void kabi_read_rules(int fd) · 227 unmodified lines
228228 if (type == KABI_RULE_TYPE_UNKNOWN)
229229 error("unsupported kABI rule type: '%s'", field);
230230
231− rule = xmalloc(sizeof(struct rule));
231+ rule = xmalloc(sizeof(*rule));
232232
233233 rule->type = type;
234234 rule->target = xstrdup(get_rule_field(&rule_str, &left));
scripts/gendwarfksyms/symbols.c+1−1
@@ -146,7 +146,7 @@ void symbol_read_exports(FILE *file) · 145 unmodified lines
146146 continue;
147147 }
148148
149− sym = xcalloc(1, sizeof(struct symbol));
149+ sym = xcalloc(1, sizeof(*sym));
150150 sym->name = name;
151151 sym->addr.section = SHN_UNDEF;
152152 sym->state = SYMBOL_UNPROCESSED;
scripts/gendwarfksyms/types.c+28−5
@@ -6,6 +6,8 @@ · 5 unmodified lines
66 #define _GNU_SOURCE
77 #include <inttypes.h>
88 #include <stdio.h>
9+#include <stdlib.h>
10+#include <string.h>
911 #include <zlib.h>
1012
1113 #include "gendwarfksyms.h"
@@ -43,7 +45,7 @@ static int type_list_append(struct list_head *list, const char *s, void *owned) · 31 unmodified lines
4345 if (!s)
4446 return 0;
4547
46− entry = xmalloc(sizeof(struct type_list_entry));
48+ entry = xmalloc(sizeof(*entry));
4749 entry->str = s;
4850 entry->owned = owned;
4951 list_add_tail(&entry->list, list);
@@ -120,7 +122,7 @@ static struct type_expansion *type_map_add(const char *name, · 70 unmodified lines
120122 struct type_expansion *e;
121123
122124 if (__type_map_get(name, &e)) {
123− e = xmalloc(sizeof(struct type_expansion));
125+ e = xmalloc(sizeof(*e));
124126 type_expansion_init(e);
125127 e->name = xstrdup(name);
126128
@@ -179,20 +181,41 @@ static int type_map_get(const char *name, struct type_expansion **res) · 52 unmodified lines
179181 return -1;
180182 }
181183
184+static int cmp_expansion_name(const void *p1, const void *p2)
185+{
186+ struct type_expansion *const *e1 = p1;
187+ struct type_expansion *const *e2 = p2;
188+
189+ return strcmp((*e1)->name, (*e2)->name);
190+}
191+
182192 static void type_map_write(FILE *file)
183193 {
184194 struct type_expansion *e;
185195 struct hlist_node *tmp;
196+ struct type_expansion **es;
197+ size_t count = 0;
198+ size_t i = 0;
186199
187200 if (!file)
188201 return;
189202
190− hash_for_each_safe(type_map, e, tmp, hash) {
191− checkp(fputs(e->name, file));
203+ hash_for_each_safe(type_map, e, tmp, hash)
204+ ++count;
205+ es = xmalloc(count * sizeof(*es));
206+ hash_for_each_safe(type_map, e, tmp, hash)
207+ es[i++] = e;
208+
209+ qsort(es, count, sizeof(*es), cmp_expansion_name);
210+
211+ for (i = 0; i < count; ++i) {
212+ checkp(fputs(es[i]->name, file));
192213 checkp(fputs(" ", file));
193− type_list_write(&e->expanded, file);
214+ type_list_write(&es[i]->expanded, file);
194215 checkp(fputs("\n", file));
195216 }
217+
218+ free(es);
196219 }
197220
198221 static void type_map_free(void)
scripts/kconfig/conf.c+1−1
@@ -594,7 +594,7 @@ static void check_conf(struct menu *menu) · 593 unmodified lines
594594 default:
595595 if (!conf_cnt++)
596596 printf("*\n* Restart config...\n*\n");
597− rootEntry = menu_get_parent_menu(menu);
597+ rootEntry = menu_get_menu_or_parent_menu(menu);
598598 conf(rootEntry);
599599 break;
600600 }
scripts/kconfig/confdata.c+1−1
@@ -77,7 +77,7 @@ static bool is_same(const char *file1, const char *file2) · 76 unmodified lines
7777 if (map2 == MAP_FAILED)
7878 goto close2;
7979
80− if (bcmp(map1, map2, st1.st_size))
80+ if (memcmp(map1, map2, st1.st_size))
8181 goto close2;
8282
8383 ret = true;
scripts/kconfig/gconf-cfg.sh+2−9
@@ -6,7 +6,7 @@ set -eu · 5 unmodified lines
66 cflags=$1
77 libs=$2
88
9−PKG="gtk+-2.0 gmodule-2.0 libglade-2.0"
9+PKG=gtk+-3.0
1010
1111 if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
1212 echo >&2 "*"
@@ -18,18 +18,11 @@ fi · 5 unmodified lines
1818 if ! ${HOSTPKG_CONFIG} --exists $PKG; then
1919 echo >&2 "*"
2020 echo >&2 "* Unable to find the GTK+ installation. Please make sure that"
21− echo >&2 "* the GTK+ 2.0 development package is correctly installed."
21+ echo >&2 "* the GTK 3 development package is correctly installed."
2222 echo >&2 "* You need $PKG"
2323 echo >&2 "*"
2424 exit 1
2525 fi
2626
27−if ! ${HOSTPKG_CONFIG} --atleast-version=2.0.0 gtk+-2.0; then
28− echo >&2 "*"
29− echo >&2 "* GTK+ is present but version >= 2.0.0 is required."
30− echo >&2 "*"
31− exit 1
32−fi
33−
3427 ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
3528 ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
scripts/kconfig/gconf.c+826−941
@@ -7,10 +7,7 @@ · 6 unmodified lines
77 #include "lkc.h"
88 #include "images.h"
99
10−#include <glade/glade.h>
1110 #include <gtk/gtk.h>
12−#include <glib.h>
13−#include <gdk/gdkkeysyms.h>
1411
1512 #include <stdio.h>
1613 #include <string.h>
@@ -18,7 +15,7 @@ · 1 unmodified line
1815 #include <unistd.h>
1916 #include <time.h>
2017
21−enum {
18+enum view_mode {
2219 SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
2320 };
2421
@@ -30,29 +27,24 @@ static gint view_mode = FULL_VIEW; · 5 unmodified lines
3027 static gboolean show_name = TRUE;
3128 static gboolean show_range = TRUE;
3229 static gboolean show_value = TRUE;
33−static gboolean resizeable = FALSE;
3430 static int opt_mode = OPT_NORMAL;
3531
36−GtkWidget *main_wnd = NULL;
37−GtkWidget *tree1_w = NULL; // left frame
38−GtkWidget *tree2_w = NULL; // right frame
39−GtkWidget *text_w = NULL;
40−GtkWidget *hpaned = NULL;
41−GtkWidget *vpaned = NULL;
42−GtkWidget *back_btn = NULL;
43−GtkWidget *save_btn = NULL;
44−GtkWidget *save_menu_item = NULL;
32+static GtkWidget *main_wnd;
33+static GtkWidget *tree1_w; // left frame
34+static GtkWidget *tree2_w; // right frame
35+static GtkWidget *text_w;
36+static GtkWidget *hpaned;
37+static GtkWidget *vpaned;
38+static GtkWidget *back_btn, *save_btn, *single_btn, *split_btn, *full_btn;
39+static GtkWidget *save_menu_item;
4540
46−GtkTextTag *tag1, *tag2;
47−GdkColor color;
41+static GtkTextTag *tag1, *tag2;
4842
49−GtkTreeStore *tree1, *tree2, *tree;
50−GtkTreeModel *model1, *model2;
51−static GtkTreeIter *parents[256];
52−static gint indent;
43+static GtkTreeStore *tree1, *tree2;
44+static GdkPixbuf *pix_menu;
5345
54−static struct menu *current; // current node for SINGLE view
55−static struct menu *browsed; // browsed node for SPLIT view
46+static struct menu *browsed; // browsed menu for SINGLE/SPLIT view
47+static struct menu *selected; // selected entry
5648
5749 enum {
5850 COL_OPTION, COL_NAME, COL_NO, COL_MOD, COL_YES, COL_VALUE,
@@ -61,28 +53,8 @@ enum { · 2 unmodified lines
6153 COL_NUMBER
6254 };
6355
64−static void display_list(void);
65−static void display_tree(struct menu *menu);
66−static void display_tree_part(void);
67−static void update_tree(struct menu *src, GtkTreeIter * dst);
68−
69−static void replace_button_icon(GladeXML *xml, GdkDrawable *window,
70− GtkStyle *style, gchar *btn_name, gchar **xpm)
71−{
72− GdkPixmap *pixmap;
73− GdkBitmap *mask;
74− GtkToolButton *button;
75− GtkWidget *image;
76−
77− pixmap = gdk_pixmap_create_from_xpm_d(window, &mask,
78− &style->bg[GTK_STATE_NORMAL],
79− xpm);
80−
81− button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name));
82− image = gtk_image_new_from_pixmap(pixmap, mask);
83− gtk_widget_show(image);
84− gtk_tool_button_set_icon_widget(button, image);
85−}
56+static void display_tree(GtkTreeStore *store, struct menu *menu);
57+static void recreate_tree(void);
8658
8759 static void conf_changed(bool dirty)
8860 {
@@ -90,465 +62,373 @@ static void conf_changed(bool dirty) · 1 unmodified line
9062 gtk_widget_set_sensitive(save_menu_item, dirty);
9163 }
9264
93−/* Main Window Initialization */
94−static void init_main_window(const gchar *glade_file)
65+/* Utility Functions */
66+
67+static void text_insert_msg(const char *title, const char *msg)
9568 {
96− GladeXML *xml;
97− GtkWidget *widget;
98− GtkTextBuffer *txtbuf;
99− GtkStyle *style;
69+ GtkTextBuffer *buffer;
70+ GtkTextIter start, end;
10071
101− xml = glade_xml_new(glade_file, "window1", NULL);
102− if (!xml)
103− g_error("GUI loading failed !\n");
104− glade_xml_signal_autoconnect(xml);
72+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
73+ gtk_text_buffer_get_bounds(buffer, &start, &end);
74+ gtk_text_buffer_delete(buffer, &start, &end);
75+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
10576
106− main_wnd = glade_xml_get_widget(xml, "window1");
107− hpaned = glade_xml_get_widget(xml, "hpaned1");
108− vpaned = glade_xml_get_widget(xml, "vpaned1");
109− tree1_w = glade_xml_get_widget(xml, "treeview1");
110− tree2_w = glade_xml_get_widget(xml, "treeview2");
111− text_w = glade_xml_get_widget(xml, "textview3");
77+ gtk_text_buffer_get_end_iter(buffer, &end);
78+ gtk_text_buffer_insert_with_tags(buffer, &end, title, -1, tag1,
79+ NULL);
80+ gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
81+ gtk_text_buffer_get_end_iter(buffer, &end);
82+ gtk_text_buffer_insert_with_tags(buffer, &end, msg, -1, tag2,
83+ NULL);
84+}
11285
113− back_btn = glade_xml_get_widget(xml, "button1");
114− gtk_widget_set_sensitive(back_btn, FALSE);
86+static void text_insert_help(struct menu *menu)
87+{
88+ struct gstr help = str_new();
11589
116− widget = glade_xml_get_widget(xml, "show_name1");
117− gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
118− show_name);
90+ menu_get_ext_help(menu, &help);
91+ text_insert_msg(menu_get_prompt(menu), str_get(&help));
92+ str_free(&help);
93+}
11994
120− widget = glade_xml_get_widget(xml, "show_range1");
121− gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
122− show_range);
95+static void _select_menu(GtkTreeView *view, GtkTreeModel *model,
96+ GtkTreeIter *parent, struct menu *match)
97+{
98+ GtkTreeIter iter;
99+ gboolean valid;
123100
124− widget = glade_xml_get_widget(xml, "show_data1");
125− gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
126− show_value);
101+ valid = gtk_tree_model_iter_children(model, &iter, parent);
102+ while (valid) {
103+ struct menu *menu;
127104
128− save_btn = glade_xml_get_widget(xml, "button3");
129− save_menu_item = glade_xml_get_widget(xml, "save1");
130− conf_set_changed_callback(conf_changed);
105+ gtk_tree_model_get(model, &iter, COL_MENU, &menu, -1);
131106
132− style = gtk_widget_get_style(main_wnd);
133− widget = glade_xml_get_widget(xml, "toolbar1");
107+ if (menu == match) {
108+ GtkTreeSelection *selection;
109+ GtkTreePath *path;
134110
135− replace_button_icon(xml, main_wnd->window, style,
136− "button4", (gchar **) xpm_single_view);
137− replace_button_icon(xml, main_wnd->window, style,
138− "button5", (gchar **) xpm_split_view);
139− replace_button_icon(xml, main_wnd->window, style,
140− "button6", (gchar **) xpm_tree_view);
111+ /*
112+ * Expand parents to reflect the selection, and
113+ * scroll down to it.
114+ */
115+ path = gtk_tree_model_get_path(model, &iter);
116+ gtk_tree_view_expand_to_path(view, path);
117+ gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE,
118+ 0.5, 0.0);
119+ gtk_tree_path_free(path);
141120
142− txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
143− tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
144− "foreground", "red",
145− "weight", PANGO_WEIGHT_BOLD,
146− NULL);
147− tag2 = gtk_text_buffer_create_tag(txtbuf, "mytag2",
148− /*"style", PANGO_STYLE_OBLIQUE, */
149− NULL);
121+ selection = gtk_tree_view_get_selection(view);
122+ gtk_tree_selection_select_iter(selection, &iter);
150123
151− gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
124+ text_insert_help(menu);
125+ }
152126
153− gtk_widget_show(main_wnd);
127+ _select_menu(view, model, &iter, match);
128+
129+ valid = gtk_tree_model_iter_next(model, &iter);
130+ }
154131 }
155132
156−static void init_tree_model(void)
133+static void select_menu(GtkTreeView *view, struct menu *match)
157134 {
158− gint i;
159−
160− tree = tree2 = gtk_tree_store_new(COL_NUMBER,
161− G_TYPE_STRING, G_TYPE_STRING,
162− G_TYPE_STRING, G_TYPE_STRING,
163− G_TYPE_STRING, G_TYPE_STRING,
164− G_TYPE_POINTER, GDK_TYPE_COLOR,
165− G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
166− G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
167− G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
168− G_TYPE_BOOLEAN);
169− model2 = GTK_TREE_MODEL(tree2);
170−
171− for (parents[0] = NULL, i = 1; i < 256; i++)
172− parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter));
173−
174− tree1 = gtk_tree_store_new(COL_NUMBER,
175− G_TYPE_STRING, G_TYPE_STRING,
176− G_TYPE_STRING, G_TYPE_STRING,
177− G_TYPE_STRING, G_TYPE_STRING,
178− G_TYPE_POINTER, GDK_TYPE_COLOR,
179− G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
180− G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
181− G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
182− G_TYPE_BOOLEAN);
183− model1 = GTK_TREE_MODEL(tree1);
135+ _select_menu(view, gtk_tree_view_get_model(view), NULL, match);
184136 }
185137
186−static void init_left_tree(void)
138+static void _update_row_visibility(GtkTreeView *view)
187139 {
188− GtkTreeView *view = GTK_TREE_VIEW(tree1_w);
189− GtkCellRenderer *renderer;
190− GtkTreeSelection *sel;
191− GtkTreeViewColumn *column;
192−
193− gtk_tree_view_set_model(view, model1);
194− gtk_tree_view_set_headers_visible(view, TRUE);
195− gtk_tree_view_set_rules_hint(view, TRUE);
196−
197− column = gtk_tree_view_column_new();
198− gtk_tree_view_append_column(view, column);
199− gtk_tree_view_column_set_title(column, "Options");
140+ GtkTreeModelFilter *filter = GTK_TREE_MODEL_FILTER(gtk_tree_view_get_model(view));
200141
201− renderer = gtk_cell_renderer_toggle_new();
202− gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
203− renderer, FALSE);
204− gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
205− renderer,
206− "active", COL_BTNACT,
207− "inconsistent", COL_BTNINC,
208− "visible", COL_BTNVIS,
209− "radio", COL_BTNRAD, NULL);
210− renderer = gtk_cell_renderer_text_new();
211− gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
212− renderer, FALSE);
213− gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
214− renderer,
215− "text", COL_OPTION,
216− "foreground-gdk",
217− COL_COLOR, NULL);
218−
219− sel = gtk_tree_view_get_selection(view);
220− gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
221− gtk_widget_realize(tree1_w);
142+ gtk_tree_model_filter_refilter(filter);
222143 }
223144
224−static void renderer_edited(GtkCellRendererText * cell,
225− const gchar * path_string,
226− const gchar * new_text, gpointer user_data);
145+static void update_row_visibility(void)
146+{
147+ if (view_mode == SPLIT_VIEW)
148+ _update_row_visibility(GTK_TREE_VIEW(tree1_w));
149+ _update_row_visibility(GTK_TREE_VIEW(tree2_w));
150+}
227151
228−static void init_right_tree(void)
152+static void set_node(GtkTreeStore *tree, GtkTreeIter *node, struct menu *menu)
229153 {
230− GtkTreeView *view = GTK_TREE_VIEW(tree2_w);
231− GtkCellRenderer *renderer;
232− GtkTreeSelection *sel;
233− GtkTreeViewColumn *column;
234− gint i;
154+ struct symbol *sym = menu->sym;
155+ tristate val;
156+ gchar *option;
157+ const gchar *_no = "";
158+ const gchar *_mod = "";
159+ const gchar *_yes = "";
160+ const gchar *value = "";
161+ GdkRGBA color;
162+ gboolean editable = FALSE;
163+ gboolean btnvis = FALSE;
164+
165+ option = g_strdup_printf("%s %s %s %s",
166+ menu->type == M_COMMENT ? "***" : "",
167+ menu_get_prompt(menu),
168+ menu->type == M_COMMENT ? "***" : "",
169+ sym && !sym_has_value(sym) ? "(NEW)" : "");
170+
171+ gdk_rgba_parse(&color, menu_is_visible(menu) ? "Black" : "DarkGray");
235172
236− gtk_tree_view_set_model(view, model2);
237− gtk_tree_view_set_headers_visible(view, TRUE);
238− gtk_tree_view_set_rules_hint(view, TRUE);
173+ if (!sym)
174+ goto set;
239175
240− column = gtk_tree_view_column_new();
241− gtk_tree_view_append_column(view, column);
242− gtk_tree_view_column_set_title(column, "Options");
176+ sym_calc_value(sym);
243177
244− renderer = gtk_cell_renderer_pixbuf_new();
245− gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
246− renderer, FALSE);
247− gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
248− renderer,
249− "pixbuf", COL_PIXBUF,
250− "visible", COL_PIXVIS, NULL);
251− renderer = gtk_cell_renderer_toggle_new();
252− gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
253− renderer, FALSE);
254− gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
255− renderer,
256− "active", COL_BTNACT,
257− "inconsistent", COL_BTNINC,
258− "visible", COL_BTNVIS,
259− "radio", COL_BTNRAD, NULL);
260− renderer = gtk_cell_renderer_text_new();
261− gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
262− renderer, FALSE);
263− gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
264− renderer,
265− "text", COL_OPTION,
266− "foreground-gdk",
267− COL_COLOR, NULL);
178+ if (menu->type == M_CHOICE) { // parse children to get a final value
179+ struct symbol *def_sym = sym_calc_choice(menu);
180+ struct menu *def_menu = NULL;
268181
269− renderer = gtk_cell_renderer_text_new();
270− gtk_tree_view_insert_column_with_attributes(view, -1,
271− "Name", renderer,
272− "text", COL_NAME,
273− "foreground-gdk",
274− COL_COLOR, NULL);
275− renderer = gtk_cell_renderer_text_new();
276− gtk_tree_view_insert_column_with_attributes(view, -1,
277− "N", renderer,
278− "text", COL_NO,
279− "foreground-gdk",
280− COL_COLOR, NULL);
281− renderer = gtk_cell_renderer_text_new();
282− gtk_tree_view_insert_column_with_attributes(view, -1,
283− "M", renderer,
284− "text", COL_MOD,
285− "foreground-gdk",
286− COL_COLOR, NULL);
287− renderer = gtk_cell_renderer_text_new();
288− gtk_tree_view_insert_column_with_attributes(view, -1,
289− "Y", renderer,
290− "text", COL_YES,
291− "foreground-gdk",
292− COL_COLOR, NULL);
293− renderer = gtk_cell_renderer_text_new();
294− gtk_tree_view_insert_column_with_attributes(view, -1,
295− "Value", renderer,
296− "text", COL_VALUE,
297− "editable",
298− COL_EDIT,
299− "foreground-gdk",
300− COL_COLOR, NULL);
301− g_signal_connect(G_OBJECT(renderer), "edited",
302− G_CALLBACK(renderer_edited), NULL);
303−
304− column = gtk_tree_view_get_column(view, COL_NAME);
305− gtk_tree_view_column_set_visible(column, show_name);
306− column = gtk_tree_view_get_column(view, COL_NO);
307− gtk_tree_view_column_set_visible(column, show_range);
308− column = gtk_tree_view_get_column(view, COL_MOD);
309− gtk_tree_view_column_set_visible(column, show_range);
310− column = gtk_tree_view_get_column(view, COL_YES);
311− gtk_tree_view_column_set_visible(column, show_range);
312− column = gtk_tree_view_get_column(view, COL_VALUE);
313− gtk_tree_view_column_set_visible(column, show_value);
314−
315− if (resizeable) {
316− for (i = 0; i < COL_VALUE; i++) {
317− column = gtk_tree_view_get_column(view, i);
318− gtk_tree_view_column_set_resizable(column, TRUE);
182+ for (struct menu *child = menu->list; child; child = child->next) {
183+ if (menu_is_visible(child) && child->sym == def_sym)
184+ def_menu = child;
319185 }
320− }
321186
322− sel = gtk_tree_view_get_selection(view);
323− gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
324−}
187+ if (def_menu)
188+ value = menu_get_prompt(def_menu);
325189
190+ goto set;
191+ }
326192
327−/* Utility Functions */
193+ switch (sym_get_type(sym)) {
194+ case S_BOOLEAN:
195+ case S_TRISTATE:
328196
197+ btnvis = TRUE;
329198
330−static void text_insert_help(struct menu *menu)
331−{
332− GtkTextBuffer *buffer;
333− GtkTextIter start, end;
334− const char *prompt = menu_get_prompt(menu);
335− struct gstr help = str_new();
199+ val = sym_get_tristate_value(sym);
200+ switch (val) {
201+ case no:
202+ _no = "N";
203+ value = "N";
204+ break;
205+ case mod:
206+ _mod = "M";
207+ value = "M";
208+ break;
209+ case yes:
210+ _yes = "Y";
211+ value = "Y";
212+ break;
213+ }
336214
337− menu_get_ext_help(menu, &help);
215+ if (val != no && sym_tristate_within_range(sym, no))
216+ _no = "_";
217+ if (val != mod && sym_tristate_within_range(sym, mod))
218+ _mod = "_";
219+ if (val != yes && sym_tristate_within_range(sym, yes))
220+ _yes = "_";
221+ break;
222+ default:
223+ value = sym_get_string_value(sym);
224+ editable = TRUE;
225+ break;
226+ }
338227
339− buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
340− gtk_text_buffer_get_bounds(buffer, &start, &end);
341− gtk_text_buffer_delete(buffer, &start, &end);
342− gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
228+set:
229+ gtk_tree_store_set(tree, node,
230+ COL_OPTION, option,
231+ COL_NAME, sym ? sym->name : "",
232+ COL_NO, _no,
233+ COL_MOD, _mod,
234+ COL_YES, _yes,
235+ COL_VALUE, value,
236+ COL_MENU, (gpointer) menu,
237+ COL_COLOR, &color,
238+ COL_EDIT, editable,
239+ COL_PIXBUF, pix_menu,
240+ COL_PIXVIS, view_mode == SINGLE_VIEW && menu->type == M_MENU,
241+ COL_BTNVIS, btnvis,
242+ COL_BTNACT, _yes[0] == 'Y',
243+ COL_BTNINC, _mod[0] == 'M',
244+ COL_BTNRAD, sym && sym_is_choice_value(sym),
245+ -1);
343246
344− gtk_text_buffer_get_end_iter(buffer, &end);
345− gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
346− NULL);
347− gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
348− gtk_text_buffer_get_end_iter(buffer, &end);
349− gtk_text_buffer_insert_with_tags(buffer, &end, str_get(&help), -1, tag2,
350− NULL);
351− str_free(&help);
247+ g_free(option);
352248 }
353249
354−
355−static void text_insert_msg(const char *title, const char *message)
250+static void _update_tree(GtkTreeStore *store, GtkTreeIter *parent)
356251 {
357− GtkTextBuffer *buffer;
358− GtkTextIter start, end;
359− const char *msg = message;
252+ GtkTreeModel *model = GTK_TREE_MODEL(store);
253+ GtkTreeIter iter;
254+ gboolean valid;
360255
361− buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
362− gtk_text_buffer_get_bounds(buffer, &start, &end);
363− gtk_text_buffer_delete(buffer, &start, &end);
364− gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
256+ valid = gtk_tree_model_iter_children(model, &iter, parent);
257+ while (valid) {
258+ struct menu *menu;
365259
366− gtk_text_buffer_get_end_iter(buffer, &end);
367− gtk_text_buffer_insert_with_tags(buffer, &end, title, -1, tag1,
368− NULL);
369− gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
370− gtk_text_buffer_get_end_iter(buffer, &end);
371− gtk_text_buffer_insert_with_tags(buffer, &end, msg, -1, tag2,
372− NULL);
373−}
260+ gtk_tree_model_get(model, &iter, COL_MENU, &menu, -1);
374261
262+ if (menu)
263+ set_node(store, &iter, menu);
375264
376−/* Main Windows Callbacks */
265+ _update_tree(store, &iter);
266+
267+ valid = gtk_tree_model_iter_next(model, &iter);
268+ }
269+}
377270
378−void on_save_activate(GtkMenuItem * menuitem, gpointer user_data);
379−gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
380− gpointer user_data)
271+static void update_tree(GtkTreeStore *store)
381272 {
382− GtkWidget *dialog, *label;
383− gint result;
273+ _update_tree(store, NULL);
274+ update_row_visibility();
275+}
384276
385− if (!conf_get_changed())
386− return FALSE;
277+static void update_trees(void)
278+{
279+ if (view_mode == SPLIT_VIEW)
280+ update_tree(tree1);
281+ update_tree(tree2);
282+}
387283
388− dialog = gtk_dialog_new_with_buttons("Warning !",
389− GTK_WINDOW(main_wnd),
390− (GtkDialogFlags)
391− (GTK_DIALOG_MODAL |
392− GTK_DIALOG_DESTROY_WITH_PARENT),
393− GTK_STOCK_OK,
394− GTK_RESPONSE_YES,
395− GTK_STOCK_NO,
396− GTK_RESPONSE_NO,
397− GTK_STOCK_CANCEL,
398− GTK_RESPONSE_CANCEL, NULL);
399− gtk_dialog_set_default_response(GTK_DIALOG(dialog),
400− GTK_RESPONSE_CANCEL);
284+static void set_view_mode(enum view_mode mode)
285+{
286+ view_mode = mode;
401287
402− label = gtk_label_new("\nSave configuration ?\n");
403− gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
404− gtk_widget_show(label);
288+ if (mode == SPLIT_VIEW) { // two panes
289+ gint w;
405290
406− result = gtk_dialog_run(GTK_DIALOG(dialog));
407− switch (result) {
408− case GTK_RESPONSE_YES:
409− on_save_activate(NULL, NULL);
410− return FALSE;
411− case GTK_RESPONSE_NO:
412− return FALSE;
413− case GTK_RESPONSE_CANCEL:
414− case GTK_RESPONSE_DELETE_EVENT:
415− default:
416− gtk_widget_destroy(dialog);
417− return TRUE;
291+ gtk_widget_show(tree1_w);
292+ gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, NULL);
293+ gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
294+ } else {
295+ gtk_widget_hide(tree1_w);
296+ gtk_paned_set_position(GTK_PANED(hpaned), 0);
418297 }
419298
420− return FALSE;
421−}
299+ gtk_widget_set_sensitive(single_btn, TRUE);
300+ gtk_widget_set_sensitive(split_btn, TRUE);
301+ gtk_widget_set_sensitive(full_btn, TRUE);
422302
303+ switch (mode) {
304+ case SINGLE_VIEW:
305+ if (selected)
306+ browsed = menu_get_parent_menu(selected) ?: &rootmenu;
307+ else
308+ browsed = &rootmenu;
309+ recreate_tree();
310+ text_insert_msg("", "");
311+ select_menu(GTK_TREE_VIEW(tree2_w), selected);
312+ gtk_widget_set_sensitive(single_btn, FALSE);
313+ break;
314+ case SPLIT_VIEW:
315+ browsed = selected;
316+ while (browsed && !(browsed->flags & MENU_ROOT))
317+ browsed = browsed->parent;
318+ gtk_tree_store_clear(tree1);
319+ display_tree(tree1, &rootmenu);
320+ gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w));
321+ gtk_tree_store_clear(tree2);
322+ if (browsed)
323+ display_tree(tree2, browsed);
324+ text_insert_msg("", "");
325+ select_menu(GTK_TREE_VIEW(tree1_w), browsed);
326+ select_menu(GTK_TREE_VIEW(tree2_w), selected);
327+ gtk_widget_set_sensitive(split_btn, FALSE);
328+ break;
329+ case FULL_VIEW:
330+ gtk_tree_store_clear(tree2);
331+ display_tree(tree2, &rootmenu);
332+ text_insert_msg("", "");
333+ select_menu(GTK_TREE_VIEW(tree2_w), selected);
334+ gtk_widget_set_sensitive(full_btn, FALSE);
335+ break;
336+ }
423337
424−void on_window1_destroy(GtkObject * object, gpointer user_data)
425−{
426− gtk_main_quit();
338+ gtk_widget_set_sensitive(back_btn,
339+ mode == SINGLE_VIEW && browsed != &rootmenu);
427340 }
428341
342+/* Menu & Toolbar Callbacks */
429343
430−void
431−on_window1_size_request(GtkWidget * widget,
432− GtkRequisition * requisition, gpointer user_data)
344+static void on_load1_activate(GtkMenuItem *menuitem, gpointer user_data)
433345 {
434− static gint old_h;
435− gint w, h;
436−
437− if (widget->window == NULL)
438− gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
439− else
440− gdk_window_get_size(widget->window, &w, &h);
441−
442− if (h == old_h)
443− return;
444− old_h = h;
445−
446− gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
447−}
346+ GtkWidget *dialog;
347+ GtkFileChooser *chooser;
348+ gint res;
448349
350+ dialog = gtk_file_chooser_dialog_new("Load file...",
351+ GTK_WINDOW(user_data),
352+ GTK_FILE_CHOOSER_ACTION_OPEN,
353+ "_Cancel", GTK_RESPONSE_CANCEL,
354+ "_Open", GTK_RESPONSE_ACCEPT,
355+ NULL);
449356
450−/* Menu & Toolbar Callbacks */
357+ chooser = GTK_FILE_CHOOSER(dialog);
358+ gtk_file_chooser_set_filename(chooser, conf_get_configname());
451359
360+ res = gtk_dialog_run(GTK_DIALOG(dialog));
361+ if (res == GTK_RESPONSE_ACCEPT) {
362+ char *filename;
452363
453−static void
454−load_filename(GtkFileSelection * file_selector, gpointer user_data)
455−{
456− const gchar *fn;
364+ filename = gtk_file_chooser_get_filename(chooser);
457365
458− fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
459− (user_data));
366+ if (conf_read(filename))
367+ text_insert_msg("Error",
368+ "Unable to load configuration!");
369+ else
370+ update_trees();
460371
461− if (conf_read(fn))
462− text_insert_msg("Error", "Unable to load configuration !");
463− else
464− display_tree_part();
465−}
372+ g_free(filename);
373+ }
466374
467−void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
468−{
469− GtkWidget *fs;
470−
471− fs = gtk_file_selection_new("Load file...");
472− g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
473− "clicked",
474− G_CALLBACK(load_filename), (gpointer) fs);
475− g_signal_connect_swapped(GTK_OBJECT
476− (GTK_FILE_SELECTION(fs)->ok_button),
477− "clicked", G_CALLBACK(gtk_widget_destroy),
478− (gpointer) fs);
479− g_signal_connect_swapped(GTK_OBJECT
480− (GTK_FILE_SELECTION(fs)->cancel_button),
481− "clicked", G_CALLBACK(gtk_widget_destroy),
482− (gpointer) fs);
483− gtk_widget_show(fs);
375+ gtk_widget_destroy(GTK_WIDGET(dialog));
484376 }
485377
486−
487−void on_save_activate(GtkMenuItem * menuitem, gpointer user_data)
378+static void on_save_activate(GtkMenuItem *menuitem, gpointer user_data)
488379 {
489380 if (conf_write(NULL))
490381 text_insert_msg("Error", "Unable to save configuration !");
491382 conf_write_autoconf(0);
492383 }
493384
494−
495−static void
496−store_filename(GtkFileSelection * file_selector, gpointer user_data)
385+static void on_save_as1_activate(GtkMenuItem *menuitem, gpointer user_data)
497386 {
498− const gchar *fn;
387+ GtkWidget *dialog;
388+ GtkFileChooser *chooser;
389+ gint res;
499390
500− fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
501− (user_data));
391+ dialog = gtk_file_chooser_dialog_new("Save file as...",
392+ GTK_WINDOW(user_data),
393+ GTK_FILE_CHOOSER_ACTION_SAVE,
394+ "_Cancel", GTK_RESPONSE_CANCEL,
395+ "_Save", GTK_RESPONSE_ACCEPT,
396+ NULL);
502397
503− if (conf_write(fn))
504− text_insert_msg("Error", "Unable to save configuration !");
398+ chooser = GTK_FILE_CHOOSER(dialog);
399+ gtk_file_chooser_set_filename(chooser, conf_get_configname());
505400
506− gtk_widget_destroy(GTK_WIDGET(user_data));
507−}
401+ res = gtk_dialog_run(GTK_DIALOG(dialog));
402+ if (res == GTK_RESPONSE_ACCEPT) {
403+ char *filename;
508404
509−void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
510−{
511− GtkWidget *fs;
512−
513− fs = gtk_file_selection_new("Save file as...");
514− g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
515− "clicked",
516− G_CALLBACK(store_filename), (gpointer) fs);
517− g_signal_connect_swapped(GTK_OBJECT
518− (GTK_FILE_SELECTION(fs)->ok_button),
519− "clicked", G_CALLBACK(gtk_widget_destroy),
520− (gpointer) fs);
521− g_signal_connect_swapped(GTK_OBJECT
522− (GTK_FILE_SELECTION(fs)->cancel_button),
523− "clicked", G_CALLBACK(gtk_widget_destroy),
524− (gpointer) fs);
525− gtk_widget_show(fs);
526−}
405+ filename = gtk_file_chooser_get_filename(chooser);
527406
407+ if (conf_write(filename))
408+ text_insert_msg("Error",
409+ "Unable to save configuration !");
528410
529−void on_quit1_activate(GtkMenuItem * menuitem, gpointer user_data)
530−{
531− if (!on_window1_delete_event(NULL, NULL, NULL))
532− gtk_widget_destroy(GTK_WIDGET(main_wnd));
533−}
411+ g_free(filename);
412+ }
534413
414+ gtk_widget_destroy(dialog);
415+}
535416
536−void on_show_name1_activate(GtkMenuItem * menuitem, gpointer user_data)
417+static void on_show_name1_activate(GtkMenuItem *menuitem, gpointer user_data)
537418 {
538419 GtkTreeViewColumn *col;
539420
540− show_name = GTK_CHECK_MENU_ITEM(menuitem)->active;
421+ show_name = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
541422 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NAME);
542423 if (col)
543424 gtk_tree_view_column_set_visible(col, show_name);
544425 }
545426
546−
547−void on_show_range1_activate(GtkMenuItem * menuitem, gpointer user_data)
427+static void on_show_range1_activate(GtkMenuItem *menuitem, gpointer user_data)
548428 {
549429 GtkTreeViewColumn *col;
550430
551− show_range = GTK_CHECK_MENU_ITEM(menuitem)->active;
431+ show_range = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
552432 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NO);
553433 if (col)
554434 gtk_tree_view_column_set_visible(col, show_range);
@@ -561,46 +441,38 @@ void on_show_range1_activate(GtkMenuItem * menuitem, gpointer user_data) · 6 unmodified lines
561441
562442 }
563443
564−
565−void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
444+static void on_show_data1_activate(GtkMenuItem *menuitem, gpointer user_data)
566445 {
567446 GtkTreeViewColumn *col;
568447
569− show_value = GTK_CHECK_MENU_ITEM(menuitem)->active;
448+ show_value = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
570449 col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_VALUE);
571450 if (col)
572451 gtk_tree_view_column_set_visible(col, show_value);
573452 }
574453
575−
576−void
577−on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
454+static void on_set_option_mode1_activate(GtkMenuItem *menuitem,
455+ gpointer user_data)
578456 {
579457 opt_mode = OPT_NORMAL;
580− gtk_tree_store_clear(tree2);
581− display_tree(&rootmenu); /* instead of update_tree to speed-up */
458+ update_row_visibility();
582459 }
583460
584−
585−void
586−on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
461+static void on_set_option_mode2_activate(GtkMenuItem *menuitem,
462+ gpointer user_data)
587463 {
588464 opt_mode = OPT_ALL;
589− gtk_tree_store_clear(tree2);
590− display_tree(&rootmenu); /* instead of update_tree to speed-up */
465+ update_row_visibility();
591466 }
592467
593−
594−void
595−on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
468+static void on_set_option_mode3_activate(GtkMenuItem *menuitem,
469+ gpointer user_data)
596470 {
597471 opt_mode = OPT_PROMPT;
598− gtk_tree_store_clear(tree2);
599− display_tree(&rootmenu); /* instead of update_tree to speed-up */
472+ update_row_visibility();
600473 }
601474
602−
603−void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
475+static void on_introduction1_activate(GtkMenuItem *menuitem, gpointer user_data)
604476 {
605477 GtkWidget *dialog;
606478 const gchar *intro_text =
@@ -621,14 +493,11 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) · 14 unmodified lines
621493 GTK_DIALOG_DESTROY_WITH_PARENT,
622494 GTK_MESSAGE_INFO,
623495 GTK_BUTTONS_CLOSE, "%s", intro_text);
624− g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
625− G_CALLBACK(gtk_widget_destroy),
626− GTK_OBJECT(dialog));
627− gtk_widget_show_all(dialog);
496+ gtk_dialog_run(GTK_DIALOG(dialog));
497+ gtk_widget_destroy(dialog);
628498 }
629499
630−
631−void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
500+static void on_about1_activate(GtkMenuItem *menuitem, gpointer user_data)
632501 {
633502 GtkWidget *dialog;
634503 const gchar *about_text =
@@ -638,15 +507,16 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data) · 3 unmodified lines
638507 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
639508 GTK_DIALOG_DESTROY_WITH_PARENT,
640509 GTK_MESSAGE_INFO,
641− GTK_BUTTONS_CLOSE, "%s", about_text);
642− g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
643− G_CALLBACK(gtk_widget_destroy),
644− GTK_OBJECT(dialog));
645− gtk_widget_show_all(dialog);
510+ GTK_BUTTONS_CLOSE, "%s\nGTK version: %d.%d.%d",
511+ about_text,
512+ gtk_get_major_version(),
513+ gtk_get_minor_version(),
514+ gtk_get_micro_version());
515+ gtk_dialog_run(GTK_DIALOG(dialog));
516+ gtk_widget_destroy(dialog);
646517 }
647518
648−
649−void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
519+static void on_license1_activate(GtkMenuItem *menuitem, gpointer user_data)
650520 {
651521 GtkWidget *dialog;
652522 const gchar *license_text =
@@ -658,81 +528,127 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data) · 5 unmodified lines
658528 GTK_DIALOG_DESTROY_WITH_PARENT,
659529 GTK_MESSAGE_INFO,
660530 GTK_BUTTONS_CLOSE, "%s", license_text);
661− g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
662− G_CALLBACK(gtk_widget_destroy),
663− GTK_OBJECT(dialog));
664− gtk_widget_show_all(dialog);
531+ gtk_dialog_run(GTK_DIALOG(dialog));
532+ gtk_widget_destroy(dialog);
665533 }
666534
667−
668−void on_back_clicked(GtkButton * button, gpointer user_data)
535+/* toolbar handlers */
536+static void on_back_clicked(GtkButton *button, gpointer user_data)
669537 {
670− enum prop_type ptype;
538+ browsed = menu_get_parent_menu(browsed) ?: &rootmenu;
671539
672− current = current->parent;
673− ptype = current->prompt ? current->prompt->type : P_UNKNOWN;
674− if (ptype != P_MENU)
675− current = current->parent;
676− display_tree_part();
540+ recreate_tree();
677541
678− if (current == &rootmenu)
542+ if (browsed == &rootmenu)
679543 gtk_widget_set_sensitive(back_btn, FALSE);
680544 }
681545
682−
683−void on_load_clicked(GtkButton * button, gpointer user_data)
546+static void on_load_clicked(GtkButton *button, gpointer user_data)
684547 {
685548 on_load1_activate(NULL, user_data);
686549 }
687550
688−
689−void on_single_clicked(GtkButton * button, gpointer user_data)
551+static void on_save_clicked(GtkButton *button, gpointer user_data)
690552 {
691− view_mode = SINGLE_VIEW;
692− gtk_widget_hide(tree1_w);
693− current = &rootmenu;
694− display_tree_part();
553+ on_save_activate(NULL, user_data);
695554 }
696555
556+static void on_single_clicked(GtkButton *button, gpointer user_data)
557+{
558+ set_view_mode(SINGLE_VIEW);
559+}
697560
698−void on_split_clicked(GtkButton * button, gpointer user_data)
561+static void on_split_clicked(GtkButton *button, gpointer user_data)
699562 {
700− gint w, h;
701− view_mode = SPLIT_VIEW;
702− gtk_widget_show(tree1_w);
703− gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
704− gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
705− if (tree2)
706− gtk_tree_store_clear(tree2);
707− display_list();
563+ set_view_mode(SPLIT_VIEW);
564+}
708565
709− /* Disable back btn, like in full mode. */
710− gtk_widget_set_sensitive(back_btn, FALSE);
566+static void on_full_clicked(GtkButton *button, gpointer user_data)
567+{
568+ set_view_mode(FULL_VIEW);
711569 }
712570
571+static void on_collapse_clicked(GtkButton *button, gpointer user_data)
572+{
573+ gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w));
574+}
713575
714−void on_full_clicked(GtkButton * button, gpointer user_data)
576+static void on_expand_clicked(GtkButton *button, gpointer user_data)
715577 {
716− view_mode = FULL_VIEW;
717− gtk_widget_hide(tree1_w);
718− if (tree2)
719− gtk_tree_store_clear(tree2);
720− display_tree(&rootmenu);
721− gtk_widget_set_sensitive(back_btn, FALSE);
578+ gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
722579 }
723580
581+/* Main Windows Callbacks */
724582
725−void on_collapse_clicked(GtkButton * button, gpointer user_data)
583+static void on_window1_destroy(GtkWidget *widget, gpointer user_data)
726584 {
727− gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w));
585+ gtk_main_quit();
728586 }
729587
588+static gboolean on_window1_configure(GtkWidget *self,
589+ GdkEventConfigure *event,
590+ gpointer user_data)
591+{
592+ gtk_paned_set_position(GTK_PANED(vpaned), 2 * event->height / 3);
593+ return FALSE;
594+}
730595
731−void on_expand_clicked(GtkButton * button, gpointer user_data)
596+static gboolean on_window1_delete_event(GtkWidget *widget, GdkEvent *event,
597+ gpointer user_data)
732598 {
733− gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
599+ GtkWidget *dialog, *label, *content_area;
600+ gint result;
601+ gint ret = FALSE;
602+
603+ if (!conf_get_changed())
604+ return FALSE;
605+
606+ dialog = gtk_dialog_new_with_buttons("Warning !",
607+ GTK_WINDOW(main_wnd),
608+ (GtkDialogFlags)
609+ (GTK_DIALOG_MODAL |
610+ GTK_DIALOG_DESTROY_WITH_PARENT),
611+ "_OK",
612+ GTK_RESPONSE_YES,
613+ "_No",
614+ GTK_RESPONSE_NO,
615+ "_Cancel",
616+ GTK_RESPONSE_CANCEL, NULL);
617+ gtk_dialog_set_default_response(GTK_DIALOG(dialog),
618+ GTK_RESPONSE_CANCEL);
619+
620+ label = gtk_label_new("\nSave configuration ?\n");
621+ content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
622+ gtk_container_add(GTK_CONTAINER(content_area), label);
623+ gtk_widget_show(label);
624+
625+ result = gtk_dialog_run(GTK_DIALOG(dialog));
626+ switch (result) {
627+ case GTK_RESPONSE_YES:
628+ on_save_activate(NULL, NULL);
629+ break;
630+ case GTK_RESPONSE_NO:
631+ break;
632+ case GTK_RESPONSE_CANCEL:
633+ case GTK_RESPONSE_DELETE_EVENT:
634+ default:
635+ ret = TRUE;
636+ break;
637+ }
638+
639+ gtk_widget_destroy(dialog);
640+
641+ if (!ret)
642+ g_object_unref(pix_menu);
643+
644+ return ret;
734645 }
735646
647+static void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data)
648+{
649+ if (!on_window1_delete_event(NULL, NULL, NULL))
650+ gtk_widget_destroy(GTK_WIDGET(main_wnd));
651+}
736652
737653 /* CTree Callbacks */
738654
@@ -741,25 +657,28 @@ static void renderer_edited(GtkCellRendererText * cell, · 2 unmodified lines
741657 const gchar * path_string,
742658 const gchar * new_text, gpointer user_data)
743659 {
660+ GtkTreeView *view = GTK_TREE_VIEW(user_data);
661+ GtkTreeModel *model = gtk_tree_view_get_model(view);
744662 GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
745663 GtkTreeIter iter;
746664 const char *old_def, *new_def;
747665 struct menu *menu;
748666 struct symbol *sym;
749667
750− if (!gtk_tree_model_get_iter(model2, &iter, path))
751− return;
668+ if (!gtk_tree_model_get_iter(model, &iter, path))
669+ goto free;
752670
753− gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
671+ gtk_tree_model_get(model, &iter, COL_MENU, &menu, -1);
754672 sym = menu->sym;
755673
756− gtk_tree_model_get(model2, &iter, COL_VALUE, &old_def, -1);
674+ gtk_tree_model_get(model, &iter, COL_VALUE, &old_def, -1);
757675 new_def = new_text;
758676
759677 sym_set_string_value(sym, new_def);
760678
761− update_tree(&rootmenu, NULL);
679+ update_trees();
762680
681+free:
763682 gtk_tree_path_free(path);
764683 }
765684
@@ -787,14 +706,7 @@ static void change_sym_value(struct menu *menu, gint col) · 21 unmodified lines
787706 if (!sym_tristate_within_range(sym, newval))
788707 newval = yes;
789708 sym_set_tristate_value(sym, newval);
790− if (view_mode == FULL_VIEW)
791− update_tree(&rootmenu, NULL);
792− else if (view_mode == SPLIT_VIEW) {
793− update_tree(browsed, NULL);
794− display_list();
795− }
796− else if (view_mode == SINGLE_VIEW)
797− display_tree_part(); //fixme: keep exp/coll
709+ update_trees();
798710 break;
799711 case S_INT:
800712 case S_HEX:
@@ -810,14 +722,7 @@ static void toggle_sym_value(struct menu *menu) · 9 unmodified lines
810722 return;
811723
812724 sym_toggle_tristate_value(menu->sym);
813− if (view_mode == FULL_VIEW)
814− update_tree(&rootmenu, NULL);
815− else if (view_mode == SPLIT_VIEW) {
816− update_tree(browsed, NULL);
817− display_list();
818− }
819− else if (view_mode == SINGLE_VIEW)
820− display_tree_part(); //fixme: keep exp/coll
725+ update_trees();
821726 }
822727
823728 static gint column2index(GtkTreeViewColumn * column)
@@ -837,43 +742,39 @@ static gint column2index(GtkTreeViewColumn * column) · 13 unmodified lines
837742
838743
839744 /* User click: update choice (full) or goes down (single) */
840−gboolean
841−on_treeview2_button_press_event(GtkWidget * widget,
842− GdkEventButton * event, gpointer user_data)
745+static gboolean on_treeview2_button_press_event(GtkWidget *widget,
746+ GdkEventButton *event,
747+ gpointer user_data)
843748 {
844749 GtkTreeView *view = GTK_TREE_VIEW(widget);
750+ GtkTreeModel *model = gtk_tree_view_get_model(view);
845751 GtkTreePath *path;
846752 GtkTreeViewColumn *column;
847753 GtkTreeIter iter;
848754 struct menu *menu;
849755 gint col;
850−
851−#if GTK_CHECK_VERSION(2,1,4) // bug in ctree with earlier version of GTK
852756 gint tx = (gint) event->x;
853757 gint ty = (gint) event->y;
854− gint cx, cy;
855758
856− gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
857− &cy);
858−#else
859− gtk_tree_view_get_cursor(view, &path, &column);
860−#endif
759+ gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, NULL, NULL);
861760 if (path == NULL)
862761 return FALSE;
863762
864− if (!gtk_tree_model_get_iter(model2, &iter, path))
763+ if (!gtk_tree_model_get_iter(model, &iter, path))
865764 return FALSE;
866− gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
765+ gtk_tree_model_get(model, &iter, COL_MENU, &menu, -1);
766+
767+ selected = menu;
867768
868769 col = column2index(column);
869770 if (event->type == GDK_2BUTTON_PRESS) {
870771 enum prop_type ptype;
871772 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
872773
873− if (ptype == P_MENU && view_mode != FULL_VIEW && col == COL_OPTION) {
774+ if (ptype == P_MENU && view_mode == SINGLE_VIEW && col == COL_OPTION) {
874775 // goes down into menu
875− current = menu;
876− display_tree_part();
776+ browsed = menu;
777+ recreate_tree();
877778 gtk_widget_set_sensitive(back_btn, TRUE);
878779 } else if (col == COL_OPTION) {
879780 toggle_sym_value(menu);
@@ -894,35 +795,31 @@ on_treeview2_button_press_event(GtkWidget * widget, · 14 unmodified lines
894795 }
895796
896797 /* Key pressed: update choice */
897−gboolean
898−on_treeview2_key_press_event(GtkWidget * widget,
899− GdkEventKey * event, gpointer user_data)
798+static gboolean on_treeview2_key_press_event(GtkWidget *widget,
799+ GdkEventKey *event,
800+ gpointer user_data)
900801 {
901802 GtkTreeView *view = GTK_TREE_VIEW(widget);
803+ GtkTreeModel *model = gtk_tree_view_get_model(view);
902804 GtkTreePath *path;
903− GtkTreeViewColumn *column;
904805 GtkTreeIter iter;
905806 struct menu *menu;
906807 gint col;
907808
908− gtk_tree_view_get_cursor(view, &path, &column);
809+ gtk_tree_view_get_cursor(view, &path, NULL);
909810 if (path == NULL)
910811 return FALSE;
911812
912− if (event->keyval == GDK_space) {
813+ if (event->keyval == GDK_KEY_space) {
913814 if (gtk_tree_view_row_expanded(view, path))
914815 gtk_tree_view_collapse_row(view, path);
915816 else
916817 gtk_tree_view_expand_row(view, path, FALSE);
917818 return TRUE;
918819 }
919− if (event->keyval == GDK_KP_Enter) {
920− }
921− if (widget == tree1_w)
922− return FALSE;
923820
924− gtk_tree_model_get_iter(model2, &iter, path);
925− gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
821+ gtk_tree_model_get_iter(model, &iter, path);
822+ gtk_tree_model_get(model, &iter, COL_MENU, &menu, -1);
926823
927824 if (!strcasecmp(event->string, "n"))
928825 col = COL_NO;
@@ -931,377 +828,82 @@ on_treeview2_key_press_event(GtkWidget * widget, · 2 unmodified lines
931828 else if (!strcasecmp(event->string, "y"))
932829 col = COL_YES;
933830 else
934− col = -1;
935− change_sym_value(menu, col);
936−
937− return FALSE;
938−}
939−
940−
941−/* Row selection changed: update help */
942−void
943−on_treeview2_cursor_changed(GtkTreeView * treeview, gpointer user_data)
944−{
945− GtkTreeSelection *selection;
946− GtkTreeIter iter;
947− struct menu *menu;
948−
949− selection = gtk_tree_view_get_selection(treeview);
950− if (gtk_tree_selection_get_selected(selection, &model2, &iter)) {
951− gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
952− text_insert_help(menu);
953− }
954−}
955−
956−
957−/* User click: display sub-tree in the right frame. */
958−gboolean
959−on_treeview1_button_press_event(GtkWidget * widget,
960− GdkEventButton * event, gpointer user_data)
961−{
962− GtkTreeView *view = GTK_TREE_VIEW(widget);
963− GtkTreePath *path;
964− GtkTreeViewColumn *column;
965− GtkTreeIter iter;
966− struct menu *menu;
967−
968− gint tx = (gint) event->x;
969− gint ty = (gint) event->y;
970− gint cx, cy;
971−
972− gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
973− &cy);
974− if (path == NULL)
975− return FALSE;
976−
977− gtk_tree_model_get_iter(model1, &iter, path);
978− gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1);
979−
980− if (event->type == GDK_2BUTTON_PRESS) {
981− toggle_sym_value(menu);
982− current = menu;
983− display_tree_part();
984− } else {
985− browsed = menu;
986− display_tree_part();
987− }
988−
989− gtk_widget_realize(tree2_w);
990− gtk_tree_view_set_cursor(view, path, NULL, FALSE);
991− gtk_widget_grab_focus(tree2_w);
992−
993− return FALSE;
994−}
995−
996−
997−/* Fill a row of strings */
998−static gchar **fill_row(struct menu *menu)
999−{
1000− static gchar *row[COL_NUMBER];
1001− struct symbol *sym = menu->sym;
1002− const char *def;
1003− int stype;
1004− tristate val;
1005− enum prop_type ptype;
1006− int i;
1007−
1008− for (i = COL_OPTION; i <= COL_COLOR; i++)
1009− g_free(row[i]);
1010− bzero(row, sizeof(row));
1011−
1012− ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
1013−
1014− row[COL_OPTION] =
1015− g_strdup_printf("%s %s %s %s",
1016− ptype == P_COMMENT ? "***" : "",
1017− menu_get_prompt(menu),
1018− ptype == P_COMMENT ? "***" : "",
1019− sym && !sym_has_value(sym) ? "(NEW)" : "");
1020−
1021− if (opt_mode == OPT_ALL && !menu_is_visible(menu))
1022− row[COL_COLOR] = g_strdup("DarkGray");
1023− else if (opt_mode == OPT_PROMPT &&
1024− menu_has_prompt(menu) && !menu_is_visible(menu))
1025− row[COL_COLOR] = g_strdup("DarkGray");
1026− else
1027− row[COL_COLOR] = g_strdup("Black");
1028−
1029− switch (ptype) {
1030− case P_MENU:
1031− row[COL_PIXBUF] = (gchar *) xpm_menu;
1032− if (view_mode == SINGLE_VIEW)
1033− row[COL_PIXVIS] = GINT_TO_POINTER(TRUE);
1034− row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1035− break;
1036− case P_COMMENT:
1037− row[COL_PIXBUF] = (gchar *) xpm_void;
1038− row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
1039− row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1040− break;
1041− default:
1042− row[COL_PIXBUF] = (gchar *) xpm_void;
1043− row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
1044− row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
1045− break;
1046− }
1047−
1048− if (!sym)
1049− return row;
1050− row[COL_NAME] = g_strdup(sym->name);
1051−
1052− sym_calc_value(sym);
1053− menu->flags &= ~MENU_CHANGED;
1054−
1055− if (sym_is_choice(sym)) { // parse childs for getting final value
1056− struct menu *child;
1057− struct symbol *def_sym = sym_calc_choice(menu);
1058− struct menu *def_menu = NULL;
1059−
1060− for (child = menu->list; child; child = child->next) {
1061− if (menu_is_visible(child)
1062− && child->sym == def_sym)
1063− def_menu = child;
1064− }
1065−
1066− if (def_menu)
1067− row[COL_VALUE] =
1068− g_strdup(menu_get_prompt(def_menu));
1069−
1070− row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1071− return row;
1072− }
1073− if (sym_is_choice_value(sym))
1074− row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
1075−
1076− stype = sym_get_type(sym);
1077− switch (stype) {
1078− case S_BOOLEAN:
1079− case S_TRISTATE:
1080− val = sym_get_tristate_value(sym);
1081− switch (val) {
1082− case no:
1083− row[COL_NO] = g_strdup("N");
1084− row[COL_VALUE] = g_strdup("N");
1085− row[COL_BTNACT] = GINT_TO_POINTER(FALSE);
1086− row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
1087− break;
1088− case mod:
1089− row[COL_MOD] = g_strdup("M");
1090− row[COL_VALUE] = g_strdup("M");
1091− row[COL_BTNINC] = GINT_TO_POINTER(TRUE);
1092− break;
1093− case yes:
1094− row[COL_YES] = g_strdup("Y");
1095− row[COL_VALUE] = g_strdup("Y");
1096− row[COL_BTNACT] = GINT_TO_POINTER(TRUE);
1097− row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
1098− break;
1099− }
1100−
1101− if (val != no && sym_tristate_within_range(sym, no))
1102− row[COL_NO] = g_strdup("_");
1103− if (val != mod && sym_tristate_within_range(sym, mod))
1104− row[COL_MOD] = g_strdup("_");
1105− if (val != yes && sym_tristate_within_range(sym, yes))
1106− row[COL_YES] = g_strdup("_");
1107− break;
1108− case S_INT:
1109− case S_HEX:
1110− case S_STRING:
1111− def = sym_get_string_value(sym);
1112− row[COL_VALUE] = g_strdup(def);
1113− row[COL_EDIT] = GINT_TO_POINTER(TRUE);
1114− row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
1115− break;
1116− }
1117−
1118− return row;
1119−}
1120−
1121−
1122−/* Set the node content with a row of strings */
1123−static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row)
1124−{
1125− GdkColor color;
1126− gboolean success;
1127− GdkPixbuf *pix;
1128−
1129− pix = gdk_pixbuf_new_from_xpm_data((const char **)
1130− row[COL_PIXBUF]);
1131−
1132− gdk_color_parse(row[COL_COLOR], &color);
1133− gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1,
1134− FALSE, FALSE, &success);
1135−
1136− gtk_tree_store_set(tree, node,
1137− COL_OPTION, row[COL_OPTION],
1138− COL_NAME, row[COL_NAME],
1139− COL_NO, row[COL_NO],
1140− COL_MOD, row[COL_MOD],
1141− COL_YES, row[COL_YES],
1142− COL_VALUE, row[COL_VALUE],
1143− COL_MENU, (gpointer) menu,
1144− COL_COLOR, &color,
1145− COL_EDIT, GPOINTER_TO_INT(row[COL_EDIT]),
1146− COL_PIXBUF, pix,
1147− COL_PIXVIS, GPOINTER_TO_INT(row[COL_PIXVIS]),
1148− COL_BTNVIS, GPOINTER_TO_INT(row[COL_BTNVIS]),
1149− COL_BTNACT, GPOINTER_TO_INT(row[COL_BTNACT]),
1150− COL_BTNINC, GPOINTER_TO_INT(row[COL_BTNINC]),
1151− COL_BTNRAD, GPOINTER_TO_INT(row[COL_BTNRAD]),
1152− -1);
1153−
1154− g_object_unref(pix);
1155−}
1156−
1157−
1158−/* Add a node to the tree */
1159−static void place_node(struct menu *menu, char **row)
1160−{
1161− GtkTreeIter *parent = parents[indent - 1];
1162− GtkTreeIter *node = parents[indent];
831+ col = -1;
832+ change_sym_value(menu, col);
1163833
1164− gtk_tree_store_append(tree, node, parent);
1165− set_node(node, menu, row);
834+ return FALSE;
1166835 }
1167836
1168837
1169−/* Find a node in the GTK+ tree */
1170−static GtkTreeIter found;
1171−
1172−/*
1173− * Find a menu in the GtkTree starting at parent.
1174− */
1175−static GtkTreeIter *gtktree_iter_find_node(GtkTreeIter *parent,
1176− struct menu *tofind)
838+/* Row selection changed: update help */
839+static void on_treeview2_cursor_changed(GtkTreeView *treeview,
840+ gpointer user_data)
1177841 {
842+ GtkTreeModel *model = gtk_tree_view_get_model(treeview);
843+ GtkTreeSelection *selection;
1178844 GtkTreeIter iter;
1179− GtkTreeIter *child = &iter;
1180− gboolean valid;
1181− GtkTreeIter *ret;
1182−
1183− valid = gtk_tree_model_iter_children(model2, child, parent);
1184− while (valid) {
1185− struct menu *menu;
1186−
1187− gtk_tree_model_get(model2, child, 6, &menu, -1);
1188−
1189− if (menu == tofind) {
1190− memcpy(&found, child, sizeof(GtkTreeIter));
1191− return &found;
1192− }
1193−
1194− ret = gtktree_iter_find_node(child, tofind);
1195− if (ret)
1196− return ret;
845+ struct menu *menu;
1197846
1198− valid = gtk_tree_model_iter_next(model2, child);
847+ selection = gtk_tree_view_get_selection(treeview);
848+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
849+ gtk_tree_model_get(model, &iter, COL_MENU, &menu, -1);
850+ text_insert_help(menu);
1199851 }
1200−
1201− return NULL;
1202852 }
1203853
1204854
1205−/*
1206− * Update the tree by adding/removing entries
1207− * Does not change other nodes
1208− */
1209−static void update_tree(struct menu *src, GtkTreeIter * dst)
855+/* User click: display sub-tree in the right frame. */
856+static gboolean on_treeview1_button_press_event(GtkWidget *widget,
857+ GdkEventButton *event,
858+ gpointer user_data)
1210859 {
1211− struct menu *child1;
1212− GtkTreeIter iter, tmp;
1213− GtkTreeIter *child2 = &iter;
1214− gboolean valid;
1215− GtkTreeIter *sibling;
1216− struct symbol *sym;
1217− struct menu *menu1, *menu2;
860+ GtkTreeView *view = GTK_TREE_VIEW(widget);
861+ GtkTreeModel *model = gtk_tree_view_get_model(view);
862+ GtkTreePath *path;
863+ GtkTreeIter iter;
864+ struct menu *menu;
865+ gint tx = (gint) event->x;
866+ gint ty = (gint) event->y;
1218867
1219− if (src == &rootmenu)
1220− indent = 1;
868+ gtk_tree_view_get_path_at_pos(view, tx, ty, &path, NULL, NULL, NULL);
869+ if (path == NULL)
870+ return FALSE;
1221871
1222− valid = gtk_tree_model_iter_children(model2, child2, dst);
1223− for (child1 = src->list; child1; child1 = child1->next) {
872+ gtk_tree_model_get_iter(model, &iter, path);
873+ gtk_tree_model_get(model, &iter, COL_MENU, &menu, -1);
1224874
1225− sym = child1->sym;
875+ if (event->type == GDK_2BUTTON_PRESS)
876+ toggle_sym_value(menu);
1226877
1227− reparse:
1228− menu1 = child1;
1229− if (valid)
1230− gtk_tree_model_get(model2, child2, COL_MENU,
1231− &menu2, -1);
1232− else
1233− menu2 = NULL; // force adding of a first child
1234−
1235− if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
1236− (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
1237− (opt_mode == OPT_ALL && !menu_get_prompt(child1))) {
1238−
1239− /* remove node */
1240− if (gtktree_iter_find_node(dst, menu1) != NULL) {
1241− memcpy(&tmp, child2, sizeof(GtkTreeIter));
1242− valid = gtk_tree_model_iter_next(model2,
1243− child2);
1244− gtk_tree_store_remove(tree2, &tmp);
1245− if (!valid)
1246− return; /* next parent */
1247− else
1248− goto reparse; /* next child */
1249− } else
1250− continue;
1251− }
878+ selected = menu;
1252879
1253− if (menu1 != menu2) {
1254− if (gtktree_iter_find_node(dst, menu1) == NULL) { // add node
1255− if (!valid && !menu2)
1256− sibling = NULL;
1257− else
1258− sibling = child2;
1259− gtk_tree_store_insert_before(tree2,
1260− child2,
1261− dst, sibling);
1262− set_node(child2, menu1, fill_row(menu1));
1263− if (menu2 == NULL)
1264− valid = TRUE;
1265− } else { // remove node
1266− memcpy(&tmp, child2, sizeof(GtkTreeIter));
1267− valid = gtk_tree_model_iter_next(model2,
1268− child2);
1269− gtk_tree_store_remove(tree2, &tmp);
1270− if (!valid)
1271− return; // next parent
1272− else
1273− goto reparse; // next child
1274− }
1275− } else if (sym && (child1->flags & MENU_CHANGED)) {
1276− set_node(child2, menu1, fill_row(menu1));
1277− }
880+ if (menu->type == M_MENU) {
881+ browsed = menu;
882+ recreate_tree();
883+ }
1278884
1279− indent++;
1280− update_tree(child1, child2);
1281− indent--;
885+ gtk_tree_view_set_cursor(view, path, NULL, FALSE);
886+ gtk_widget_grab_focus(tree2_w);
1282887
1283− valid = gtk_tree_model_iter_next(model2, child2);
1284− }
888+ return FALSE;
1285889 }
1286890
1287−
1288891 /* Display the whole tree (single/split/full view) */
1289−static void display_tree(struct menu *menu)
892+static void _display_tree(GtkTreeStore *tree, struct menu *menu,
893+ GtkTreeIter *parent)
1290894 {
1291− struct property *prop;
1292895 struct menu *child;
1293− enum prop_type ptype;
1294−
1295− if (menu == &rootmenu) {
1296− indent = 1;
1297− current = &rootmenu;
1298− }
896+ GtkTreeIter iter;
1299897
1300898 for (child = menu->list; child; child = child->next) {
1301− prop = child->prompt;
1302− ptype = prop ? prop->type : P_UNKNOWN;
1303−
1304− menu->flags &= ~MENU_CHANGED;
899+ /*
900+ * REVISIT:
901+ * menu_finalize() creates empty "if" entries.
902+ * Do not confuse gtk_tree_model_get(), which would otherwise
903+ * return "if" menu entry.
904+ */
905+ if (child->type == M_IF)
906+ continue;
1305907
1306908 if ((view_mode == SPLIT_VIEW)
1307909 && !(child->flags & MENU_ROOT) && (tree == tree1))
@@ -1311,58 +913,25 @@ static void display_tree(struct menu *menu) · 3 unmodified lines
1311913 && (tree == tree2))
1312914 continue;
1313915
1314− if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
1315− (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
1316− (opt_mode == OPT_ALL && menu_get_prompt(child)))
1317− place_node(child, fill_row(child));
1318−
1319− if ((view_mode != FULL_VIEW) && (ptype == P_MENU)
1320− && (tree == tree2))
1321− continue;
1322−/*
1323− if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
1324− || (view_mode == FULL_VIEW)
1325− || (view_mode == SPLIT_VIEW))*/
1326−
1327− /* Change paned position if the view is not in 'split mode' */
1328− if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
1329− gtk_paned_set_position(GTK_PANED(hpaned), 0);
1330− }
916+ gtk_tree_store_append(tree, &iter, parent);
917+ set_node(tree, &iter, child);
1331918
1332− if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
1333− || (view_mode == FULL_VIEW)
1334− || (view_mode == SPLIT_VIEW)) {
1335− indent++;
1336− display_tree(child);
1337− indent--;
1338− }
919+ if (view_mode != SINGLE_VIEW || child->type != M_MENU)
920+ _display_tree(tree, child, &iter);
1339921 }
1340922 }
1341923
1342−/* Display a part of the tree starting at current node (single/split view) */
1343−static void display_tree_part(void)
924+static void display_tree(GtkTreeStore *store, struct menu *menu)
1344925 {
1345− if (tree2)
1346− gtk_tree_store_clear(tree2);
1347− if (view_mode == SINGLE_VIEW)
1348− display_tree(current);
1349− else if (view_mode == SPLIT_VIEW)
1350− display_tree(browsed);
1351− else if (view_mode == FULL_VIEW)
1352− display_tree(&rootmenu);
1353− gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
926+ _display_tree(store, menu, NULL);
1354927 }
1355928
1356−/* Display the list in the left frame (split view) */
1357−static void display_list(void)
929+/* Recreate the tree store starting at 'browsed' node */
930+static void recreate_tree(void)
1358931 {
1359− if (tree1)
1360− gtk_tree_store_clear(tree1);
1361−
1362− tree = tree1;
1363− display_tree(&rootmenu);
1364− gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w));
1365− tree = tree2;
932+ gtk_tree_store_clear(tree2);
933+ display_tree(tree2, browsed);
934+ gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
1366935 }
1367936
1368937 static void fixup_rootmenu(struct menu *menu)
@@ -1381,6 +950,335 @@ static void fixup_rootmenu(struct menu *menu) · 12 unmodified lines
1381950 }
1382951 }
1383952
953+/* Main Window Initialization */
954+static void replace_button_icon(GtkWidget *widget, const char * const xpm[])
955+{
956+ GdkPixbuf *pixbuf;
957+ GtkWidget *image;
958+
959+ pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)xpm);
960+ image = gtk_image_new_from_pixbuf(pixbuf);
961+ g_object_unref(pixbuf);
962+
963+ gtk_widget_show(image);
964+ gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(widget), image);
965+}
966+
967+static void init_main_window(const gchar *glade_file)
968+{
969+ GtkBuilder *builder;
970+ GtkWidget *widget;
971+ GtkTextBuffer *txtbuf;
972+
973+ builder = gtk_builder_new_from_file(glade_file);
974+ if (!builder)
975+ g_error("GUI loading failed !\n");
976+
977+ main_wnd = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
978+ g_signal_connect(main_wnd, "destroy",
979+ G_CALLBACK(on_window1_destroy), NULL);
980+ g_signal_connect(main_wnd, "configure-event",
981+ G_CALLBACK(on_window1_configure), NULL);
982+ g_signal_connect(main_wnd, "delete-event",
983+ G_CALLBACK(on_window1_delete_event), NULL);
984+
985+ hpaned = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned1"));
986+ vpaned = GTK_WIDGET(gtk_builder_get_object(builder, "vpaned1"));
987+ tree1_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview1"));
988+ g_signal_connect(tree1_w, "cursor-changed",
989+ G_CALLBACK(on_treeview2_cursor_changed), NULL);
990+ g_signal_connect(tree1_w, "button-press-event",
991+ G_CALLBACK(on_treeview1_button_press_event), NULL);
992+ g_signal_connect(tree1_w, "key-press-event",
993+ G_CALLBACK(on_treeview2_key_press_event), NULL);
994+
995+ tree2_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview2"));
996+ g_signal_connect(tree2_w, "cursor-changed",
997+ G_CALLBACK(on_treeview2_cursor_changed), NULL);
998+ g_signal_connect(tree2_w, "button-press-event",
999+ G_CALLBACK(on_treeview2_button_press_event), NULL);
1000+ g_signal_connect(tree2_w, "key-press-event",
1001+ G_CALLBACK(on_treeview2_key_press_event), NULL);
1002+
1003+ text_w = GTK_WIDGET(gtk_builder_get_object(builder, "textview3"));
1004+
1005+ /* menubar */
1006+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "load1"));
1007+ g_signal_connect(widget, "activate",
1008+ G_CALLBACK(on_load1_activate), NULL);
1009+
1010+ save_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "save1"));
1011+ g_signal_connect(save_menu_item, "activate",
1012+ G_CALLBACK(on_save_activate), NULL);
1013+
1014+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "save_as1"));
1015+ g_signal_connect(widget, "activate",
1016+ G_CALLBACK(on_save_as1_activate), NULL);
1017+
1018+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "quit1"));
1019+ g_signal_connect(widget, "activate",
1020+ G_CALLBACK(on_quit1_activate), NULL);
1021+
1022+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_name1"));
1023+ g_signal_connect(widget, "activate",
1024+ G_CALLBACK(on_show_name1_activate), NULL);
1025+ gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
1026+ show_name);
1027+
1028+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_range1"));
1029+ g_signal_connect(widget, "activate",
1030+ G_CALLBACK(on_show_range1_activate), NULL);
1031+ gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
1032+ show_range);
1033+
1034+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_data1"));
1035+ g_signal_connect(widget, "activate",
1036+ G_CALLBACK(on_show_data1_activate), NULL);
1037+ gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
1038+ show_value);
1039+
1040+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "set_option_mode1"));
1041+ g_signal_connect(widget, "activate",
1042+ G_CALLBACK(on_set_option_mode1_activate), NULL);
1043+
1044+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "set_option_mode2"));
1045+ g_signal_connect(widget, "activate",
1046+ G_CALLBACK(on_set_option_mode2_activate), NULL);
1047+
1048+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "set_option_mode3"));
1049+ g_signal_connect(widget, "activate",
1050+ G_CALLBACK(on_set_option_mode3_activate), NULL);
1051+
1052+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "introduction1"));
1053+ g_signal_connect(widget, "activate",
1054+ G_CALLBACK(on_introduction1_activate), NULL);
1055+
1056+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "about1"));
1057+ g_signal_connect(widget, "activate",
1058+ G_CALLBACK(on_about1_activate), NULL);
1059+
1060+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "license1"));
1061+ g_signal_connect(widget, "activate",
1062+ G_CALLBACK(on_license1_activate), NULL);
1063+
1064+ /* toolbar */
1065+ back_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button1"));
1066+ g_signal_connect(back_btn, "clicked",
1067+ G_CALLBACK(on_back_clicked), NULL);
1068+ gtk_widget_set_sensitive(back_btn, FALSE);
1069+
1070+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "button2"));
1071+ g_signal_connect(widget, "clicked",
1072+ G_CALLBACK(on_load_clicked), NULL);
1073+
1074+ save_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button3"));
1075+ g_signal_connect(save_btn, "clicked",
1076+ G_CALLBACK(on_save_clicked), NULL);
1077+
1078+ single_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button4"));
1079+ g_signal_connect(single_btn, "clicked",
1080+ G_CALLBACK(on_single_clicked), NULL);
1081+ replace_button_icon(single_btn, xpm_single_view);
1082+
1083+ split_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button5"));
1084+ g_signal_connect(split_btn, "clicked",
1085+ G_CALLBACK(on_split_clicked), NULL);
1086+ replace_button_icon(split_btn, xpm_split_view);
1087+
1088+ full_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button6"));
1089+ g_signal_connect(full_btn, "clicked",
1090+ G_CALLBACK(on_full_clicked), NULL);
1091+ replace_button_icon(full_btn, xpm_tree_view);
1092+
1093+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "button7"));
1094+ g_signal_connect(widget, "clicked",
1095+ G_CALLBACK(on_collapse_clicked), NULL);
1096+
1097+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "button8"));
1098+ g_signal_connect(widget, "clicked",
1099+ G_CALLBACK(on_expand_clicked), NULL);
1100+
1101+ txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
1102+ tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
1103+ "foreground", "red",
1104+ "weight", PANGO_WEIGHT_BOLD,
1105+ NULL);
1106+ tag2 = gtk_text_buffer_create_tag(txtbuf, "mytag2",
1107+ /*"style", PANGO_STYLE_OBLIQUE, */
1108+ NULL);
1109+
1110+ gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
1111+
1112+ gtk_widget_show_all(main_wnd);
1113+
1114+ g_object_unref(builder);
1115+
1116+ conf_set_changed_callback(conf_changed);
1117+}
1118+
1119+static gboolean visible_func(GtkTreeModel *model, GtkTreeIter *iter,
1120+ gpointer data)
1121+{
1122+ struct menu *menu;
1123+
1124+ gtk_tree_model_get(model, iter, COL_MENU, &menu, -1);
1125+
1126+ if (!menu)
1127+ return FALSE;
1128+
1129+ return menu_is_visible(menu) || opt_mode == OPT_ALL ||
1130+ (opt_mode == OPT_PROMPT && menu_has_prompt(menu));
1131+}
1132+
1133+static void init_left_tree(void)
1134+{
1135+ GtkTreeView *view = GTK_TREE_VIEW(tree1_w);
1136+ GtkCellRenderer *renderer;
1137+ GtkTreeSelection *sel;
1138+ GtkTreeViewColumn *column;
1139+ GtkTreeModel *filter;
1140+
1141+ tree1 = gtk_tree_store_new(COL_NUMBER,
1142+ G_TYPE_STRING, G_TYPE_STRING,
1143+ G_TYPE_STRING, G_TYPE_STRING,
1144+ G_TYPE_STRING, G_TYPE_STRING,
1145+ G_TYPE_POINTER, GDK_TYPE_RGBA,
1146+ G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
1147+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
1148+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
1149+ G_TYPE_BOOLEAN);
1150+
1151+ filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(tree1), NULL);
1152+
1153+ gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(filter),
1154+ visible_func, NULL, NULL);
1155+ gtk_tree_view_set_model(view, filter);
1156+
1157+ column = gtk_tree_view_column_new();
1158+ gtk_tree_view_append_column(view, column);
1159+ gtk_tree_view_column_set_title(column, "Options");
1160+
1161+ renderer = gtk_cell_renderer_toggle_new();
1162+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
1163+ renderer, FALSE);
1164+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
1165+ renderer,
1166+ "active", COL_BTNACT,
1167+ "inconsistent", COL_BTNINC,
1168+ "visible", COL_BTNVIS,
1169+ "radio", COL_BTNRAD, NULL);
1170+ renderer = gtk_cell_renderer_text_new();
1171+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
1172+ renderer, FALSE);
1173+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
1174+ renderer,
1175+ "text", COL_OPTION,
1176+ "foreground-rgba",
1177+ COL_COLOR, NULL);
1178+
1179+ sel = gtk_tree_view_get_selection(view);
1180+ gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
1181+}
1182+
1183+static void init_right_tree(void)
1184+{
1185+ GtkTreeView *view = GTK_TREE_VIEW(tree2_w);
1186+ GtkCellRenderer *renderer;
1187+ GtkTreeSelection *sel;
1188+ GtkTreeViewColumn *column;
1189+ GtkTreeModel *filter;
1190+ gint i;
1191+
1192+ tree2 = gtk_tree_store_new(COL_NUMBER,
1193+ G_TYPE_STRING, G_TYPE_STRING,
1194+ G_TYPE_STRING, G_TYPE_STRING,
1195+ G_TYPE_STRING, G_TYPE_STRING,
1196+ G_TYPE_POINTER, GDK_TYPE_RGBA,
1197+ G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
1198+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
1199+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
1200+ G_TYPE_BOOLEAN);
1201+
1202+ filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(tree2), NULL);
1203+
1204+ gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(filter),
1205+ visible_func, NULL, NULL);
1206+ gtk_tree_view_set_model(view, filter);
1207+
1208+ column = gtk_tree_view_column_new();
1209+ gtk_tree_view_append_column(view, column);
1210+ gtk_tree_view_column_set_title(column, "Options");
1211+
1212+ renderer = gtk_cell_renderer_pixbuf_new();
1213+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
1214+ renderer, FALSE);
1215+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
1216+ renderer,
1217+ "pixbuf", COL_PIXBUF,
1218+ "visible", COL_PIXVIS, NULL);
1219+ renderer = gtk_cell_renderer_toggle_new();
1220+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
1221+ renderer, FALSE);
1222+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
1223+ renderer,
1224+ "active", COL_BTNACT,
1225+ "inconsistent", COL_BTNINC,
1226+ "visible", COL_BTNVIS,
1227+ "radio", COL_BTNRAD, NULL);
1228+ renderer = gtk_cell_renderer_text_new();
1229+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
1230+ renderer, FALSE);
1231+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
1232+ renderer,
1233+ "text", COL_OPTION,
1234+ "foreground-rgba",
1235+ COL_COLOR, NULL);
1236+
1237+ renderer = gtk_cell_renderer_text_new();
1238+ gtk_tree_view_insert_column_with_attributes(view, -1,
1239+ "Name", renderer,
1240+ "text", COL_NAME,
1241+ "foreground-rgba",
1242+ COL_COLOR, NULL);
1243+ renderer = gtk_cell_renderer_text_new();
1244+ gtk_tree_view_insert_column_with_attributes(view, -1,
1245+ "N", renderer,
1246+ "text", COL_NO,
1247+ "foreground-rgba",
1248+ COL_COLOR, NULL);
1249+ renderer = gtk_cell_renderer_text_new();
1250+ gtk_tree_view_insert_column_with_attributes(view, -1,
1251+ "M", renderer,
1252+ "text", COL_MOD,
1253+ "foreground-rgba",
1254+ COL_COLOR, NULL);
1255+ renderer = gtk_cell_renderer_text_new();
1256+ gtk_tree_view_insert_column_with_attributes(view, -1,
1257+ "Y", renderer,
1258+ "text", COL_YES,
1259+ "foreground-rgba",
1260+ COL_COLOR, NULL);
1261+ renderer = gtk_cell_renderer_text_new();
1262+ gtk_tree_view_insert_column_with_attributes(view, -1,
1263+ "Value", renderer,
1264+ "text", COL_VALUE,
1265+ "editable",
1266+ COL_EDIT,
1267+ "foreground-rgba",
1268+ COL_COLOR, NULL);
1269+ g_signal_connect(G_OBJECT(renderer), "edited",
1270+ G_CALLBACK(renderer_edited), tree2_w);
1271+
1272+ pix_menu = gdk_pixbuf_new_from_xpm_data((const char **)xpm_menu);
1273+
1274+ for (i = 0; i < COL_VALUE; i++) {
1275+ column = gtk_tree_view_get_column(view, i);
1276+ gtk_tree_view_column_set_resizable(column, TRUE);
1277+ }
1278+
1279+ sel = gtk_tree_view_get_selection(view);
1280+ gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
1281+}
13841282
13851283 /* Main */
13861284 int main(int ac, char *av[])
@@ -1390,18 +1288,16 @@ int main(int ac, char *av[]) · 3 unmodified lines
13901288 gchar *glade_file;
13911289
13921290 /* GTK stuffs */
1393− gtk_set_locale();
13941291 gtk_init(&ac, &av);
1395− glade_init();
13961292
13971293 /* Determine GUI path */
13981294 env = getenv(SRCTREE);
13991295 if (env)
1400− glade_file = g_strconcat(env, "/scripts/kconfig/gconf.glade", NULL);
1296+ glade_file = g_strconcat(env, "/scripts/kconfig/gconf.ui", NULL);
14011297 else if (av[0][0] == '/')
1402− glade_file = g_strconcat(av[0], ".glade", NULL);
1298+ glade_file = g_strconcat(av[0], ".ui", NULL);
14031299 else
1404− glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
1300+ glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".ui", NULL);
14051301
14061302 /* Conf stuffs */
14071303 if (ac > 1 && av[1][0] == '-') {
@@ -1426,23 +1322,12 @@ int main(int ac, char *av[]) · 18 unmodified lines
14261322
14271323 /* Load the interface and connect signals */
14281324 init_main_window(glade_file);
1429− init_tree_model();
14301325 init_left_tree();
14311326 init_right_tree();
14321327
14331328 conf_read(NULL);
14341329
1435− switch (view_mode) {
1436− case SINGLE_VIEW:
1437− display_tree_part();
1438− break;
1439− case SPLIT_VIEW:
1440− display_list();
1441− break;
1442− case FULL_VIEW:
1443− display_tree(&rootmenu);
1444− break;
1445− }
1330+ set_view_mode(view_mode);
14461331
14471332 gtk_main();
14481333
scripts/kconfig/gconf.uirenamed from scripts/kconfig/gconf.glade+118−243
@@ -1,8 +1,8 @@
11 <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
22
3−<glade-interface>
3+<interface>
44
5−<widget class="GtkWindow" id="window1">
5+<object class="GtkWindow" id="window1">
66 <property name="visible">True</property>
77 <property name="title" translatable="yes">Gtk Kernel Configurator</property>
88 <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -17,295 +17,196 @@ · 8 unmodified lines
1717 <property name="skip_pager_hint">False</property>
1818 <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
1919 <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
20− <signal name="destroy" handler="on_window1_destroy" object="window1"/>
21− <signal name="size_request" handler="on_window1_size_request" object="vpaned1" last_modification_time="Fri, 11 Jan 2002 16:17:11 GMT"/>
22− <signal name="delete_event" handler="on_window1_delete_event" object="window1" last_modification_time="Sun, 09 Mar 2003 19:42:46 GMT"/>
2320
2421 <child>
25− <widget class="GtkVBox" id="vbox1">
22+ <object class="GtkBox" id="vbox1">
23+ <property name="orientation">vertical</property>
2624 <property name="visible">True</property>
2725 <property name="homogeneous">False</property>
2826 <property name="spacing">0</property>
2927
3028 <child>
31− <widget class="GtkMenuBar" id="menubar1">
29+ <object class="GtkMenuBar" id="menubar1">
3230 <property name="visible">True</property>
3331
3432 <child>
35− <widget class="GtkMenuItem" id="file1">
33+ <object class="GtkMenuItem" id="file1">
3634 <property name="visible">True</property>
3735 <property name="label" translatable="yes">_File</property>
3836 <property name="use_underline">True</property>
3937
40− <child>
41− <widget class="GtkMenu" id="file1_menu">
38+ <child type="submenu">
39+ <object class="GtkMenu" id="file1_menu">
4240
4341 <child>
44− <widget class="GtkImageMenuItem" id="load1">
42+ <object class="GtkMenuItem" id="load1">
4543 <property name="visible">True</property>
46− <property name="tooltip" translatable="yes">Load a config file</property>
44+ <property name="tooltip-text" translatable="yes">Load a config file</property>
4745 <property name="label" translatable="yes">_Load</property>
4846 <property name="use_underline">True</property>
49− <signal name="activate" handler="on_load1_activate"/>
5047 <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
51−
52− <child internal-child="image">
53− <widget class="GtkImage" id="image39">
54− <property name="visible">True</property>
55− <property name="stock">gtk-open</property>
56− <property name="icon_size">1</property>
57− <property name="xalign">0.5</property>
58− <property name="yalign">0.5</property>
59− <property name="xpad">0</property>
60− <property name="ypad">0</property>
61− </widget>
62− </child>
63− </widget>
48+ </object>
6449 </child>
6550
6651 <child>
67− <widget class="GtkImageMenuItem" id="save1">
52+ <object class="GtkMenuItem" id="save1">
6853 <property name="visible">True</property>
69− <property name="tooltip" translatable="yes">Save the config in .config</property>
54+ <property name="tooltip-text" translatable="yes">Save the config in .config</property>
7055 <property name="label" translatable="yes">_Save</property>
7156 <property name="use_underline">True</property>
72− <signal name="activate" handler="on_save_activate"/>
7357 <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
74−
75− <child internal-child="image">
76− <widget class="GtkImage" id="image40">
77− <property name="visible">True</property>
78− <property name="stock">gtk-save</property>
79− <property name="icon_size">1</property>
80− <property name="xalign">0.5</property>
81− <property name="yalign">0.5</property>
82− <property name="xpad">0</property>
83− <property name="ypad">0</property>
84− </widget>
85− </child>
86− </widget>
58+ </object>
8759 </child>
8860
8961 <child>
90− <widget class="GtkImageMenuItem" id="save_as1">
62+ <object class="GtkMenuItem" id="save_as1">
9163 <property name="visible">True</property>
92− <property name="tooltip" translatable="yes">Save the config in a file</property>
64+ <property name="tooltip-text" translatable="yes">Save the config in a file</property>
9365 <property name="label" translatable="yes">Save _as</property>
9466 <property name="use_underline">True</property>
95− <signal name="activate" handler="on_save_as1_activate"/>
96−
97− <child internal-child="image">
98− <widget class="GtkImage" id="image41">
99− <property name="visible">True</property>
100− <property name="stock">gtk-save-as</property>
101− <property name="icon_size">1</property>
102− <property name="xalign">0.5</property>
103− <property name="yalign">0.5</property>
104− <property name="xpad">0</property>
105− <property name="ypad">0</property>
106− </widget>
107− </child>
108− </widget>
67+ </object>
10968 </child>
11069
11170 <child>
112− <widget class="GtkSeparatorMenuItem" id="separator1">
71+ <object class="GtkSeparatorMenuItem" id="separator1">
11372 <property name="visible">True</property>
114− </widget>
73+ </object>
11574 </child>
11675
11776 <child>
118− <widget class="GtkImageMenuItem" id="quit1">
77+ <object class="GtkMenuItem" id="quit1">
11978 <property name="visible">True</property>
12079 <property name="label" translatable="yes">_Quit</property>
12180 <property name="use_underline">True</property>
122− <signal name="activate" handler="on_quit1_activate"/>
12381 <accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
124−
125− <child internal-child="image">
126− <widget class="GtkImage" id="image42">
127− <property name="visible">True</property>
128− <property name="stock">gtk-quit</property>
129− <property name="icon_size">1</property>
130− <property name="xalign">0.5</property>
131− <property name="yalign">0.5</property>
132− <property name="xpad">0</property>
133− <property name="ypad">0</property>
134− </widget>
135− </child>
136− </widget>
82+ </object>
13783 </child>
138− </widget>
84+ </object>
13985 </child>
140− </widget>
86+ </object>
14187 </child>
14288
14389 <child>
144− <widget class="GtkMenuItem" id="options1">
90+ <object class="GtkMenuItem" id="options1">
14591 <property name="visible">True</property>
14692 <property name="label" translatable="yes">_Options</property>
14793 <property name="use_underline">True</property>
14894
149− <child>
150− <widget class="GtkMenu" id="options1_menu">
95+ <child type="submenu">
96+ <object class="GtkMenu" id="options1_menu">
15197
15298 <child>
153− <widget class="GtkCheckMenuItem" id="show_name1">
99+ <object class="GtkCheckMenuItem" id="show_name1">
154100 <property name="visible">True</property>
155− <property name="tooltip" translatable="yes">Show name</property>
101+ <property name="tooltip-text" translatable="yes">Show name</property>
156102 <property name="label" translatable="yes">Show _name</property>
157103 <property name="use_underline">True</property>
158104 <property name="active">False</property>
159− <signal name="activate" handler="on_show_name1_activate"/>
160− </widget>
105+ </object>
161106 </child>
162107
163108 <child>
164− <widget class="GtkCheckMenuItem" id="show_range1">
109+ <object class="GtkCheckMenuItem" id="show_range1">
165110 <property name="visible">True</property>
166− <property name="tooltip" translatable="yes">Show range (Y/M/N)</property>
111+ <property name="tooltip-text" translatable="yes">Show range (Y/M/N)</property>
167112 <property name="label" translatable="yes">Show _range</property>
168113 <property name="use_underline">True</property>
169114 <property name="active">False</property>
170− <signal name="activate" handler="on_show_range1_activate"/>
171− </widget>
115+ </object>
172116 </child>
173117
174118 <child>
175− <widget class="GtkCheckMenuItem" id="show_data1">
119+ <object class="GtkCheckMenuItem" id="show_data1">
176120 <property name="visible">True</property>
177− <property name="tooltip" translatable="yes">Show value of the option</property>
121+ <property name="tooltip-text" translatable="yes">Show value of the option</property>
178122 <property name="label" translatable="yes">Show _data</property>
179123 <property name="use_underline">True</property>
180124 <property name="active">False</property>
181− <signal name="activate" handler="on_show_data1_activate"/>
182− </widget>
125+ </object>
183126 </child>
184127
185128 <child>
186− <widget class="GtkSeparatorMenuItem" id="separator2">
129+ <object class="GtkSeparatorMenuItem" id="separator2">
187130 <property name="visible">True</property>
188− </widget>
131+ </object>
189132 </child>
190133
191134 <child>
192− <widget class="GtkRadioMenuItem" id="set_option_mode1">
135+ <object class="GtkRadioMenuItem" id="set_option_mode1">
193136 <property name="visible">True</property>
194− <property name="tooltip" translatable="yes">Show normal options</property>
137+ <property name="tooltip-text" translatable="yes">Show normal options</property>
195138 <property name="label" translatable="yes">Show normal options</property>
196139 <property name="use_underline">True</property>
197140 <property name="active">True</property>
198− <signal name="activate" handler="on_set_option_mode1_activate"/>
199− </widget>
141+ </object>
200142 </child>
201143
202144 <child>
203− <widget class="GtkRadioMenuItem" id="set_option_mode2">
145+ <object class="GtkRadioMenuItem" id="set_option_mode2">
204146 <property name="visible">True</property>
205− <property name="tooltip" translatable="yes">Show all options</property>
147+ <property name="tooltip-text" translatable="yes">Show all options</property>
206148 <property name="label" translatable="yes">Show all _options</property>
207149 <property name="use_underline">True</property>
208150 <property name="active">False</property>
209151 <property name="group">set_option_mode1</property>
210− <signal name="activate" handler="on_set_option_mode2_activate"/>
211− </widget>
152+ </object>
212153 </child>
213154
214155 <child>
215− <widget class="GtkRadioMenuItem" id="set_option_mode3">
156+ <object class="GtkRadioMenuItem" id="set_option_mode3">
216157 <property name="visible">True</property>
217− <property name="tooltip" translatable="yes">Show all options with prompts</property>
158+ <property name="tooltip-text" translatable="yes">Show all options with prompts</property>
218159 <property name="label" translatable="yes">Show all prompt options</property>
219160 <property name="use_underline">True</property>
220161 <property name="active">False</property>
221162 <property name="group">set_option_mode1</property>
222− <signal name="activate" handler="on_set_option_mode3_activate"/>
223− </widget>
163+ </object>
224164 </child>
225165
226− </widget>
166+ </object>
227167 </child>
228− </widget>
168+ </object>
229169 </child>
230170
231171 <child>
232− <widget class="GtkMenuItem" id="help1">
172+ <object class="GtkMenuItem" id="help1">
233173 <property name="visible">True</property>
234174 <property name="label" translatable="yes">_Help</property>
235175 <property name="use_underline">True</property>
236176
237− <child>
238− <widget class="GtkMenu" id="help1_menu">
177+ <child type="submenu">
178+ <object class="GtkMenu" id="help1_menu">
239179
240180 <child>
241− <widget class="GtkImageMenuItem" id="introduction1">
181+ <object class="GtkMenuItem" id="introduction1">
242182 <property name="visible">True</property>
243183 <property name="label" translatable="yes">_Introduction</property>
244184 <property name="use_underline">True</property>
245− <signal name="activate" handler="on_introduction1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
246185 <accelerator key="I" modifiers="GDK_CONTROL_MASK" signal="activate"/>
247−
248− <child internal-child="image">
249− <widget class="GtkImage" id="image43">
250− <property name="visible">True</property>
251− <property name="stock">gtk-dialog-question</property>
252− <property name="icon_size">1</property>
253− <property name="xalign">0.5</property>
254− <property name="yalign">0.5</property>
255− <property name="xpad">0</property>
256− <property name="ypad">0</property>
257− </widget>
258− </child>
259− </widget>
186+ </object>
260187 </child>
261188
262189 <child>
263− <widget class="GtkImageMenuItem" id="about1">
190+ <object class="GtkMenuItem" id="about1">
264191 <property name="visible">True</property>
265192 <property name="label" translatable="yes">_About</property>
266193 <property name="use_underline">True</property>
267− <signal name="activate" handler="on_about1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
268194 <accelerator key="A" modifiers="GDK_CONTROL_MASK" signal="activate"/>
269−
270− <child internal-child="image">
271− <widget class="GtkImage" id="image44">
272− <property name="visible">True</property>
273− <property name="stock">gtk-properties</property>
274− <property name="icon_size">1</property>
275− <property name="xalign">0.5</property>
276− <property name="yalign">0.5</property>
277− <property name="xpad">0</property>
278− <property name="ypad">0</property>
279− </widget>
280− </child>
281− </widget>
195+ </object>
282196 </child>
283197
284198 <child>
285− <widget class="GtkImageMenuItem" id="license1">
199+ <object class="GtkMenuItem" id="license1">
286200 <property name="visible">True</property>
287201 <property name="label" translatable="yes">_License</property>
288202 <property name="use_underline">True</property>
289− <signal name="activate" handler="on_license1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
290−
291− <child internal-child="image">
292− <widget class="GtkImage" id="image45">
293− <property name="visible">True</property>
294− <property name="stock">gtk-justify-fill</property>
295− <property name="icon_size">1</property>
296− <property name="xalign">0.5</property>
297− <property name="yalign">0.5</property>
298− <property name="xpad">0</property>
299− <property name="ypad">0</property>
300− </widget>
301− </child>
302− </widget>
203+ </object>
303204 </child>
304− </widget>
205+ </object>
305206 </child>
306− </widget>
207+ </object>
307208 </child>
308− </widget>
209+ </object>
309210 <packing>
310211 <property name="padding">0</property>
311212 <property name="expand">False</property>
@@ -314,32 +215,23 @@ · 2 unmodified lines
314215 </child>
315216
316217 <child>
317− <widget class="GtkHandleBox" id="handlebox1">
318− <property name="visible">True</property>
319− <property name="shadow_type">GTK_SHADOW_OUT</property>
320− <property name="handle_position">GTK_POS_LEFT</property>
321− <property name="snap_edge">GTK_POS_TOP</property>
322−
323− <child>
324− <widget class="GtkToolbar" id="toolbar1">
218+ <object class="GtkToolbar" id="toolbar1">
325219 <property name="visible">True</property>
326220 <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
327221 <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
328− <property name="tooltips">True</property>
329222 <property name="show_arrow">True</property>
330223
331224 <child>
332− <widget class="GtkToolButton" id="button1">
225+ <object class="GtkToolButton" id="button1">
333226 <property name="visible">True</property>
334− <property name="tooltip" translatable="yes">Goes up of one level (single view)</property>
227+ <property name="tooltip-text" translatable="yes">Goes up one level (single view)</property>
335228 <property name="label" translatable="yes">Back</property>
336229 <property name="use_underline">True</property>
337230 <property name="stock_id">gtk-undo</property>
338231 <property name="visible_horizontal">True</property>
339232 <property name="visible_vertical">True</property>
340233 <property name="is_important">False</property>
341− <signal name="clicked" handler="on_back_clicked"/>
342− </widget>
234+ </object>
343235 <packing>
344236 <property name="expand">False</property>
345237 <property name="homogeneous">True</property>
@@ -347,18 +239,18 @@ · 1 unmodified line
347239 </child>
348240
349241 <child>
350− <widget class="GtkToolItem" id="toolitem1">
242+ <object class="GtkToolItem" id="toolitem1">
351243 <property name="visible">True</property>
352244 <property name="visible_horizontal">True</property>
353245 <property name="visible_vertical">True</property>
354246 <property name="is_important">False</property>
355247
356248 <child>
357− <widget class="GtkVSeparator" id="vseparator1">
249+ <object class="GtkVSeparator" id="vseparator1">
358250 <property name="visible">True</property>
359− </widget>
251+ </object>
360252 </child>
361− </widget>
253+ </object>
362254 <packing>
363255 <property name="expand">False</property>
364256 <property name="homogeneous">False</property>
@@ -366,17 +258,16 @@ · 1 unmodified line
366258 </child>
367259
368260 <child>
369− <widget class="GtkToolButton" id="button2">
261+ <object class="GtkToolButton" id="button2">
370262 <property name="visible">True</property>
371− <property name="tooltip" translatable="yes">Load a config file</property>
263+ <property name="tooltip-text" translatable="yes">Load a config file</property>
372264 <property name="label" translatable="yes">Load</property>
373265 <property name="use_underline">True</property>
374266 <property name="stock_id">gtk-open</property>
375267 <property name="visible_horizontal">True</property>
376268 <property name="visible_vertical">True</property>
377269 <property name="is_important">False</property>
378− <signal name="clicked" handler="on_load_clicked"/>
379− </widget>
270+ </object>
380271 <packing>
381272 <property name="expand">False</property>
382273 <property name="homogeneous">True</property>
@@ -384,17 +275,16 @@ · 1 unmodified line
384275 </child>
385276
386277 <child>
387− <widget class="GtkToolButton" id="button3">
278+ <object class="GtkToolButton" id="button3">
388279 <property name="visible">True</property>
389− <property name="tooltip" translatable="yes">Save a config file</property>
280+ <property name="tooltip-text" translatable="yes">Save a config file</property>
390281 <property name="label" translatable="yes">Save</property>
391282 <property name="use_underline">True</property>
392283 <property name="stock_id">gtk-save</property>
393284 <property name="visible_horizontal">True</property>
394285 <property name="visible_vertical">True</property>
395286 <property name="is_important">False</property>
396− <signal name="clicked" handler="on_save_activate"/>
397− </widget>
287+ </object>
398288 <packing>
399289 <property name="expand">False</property>
400290 <property name="homogeneous">True</property>
@@ -402,18 +292,18 @@ · 1 unmodified line
402292 </child>
403293
404294 <child>
405− <widget class="GtkToolItem" id="toolitem2">
295+ <object class="GtkToolItem" id="toolitem2">
406296 <property name="visible">True</property>
407297 <property name="visible_horizontal">True</property>
408298 <property name="visible_vertical">True</property>
409299 <property name="is_important">False</property>
410300
411301 <child>
412− <widget class="GtkVSeparator" id="vseparator2">
302+ <object class="GtkVSeparator" id="vseparator2">
413303 <property name="visible">True</property>
414− </widget>
304+ </object>
415305 </child>
416− </widget>
306+ </object>
417307 <packing>
418308 <property name="expand">False</property>
419309 <property name="homogeneous">False</property>
@@ -421,17 +311,16 @@ · 1 unmodified line
421311 </child>
422312
423313 <child>
424− <widget class="GtkToolButton" id="button4">
314+ <object class="GtkToolButton" id="button4">
425315 <property name="visible">True</property>
426− <property name="tooltip" translatable="yes">Single view</property>
316+ <property name="tooltip-text" translatable="yes">Single view</property>
427317 <property name="label" translatable="yes">Single</property>
428318 <property name="use_underline">True</property>
429319 <property name="stock_id">gtk-missing-image</property>
430320 <property name="visible_horizontal">True</property>
431321 <property name="visible_vertical">True</property>
432322 <property name="is_important">False</property>
433− <signal name="clicked" handler="on_single_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:39 GMT"/>
434− </widget>
323+ </object>
435324 <packing>
436325 <property name="expand">False</property>
437326 <property name="homogeneous">True</property>
@@ -439,17 +328,16 @@ · 1 unmodified line
439328 </child>
440329
441330 <child>
442− <widget class="GtkToolButton" id="button5">
331+ <object class="GtkToolButton" id="button5">
443332 <property name="visible">True</property>
444− <property name="tooltip" translatable="yes">Split view</property>
333+ <property name="tooltip-text" translatable="yes">Split view</property>
445334 <property name="label" translatable="yes">Split</property>
446335 <property name="use_underline">True</property>
447336 <property name="stock_id">gtk-missing-image</property>
448337 <property name="visible_horizontal">True</property>
449338 <property name="visible_vertical">True</property>
450339 <property name="is_important">False</property>
451− <signal name="clicked" handler="on_split_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:45 GMT"/>
452− </widget>
340+ </object>
453341 <packing>
454342 <property name="expand">False</property>
455343 <property name="homogeneous">True</property>
@@ -457,17 +345,16 @@ · 1 unmodified line
457345 </child>
458346
459347 <child>
460− <widget class="GtkToolButton" id="button6">
348+ <object class="GtkToolButton" id="button6">
461349 <property name="visible">True</property>
462− <property name="tooltip" translatable="yes">Full view</property>
350+ <property name="tooltip-text" translatable="yes">Full view</property>
463351 <property name="label" translatable="yes">Full</property>
464352 <property name="use_underline">True</property>
465353 <property name="stock_id">gtk-missing-image</property>
466354 <property name="visible_horizontal">True</property>
467355 <property name="visible_vertical">True</property>
468356 <property name="is_important">False</property>
469− <signal name="clicked" handler="on_full_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:50 GMT"/>
470− </widget>
357+ </object>
471358 <packing>
472359 <property name="expand">False</property>
473360 <property name="homogeneous">True</property>
@@ -475,18 +362,18 @@ · 1 unmodified line
475362 </child>
476363
477364 <child>
478− <widget class="GtkToolItem" id="toolitem3">
365+ <object class="GtkToolItem" id="toolitem3">
479366 <property name="visible">True</property>
480367 <property name="visible_horizontal">True</property>
481368 <property name="visible_vertical">True</property>
482369 <property name="is_important">False</property>
483370
484371 <child>
485− <widget class="GtkVSeparator" id="vseparator3">
372+ <object class="GtkVSeparator" id="vseparator3">
486373 <property name="visible">True</property>
487− </widget>
374+ </object>
488375 </child>
489− </widget>
376+ </object>
490377 <packing>
491378 <property name="expand">False</property>
492379 <property name="homogeneous">False</property>
@@ -494,17 +381,16 @@ · 1 unmodified line
494381 </child>
495382
496383 <child>
497− <widget class="GtkToolButton" id="button7">
384+ <object class="GtkToolButton" id="button7">
498385 <property name="visible">True</property>
499− <property name="tooltip" translatable="yes">Collapse the whole tree in the right frame</property>
386+ <property name="tooltip-text" translatable="yes">Collapse the whole tree in the right frame</property>
500387 <property name="label" translatable="yes">Collapse</property>
501388 <property name="use_underline">True</property>
502389 <property name="stock_id">gtk-remove</property>
503390 <property name="visible_horizontal">True</property>
504391 <property name="visible_vertical">True</property>
505392 <property name="is_important">False</property>
506− <signal name="clicked" handler="on_collapse_clicked"/>
507− </widget>
393+ </object>
508394 <packing>
509395 <property name="expand">False</property>
510396 <property name="homogeneous">True</property>
@@ -512,25 +398,22 @@ · 1 unmodified line
512398 </child>
513399
514400 <child>
515− <widget class="GtkToolButton" id="button8">
401+ <object class="GtkToolButton" id="button8">
516402 <property name="visible">True</property>
517− <property name="tooltip" translatable="yes">Expand the whole tree in the right frame</property>
403+ <property name="tooltip-text" translatable="yes">Expand the whole tree in the right frame</property>
518404 <property name="label" translatable="yes">Expand</property>
519405 <property name="use_underline">True</property>
520406 <property name="stock_id">gtk-add</property>
521407 <property name="visible_horizontal">True</property>
522408 <property name="visible_vertical">True</property>
523409 <property name="is_important">False</property>
524− <signal name="clicked" handler="on_expand_clicked"/>
525− </widget>
410+ </object>
526411 <packing>
527412 <property name="expand">False</property>
528413 <property name="homogeneous">True</property>
529414 </packing>
530415 </child>
531− </widget>
532− </child>
533− </widget>
416+ </object>
534417 <packing>
535418 <property name="padding">0</property>
536419 <property name="expand">False</property>
@@ -539,14 +422,13 @@ · 2 unmodified lines
539422 </child>
540423
541424 <child>
542− <widget class="GtkHPaned" id="hpaned1">
425+ <object class="GtkPaned" id="hpaned1">
543426 <property name="width_request">1</property>
544427 <property name="visible">True</property>
545428 <property name="can_focus">True</property>
546− <property name="position">0</property>
547429
548430 <child>
549− <widget class="GtkScrolledWindow" id="scrolledwindow1">
431+ <object class="GtkScrolledWindow" id="scrolledwindow1">
550432 <property name="visible">True</property>
551433 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
552434 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
@@ -554,19 +436,16 @@ · 1 unmodified line
554436 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
555437
556438 <child>
557− <widget class="GtkTreeView" id="treeview1">
439+ <object class="GtkTreeView" id="treeview1">
558440 <property name="visible">True</property>
559441 <property name="can_focus">True</property>
560442 <property name="headers_visible">True</property>
561443 <property name="rules_hint">False</property>
562444 <property name="reorderable">False</property>
563445 <property name="enable_search">False</property>
564− <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/>
565− <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/>
566− <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/>
567− </widget>
446+ </object>
568447 </child>
569− </widget>
448+ </object>
570449 <packing>
571450 <property name="shrink">True</property>
572451 <property name="resize">False</property>
@@ -574,13 +453,13 @@ · 1 unmodified line
574453 </child>
575454
576455 <child>
577− <widget class="GtkVPaned" id="vpaned1">
456+ <object class="GtkPaned" id="vpaned1">
457+ <property name="orientation">vertical</property>
578458 <property name="visible">True</property>
579459 <property name="can_focus">True</property>
580− <property name="position">0</property>
581460
582461 <child>
583− <widget class="GtkScrolledWindow" id="scrolledwindow2">
462+ <object class="GtkScrolledWindow" id="scrolledwindow2">
584463 <property name="visible">True</property>
585464 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
586465 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
@@ -588,7 +467,7 @@ · 1 unmodified line
588467 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
589468
590469 <child>
591− <widget class="GtkTreeView" id="treeview2">
470+ <object class="GtkTreeView" id="treeview2">
592471 <property name="visible">True</property>
593472 <property name="can_focus">True</property>
594473 <property name="has_focus">True</property>
@@ -596,12 +475,9 @@ · 1 unmodified line
596475 <property name="rules_hint">False</property>
597476 <property name="reorderable">False</property>
598477 <property name="enable_search">False</property>
599− <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/>
600− <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/>
601− <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/>
602− </widget>
478+ </object>
603479 </child>
604− </widget>
480+ </object>
605481 <packing>
606482 <property name="shrink">True</property>
607483 <property name="resize">False</property>
@@ -609,7 +485,7 @@ · 1 unmodified line
609485 </child>
610486
611487 <child>
612− <widget class="GtkScrolledWindow" id="scrolledwindow3">
488+ <object class="GtkScrolledWindow" id="scrolledwindow3">
613489 <property name="visible">True</property>
614490 <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
615491 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
@@ -617,7 +493,7 @@ · 1 unmodified line
617493 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
618494
619495 <child>
620− <widget class="GtkTextView" id="textview3">
496+ <object class="GtkTextView" id="textview3">
621497 <property name="visible">True</property>
622498 <property name="can_focus">True</property>
623499 <property name="editable">False</property>
@@ -632,30 +508,29 @@ · 8 unmodified lines
632508 <property name="left_margin">0</property>
633509 <property name="right_margin">0</property>
634510 <property name="indent">0</property>
635− <property name="text" translatable="yes">Sorry, no help available for this option yet.</property>
636− </widget>
511+ </object>
637512 </child>
638− </widget>
513+ </object>
639514 <packing>
640515 <property name="shrink">True</property>
641516 <property name="resize">True</property>
642517 </packing>
643518 </child>
644− </widget>
519+ </object>
645520 <packing>
646521 <property name="shrink">True</property>
647522 <property name="resize">True</property>
648523 </packing>
649524 </child>
650− </widget>
525+ </object>
651526 <packing>
652527 <property name="padding">0</property>
653528 <property name="expand">True</property>
654529 <property name="fill">True</property>
655530 </packing>
656531 </child>
657− </widget>
532+ </object>
658533 </child>
659−</widget>
534+</object>
660535
661−</glade-interface>
536+</interface>
scripts/kconfig/lkc.h+2−0
@@ -98,9 +98,11 @@ bool menu_is_visible(struct menu *menu); · 97 unmodified lines
9898 bool menu_has_prompt(const struct menu *menu);
9999 const char *menu_get_prompt(const struct menu *menu);
100100 struct menu *menu_get_parent_menu(struct menu *menu);
101+struct menu *menu_get_menu_or_parent_menu(struct menu *menu);
101102 int get_jump_key_char(void);
102103 struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
103104 void menu_get_ext_help(struct menu *menu, struct gstr *help);
105+void menu_dump(void);
104106
105107 /* symbol.c */
106108 void sym_clear_all_valid(void);
scripts/kconfig/lxdialog/inputbox.c+4−2
@@ -39,8 +39,10 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width · 38 unmodified lines
3939
4040 if (!init)
4141 instr[0] = '\0';
42− else
43− strcpy(instr, init);
42+ else {
43+ strncpy(instr, init, sizeof(dialog_input_result) - 1);
44+ instr[sizeof(dialog_input_result) - 1] = '\0';
45+ }
4446
4547 do_resize:
4648 if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGHT_MIN))
scripts/kconfig/lxdialog/menubox.c+1−1
@@ -264,7 +264,7 @@ do_resize: · 263 unmodified lines
264264 if (key < 256 && isalpha(key))
265265 key = tolower(key);
266266
267− if (strchr("ynmh", key))
267+ if (strchr("ynmh ", key))
268268 i = max_choice;
269269 else {
270270 for (i = choice + 1; i < max_choice; i++) {
scripts/kconfig/lxdialog/util.c+1−2
@@ -345,8 +345,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) · 344 unmodified lines
345345 int prompt_len, room, wlen;
346346 char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
347347
348− strcpy(tempstr, prompt);
349−
348+ snprintf(tempstr, sizeof(tempstr), "%s", prompt);
350349 prompt_len = strlen(tempstr);
351350
352351 if (prompt_len <= width - x * 2) { /* If prompt is short */
scripts/kconfig/menu.c+94−0
@@ -575,7 +575,27 @@ const char *menu_get_prompt(const struct menu *menu) · 574 unmodified lines
575575 return NULL;
576576 }
577577
578+/**
579+ * menu_get_parent_menu - return the parent menu or NULL
580+ * @menu: pointer to the menu
581+ * return: the parent menu, or NULL if there is no parent.
582+ */
578583 struct menu *menu_get_parent_menu(struct menu *menu)
584+{
585+ for (menu = menu->parent; menu; menu = menu->parent)
586+ if (menu->type == M_MENU)
587+ return menu;
588+
589+ return NULL;
590+}
591+
592+/**
593+ * menu_get_menu_or_parent_menu - return the parent menu or the menu itself
594+ * @menu: pointer to the menu
595+ * return: the parent menu. If the given argument is already a menu, return
596+ * itself.
597+ */
598+struct menu *menu_get_menu_or_parent_menu(struct menu *menu)
579599 {
580600 enum prop_type type;
581601
@@ -768,3 +788,77 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help) · 186 unmodified lines
768788 if (sym)
769789 get_symbol_str(help, sym, NULL);
770790 }
791+
792+/**
793+ * menu_dump - dump all menu entries in a tree-like format
794+ */
795+void menu_dump(void)
796+{
797+ struct menu *menu = &rootmenu;
798+ unsigned long long bits = 0;
799+ int indent = 0;
800+
801+ while (menu) {
802+
803+ for (int i = indent - 1; i >= 0; i--) {
804+ if (bits & (1ULL << i)) {
805+ if (i > 0)
806+ printf("| ");
807+ else
808+ printf("|-- ");
809+ } else {
810+ if (i > 0)
811+ printf(" ");
812+ else
813+ printf("`-- ");
814+ }
815+ }
816+
817+ switch (menu->type) {
818+ case M_CHOICE:
819+ printf("choice \"%s\"\n", menu->prompt->text);
820+ break;
821+ case M_COMMENT:
822+ printf("comment \"%s\"\n", menu->prompt->text);
823+ break;
824+ case M_IF:
825+ printf("if\n");
826+ break;
827+ case M_MENU:
828+ printf("menu \"%s\"", menu->prompt->text);
829+ if (!menu->sym) {
830+ printf("\n");
831+ break;
832+ }
833+ printf(" + ");
834+ /* fallthrough */
835+ case M_NORMAL:
836+ printf("symbol %s\n", menu->sym->name);
837+ break;
838+ }
839+ if (menu->list) {
840+ bits <<= 1;
841+ menu = menu->list;
842+ if (menu->next)
843+ bits |= 1;
844+ else
845+ bits &= ~1;
846+ indent++;
847+ continue;
848+ }
849+
850+ while (menu && !menu->next) {
851+ menu = menu->parent;
852+ bits >>= 1;
853+ indent--;
854+ }
855+
856+ if (menu) {
857+ menu = menu->next;
858+ if (menu->next)
859+ bits |= 1;
860+ else
861+ bits &= ~1;
862+ }
863+ }
864+}
scripts/kconfig/nconf.c+2−0
@@ -593,6 +593,8 @@ static void item_add_str(const char *fmt, ...) · 592 unmodified lines
593593 tmp_str,
594594 sizeof(k_menu_items[index].str));
595595
596+ k_menu_items[index].str[sizeof(k_menu_items[index].str) - 1] = '\0';
597+
596598 free_item(curses_menu_items[index]);
597599 curses_menu_items[index] = new_item(
598600 k_menu_items[index].str,
scripts/kconfig/nconf.gui.c+1−0
@@ -359,6 +359,7 @@ int dialog_inputbox(WINDOW *main_window, · 358 unmodified lines
359359 x = (columns-win_cols)/2;
360360
361361 strncpy(result, init, *result_len);
362+ result[*result_len - 1] = '\0';
362363
363364 /* create the windows */
364365 win = newwin(win_lines, win_cols, y, x);
scripts/kconfig/qconf.cc+24−12
@@ -37,6 +37,12 @@ QAction *ConfigMainWindow::saveAction; · 36 unmodified lines
3737 ConfigSettings::ConfigSettings()
3838 : QSettings("kernel.org", "qconf")
3939 {
40+ beginGroup("/kconfig/qconf");
41+}
42+
43+ConfigSettings::~ConfigSettings()
44+{
45+ endGroup();
4046 }
4147
4248 /**
@@ -92,7 +98,6 @@ void ConfigItem::updateMenu(void) · 49 unmodified lines
9298 {
9399 ConfigList* list;
94100 struct symbol* sym;
95− struct property *prop;
96101 QString prompt;
97102 int type;
98103 tristate expr;
@@ -105,11 +110,10 @@ void ConfigItem::updateMenu(void) · 6 unmodified lines
105110 }
106111
107112 sym = menu->sym;
108− prop = menu->prompt;
109113 prompt = menu_get_prompt(menu);
110114
111− if (prop) switch (prop->type) {
112− case P_MENU:
115+ switch (menu->type) {
116+ case M_MENU:
113117 if (list->mode == singleMode) {
114118 /* a menuconfig entry is displayed differently
115119 * depending whether it's at the view root or a child.
@@ -123,10 +127,16 @@ void ConfigItem::updateMenu(void) · 7 unmodified lines
123127 setIcon(promptColIdx, QIcon());
124128 }
125129 goto set_prompt;
126− case P_COMMENT:
130+ case M_COMMENT:
127131 setIcon(promptColIdx, QIcon());
128132 prompt = "*** " + prompt + " ***";
129133 goto set_prompt;
134+ case M_CHOICE:
135+ setIcon(promptColIdx, QIcon());
136+ sym = sym_calc_choice(menu);
137+ if (sym)
138+ setText(dataColIdx, sym->name);
139+ goto set_prompt;
130140 default:
131141 ;
132142 }
@@ -188,7 +198,11 @@ void ConfigItem::testUpdateMenu(void) · 55 unmodified lines
188198 if (!menu)
189199 return;
190200
191− sym_calc_value(menu->sym);
201+ if (menu->type == M_CHOICE)
202+ sym_calc_choice(menu);
203+ else
204+ sym_calc_value(menu->sym);
205+
192206 if (menu->flags & MENU_CHANGED) {
193207 /* the menu entry changed, so update all list items */
194208 menu->flags &= ~MENU_CHANGED;
@@ -478,7 +492,7 @@ void ConfigList::updateListAllForAll() · 283 unmodified lines
478492 while (it.hasNext()) {
479493 ConfigList *list = it.next();
480494
481− list->updateList();
495+ list->updateListAll();
482496 }
483497 }
484498
@@ -569,7 +583,7 @@ void ConfigList::setParentMenu(void) · 84 unmodified lines
569583 oldroot = rootEntry;
570584 if (rootEntry == &rootmenu)
571585 return;
572− setRootMenu(menu_get_parent_menu(rootEntry->parent));
586+ setRootMenu(menu_get_menu_or_parent_menu(rootEntry->parent));
573587
574588 QTreeWidgetItemIterator it(this);
575589 while (*it) {
@@ -1532,7 +1546,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) · 956 unmodified lines
15321546 switch (configList->mode) {
15331547 case singleMode:
15341548 list = configList;
1535− parent = menu_get_parent_menu(menu);
1549+ parent = menu_get_menu_or_parent_menu(menu);
15361550 if (!parent)
15371551 return;
15381552 list->setRootMenu(parent);
@@ -1543,7 +1557,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) · 4 unmodified lines
15431557 configList->clearSelection();
15441558 list = configList;
15451559 } else {
1546− parent = menu_get_parent_menu(menu->parent);
1560+ parent = menu_get_menu_or_parent_menu(menu->parent);
15471561 if (!parent)
15481562 return;
15491563
@@ -1821,7 +1835,6 @@ int main(int ac, char** av) · 271 unmodified lines
18211835 configApp = new QApplication(ac, av);
18221836
18231837 configSettings = new ConfigSettings();
1824− configSettings->beginGroup("/kconfig/qconf");
18251838 v = new ConfigMainWindow();
18261839
18271840 //zconfdump(stdout);
@@ -1829,7 +1842,6 @@ int main(int ac, char** av) · 1 unmodified line
18291842 v->show();
18301843 configApp->exec();
18311844
1832− configSettings->endGroup();
18331845 delete configSettings;
18341846 delete v;
18351847 delete configApp;
scripts/kconfig/qconf.h+1−0
@@ -24,6 +24,7 @@ class ConfigMainWindow; · 23 unmodified lines
2424 class ConfigSettings : public QSettings {
2525 public:
2626 ConfigSettings();
27+ ~ConfigSettings(void);
2728 QList<int> readSizes(const QString& key, bool *ok);
2829 bool writeSizes(const QString& key, const QList<int>& value);
2930 };
scripts/kconfig/symbol.c+4−0
@@ -195,6 +195,10 @@ static void sym_set_changed(struct symbol *sym) · 194 unmodified lines
195195
196196 list_for_each_entry(menu, &sym->menus, link)
197197 menu->flags |= MENU_CHANGED;
198+
199+ menu = sym_get_choice_menu(sym);
200+ if (menu)
201+ menu->flags |= MENU_CHANGED;
198202 }
199203
200204 static void sym_set_all_changed(void)