* [PATCH 2/9] kconfig: Update gtk interface codebase.
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
@ 2013-07-02 15:22 ` davidgraeff
2013-07-02 15:22 ` [PATCH 3/9] kconfig: gtk interface port to Gtk3 davidgraeff
` (7 subsequent siblings)
8 siblings, 0 replies; 33+ messages in thread
From: davidgraeff @ 2013-07-02 15:22 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, davidgraeff
Use only non-deprecated functions, use accessor functions instead of
direct access. A port to gtk3 should be easy now.
---
scripts/kconfig/gconfig/Makefile | 4 +-
scripts/kconfig/gconfig/gconf.c | 177 +++++++++++++--------------------------
2 files changed, 63 insertions(+), 118 deletions(-)
diff --git a/scripts/kconfig/gconfig/Makefile b/scripts/kconfig/gconfig/Makefile
index 1ce47a6..cf0c32b 100644
--- a/scripts/kconfig/gconfig/Makefile
+++ b/scripts/kconfig/gconfig/Makefile
@@ -28,7 +28,9 @@ clean-files += zconf.tab.c gconfig/gconf.glade.h gconf
HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
- -Wno-missing-prototypes
+ -Wno-missing-prototypes -DGTK_DISABLE_SINGLE_INCLUDES \
+ -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
+ -DGSEAL_ENABLE
$(obj)/gconfig/gconf.o: $(obj)/gconfig/.tmp_gtkcheck
diff --git a/scripts/kconfig/gconfig/gconf.c b/scripts/kconfig/gconfig/gconf.c
index aab4abf..36bad03 100644
--- a/scripts/kconfig/gconfig/gconf.c
+++ b/scripts/kconfig/gconfig/gconf.c
@@ -17,6 +17,7 @@
#include <glade/glade.h>
#include <gtk/gtk.h>
#include <glib.h>
+#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <stdio.h>
@@ -109,20 +110,17 @@ const char *dbg_sym_flags(int val)
return buf;
}
-void replace_button_icon(GladeXML * xml, GdkDrawable * window,
- GtkStyle * style, gchar * btn_name, gchar ** xpm)
+void replace_button_icon(GladeXML * xml,
+ gchar * btn_name, const char ** xpm)
{
- GdkPixmap *pixmap;
- GdkBitmap *mask;
+ GdkPixbuf * pixmap;
GtkToolButton *button;
GtkWidget *image;
- pixmap = gdk_pixmap_create_from_xpm_d(window, &mask,
- &style->bg[GTK_STATE_NORMAL],
- xpm);
+ pixmap = gdk_pixbuf_new_from_xpm_data(xpm);
button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name));
- image = gtk_image_new_from_pixmap(pixmap, mask);
+ image = gtk_image_new_from_pixbuf(pixmap);
gtk_widget_show(image);
gtk_tool_button_set_icon_widget(button, image);
}
@@ -133,7 +131,6 @@ void init_main_window(const gchar * glade_file)
GladeXML *xml;
GtkWidget *widget;
GtkTextBuffer *txtbuf;
- GtkStyle *style;
xml = glade_xml_new(glade_file, "window1", NULL);
if (!xml)
@@ -166,40 +163,12 @@ void init_main_window(const gchar * glade_file)
save_menu_item = glade_xml_get_widget(xml, "save1");
conf_set_changed_callback(conf_changed);
- style = gtk_widget_get_style(main_wnd);
widget = glade_xml_get_widget(xml, "toolbar1");
-#if 0 /* Use stock Gtk icons instead */
- replace_button_icon(xml, main_wnd->window, style,
- "button1", (gchar **) xpm_back);
- replace_button_icon(xml, main_wnd->window, style,
- "button2", (gchar **) xpm_load);
- replace_button_icon(xml, main_wnd->window, style,
- "button3", (gchar **) xpm_save);
-#endif
- replace_button_icon(xml, main_wnd->window, style,
- "button4", (gchar **) xpm_single_view);
- replace_button_icon(xml, main_wnd->window, style,
- "button5", (gchar **) xpm_split_view);
- replace_button_icon(xml, main_wnd->window, style,
- "button6", (gchar **) xpm_tree_view);
-
-#if 0
- switch (view_mode) {
- case SINGLE_VIEW:
- widget = glade_xml_get_widget(xml, "button4");
- g_signal_emit_by_name(widget, "clicked");
- break;
- case SPLIT_VIEW:
- widget = glade_xml_get_widget(xml, "button5");
- g_signal_emit_by_name(widget, "clicked");
- break;
- case FULL_VIEW:
- widget = glade_xml_get_widget(xml, "button6");
- g_signal_emit_by_name(widget, "clicked");
- break;
- }
-#endif
+ replace_button_icon(xml, "button4", xpm_single_view);
+ replace_button_icon(xml, "button5", xpm_split_view);
+ replace_button_icon(xml, "button6", xpm_tree_view);
+
txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
"foreground", "red",
@@ -436,7 +405,6 @@ static void text_insert_msg(const char *title, const char *message)
/* Main Windows Callbacks */
-void on_save_activate(GtkMenuItem * menuitem, gpointer user_data);
gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
gpointer user_data)
{
@@ -461,13 +429,14 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
GTK_RESPONSE_CANCEL);
label = gtk_label_new(_("\nSave configuration ?\n"));
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label);
gtk_widget_show(label);
result = gtk_dialog_run(GTK_DIALOG(dialog));
switch (result) {
case GTK_RESPONSE_YES:
- on_save_activate(NULL, NULL);
+ if (conf_write(NULL))
+ text_insert_msg(_("Error"), _("Unable to save configuration !"));
return FALSE;
case GTK_RESPONSE_NO:
return FALSE;
@@ -493,12 +462,15 @@ on_window1_size_request(GtkWidget * widget,
GtkRequisition * requisition, gpointer user_data)
{
static gint old_h;
- gint w, h;
+ int w, h;
+ GdkWindow * window = gtk_widget_get_window(widget);
- if (widget->window == NULL)
+ if (window == NULL)
gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
- else
- gdk_window_get_size(widget->window, &w, &h);
+ else {
+ w = gdk_window_get_width(window);
+ h = gdk_window_get_height(window);
+ }
if (h == old_h)
return;
@@ -510,79 +482,50 @@ on_window1_size_request(GtkWidget * widget,
/* Menu & Toolbar Callbacks */
-
-static void
-load_filename(GtkFileSelection * file_selector, gpointer user_data)
-{
- const gchar *fn;
-
- fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
- (user_data));
-
- if (conf_read(fn))
- text_insert_msg(_("Error"), _("Unable to load configuration !"));
- else
- display_tree(&rootmenu);
-}
-
void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
- GtkWidget *fs;
-
- fs = gtk_file_selection_new(_("Load file..."));
- g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
- "clicked",
- G_CALLBACK(load_filename), (gpointer) fs);
- g_signal_connect_swapped(GTK_OBJECT
- (GTK_FILE_SELECTION(fs)->ok_button),
- "clicked", G_CALLBACK(gtk_widget_destroy),
- (gpointer) fs);
- g_signal_connect_swapped(GTK_OBJECT
- (GTK_FILE_SELECTION(fs)->cancel_button),
- "clicked", G_CALLBACK(gtk_widget_destroy),
- (gpointer) fs);
- gtk_widget_show(fs);
-}
-
-
-void on_save_activate(GtkMenuItem * menuitem, gpointer user_data)
-{
- if (conf_write(NULL))
- text_insert_msg(_("Error"), _("Unable to save configuration !"));
+ GtkWidget *dialog;
+ dialog = gtk_file_chooser_dialog_new (_("Load file..."),
+ GTK_WINDOW(main_wnd),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ char *filename;
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ if (conf_read(filename))
+ text_insert_msg(_("Error"), _("Unable to load configuration !"));
+ else
+ display_tree(&rootmenu);
+ g_free (filename);
+ }
+ gtk_widget_destroy (dialog);
}
-static void
-store_filename(GtkFileSelection * file_selector, gpointer user_data)
-{
- const gchar *fn;
-
- fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
- (user_data));
-
- if (conf_write(fn))
- text_insert_msg(_("Error"), _("Unable to save configuration !"));
-
- gtk_widget_destroy(GTK_WIDGET(user_data));
-}
-
void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
- GtkWidget *fs;
-
- fs = gtk_file_selection_new(_("Save file as..."));
- g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
- "clicked",
- G_CALLBACK(store_filename), (gpointer) fs);
- g_signal_connect_swapped(GTK_OBJECT
- (GTK_FILE_SELECTION(fs)->ok_button),
- "clicked", G_CALLBACK(gtk_widget_destroy),
- (gpointer) fs);
- g_signal_connect_swapped(GTK_OBJECT
- (GTK_FILE_SELECTION(fs)->cancel_button),
- "clicked", G_CALLBACK(gtk_widget_destroy),
- (gpointer) fs);
- gtk_widget_show(fs);
+ GtkWidget *dialog;
+
+ dialog = gtk_file_chooser_dialog_new (_("Save File as..."),
+ GTK_WINDOW(main_wnd),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ char *filename;
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ if (conf_write(filename))
+ text_insert_msg(_("Error"), _("Unable to save configuration !"));
+ g_free (filename);
+ }
+ gtk_widget_destroy (dialog);
}
@@ -597,7 +540,7 @@ void on_show_name1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkTreeViewColumn *col;
- show_name = GTK_CHECK_MENU_ITEM(menuitem)->active;
+ show_name = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NAME);
if (col)
gtk_tree_view_column_set_visible(col, show_name);
@@ -608,7 +551,7 @@ void on_show_range1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkTreeViewColumn *col;
- show_range = GTK_CHECK_MENU_ITEM(menuitem)->active;
+ show_range = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NO);
if (col)
gtk_tree_view_column_set_visible(col, show_range);
@@ -626,7 +569,7 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkTreeViewColumn *col;
- show_value = GTK_CHECK_MENU_ITEM(menuitem)->active;
+ show_value = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_VALUE);
if (col)
gtk_tree_view_column_set_visible(col, show_value);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH 3/9] kconfig: gtk interface port to Gtk3
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
2013-07-02 15:22 ` [PATCH 2/9] kconfig: Update gtk interface codebase davidgraeff
@ 2013-07-02 15:22 ` davidgraeff
2013-07-02 15:22 ` [PATCH 4/9] kconfig: gtk interface: fix splitview, split code into two files davidgraeff
` (6 subsequent siblings)
8 siblings, 0 replies; 33+ messages in thread
From: davidgraeff @ 2013-07-02 15:22 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, davidgraeff
libglade is deprecated: use GtkBuilder and ui files instead.
Remove some global variables.
Use new gtk signals.
---
scripts/kconfig/POTFILES.in | 2 +-
scripts/kconfig/gconfig/Makefile | 14 +-
scripts/kconfig/gconfig/gconf.c | 416 +++++++++++------------
scripts/kconfig/gconfig/gconf.glade | 661 ------------------------------------
scripts/kconfig/gconfig/gconf.ui | 534 +++++++++++++++++++++++++++++
5 files changed, 741 insertions(+), 886 deletions(-)
delete mode 100644 scripts/kconfig/gconfig/gconf.glade
create mode 100644 scripts/kconfig/gconfig/gconf.ui
diff --git a/scripts/kconfig/POTFILES.in b/scripts/kconfig/POTFILES.in
index 4984825..2e44446 100644
--- a/scripts/kconfig/POTFILES.in
+++ b/scripts/kconfig/POTFILES.in
@@ -6,7 +6,7 @@ scripts/kconfig/lxdialog/util.c
scripts/kconfig/lxdialog/yesno.c
scripts/kconfig/lxdialog/mconf.c
scripts/kconfig/gkonfig/gconf.c
-scripts/kconfig/gkonfig/gconf.glade.h
+[type: gettext/glade]scripts/kconfig/gkonfig/gconf.ui
scripts/kconfig/qconfig/qconf.cc
scripts/kconfig/conf.c
scripts/kconfig/confdata.c
diff --git a/scripts/kconfig/gconfig/Makefile b/scripts/kconfig/gconfig/Makefile
index cf0c32b..282c500 100644
--- a/scripts/kconfig/gconfig/Makefile
+++ b/scripts/kconfig/gconfig/Makefile
@@ -26,8 +26,8 @@ endif
clean-files += zconf.tab.c gconfig/gconf.glade.h gconf
-HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
-HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
+HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-3.0 gmodule-2.0`
+HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-3.0 gmodule-2.0` \
-Wno-missing-prototypes -DGTK_DISABLE_SINGLE_INCLUDES \
-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
-DGSEAL_ENABLE
@@ -39,20 +39,20 @@ ifeq ($(gconf-target),1)
# GTK needs some extra effort, too...
$(obj)/gconfig/.tmp_gtkcheck:
- @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
- if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
+ @if `pkg-config --exists gtk+-3.0`; then \
+ if `pkg-config --atleast-version=3.0.0 gtk+-3.0`; then \
touch $@; \
else \
echo >&2 "*"; \
- echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
+ echo >&2 "* GTK+ is present but version >= 3.0.0 is required."; \
echo >&2 "*"; \
false; \
fi \
else \
echo >&2 "*"; \
echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
- echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
- echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
+ echo >&2 "* the GTK+ 3.0 development package is correctly installed..."; \
+ echo >&2 "* You need gtk+-3.0 and glib-2.0."; \
echo >&2 "*"; \
false; \
fi
diff --git a/scripts/kconfig/gconfig/gconf.c b/scripts/kconfig/gconfig/gconf.c
index 36bad03..5eb765c 100644
--- a/scripts/kconfig/gconfig/gconf.c
+++ b/scripts/kconfig/gconfig/gconf.c
@@ -11,19 +11,18 @@
#endif
#include <stdlib.h>
-#include "../lkc.h"
-#include "../images.c"
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
-#include <glade/glade.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
+#include "../lkc.h"
+#include "../images.c"
//#define DEBUG
@@ -55,8 +54,6 @@ GtkWidget *save_menu_item = NULL;
GtkTextTag *tag1, *tag2;
GdkColor color;
-GtkTreeStore *tree1, *tree2, *tree;
-GtkTreeModel *model1, *model2;
static GtkTreeIter *parents[256];
static gint indent;
@@ -71,10 +68,10 @@ enum {
};
static void display_list(void);
-static void display_tree(struct menu *menu);
+static void display_tree(struct menu *menu, GtkTreeStore* tree);
static void display_tree_part(void);
-static void update_tree(struct menu *src, GtkTreeIter * dst);
-static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row);
+static void update_tree(struct menu *src, GtkTreeIter * dst, GtkTreeStore* tree);
+static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row, GtkTreeStore* tree);
static gchar **fill_row(struct menu *menu);
static void conf_changed(void);
@@ -110,7 +107,7 @@ const char *dbg_sym_flags(int val)
return buf;
}
-void replace_button_icon(GladeXML * xml,
+void replace_button_icon(GtkBuilder * builder,
gchar * btn_name, const char ** xpm)
{
GdkPixbuf * pixmap;
@@ -119,55 +116,58 @@ void replace_button_icon(GladeXML * xml,
pixmap = gdk_pixbuf_new_from_xpm_data(xpm);
- button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name));
+ button = GTK_TOOL_BUTTON(gtk_builder_get_object(builder, btn_name));
image = gtk_image_new_from_pixbuf(pixmap);
gtk_widget_show(image);
gtk_tool_button_set_icon_widget(button, image);
}
/* Main Window Initialization */
-void init_main_window(const gchar * glade_file)
+void init_main_window(const gchar * ui_file)
{
- GladeXML *xml;
+ GtkBuilder *builder;
GtkWidget *widget;
GtkTextBuffer *txtbuf;
- xml = glade_xml_new(glade_file, "window1", NULL);
- if (!xml)
+ builder = gtk_builder_new();
+ int result = gtk_builder_add_from_file(builder, ui_file, NULL);
+ if (!result)
g_error(_("GUI loading failed !\n"));
- glade_xml_signal_autoconnect(xml);
+ gtk_builder_connect_signals (builder, NULL);
- main_wnd = glade_xml_get_widget(xml, "window1");
- hpaned = glade_xml_get_widget(xml, "hpaned1");
- vpaned = glade_xml_get_widget(xml, "vpaned1");
- tree1_w = glade_xml_get_widget(xml, "treeview1");
- tree2_w = glade_xml_get_widget(xml, "treeview2");
- text_w = glade_xml_get_widget(xml, "textview3");
+ main_wnd = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
+ hpaned = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned1"));
+ vpaned = GTK_WIDGET(gtk_builder_get_object(builder, "vpaned1"));
+ tree1_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview1"));
+ tree2_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview2"));
+ text_w = GTK_WIDGET(gtk_builder_get_object(builder, "textview3"));
- back_btn = glade_xml_get_widget(xml, "button1");
+ back_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button1"));
gtk_widget_set_sensitive(back_btn, FALSE);
- widget = glade_xml_get_widget(xml, "show_name1");
+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_name1"));
gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
show_name);
- widget = glade_xml_get_widget(xml, "show_range1");
+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_range1"));
gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
show_range);
- widget = glade_xml_get_widget(xml, "show_data1");
+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_data1"));
gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
show_value);
- save_btn = glade_xml_get_widget(xml, "button3");
- save_menu_item = glade_xml_get_widget(xml, "save1");
+ save_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button3"));
+ save_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "save1"));
conf_set_changed_callback(conf_changed);
- widget = glade_xml_get_widget(xml, "toolbar1");
+ widget = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar1"));
- replace_button_icon(xml, "button4", xpm_single_view);
- replace_button_icon(xml, "button5", xpm_split_view);
- replace_button_icon(xml, "button6", xpm_tree_view);
+ replace_button_icon(builder, "button4", xpm_single_view);
+ replace_button_icon(builder, "button5", xpm_split_view);
+ replace_button_icon(builder, "button6", xpm_tree_view);
+
+ g_object_unref (G_OBJECT (builder));
txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
@@ -183,34 +183,44 @@ void init_main_window(const gchar * glade_file)
gtk_widget_show(main_wnd);
}
-void init_tree_model(void)
+/**
+ * Called by main() and load..(). Display data depending on the view mode
+ * and changes the layout.
+ */
+void show_data(void)
{
- gint i;
-
- tree = tree2 = gtk_tree_store_new(COL_NUMBER,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER, GDK_TYPE_COLOR,
- G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN);
- model2 = GTK_TREE_MODEL(tree2);
-
- for (parents[0] = NULL, i = 1; i < 256; i++)
- parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter));
+ switch (view_mode) {
+ case SINGLE_VIEW:
+ gtk_widget_hide(tree1_w);
+ current = &rootmenu;
+ display_tree_part();
+ break;
+ case SPLIT_VIEW:
+ {
+ gtk_widget_show(tree1_w);
+ gint w, h;
+ gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
+ gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
+ // Clear right frame, the user has to choose a subtree first
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ gtk_tree_store_clear(tree2);
+ // Display tree in left frame
+ display_list();
- tree1 = gtk_tree_store_new(COL_NUMBER,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER, GDK_TYPE_COLOR,
- G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN);
- model1 = GTK_TREE_MODEL(tree1);
+ /* Disable back btn, like in full mode. */
+ gtk_widget_set_sensitive(back_btn, FALSE);
+ break;
+ }
+ case FULL_VIEW:
+ {
+ gtk_widget_hide(tree1_w);
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ gtk_tree_store_clear(tree2);
+ display_tree(&rootmenu, tree2);
+ gtk_widget_set_sensitive(back_btn, FALSE);
+ break;
+ }
+ }
}
void init_left_tree(void)
@@ -220,6 +230,19 @@ void init_left_tree(void)
GtkTreeSelection *sel;
GtkTreeViewColumn *column;
+ GtkTreeStore *tree1;
+ GtkTreeModel *model1;
+ tree1 = gtk_tree_store_new(COL_NUMBER,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_POINTER, GDK_TYPE_COLOR,
+ G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN);
+ model1 = GTK_TREE_MODEL(tree1);
+
gtk_tree_view_set_model(view, model1);
gtk_tree_view_set_headers_visible(view, TRUE);
gtk_tree_view_set_rules_hint(view, TRUE);
@@ -262,6 +285,19 @@ void init_right_tree(void)
GtkTreeSelection *sel;
GtkTreeViewColumn *column;
gint i;
+
+ GtkTreeStore *tree2;
+ GtkTreeModel *model2;
+ tree2 = gtk_tree_store_new(COL_NUMBER,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_POINTER, GDK_TYPE_COLOR,
+ G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN);
+ model2 = GTK_TREE_MODEL(tree2);
gtk_tree_view_set_model(view, model2);
gtk_tree_view_set_headers_visible(view, TRUE);
@@ -436,7 +472,7 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
switch (result) {
case GTK_RESPONSE_YES:
if (conf_write(NULL))
- text_insert_msg(_("Error"), _("Unable to save configuration !"));
+ text_insert_msg(_("Error"), _("Unable to save configuration on exit!"));
return FALSE;
case GTK_RESPONSE_NO:
return FALSE;
@@ -451,35 +487,12 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
}
-void on_window1_destroy(GtkObject * object, gpointer user_data)
+void on_window1_destroy(GObject * object, gpointer user_data)
{
gtk_main_quit();
}
-void
-on_window1_size_request(GtkWidget * widget,
- GtkRequisition * requisition, gpointer user_data)
-{
- static gint old_h;
- int w, h;
- GdkWindow * window = gtk_widget_get_window(widget);
-
- if (window == NULL)
- gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
- else {
- w = gdk_window_get_width(window);
- h = gdk_window_get_height(window);
- }
-
- if (h == old_h)
- return;
- old_h = h;
-
- gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
-}
-
-
/* Menu & Toolbar Callbacks */
void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
@@ -498,12 +511,17 @@ void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
if (conf_read(filename))
text_insert_msg(_("Error"), _("Unable to load configuration !"));
else
- display_tree(&rootmenu);
+ show_data();
g_free (filename);
}
gtk_widget_destroy (dialog);
}
+void on_save_activate(GtkMenuItem * menuitem, gpointer user_data)
+{
+ if (conf_write(NULL))
+ text_insert_msg(_("Error"), _("Unable to save configuration !"));
+}
void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
@@ -580,8 +598,9 @@ void
on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
opt_mode = OPT_NORMAL;
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
gtk_tree_store_clear(tree2);
- display_tree(&rootmenu); /* instead of update_tree to speed-up */
+ display_tree(&rootmenu, tree2); /* instead of update_tree to speed-up */
}
@@ -589,8 +608,9 @@ void
on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
{
opt_mode = OPT_ALL;
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
gtk_tree_store_clear(tree2);
- display_tree(&rootmenu); /* instead of update_tree to speed-up */
+ display_tree(&rootmenu, tree2); /* instead of update_tree to speed-up */
}
@@ -598,8 +618,9 @@ void
on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
{
opt_mode = OPT_PROMPT;
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
gtk_tree_store_clear(tree2);
- display_tree(&rootmenu); /* instead of update_tree to speed-up */
+ display_tree(&rootmenu, tree2); /* instead of update_tree to speed-up */
}
@@ -627,9 +648,9 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE, "%s", intro_text);
- g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
+ g_signal_connect(dialog, "response",
G_CALLBACK(gtk_widget_destroy),
- GTK_OBJECT(dialog));
+ dialog);
gtk_widget_show_all(dialog);
}
@@ -638,16 +659,17 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkWidget *dialog;
const gchar *about_text =
- _("gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
+ _("Updated to gtk3, copyright (c) 2013 David Gräff <david.graeff@udo.edu>.\n"
+ "gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
"Based on the source code from Roman Zippel.\n");
dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE, "%s", about_text);
- g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
+ g_signal_connect(dialog, "response",
G_CALLBACK(gtk_widget_destroy),
- GTK_OBJECT(dialog));
+ dialog);
gtk_widget_show_all(dialog);
}
@@ -664,9 +686,9 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE, "%s", license_text);
- g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
+ g_signal_connect(dialog, "response",
G_CALLBACK(gtk_widget_destroy),
- GTK_OBJECT(dialog));
+ dialog);
gtk_widget_show_all(dialog);
}
@@ -695,36 +717,21 @@ void on_load_clicked(GtkButton * button, gpointer user_data)
void on_single_clicked(GtkButton * button, gpointer user_data)
{
view_mode = SINGLE_VIEW;
- gtk_widget_hide(tree1_w);
- current = &rootmenu;
- display_tree_part();
+ show_data();
}
void on_split_clicked(GtkButton * button, gpointer user_data)
{
- gint w, h;
view_mode = SPLIT_VIEW;
- gtk_widget_show(tree1_w);
- gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
- gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
- if (tree2)
- gtk_tree_store_clear(tree2);
- display_list();
-
- /* Disable back btn, like in full mode. */
- gtk_widget_set_sensitive(back_btn, FALSE);
+ show_data();
}
void on_full_clicked(GtkButton * button, gpointer user_data)
{
view_mode = FULL_VIEW;
- gtk_widget_hide(tree1_w);
- if (tree2)
- gtk_tree_store_clear(tree2);
- display_tree(&rootmenu);
- gtk_widget_set_sensitive(back_btn, FALSE);
+ show_data();
}
@@ -752,6 +759,9 @@ static void renderer_edited(GtkCellRendererText * cell,
const char *old_def, *new_def;
struct menu *menu;
struct symbol *sym;
+
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
+ GtkTreeStore* tree2 = GTK_TREE_STORE(model2);
if (!gtk_tree_model_get_iter(model2, &iter, path))
return;
@@ -764,13 +774,13 @@ static void renderer_edited(GtkCellRendererText * cell,
sym_set_string_value(sym, new_def);
- update_tree(&rootmenu, NULL);
+ update_tree(&rootmenu, NULL, tree2);
gtk_tree_path_free(path);
}
/* Change the value of a symbol and update the tree */
-static void change_sym_value(struct menu *menu, gint col)
+static void change_sym_value(struct menu *menu, gint col, GtkTreeStore* tree)
{
struct symbol *sym = menu->sym;
tristate newval;
@@ -794,9 +804,9 @@ static void change_sym_value(struct menu *menu, gint col)
newval = yes;
sym_set_tristate_value(sym, newval);
if (view_mode == FULL_VIEW)
- update_tree(&rootmenu, NULL);
+ update_tree(&rootmenu, NULL, tree);
else if (view_mode == SPLIT_VIEW) {
- update_tree(browsed, NULL);
+ update_tree(browsed, NULL, tree);
display_list();
}
else if (view_mode == SINGLE_VIEW)
@@ -810,16 +820,16 @@ static void change_sym_value(struct menu *menu, gint col)
}
}
-static void toggle_sym_value(struct menu *menu)
+static void toggle_sym_value(struct menu *menu, GtkTreeStore* tree)
{
if (!menu->sym)
return;
sym_toggle_tristate_value(menu->sym);
if (view_mode == FULL_VIEW)
- update_tree(&rootmenu, NULL);
+ update_tree(&rootmenu, NULL, tree);
else if (view_mode == SPLIT_VIEW) {
- update_tree(browsed, NULL);
+ update_tree(browsed, NULL, tree);
display_list();
}
else if (view_mode == SINGLE_VIEW)
@@ -848,22 +858,16 @@ on_treeview2_button_press_event(GtkWidget * widget,
GdkEventButton * event, gpointer user_data)
{
GtkTreeView *view = GTK_TREE_VIEW(widget);
+ GtkTreeModel* model2 = gtk_tree_view_get_model(view);
+ GtkTreeStore* tree2 = GTK_TREE_STORE(model2);
GtkTreePath *path;
GtkTreeViewColumn *column;
GtkTreeIter iter;
struct menu *menu;
gint col;
+
-#if GTK_CHECK_VERSION(2,1,4) // bug in ctree with earlier version of GTK
- gint tx = (gint) event->x;
- gint ty = (gint) event->y;
- gint cx, cy;
-
- gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
- &cy);
-#else
gtk_tree_view_get_cursor(view, &path, &column);
-#endif
if (path == NULL)
return FALSE;
@@ -882,16 +886,16 @@ on_treeview2_button_press_event(GtkWidget * widget,
display_tree_part();
gtk_widget_set_sensitive(back_btn, TRUE);
} else if ((col == COL_OPTION)) {
- toggle_sym_value(menu);
+ toggle_sym_value(menu, tree2);
gtk_tree_view_expand_row(view, path, TRUE);
}
} else {
if (col == COL_VALUE) {
- toggle_sym_value(menu);
+ toggle_sym_value(menu, tree2);
gtk_tree_view_expand_row(view, path, TRUE);
} else if (col == COL_NO || col == COL_MOD
|| col == COL_YES) {
- change_sym_value(menu, col);
+ change_sym_value(menu, col, tree2);
gtk_tree_view_expand_row(view, path, TRUE);
}
}
@@ -905,6 +909,8 @@ on_treeview2_key_press_event(GtkWidget * widget,
GdkEventKey * event, gpointer user_data)
{
GtkTreeView *view = GTK_TREE_VIEW(widget);
+ GtkTreeModel* model2 = gtk_tree_view_get_model(view);
+ GtkTreeStore* tree2 = GTK_TREE_STORE(model2);
GtkTreePath *path;
GtkTreeViewColumn *column;
GtkTreeIter iter;
@@ -915,14 +921,14 @@ on_treeview2_key_press_event(GtkWidget * widget,
if (path == NULL)
return FALSE;
- if (event->keyval == GDK_space) {
+ if (event->keyval == GDK_KEY_space) {
if (gtk_tree_view_row_expanded(view, path))
gtk_tree_view_collapse_row(view, path);
else
gtk_tree_view_expand_row(view, path, FALSE);
return TRUE;
}
- if (event->keyval == GDK_KP_Enter) {
+ if (event->keyval == GDK_KEY_KP_Enter) {
}
if (widget == tree1_w)
return FALSE;
@@ -938,7 +944,7 @@ on_treeview2_key_press_event(GtkWidget * widget,
col = COL_YES;
else
col = -1;
- change_sym_value(menu, col);
+ change_sym_value(menu, col, tree2);
return FALSE;
}
@@ -946,57 +952,39 @@ on_treeview2_key_press_event(GtkWidget * widget,
/* Row selection changed: update help */
void
-on_treeview2_cursor_changed(GtkTreeView * treeview, gpointer user_data)
+on_treeview2_selection_changed(GtkTreeSelection *selection, gpointer user_data)
{
- GtkTreeSelection *selection;
GtkTreeIter iter;
struct menu *menu;
- selection = gtk_tree_view_get_selection(treeview);
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
if (gtk_tree_selection_get_selected(selection, &model2, &iter)) {
gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
text_insert_help(menu);
}
}
-
/* User click: display sub-tree in the right frame. */
-gboolean
-on_treeview1_button_press_event(GtkWidget * widget,
- GdkEventButton * event, gpointer user_data)
+void
+on_treeview1_selection_changed(GtkTreeSelection *selection, gpointer user_data)
{
- GtkTreeView *view = GTK_TREE_VIEW(widget);
- GtkTreePath *path;
- GtkTreeViewColumn *column;
GtkTreeIter iter;
struct menu *menu;
- gint tx = (gint) event->x;
- gint ty = (gint) event->y;
- gint cx, cy;
-
- gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
- &cy);
- if (path == NULL)
- return FALSE;
-
- gtk_tree_model_get_iter(model1, &iter, path);
- gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1);
-
- if (event->type == GDK_2BUTTON_PRESS) {
- toggle_sym_value(menu);
- current = menu;
- display_tree_part();
- } else {
+ GtkTreeModel* model1 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree1_w));
+ if (gtk_tree_selection_get_selected(selection, &model1, &iter)) {
+ gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1);
+
+ text_insert_help(menu);
+
+// GtkTreeStore* tree1 = GTK_TREE_STORE(model1);
+
browsed = menu;
display_tree_part();
- }
-
- gtk_widget_realize(tree2_w);
- gtk_tree_view_set_cursor(view, path, NULL, FALSE);
- gtk_widget_grab_focus(tree2_w);
- return FALSE;
+// gtk_widget_realize(tree2_w);
+ gtk_widget_grab_focus(tree2_w);
+ }
}
@@ -1126,18 +1114,17 @@ static gchar **fill_row(struct menu *menu)
/* Set the node content with a row of strings */
-static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row)
+static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row, GtkTreeStore* tree)
{
GdkColor color;
- gboolean success;
GdkPixbuf *pix;
pix = gdk_pixbuf_new_from_xpm_data((const char **)
row[COL_PIXBUF]);
- gdk_color_parse(row[COL_COLOR], &color);
- gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1,
- FALSE, FALSE, &success);
+ gdk_color_parse(row[COL_COLOR], &color);
+// gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1,
+// FALSE, FALSE, &success);
gtk_tree_store_set(tree, node,
COL_OPTION, row[COL_OPTION],
@@ -1162,13 +1149,13 @@ static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row)
/* Add a node to the tree */
-static void place_node(struct menu *menu, char **row)
+static void place_node(struct menu *menu, char **row, GtkTreeStore* tree)
{
GtkTreeIter *parent = parents[indent - 1];
GtkTreeIter *node = parents[indent];
gtk_tree_store_append(tree, node, parent);
- set_node(node, menu, row);
+ set_node(node, menu, row, tree);
}
@@ -1186,6 +1173,7 @@ GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent,
gboolean valid;
GtkTreeIter *ret;
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
valid = gtk_tree_model_iter_children(model2, child, parent);
while (valid) {
struct menu *menu;
@@ -1212,7 +1200,7 @@ GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent,
* Update the tree by adding/removing entries
* Does not change other nodes
*/
-static void update_tree(struct menu *src, GtkTreeIter * dst)
+static void update_tree(struct menu *src, GtkTreeIter * dst, GtkTreeStore* tree)
{
struct menu *child1;
GtkTreeIter iter, tmp;
@@ -1225,6 +1213,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
if (src == &rootmenu)
indent = 1;
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
valid = gtk_tree_model_iter_children(model2, child2, dst);
for (child1 = src->list; child1; child1 = child1->next) {
@@ -1253,7 +1242,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
memcpy(&tmp, child2, sizeof(GtkTreeIter));
valid = gtk_tree_model_iter_next(model2,
child2);
- gtk_tree_store_remove(tree2, &tmp);
+ gtk_tree_store_remove(tree, &tmp);
if (!valid)
return; /* next parent */
else
@@ -1268,28 +1257,28 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
sibling = NULL;
else
sibling = child2;
- gtk_tree_store_insert_before(tree2,
+ gtk_tree_store_insert_before(tree,
child2,
dst, sibling);
- set_node(child2, menu1, fill_row(menu1));
+ set_node(child2, menu1, fill_row(menu1), tree);
if (menu2 == NULL)
valid = TRUE;
} else { // remove node
memcpy(&tmp, child2, sizeof(GtkTreeIter));
valid = gtk_tree_model_iter_next(model2,
child2);
- gtk_tree_store_remove(tree2, &tmp);
+ gtk_tree_store_remove(tree, &tmp);
if (!valid)
return; // next parent
else
goto reparse; // next child
}
} else if (sym && (sym->flags & SYMBOL_CHANGED)) {
- set_node(child2, menu1, fill_row(menu1));
+ set_node(child2, menu1, fill_row(menu1), tree);
}
indent++;
- update_tree(child1, child2);
+ update_tree(child1, child2, tree);
indent--;
valid = gtk_tree_model_iter_next(model2, child2);
@@ -1298,12 +1287,14 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
/* Display the whole tree (single/split/full view) */
-static void display_tree(struct menu *menu)
+static void display_tree(struct menu *menu, GtkTreeStore* tree)
{
struct symbol *sym;
struct property *prop;
struct menu *child;
enum prop_type ptype;
+ GtkTreeStore* tree1 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree1_w)));
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
if (menu == &rootmenu) {
indent = 1;
@@ -1329,7 +1320,7 @@ static void display_tree(struct menu *menu)
if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
(opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
(opt_mode == OPT_ALL && menu_get_prompt(child)))
- place_node(child, fill_row(child));
+ place_node(child, fill_row(child), tree);
#ifdef DEBUG
printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
@@ -1360,7 +1351,7 @@ static void display_tree(struct menu *menu)
|| (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW)) {
indent++;
- display_tree(child);
+ display_tree(child, tree);
indent--;
}
}
@@ -1369,25 +1360,24 @@ static void display_tree(struct menu *menu)
/* Display a part of the tree starting at current node (single/split view) */
static void display_tree_part(void)
{
- if (tree2)
- gtk_tree_store_clear(tree2);
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ gtk_tree_store_clear(tree2);
+
if (view_mode == SINGLE_VIEW)
- display_tree(current);
+ display_tree(current, tree2);
else if (view_mode == SPLIT_VIEW)
- display_tree(browsed);
+ display_tree(browsed, tree2);
gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
}
/* Display the list in the left frame (split view) */
static void display_list(void)
{
- if (tree1)
- gtk_tree_store_clear(tree1);
+ GtkTreeStore* tree1 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree1_w)));
+ gtk_tree_store_clear(tree1);
- tree = tree1;
- display_tree(&rootmenu);
+ display_tree(&rootmenu, tree1);
gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w));
- tree = tree2;
}
void fixup_rootmenu(struct menu *menu)
@@ -1412,16 +1402,15 @@ int main(int ac, char *av[])
{
const char *name;
char *env;
- gchar *glade_file;
+ gchar *ui_file;
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);
+ setlocale (LC_ALL, NULL);
/* GTK stuffs */
- gtk_set_locale();
gtk_init(&ac, &av);
- glade_init();
//add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
//add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");
@@ -1429,11 +1418,11 @@ int main(int ac, char *av[])
/* Determine GUI path */
env = getenv(SRCTREE);
if (env)
- glade_file = g_strconcat(env, "/scripts/kconfig/gconfig/gconf.glade", NULL);
+ ui_file = g_strconcat(env, "/scripts/kconfig/gconfig/gconf.ui", NULL);
else if (av[0][0] == '/')
- glade_file = g_strconcat(av[0], ".glade", NULL);
+ ui_file = g_strconcat(av[0], ".ui", NULL);
else
- glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
+ ui_file = g_strconcat(g_get_current_dir(), "/", av[0], ".ui", NULL);
/* Conf stuffs */
if (ac > 1 && av[1][0] == '-') {
@@ -1454,23 +1443,16 @@ int main(int ac, char *av[])
fixup_rootmenu(&rootmenu);
conf_read(NULL);
+ /* Prepare GtkTreeIter */
+ gint i;
+ for (parents[0] = NULL, i = 1; i < 256; i++)
+ parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter));
+
/* Load the interface and connect signals */
- init_main_window(glade_file);
- init_tree_model();
+ init_main_window(ui_file);
init_left_tree();
init_right_tree();
-
- switch (view_mode) {
- case SINGLE_VIEW:
- display_tree_part();
- break;
- case SPLIT_VIEW:
- display_list();
- break;
- case FULL_VIEW:
- display_tree(&rootmenu);
- break;
- }
+ show_data();
gtk_main();
diff --git a/scripts/kconfig/gconfig/gconf.glade b/scripts/kconfig/gconfig/gconf.glade
deleted file mode 100644
index aa483cb..0000000
--- a/scripts/kconfig/gconfig/gconf.glade
+++ /dev/null
@@ -1,661 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-
-<glade-interface>
-
-<widget class="GtkWindow" id="window1">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Gtk Kernel Configurator</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="default_width">640</property>
- <property name="default_height">480</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <signal name="destroy" handler="on_window1_destroy" object="window1"/>
- <signal name="size_request" handler="on_window1_size_request" object="vpaned1" last_modification_time="Fri, 11 Jan 2002 16:17:11 GMT"/>
- <signal name="delete_event" handler="on_window1_delete_event" object="window1" last_modification_time="Sun, 09 Mar 2003 19:42:46 GMT"/>
-
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkMenuBar" id="menubar1">
- <property name="visible">True</property>
-
- <child>
- <widget class="GtkMenuItem" id="file1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_File</property>
- <property name="use_underline">True</property>
-
- <child>
- <widget class="GtkMenu" id="file1_menu">
-
- <child>
- <widget class="GtkImageMenuItem" id="load1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Load a config file</property>
- <property name="label" translatable="yes">_Load</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_load1_activate"/>
- <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
-
- <child internal-child="image">
- <widget class="GtkImage" id="image39">
- <property name="visible">True</property>
- <property name="stock">gtk-open</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkImageMenuItem" id="save1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Save the config in .config</property>
- <property name="label" translatable="yes">_Save</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_save_activate"/>
- <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
-
- <child internal-child="image">
- <widget class="GtkImage" id="image40">
- <property name="visible">True</property>
- <property name="stock">gtk-save</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkImageMenuItem" id="save_as1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Save the config in a file</property>
- <property name="label" translatable="yes">Save _as</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_save_as1_activate"/>
-
- <child internal-child="image">
- <widget class="GtkImage" id="image41">
- <property name="visible">True</property>
- <property name="stock">gtk-save-as</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkSeparatorMenuItem" id="separator1">
- <property name="visible">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkImageMenuItem" id="quit1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Quit</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_quit1_activate"/>
- <accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
-
- <child internal-child="image">
- <widget class="GtkImage" id="image42">
- <property name="visible">True</property>
- <property name="stock">gtk-quit</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="options1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Options</property>
- <property name="use_underline">True</property>
-
- <child>
- <widget class="GtkMenu" id="options1_menu">
-
- <child>
- <widget class="GtkCheckMenuItem" id="show_name1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show name</property>
- <property name="label" translatable="yes">Show _name</property>
- <property name="use_underline">True</property>
- <property name="active">False</property>
- <signal name="activate" handler="on_show_name1_activate"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkCheckMenuItem" id="show_range1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show range (Y/M/N)</property>
- <property name="label" translatable="yes">Show _range</property>
- <property name="use_underline">True</property>
- <property name="active">False</property>
- <signal name="activate" handler="on_show_range1_activate"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkCheckMenuItem" id="show_data1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show value of the option</property>
- <property name="label" translatable="yes">Show _data</property>
- <property name="use_underline">True</property>
- <property name="active">False</property>
- <signal name="activate" handler="on_show_data1_activate"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkSeparatorMenuItem" id="separator2">
- <property name="visible">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkRadioMenuItem" id="set_option_mode1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show normal options</property>
- <property name="label" translatable="yes">Show normal options</property>
- <property name="use_underline">True</property>
- <property name="active">True</property>
- <signal name="activate" handler="on_set_option_mode1_activate"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkRadioMenuItem" id="set_option_mode2">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show all options</property>
- <property name="label" translatable="yes">Show all _options</property>
- <property name="use_underline">True</property>
- <property name="active">False</property>
- <property name="group">set_option_mode1</property>
- <signal name="activate" handler="on_set_option_mode2_activate"/>
- </widget>
- </child>
-
- <child>
- <widget class="GtkRadioMenuItem" id="set_option_mode3">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show all options with prompts</property>
- <property name="label" translatable="yes">Show all prompt options</property>
- <property name="use_underline">True</property>
- <property name="active">False</property>
- <property name="group">set_option_mode1</property>
- <signal name="activate" handler="on_set_option_mode3_activate"/>
- </widget>
- </child>
-
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="help1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Help</property>
- <property name="use_underline">True</property>
-
- <child>
- <widget class="GtkMenu" id="help1_menu">
-
- <child>
- <widget class="GtkImageMenuItem" id="introduction1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Introduction</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_introduction1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
- <accelerator key="I" modifiers="GDK_CONTROL_MASK" signal="activate"/>
-
- <child internal-child="image">
- <widget class="GtkImage" id="image43">
- <property name="visible">True</property>
- <property name="stock">gtk-dialog-question</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkImageMenuItem" id="about1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_About</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_about1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
- <accelerator key="A" modifiers="GDK_CONTROL_MASK" signal="activate"/>
-
- <child internal-child="image">
- <widget class="GtkImage" id="image44">
- <property name="visible">True</property>
- <property name="stock">gtk-properties</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkImageMenuItem" id="license1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_License</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="on_license1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/>
-
- <child internal-child="image">
- <widget class="GtkImage" id="image45">
- <property name="visible">True</property>
- <property name="stock">gtk-justify-fill</property>
- <property name="icon_size">1</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHandleBox" id="handlebox1">
- <property name="visible">True</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <property name="handle_position">GTK_POS_LEFT</property>
- <property name="snap_edge">GTK_POS_TOP</property>
-
- <child>
- <widget class="GtkToolbar" id="toolbar1">
- <property name="visible">True</property>
- <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
- <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
- <property name="tooltips">True</property>
- <property name="show_arrow">True</property>
-
- <child>
- <widget class="GtkToolButton" id="button1">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Goes up of one level (single view)</property>
- <property name="label" translatable="yes">Back</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-undo</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_back_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolItem" id="toolitem1">
- <property name="visible">True</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
-
- <child>
- <widget class="GtkVSeparator" id="vseparator1">
- <property name="visible">True</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="button2">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Load a config file</property>
- <property name="label" translatable="yes">Load</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-open</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_load_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="button3">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Save a config file</property>
- <property name="label" translatable="yes">Save</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-save</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_save_activate"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolItem" id="toolitem2">
- <property name="visible">True</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
-
- <child>
- <widget class="GtkVSeparator" id="vseparator2">
- <property name="visible">True</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="button4">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Single view</property>
- <property name="label" translatable="yes">Single</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-missing-image</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_single_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:39 GMT"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="button5">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Split view</property>
- <property name="label" translatable="yes">Split</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-missing-image</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_split_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:45 GMT"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="button6">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Full view</property>
- <property name="label" translatable="yes">Full</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-missing-image</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_full_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:50 GMT"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolItem" id="toolitem3">
- <property name="visible">True</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
-
- <child>
- <widget class="GtkVSeparator" id="vseparator3">
- <property name="visible">True</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="button7">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Collapse the whole tree in the right frame</property>
- <property name="label" translatable="yes">Collapse</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-remove</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_collapse_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="button8">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Expand the whole tree in the right frame</property>
- <property name="label" translatable="yes">Expand</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-add</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_expand_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHPaned" id="hpaned1">
- <property name="width_request">1</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="position">0</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="treeview1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">False</property>
- <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/>
- <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/>
- <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="shrink">True</property>
- <property name="resize">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVPaned" id="vpaned1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="position">0</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="visible">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="treeview2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">False</property>
- <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/>
- <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/>
- <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="shrink">True</property>
- <property name="resize">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow3">
- <property name="visible">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTextView" id="textview3">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="overwrite">False</property>
- <property name="accepts_tab">True</property>
- <property name="justification">GTK_JUSTIFY_LEFT</property>
- <property name="wrap_mode">GTK_WRAP_WORD</property>
- <property name="cursor_visible">True</property>
- <property name="pixels_above_lines">0</property>
- <property name="pixels_below_lines">0</property>
- <property name="pixels_inside_wrap">0</property>
- <property name="left_margin">0</property>
- <property name="right_margin">0</property>
- <property name="indent">0</property>
- <property name="text" translatable="yes">Sorry, no help available for this option yet.</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="shrink">True</property>
- <property name="resize">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="shrink">True</property>
- <property name="resize">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-</glade-interface>
diff --git a/scripts/kconfig/gconfig/gconf.ui b/scripts/kconfig/gconfig/gconf.ui
new file mode 100644
index 0000000..6aa29f7
--- /dev/null
+++ b/scripts/kconfig/gconfig/gconf.ui
@@ -0,0 +1,534 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0.47999998927116394</property>
+ <property name="stock">gtk-dialog-question</property>
+ </object>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-justify-fill</property>
+ </object>
+ <object class="GtkTextBuffer" id="textbuffer1">
+ <property name="text">Sorry, no help available for this option yet.</property>
+ </object>
+ <object class="GtkWindow" id="window1">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Gtk Kernel Configurator</property>
+ <property name="default_width">640</property>
+ <property name="default_height">250</property>
+ <signal name="destroy" handler="on_window1_destroy" swapped="no"/>
+ <signal name="delete-event" handler="on_window1_delete_event" swapped="no"/>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuBar" id="menubar1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="file1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_File</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem" id="load1">
+ <property name="label">gtk-open</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Load a config file</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_load1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="save1">
+ <property name="label">gtk-save</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Save the config in .config</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_save_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="save_as1">
+ <property name="label">gtk-save-as</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Save the config in a file</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_save_as1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="separator1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="quit1">
+ <property name="label">gtk-quit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_quit1_activate" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="options1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Options</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="options1_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckMenuItem" id="show_name1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Show name</property>
+ <property name="label" translatable="yes">Show _name</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_show_name1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckMenuItem" id="show_range1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Show range (Y/M/N)</property>
+ <property name="label" translatable="yes">Show _range</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_show_range1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckMenuItem" id="show_data1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Show value of the option</property>
+ <property name="label" translatable="yes">Show _data</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_show_data1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="separator2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioMenuItem" id="set_option_mode1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Show normal options</property>
+ <property name="label" translatable="yes">Show normal options</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <signal name="activate" handler="on_set_option_mode1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioMenuItem" id="set_option_mode2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Show all options</property>
+ <property name="label" translatable="yes">Show all _options</property>
+ <property name="use_underline">True</property>
+ <property name="group">set_option_mode1</property>
+ <signal name="activate" handler="on_set_option_mode2_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioMenuItem" id="set_option_mode3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Show all options with prompts</property>
+ <property name="label" translatable="yes">Show all prompt options</property>
+ <property name="use_underline">True</property>
+ <property name="group">set_option_mode1</property>
+ <signal name="activate" handler="on_set_option_mode3_activate" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Hilfe</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem" id="introduction1">
+ <property name="label" translatable="yes">_Introduction</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="image">image1</property>
+ <property name="use_stock">False</property>
+ <signal name="activate" handler="on_introduction1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="about1">
+ <property name="label">gtk-about</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_about1_activate" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="license1">
+ <property name="label" translatable="yes">_License</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="image">image2</property>
+ <property name="use_stock">False</property>
+ <signal name="activate" handler="on_license1_activate" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHandleBox" id="handlebox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkToolbar" id="toolbar1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
+ <child>
+ <object class="GtkToolButton" id="button1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Goes up of one level (single view)</property>
+ <property name="tooltip_text" translatable="yes">Goes up of one level (single view)</property>
+ <property name="label" translatable="yes">Back</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-undo</property>
+ <signal name="clicked" handler="on_back_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolItem" id="toolitem1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkVSeparator" id="vseparator1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Load a config file</property>
+ <property name="tooltip_text" translatable="yes">Load a config file</property>
+ <property name="label" translatable="yes">Load</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-open</property>
+ <signal name="clicked" handler="on_load_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Save a config file</property>
+ <property name="tooltip_text" translatable="yes">Save a config file</property>
+ <property name="label" translatable="yes">Save</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-save</property>
+ <signal name="clicked" handler="on_save_activate" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolItem" id="toolitem2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkVSeparator" id="vseparator2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Single view</property>
+ <property name="tooltip_text" translatable="yes">Single view</property>
+ <property name="label" translatable="yes">Single</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-missing-image</property>
+ <signal name="clicked" handler="on_single_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Split view</property>
+ <property name="tooltip_text" translatable="yes">Split view</property>
+ <property name="label" translatable="yes">Split</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-missing-image</property>
+ <signal name="clicked" handler="on_split_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Full view</property>
+ <property name="tooltip_text" translatable="yes">Full view</property>
+ <property name="label" translatable="yes">Full</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-missing-image</property>
+ <signal name="clicked" handler="on_full_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolItem" id="toolitem3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkVSeparator" id="vseparator3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Collapse the whole tree in the right frame</property>
+ <property name="tooltip_text" translatable="yes">Collapse the whole tree in the right frame</property>
+ <property name="label" translatable="yes">Collapse</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-remove</property>
+ <signal name="clicked" handler="on_collapse_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="button8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Expand the whole tree in the right frame</property>
+ <property name="tooltip_text" translatable="yes">Expand the whole tree in the right frame</property>
+ <property name="label" translatable="yes">Expand</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-add</property>
+ <signal name="clicked" handler="on_expand_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHPaned" id="hpaned1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="width_request">100</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_right">3</property>
+ <property name="shadow_type">in</property>
+ <property name="min_content_width">150</property>
+ <child>
+ <object class="GtkTreeView" id="treeview1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="headers_clickable">False</property>
+ <property name="enable_search">False</property>
+ <signal name="key-press-event" handler="on_treeview2_key_press_event" swapped="no"/>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection3">
+ <signal name="changed" handler="on_treeview1_selection_changed" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVPaned" id="vpaned1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_left">3</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkTreeView" id="treeview2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="enable_search">False</property>
+ <signal name="button-press-event" handler="on_treeview2_button_press_event" swapped="no"/>
+ <signal name="key-press-event" handler="on_treeview2_key_press_event" swapped="no"/>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection4">
+ <signal name="changed" handler="on_treeview2_selection_changed" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow3">
+ <property name="height_request">80</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTextView" id="textview3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="wrap_mode">word</property>
+ <property name="buffer">textbuffer1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
--
1.8.1.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH 4/9] kconfig: gtk interface: fix splitview, split code into two files
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
2013-07-02 15:22 ` [PATCH 2/9] kconfig: Update gtk interface codebase davidgraeff
2013-07-02 15:22 ` [PATCH 3/9] kconfig: gtk interface port to Gtk3 davidgraeff
@ 2013-07-02 15:22 ` davidgraeff
2013-07-02 15:22 ` [PATCH 5/9] kconfig: images.c for gtk/qt gui flavour reoganized davidgraeff
` (5 subsequent siblings)
8 siblings, 0 replies; 33+ messages in thread
From: davidgraeff @ 2013-07-02 15:22 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, davidgraeff
Split code into gconf.c and gconf_treeview_model. gconf.c now
only contains ui init and ui signal callback code, all tree/model
code is in the second file.
Issues with split view are fixed.
---
scripts/kconfig/gconfig/Makefile | 10 +-
scripts/kconfig/gconfig/gconf.c | 1103 +++++-------------------
scripts/kconfig/gconfig/gconf.h | 80 ++
scripts/kconfig/gconfig/gconf.ui | 16 +-
scripts/kconfig/gconfig/gconf_treeview_model.c | 714 +++++++++++++++
scripts/kconfig/gconfig/gconf_treeview_model.h | 43 +
scripts/kconfig/gconfig/util.h | 33 +
7 files changed, 1082 insertions(+), 917 deletions(-)
create mode 100644 scripts/kconfig/gconfig/gconf.h
create mode 100644 scripts/kconfig/gconfig/gconf_treeview_model.c
create mode 100644 scripts/kconfig/gconfig/gconf_treeview_model.h
create mode 100644 scripts/kconfig/gconfig/util.h
diff --git a/scripts/kconfig/gconfig/Makefile b/scripts/kconfig/gconfig/Makefile
index 282c500..f2ca18e 100644
--- a/scripts/kconfig/gconfig/Makefile
+++ b/scripts/kconfig/gconfig/Makefile
@@ -13,7 +13,7 @@ gconfig: $(obj)/gconf
# Based on GTK which needs to be installed to compile it
# object files used by all kconfig flavours listed above
-gconf-objs := gconfig/gconf.o zconf.tab.o
+gconf-objs := gconfig/gconf.o gconfig/gconf_treeview_model.o zconf.tab.o
ifeq ($(MAKECMDGOALS),gconfig)
gconf-target := 1
@@ -30,8 +30,12 @@ HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-3.0 gmodule-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-3.0 gmodule-2.0` \
-Wno-missing-prototypes -DGTK_DISABLE_SINGLE_INCLUDES \
-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
- -DGSEAL_ENABLE
-
+ -DGSEAL_ENABLE -std=c99
+HOSTCFLAGS_gconf_treeview_model.o = `pkg-config --cflags gtk+-3.0 gmodule-2.0` \
+ -Wno-missing-prototypes -DGTK_DISABLE_SINGLE_INCLUDES \
+ -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
+ -DGSEAL_ENABLE -std=c99
+
$(obj)/gconfig/gconf.o: $(obj)/gconfig/.tmp_gtkcheck
ifeq ($(gconf-target),1)
diff --git a/scripts/kconfig/gconfig/gconf.c b/scripts/kconfig/gconfig/gconf.c
index 5eb765c..9d7825e 100644
--- a/scripts/kconfig/gconfig/gconf.c
+++ b/scripts/kconfig/gconfig/gconf.c
@@ -1,113 +1,21 @@
-/* Hey EMACS -*- linux-c -*- */
/*
*
+ * Copyright (C) 2013 David Gräff <david.graeff@web.de>
* Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
* Released under the terms of the GNU GPL v2.0.
*
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <locale.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <gdk/gdk.h>
-
-#include "../lkc.h"
+#include "gconf.h"
+#include "gconf_treeview_model.h"
+#define IMAGES_TOOLBAR
#include "../images.c"
-//#define DEBUG
-
-enum {
- SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
-};
-
-enum {
- OPT_NORMAL, OPT_ALL, OPT_PROMPT
-};
-
-static gint view_mode = FULL_VIEW;
-static gboolean show_name = TRUE;
-static gboolean show_range = TRUE;
-static gboolean show_value = TRUE;
-static gboolean resizeable = FALSE;
-static int opt_mode = OPT_NORMAL;
-
-GtkWidget *main_wnd = NULL;
-GtkWidget *tree1_w = NULL; // left frame
-GtkWidget *tree2_w = NULL; // right frame
-GtkWidget *text_w = NULL;
-GtkWidget *hpaned = NULL;
-GtkWidget *vpaned = NULL;
-GtkWidget *back_btn = NULL;
-GtkWidget *save_btn = NULL;
-GtkWidget *save_menu_item = NULL;
-
+enum view_mode_enum view_mode = FULL_VIEW;
+struct gconfwindow_s gconfwindow;
GtkTextTag *tag1, *tag2;
-GdkColor color;
-
-static GtkTreeIter *parents[256];
-static gint indent;
-
-static struct menu *current; // current node for SINGLE view
-static struct menu *browsed; // browsed node for SPLIT view
-
-enum {
- COL_OPTION, COL_NAME, COL_NO, COL_MOD, COL_YES, COL_VALUE,
- COL_MENU, COL_COLOR, COL_EDIT, COL_PIXBUF,
- COL_PIXVIS, COL_BTNVIS, COL_BTNACT, COL_BTNINC, COL_BTNRAD,
- COL_NUMBER
-};
-
-static void display_list(void);
-static void display_tree(struct menu *menu, GtkTreeStore* tree);
-static void display_tree_part(void);
-static void update_tree(struct menu *src, GtkTreeIter * dst, GtkTreeStore* tree);
-static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row, GtkTreeStore* tree);
-static gchar **fill_row(struct menu *menu);
-static void conf_changed(void);
-
-/* Helping/Debugging Functions */
-
-const char *dbg_sym_flags(int val)
-{
- static char buf[256];
-
- bzero(buf, 256);
-
- if (val & SYMBOL_CONST)
- strcat(buf, "const/");
- if (val & SYMBOL_CHECK)
- strcat(buf, "check/");
- if (val & SYMBOL_CHOICE)
- strcat(buf, "choice/");
- if (val & SYMBOL_CHOICEVAL)
- strcat(buf, "choiceval/");
- if (val & SYMBOL_VALID)
- strcat(buf, "valid/");
- if (val & SYMBOL_OPTIONAL)
- strcat(buf, "optional/");
- if (val & SYMBOL_WRITE)
- strcat(buf, "write/");
- if (val & SYMBOL_CHANGED)
- strcat(buf, "changed/");
- if (val & SYMBOL_AUTO)
- strcat(buf, "auto/");
-
- buf[strlen(buf) - 1] = '\0';
-
- return buf;
-}
-void replace_button_icon(GtkBuilder * builder,
+static void replace_button_icon(GtkBuilder * builder,
gchar * btn_name, const char ** xpm)
{
GdkPixbuf * pixmap;
@@ -122,12 +30,26 @@ void replace_button_icon(GtkBuilder * builder,
gtk_tool_button_set_icon_widget(button, image);
}
+static void conf_changed(void)
+{
+ bool changed = conf_get_changed();
+ gtk_widget_set_sensitive(gconfwindow.save_btn, changed);
+ gtk_widget_set_sensitive(gconfwindow.save_menu_item, changed);
+}
+
/* Main Window Initialization */
-void init_main_window(const gchar * ui_file)
+static void init_main_window(const gchar * ui_file)
{
GtkBuilder *builder;
GtkWidget *widget;
GtkTextBuffer *txtbuf;
+
+ // init default values for options
+ gconfwindow.show_name = TRUE;
+ gconfwindow.show_range = TRUE;
+ gconfwindow.show_value = TRUE;
+ gconfwindow.resizeable = FALSE;
+ gconfwindow.opt_mode = OPT_NORMAL;
builder = gtk_builder_new();
int result = gtk_builder_add_from_file(builder, ui_file, NULL);
@@ -135,30 +57,29 @@ void init_main_window(const gchar * ui_file)
g_error(_("GUI loading failed !\n"));
gtk_builder_connect_signals (builder, NULL);
- main_wnd = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
- hpaned = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned1"));
- vpaned = GTK_WIDGET(gtk_builder_get_object(builder, "vpaned1"));
- tree1_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview1"));
- tree2_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview2"));
- text_w = GTK_WIDGET(gtk_builder_get_object(builder, "textview3"));
+ gconfwindow.main_wnd = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
+ gconfwindow.hpaned = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned1"));
+ gconfwindow.tree1_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview1"));
+ gconfwindow.tree2_w = GTK_WIDGET(gtk_builder_get_object(builder, "treeview2"));
+ gconfwindow.text_w = GTK_WIDGET(gtk_builder_get_object(builder, "textview3"));
- back_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button1"));
- gtk_widget_set_sensitive(back_btn, FALSE);
+ gconfwindow.back_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button1"));
+ gtk_widget_set_sensitive(gconfwindow.back_btn, FALSE);
widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_name1"));
gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
- show_name);
+ gconfwindow.show_name);
widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_range1"));
gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
- show_range);
+ gconfwindow.show_range);
widget = GTK_WIDGET(gtk_builder_get_object(builder, "show_data1"));
gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
- show_value);
+ gconfwindow.show_value);
- save_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button3"));
- save_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "save1"));
+ gconfwindow.save_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button3"));
+ gconfwindow.save_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "save1"));
conf_set_changed_callback(conf_changed);
widget = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar1"));
@@ -169,7 +90,7 @@ void init_main_window(const gchar * ui_file)
g_object_unref (G_OBJECT (builder));
- txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
+ txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gconfwindow.text_w));
tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
"foreground", "red",
"weight", PANGO_WEIGHT_BOLD,
@@ -178,9 +99,9 @@ void init_main_window(const gchar * ui_file)
/*"style", PANGO_STYLE_OBLIQUE, */
NULL);
- gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
+ gtk_window_set_title(GTK_WINDOW(gconfwindow.main_wnd), rootmenu.prompt->text);
- gtk_widget_show(main_wnd);
+ gtk_widget_show(gconfwindow.main_wnd);
}
/**
@@ -191,205 +112,37 @@ void show_data(void)
{
switch (view_mode) {
case SINGLE_VIEW:
- gtk_widget_hide(tree1_w);
- current = &rootmenu;
- display_tree_part();
+ gtk_widget_hide(gconfwindow.tree1_w);
+ display_tree_part(&rootmenu);
break;
case SPLIT_VIEW:
{
- gtk_widget_show(tree1_w);
+ gtk_widget_show(gconfwindow.tree1_w);
gint w, h;
- gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
- gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
+ gtk_window_get_default_size(GTK_WINDOW(gconfwindow.main_wnd), &w, &h);
+ gtk_paned_set_position(GTK_PANED(gconfwindow.hpaned), w / 2);
// Clear right frame, the user has to choose a subtree first
- GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
gtk_tree_store_clear(tree2);
// Display tree in left frame
display_list();
/* Disable back btn, like in full mode. */
- gtk_widget_set_sensitive(back_btn, FALSE);
+ gtk_widget_set_sensitive(gconfwindow.back_btn, FALSE);
break;
}
case FULL_VIEW:
{
- gtk_widget_hide(tree1_w);
- GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ gtk_widget_hide(gconfwindow.tree1_w);
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
gtk_tree_store_clear(tree2);
display_tree(&rootmenu, tree2);
- gtk_widget_set_sensitive(back_btn, FALSE);
+ gtk_widget_set_sensitive(gconfwindow.back_btn, FALSE);
break;
}
}
}
-void init_left_tree(void)
-{
- GtkTreeView *view = GTK_TREE_VIEW(tree1_w);
- GtkCellRenderer *renderer;
- GtkTreeSelection *sel;
- GtkTreeViewColumn *column;
-
- GtkTreeStore *tree1;
- GtkTreeModel *model1;
- tree1 = gtk_tree_store_new(COL_NUMBER,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER, GDK_TYPE_COLOR,
- G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN);
- model1 = GTK_TREE_MODEL(tree1);
-
- gtk_tree_view_set_model(view, model1);
- gtk_tree_view_set_headers_visible(view, TRUE);
- gtk_tree_view_set_rules_hint(view, TRUE);
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_append_column(view, column);
- gtk_tree_view_column_set_title(column, _("Options"));
-
- renderer = gtk_cell_renderer_toggle_new();
- gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
- renderer, FALSE);
- gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
- renderer,
- "active", COL_BTNACT,
- "inconsistent", COL_BTNINC,
- "visible", COL_BTNVIS,
- "radio", COL_BTNRAD, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
- renderer, FALSE);
- gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
- renderer,
- "text", COL_OPTION,
- "foreground-gdk",
- COL_COLOR, NULL);
-
- sel = gtk_tree_view_get_selection(view);
- gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
- gtk_widget_realize(tree1_w);
-}
-
-static void renderer_edited(GtkCellRendererText * cell,
- const gchar * path_string,
- const gchar * new_text, gpointer user_data);
-
-void init_right_tree(void)
-{
- GtkTreeView *view = GTK_TREE_VIEW(tree2_w);
- GtkCellRenderer *renderer;
- GtkTreeSelection *sel;
- GtkTreeViewColumn *column;
- gint i;
-
- GtkTreeStore *tree2;
- GtkTreeModel *model2;
- tree2 = gtk_tree_store_new(COL_NUMBER,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER, GDK_TYPE_COLOR,
- G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN);
- model2 = GTK_TREE_MODEL(tree2);
-
- gtk_tree_view_set_model(view, model2);
- gtk_tree_view_set_headers_visible(view, TRUE);
- gtk_tree_view_set_rules_hint(view, TRUE);
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_append_column(view, column);
- gtk_tree_view_column_set_title(column, _("Options"));
-
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
- renderer, FALSE);
- gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
- renderer,
- "pixbuf", COL_PIXBUF,
- "visible", COL_PIXVIS, NULL);
- renderer = gtk_cell_renderer_toggle_new();
- gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
- renderer, FALSE);
- gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
- renderer,
- "active", COL_BTNACT,
- "inconsistent", COL_BTNINC,
- "visible", COL_BTNVIS,
- "radio", COL_BTNRAD, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
- renderer, FALSE);
- gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
- renderer,
- "text", COL_OPTION,
- "foreground-gdk",
- COL_COLOR, NULL);
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes(view, -1,
- _("Name"), renderer,
- "text", COL_NAME,
- "foreground-gdk",
- COL_COLOR, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes(view, -1,
- "N", renderer,
- "text", COL_NO,
- "foreground-gdk",
- COL_COLOR, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes(view, -1,
- "M", renderer,
- "text", COL_MOD,
- "foreground-gdk",
- COL_COLOR, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes(view, -1,
- "Y", renderer,
- "text", COL_YES,
- "foreground-gdk",
- COL_COLOR, NULL);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes(view, -1,
- _("Value"), renderer,
- "text", COL_VALUE,
- "editable",
- COL_EDIT,
- "foreground-gdk",
- COL_COLOR, NULL);
- g_signal_connect(G_OBJECT(renderer), "edited",
- G_CALLBACK(renderer_edited), NULL);
-
- column = gtk_tree_view_get_column(view, COL_NAME);
- gtk_tree_view_column_set_visible(column, show_name);
- column = gtk_tree_view_get_column(view, COL_NO);
- gtk_tree_view_column_set_visible(column, show_range);
- column = gtk_tree_view_get_column(view, COL_MOD);
- gtk_tree_view_column_set_visible(column, show_range);
- column = gtk_tree_view_get_column(view, COL_YES);
- gtk_tree_view_column_set_visible(column, show_range);
- column = gtk_tree_view_get_column(view, COL_VALUE);
- gtk_tree_view_column_set_visible(column, show_value);
-
- if (resizeable) {
- for (i = 0; i < COL_VALUE; i++) {
- column = gtk_tree_view_get_column(view, i);
- gtk_tree_view_column_set_resizable(column, TRUE);
- }
- }
-
- sel = gtk_tree_view_get_selection(view);
- gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
-}
-
-
/* Utility Functions */
@@ -402,10 +155,10 @@ static void text_insert_help(struct menu *menu)
menu_get_ext_help(menu, &help);
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gconfwindow.text_w));
gtk_text_buffer_get_bounds(buffer, &start, &end);
gtk_text_buffer_delete(buffer, &start, &end);
- gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(gconfwindow.text_w), 15);
gtk_text_buffer_get_end_iter(buffer, &end);
gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
@@ -424,10 +177,10 @@ static void text_insert_msg(const char *title, const char *message)
GtkTextIter start, end;
const char *msg = message;
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gconfwindow.text_w));
gtk_text_buffer_get_bounds(buffer, &start, &end);
gtk_text_buffer_delete(buffer, &start, &end);
- gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(gconfwindow.text_w), 15);
gtk_text_buffer_get_end_iter(buffer, &end);
gtk_text_buffer_insert_with_tags(buffer, &end, title, -1, tag1,
@@ -451,7 +204,7 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
return FALSE;
dialog = gtk_dialog_new_with_buttons(_("Warning !"),
- GTK_WINDOW(main_wnd),
+ GTK_WINDOW(gconfwindow.main_wnd),
(GtkDialogFlags)
(GTK_DIALOG_MODAL |
GTK_DIALOG_DESTROY_WITH_PARENT),
@@ -499,7 +252,7 @@ void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkWidget *dialog;
dialog = gtk_file_chooser_dialog_new (_("Load file..."),
- GTK_WINDOW(main_wnd),
+ GTK_WINDOW(gconfwindow.main_wnd),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
@@ -528,7 +281,7 @@ void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
GtkWidget *dialog;
dialog = gtk_file_chooser_dialog_new (_("Save File as..."),
- GTK_WINDOW(main_wnd),
+ GTK_WINDOW(gconfwindow.main_wnd),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
@@ -550,7 +303,7 @@ void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
void on_quit1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
if (!on_window1_delete_event(NULL, NULL, NULL))
- gtk_widget_destroy(GTK_WIDGET(main_wnd));
+ gtk_widget_destroy(GTK_WIDGET(gconfwindow.main_wnd));
}
@@ -558,10 +311,10 @@ void on_show_name1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkTreeViewColumn *col;
- show_name = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NAME);
+ gconfwindow.show_name = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
+ col = gtk_tree_view_get_column(GTK_TREE_VIEW(gconfwindow.tree2_w), COL_NAME);
if (col)
- gtk_tree_view_column_set_visible(col, show_name);
+ gtk_tree_view_column_set_visible(col, gconfwindow.show_name);
}
@@ -569,16 +322,16 @@ void on_show_range1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkTreeViewColumn *col;
- show_range = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NO);
+ gconfwindow.show_range = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
+ col = gtk_tree_view_get_column(GTK_TREE_VIEW(gconfwindow.tree2_w), COL_NO);
if (col)
- gtk_tree_view_column_set_visible(col, show_range);
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_MOD);
+ gtk_tree_view_column_set_visible(col, gconfwindow.show_range);
+ col = gtk_tree_view_get_column(GTK_TREE_VIEW(gconfwindow.tree2_w), COL_MOD);
if (col)
- gtk_tree_view_column_set_visible(col, show_range);
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_YES);
+ gtk_tree_view_column_set_visible(col, gconfwindow.show_range);
+ col = gtk_tree_view_get_column(GTK_TREE_VIEW(gconfwindow.tree2_w), COL_YES);
if (col)
- gtk_tree_view_column_set_visible(col, show_range);
+ gtk_tree_view_column_set_visible(col, gconfwindow.show_range);
}
@@ -587,18 +340,18 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
GtkTreeViewColumn *col;
- show_value = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_VALUE);
+ gconfwindow.show_value = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem));
+ col = gtk_tree_view_get_column(GTK_TREE_VIEW(gconfwindow.tree2_w), COL_VALUE);
if (col)
- gtk_tree_view_column_set_visible(col, show_value);
+ gtk_tree_view_column_set_visible(col, gconfwindow.show_value);
}
void
on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- opt_mode = OPT_NORMAL;
- GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ gconfwindow.opt_mode = OPT_NORMAL;
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
gtk_tree_store_clear(tree2);
display_tree(&rootmenu, tree2); /* instead of update_tree to speed-up */
}
@@ -607,8 +360,8 @@ on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
void
on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- opt_mode = OPT_ALL;
- GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ gconfwindow.opt_mode = OPT_ALL;
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
gtk_tree_store_clear(tree2);
display_tree(&rootmenu, tree2); /* instead of update_tree to speed-up */
}
@@ -617,8 +370,8 @@ on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
void
on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- opt_mode = OPT_PROMPT;
- GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
+ gconfwindow.opt_mode = OPT_PROMPT;
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
gtk_tree_store_clear(tree2);
display_tree(&rootmenu, tree2); /* instead of update_tree to speed-up */
}
@@ -644,7 +397,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
"Toggling Show Debug Info under the Options menu will show \n"
"the dependencies, which you can then match by examining other options.");
- dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
+ dialog = gtk_message_dialog_new(GTK_WINDOW(gconfwindow.main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE, "%s", intro_text);
@@ -663,7 +416,7 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
"gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
"Based on the source code from Roman Zippel.\n");
- dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
+ dialog = gtk_message_dialog_new(GTK_WINDOW(gconfwindow.main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE, "%s", about_text);
@@ -682,7 +435,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
"For more information, please see the source code or\n"
"visit http://www.fsf.org/licenses/licenses.html\n");
- dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
+ dialog = gtk_message_dialog_new(GTK_WINDOW(gconfwindow.main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE, "%s", license_text);
@@ -697,14 +450,15 @@ void on_back_clicked(GtkButton * button, gpointer user_data)
{
enum prop_type ptype;
- current = current->parent;
+ struct menu *current = getCurrentMenu()->parent;
ptype = current->prompt ? current->prompt->type : P_UNKNOWN;
if (ptype != P_MENU)
current = current->parent;
- display_tree_part();
-
+
if (current == &rootmenu)
- gtk_widget_set_sensitive(back_btn, FALSE);
+ gtk_widget_set_sensitive(gconfwindow.back_btn, FALSE);
+
+ display_tree_part(current);
}
@@ -737,175 +491,70 @@ void on_full_clicked(GtkButton * button, gpointer user_data)
void on_collapse_clicked(GtkButton * button, gpointer user_data)
{
- gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w));
+ gtk_tree_view_collapse_all(GTK_TREE_VIEW(gconfwindow.tree2_w));
}
void on_expand_clicked(GtkButton * button, gpointer user_data)
{
- gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
+ gtk_tree_view_expand_all(GTK_TREE_VIEW(gconfwindow.tree2_w));
}
-
-/* CTree Callbacks */
-
-/* Change hex/int/string value in the cell */
-static void renderer_edited(GtkCellRendererText * cell,
- const gchar * path_string,
- const gchar * new_text, gpointer user_data)
+/**
+ * If you click on one of the columns N|M|Y this method is called
+ * by the toggle signal handler (via a proxy methods below)
+ */
+void changeEnabledToogle(int colChangable, int colValue, gchar *path_str)
{
- GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
- GtkTreeIter iter;
- const char *old_def, *new_def;
+ GtkTreeIter iter;
struct menu *menu;
- struct symbol *sym;
-
- GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
- GtkTreeStore* tree2 = GTK_TREE_STORE(model2);
-
- if (!gtk_tree_model_get_iter(model2, &iter, path))
- return;
-
- gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
- sym = menu->sym;
-
- gtk_tree_model_get(model2, &iter, COL_VALUE, &old_def, -1);
- new_def = new_text;
-
- sym_set_string_value(sym, new_def);
-
- update_tree(&rootmenu, NULL, tree2);
-
- gtk_tree_path_free(path);
-}
-
-/* Change the value of a symbol and update the tree */
-static void change_sym_value(struct menu *menu, gint col, GtkTreeStore* tree)
-{
- struct symbol *sym = menu->sym;
- tristate newval;
-
- if (!sym)
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w));
+ gtk_tree_model_get_iter (model2, &iter, path);
+ gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); // get menu data
+ // get changable state
+ gboolean enabled;
+ gtk_tree_model_get(model2, &iter, colChangable, &enabled, -1);
+ if (!enabled) // not changable, do nothing
return;
-
- if (col == COL_NO)
- newval = no;
- else if (col == COL_MOD)
- newval = mod;
- else if (col == COL_YES)
- newval = yes;
+
+ if (colValue != -1)
+ change_sym_value(menu, colValue, GTK_TREE_STORE(model2));
else
- return;
-
- switch (sym_get_type(sym)) {
- case S_BOOLEAN:
- case S_TRISTATE:
- if (!sym_tristate_within_range(sym, newval))
- newval = yes;
- sym_set_tristate_value(sym, newval);
- if (view_mode == FULL_VIEW)
- update_tree(&rootmenu, NULL, tree);
- else if (view_mode == SPLIT_VIEW) {
- update_tree(browsed, NULL, tree);
- display_list();
- }
- else if (view_mode == SINGLE_VIEW)
- display_tree_part(); //fixme: keep exp/coll
- break;
- case S_INT:
- case S_HEX:
- case S_STRING:
- default:
- break;
- }
+ toggle_sym_value(menu, GTK_TREE_STORE(model2));
+
+ gtk_tree_view_expand_row(GTK_TREE_VIEW (gconfwindow.tree2_w), path, TRUE);
+ gtk_tree_path_free (path);
}
-static void toggle_sym_value(struct menu *menu, GtkTreeStore* tree)
+void on_treeview2_makeDisable_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data)
{
- if (!menu->sym)
- return;
-
- sym_toggle_tristate_value(menu->sym);
- if (view_mode == FULL_VIEW)
- update_tree(&rootmenu, NULL, tree);
- else if (view_mode == SPLIT_VIEW) {
- update_tree(browsed, NULL, tree);
- display_list();
- }
- else if (view_mode == SINGLE_VIEW)
- display_tree_part(); //fixme: keep exp/coll
-}
+ changeEnabledToogle(COL_NO_EN, COL_NO, path_str);
+};
-static gint column2index(GtkTreeViewColumn * column)
+void on_treeview2_makeModule_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data)
{
- gint i;
-
- for (i = 0; i < COL_NUMBER; i++) {
- GtkTreeViewColumn *col;
-
- col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), i);
- if (col == column)
- return i;
- }
-
- return -1;
-}
-
+ changeEnabledToogle(COL_MOD_EN, COL_MOD, path_str);
+};
-/* User click: update choice (full) or goes down (single) */
-gboolean
-on_treeview2_button_press_event(GtkWidget * widget,
- GdkEventButton * event, gpointer user_data)
+void on_treeview2_makeEnable_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data)
{
- GtkTreeView *view = GTK_TREE_VIEW(widget);
- GtkTreeModel* model2 = gtk_tree_view_get_model(view);
- GtkTreeStore* tree2 = GTK_TREE_STORE(model2);
- GtkTreePath *path;
- GtkTreeViewColumn *column;
- GtkTreeIter iter;
- struct menu *menu;
- gint col;
-
-
- gtk_tree_view_get_cursor(view, &path, &column);
- if (path == NULL)
- return FALSE;
-
- if (!gtk_tree_model_get_iter(model2, &iter, path))
- return FALSE;
- gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
-
- col = column2index(column);
- if (event->type == GDK_2BUTTON_PRESS) {
- enum prop_type ptype;
- ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
-
- if (ptype == P_MENU && view_mode != FULL_VIEW && col == COL_OPTION) {
- // goes down into menu
- current = menu;
- display_tree_part();
- gtk_widget_set_sensitive(back_btn, TRUE);
- } else if ((col == COL_OPTION)) {
- toggle_sym_value(menu, tree2);
- gtk_tree_view_expand_row(view, path, TRUE);
- }
- } else {
- if (col == COL_VALUE) {
- toggle_sym_value(menu, tree2);
- gtk_tree_view_expand_row(view, path, TRUE);
- } else if (col == COL_NO || col == COL_MOD
- || col == COL_YES) {
- change_sym_value(menu, col, tree2);
- gtk_tree_view_expand_row(view, path, TRUE);
- }
- }
+ changeEnabledToogle(COL_YES_EN, COL_YES, path_str);
+};
- return FALSE;
+void
+on_treeview2_toggleEnable_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data)
+{
+ changeEnabledToogle(COL_BTNVISIBLE, -1, path_str);
}
/* Key pressed: update choice */
gboolean
-on_treeview2_key_press_event(GtkWidget * widget,
+on_treeviews_key_press_event(GtkWidget * widget,
GdkEventKey * event, gpointer user_data)
{
GtkTreeView *view = GTK_TREE_VIEW(widget);
@@ -930,17 +579,17 @@ on_treeview2_key_press_event(GtkWidget * widget,
}
if (event->keyval == GDK_KEY_KP_Enter) {
}
- if (widget == tree1_w)
+ if (widget == gconfwindow.tree1_w)
return FALSE;
gtk_tree_model_get_iter(model2, &iter, path);
gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
- if (!strcasecmp(event->string, "n"))
+ if (!strncasecmp(event->string, "n", 1))
col = COL_NO;
- else if (!strcasecmp(event->string, "m"))
+ else if (!strncasecmp(event->string, "m", 1))
col = COL_MOD;
- else if (!strcasecmp(event->string, "y"))
+ else if (!strncasecmp(event->string, "y", 1))
col = COL_YES;
else
col = -1;
@@ -950,453 +599,96 @@ on_treeview2_key_press_event(GtkWidget * widget,
}
-/* Row selection changed: update help */
-void
-on_treeview2_selection_changed(GtkTreeSelection *selection, gpointer user_data)
+/* User click: goes down (single) */
+gboolean
+on_treeview2_button_press_event(GtkWidget * widget,
+ GdkEventButton * event, gpointer user_data)
{
- GtkTreeIter iter;
- struct menu *menu;
-
- GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
- if (gtk_tree_selection_get_selected(selection, &model2, &iter)) {
- gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
- text_insert_help(menu);
+ if (event->type != GDK_2BUTTON_PRESS || view_mode == FULL_VIEW) {
+ return FALSE;
}
-}
-
-/* User click: display sub-tree in the right frame. */
-void
-on_treeview1_selection_changed(GtkTreeSelection *selection, gpointer user_data)
-{
+
+ GtkTreeView *view = GTK_TREE_VIEW(widget);
+ GtkTreeModel* model2 = gtk_tree_view_get_model(view);
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
GtkTreeIter iter;
struct menu *menu;
- GtkTreeModel* model1 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree1_w));
- if (gtk_tree_selection_get_selected(selection, &model1, &iter)) {
- gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1);
-
- text_insert_help(menu);
-
-// GtkTreeStore* tree1 = GTK_TREE_STORE(model1);
-
- browsed = menu;
- display_tree_part();
-
-// gtk_widget_realize(tree2_w);
- gtk_widget_grab_focus(tree2_w);
- }
-}
+ gtk_tree_view_get_cursor(view, &path, &column);
+ if (path == NULL)
+ return FALSE;
+ if (!gtk_tree_model_get_iter(model2, &iter, path))
+ return FALSE;
+ gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
-/* Fill a row of strings */
-static gchar **fill_row(struct menu *menu)
-{
- static gchar *row[COL_NUMBER];
- struct symbol *sym = menu->sym;
- const char *def;
- int stype;
- tristate val;
enum prop_type ptype;
- int i;
-
- for (i = COL_OPTION; i <= COL_COLOR; i++)
- g_free(row[i]);
- bzero(row, sizeof(row));
-
- row[COL_OPTION] =
- g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
- sym && !sym_has_value(sym) ? "(NEW)" : "");
-
- if (opt_mode == OPT_ALL && !menu_is_visible(menu))
- row[COL_COLOR] = g_strdup("DarkGray");
- else if (opt_mode == OPT_PROMPT &&
- menu_has_prompt(menu) && !menu_is_visible(menu))
- row[COL_COLOR] = g_strdup("DarkGray");
- else
- row[COL_COLOR] = g_strdup("Black");
-
ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
- switch (ptype) {
- case P_MENU:
- row[COL_PIXBUF] = (gchar *) xpm_menu;
- if (view_mode == SINGLE_VIEW)
- row[COL_PIXVIS] = GINT_TO_POINTER(TRUE);
- row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
- break;
- case P_COMMENT:
- row[COL_PIXBUF] = (gchar *) xpm_void;
- row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
- row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
- break;
- default:
- row[COL_PIXBUF] = (gchar *) xpm_void;
- row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
- row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
- break;
- }
- if (!sym)
- return row;
- row[COL_NAME] = g_strdup(sym->name);
-
- sym_calc_value(sym);
- sym->flags &= ~SYMBOL_CHANGED;
-
- if (sym_is_choice(sym)) { // parse childs for getting final value
- struct menu *child;
- struct symbol *def_sym = sym_get_choice_value(sym);
- struct menu *def_menu = NULL;
-
- row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
-
- for (child = menu->list; child; child = child->next) {
- if (menu_is_visible(child)
- && child->sym == def_sym)
- def_menu = child;
- }
-
- if (def_menu)
- row[COL_VALUE] =
- g_strdup(_(menu_get_prompt(def_menu)));
- }
- if (sym->flags & SYMBOL_CHOICEVAL)
- row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
-
- stype = sym_get_type(sym);
- switch (stype) {
- case S_BOOLEAN:
- if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE)
- row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
- if (sym_is_choice(sym))
- break;
- /* fall through */
- case S_TRISTATE:
- val = sym_get_tristate_value(sym);
- switch (val) {
- case no:
- row[COL_NO] = g_strdup("N");
- row[COL_VALUE] = g_strdup("N");
- row[COL_BTNACT] = GINT_TO_POINTER(FALSE);
- row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
- break;
- case mod:
- row[COL_MOD] = g_strdup("M");
- row[COL_VALUE] = g_strdup("M");
- row[COL_BTNINC] = GINT_TO_POINTER(TRUE);
- break;
- case yes:
- row[COL_YES] = g_strdup("Y");
- row[COL_VALUE] = g_strdup("Y");
- row[COL_BTNACT] = GINT_TO_POINTER(TRUE);
- row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
- break;
- }
-
- if (val != no && sym_tristate_within_range(sym, no))
- row[COL_NO] = g_strdup("_");
- if (val != mod && sym_tristate_within_range(sym, mod))
- row[COL_MOD] = g_strdup("_");
- if (val != yes && sym_tristate_within_range(sym, yes))
- row[COL_YES] = g_strdup("_");
- break;
- case S_INT:
- case S_HEX:
- case S_STRING:
- def = sym_get_string_value(sym);
- row[COL_VALUE] = g_strdup(def);
- row[COL_EDIT] = GINT_TO_POINTER(TRUE);
- row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
- break;
+ if (ptype == P_MENU) {
+ // goes down into menu
+ display_tree_part(menu);
+ gtk_widget_set_sensitive(gconfwindow.back_btn, TRUE);
}
-
- return row;
-}
-
-
-/* Set the node content with a row of strings */
-static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row, GtkTreeStore* tree)
-{
- GdkColor color;
- GdkPixbuf *pix;
-
- pix = gdk_pixbuf_new_from_xpm_data((const char **)
- row[COL_PIXBUF]);
-
- gdk_color_parse(row[COL_COLOR], &color);
-// gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1,
-// FALSE, FALSE, &success);
-
- gtk_tree_store_set(tree, node,
- COL_OPTION, row[COL_OPTION],
- COL_NAME, row[COL_NAME],
- COL_NO, row[COL_NO],
- COL_MOD, row[COL_MOD],
- COL_YES, row[COL_YES],
- COL_VALUE, row[COL_VALUE],
- COL_MENU, (gpointer) menu,
- COL_COLOR, &color,
- COL_EDIT, GPOINTER_TO_INT(row[COL_EDIT]),
- COL_PIXBUF, pix,
- COL_PIXVIS, GPOINTER_TO_INT(row[COL_PIXVIS]),
- COL_BTNVIS, GPOINTER_TO_INT(row[COL_BTNVIS]),
- COL_BTNACT, GPOINTER_TO_INT(row[COL_BTNACT]),
- COL_BTNINC, GPOINTER_TO_INT(row[COL_BTNINC]),
- COL_BTNRAD, GPOINTER_TO_INT(row[COL_BTNRAD]),
- -1);
-
- g_object_unref(pix);
-}
-
-
-/* Add a node to the tree */
-static void place_node(struct menu *menu, char **row, GtkTreeStore* tree)
-{
- GtkTreeIter *parent = parents[indent - 1];
- GtkTreeIter *node = parents[indent];
-
- gtk_tree_store_append(tree, node, parent);
- set_node(node, menu, row, tree);
+
+ return FALSE;
}
-/* Find a node in the GTK+ tree */
-static GtkTreeIter found;
-
-/*
- * Find a menu in the GtkTree starting at parent.
- */
-GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent,
- struct menu *tofind)
+/* Row selection changed: update help */
+void
+on_treeview2_selection_changed(GtkTreeSelection *selection, gpointer user_data)
{
GtkTreeIter iter;
- GtkTreeIter *child = &iter;
- gboolean valid;
- GtkTreeIter *ret;
-
- GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
- valid = gtk_tree_model_iter_children(model2, child, parent);
- while (valid) {
- struct menu *menu;
-
- gtk_tree_model_get(model2, child, 6, &menu, -1);
-
- if (menu == tofind) {
- memcpy(&found, child, sizeof(GtkTreeIter));
- return &found;
- }
-
- ret = gtktree_iter_find_node(child, tofind);
- if (ret)
- return ret;
-
- valid = gtk_tree_model_iter_next(model2, child);
- }
-
- return NULL;
-}
-
-
-/*
- * Update the tree by adding/removing entries
- * Does not change other nodes
- */
-static void update_tree(struct menu *src, GtkTreeIter * dst, GtkTreeStore* tree)
-{
- struct menu *child1;
- GtkTreeIter iter, tmp;
- GtkTreeIter *child2 = &iter;
- gboolean valid;
- GtkTreeIter *sibling;
- struct symbol *sym;
- struct menu *menu1, *menu2;
-
- if (src == &rootmenu)
- indent = 1;
-
- GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w));
- valid = gtk_tree_model_iter_children(model2, child2, dst);
- for (child1 = src->list; child1; child1 = child1->next) {
-
- sym = child1->sym;
-
- reparse:
- menu1 = child1;
- if (valid)
- gtk_tree_model_get(model2, child2, COL_MENU,
- &menu2, -1);
- else
- menu2 = NULL; // force adding of a first child
-
-#ifdef DEBUG
- printf("%*c%s | %s\n", indent, ' ',
- menu1 ? menu_get_prompt(menu1) : "nil",
- menu2 ? menu_get_prompt(menu2) : "nil");
-#endif
-
- if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
- (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
- (opt_mode == OPT_ALL && !menu_get_prompt(child1))) {
-
- /* remove node */
- if (gtktree_iter_find_node(dst, menu1) != NULL) {
- memcpy(&tmp, child2, sizeof(GtkTreeIter));
- valid = gtk_tree_model_iter_next(model2,
- child2);
- gtk_tree_store_remove(tree, &tmp);
- if (!valid)
- return; /* next parent */
- else
- goto reparse; /* next child */
- } else
- continue;
- }
-
- if (menu1 != menu2) {
- if (gtktree_iter_find_node(dst, menu1) == NULL) { // add node
- if (!valid && !menu2)
- sibling = NULL;
- else
- sibling = child2;
- gtk_tree_store_insert_before(tree,
- child2,
- dst, sibling);
- set_node(child2, menu1, fill_row(menu1), tree);
- if (menu2 == NULL)
- valid = TRUE;
- } else { // remove node
- memcpy(&tmp, child2, sizeof(GtkTreeIter));
- valid = gtk_tree_model_iter_next(model2,
- child2);
- gtk_tree_store_remove(tree, &tmp);
- if (!valid)
- return; // next parent
- else
- goto reparse; // next child
- }
- } else if (sym && (sym->flags & SYMBOL_CHANGED)) {
- set_node(child2, menu1, fill_row(menu1), tree);
- }
-
- indent++;
- update_tree(child1, child2, tree);
- indent--;
+ struct menu *menu;
- valid = gtk_tree_model_iter_next(model2, child2);
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w));
+ if (gtk_tree_selection_get_selected(selection, &model2, &iter)) {
+ gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
+ text_insert_help(menu);
}
}
-
-/* Display the whole tree (single/split/full view) */
-static void display_tree(struct menu *menu, GtkTreeStore* tree)
+/* User click: display sub-tree in the right frame. */
+void
+on_treeview1_selection_changed(GtkTreeSelection *selection, gpointer user_data)
{
- struct symbol *sym;
- struct property *prop;
- struct menu *child;
- enum prop_type ptype;
- GtkTreeStore* tree1 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree1_w)));
- GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
-
- if (menu == &rootmenu) {
- indent = 1;
- current = &rootmenu;
- }
+ GtkTreeIter iter;
+ struct menu *menu;
- for (child = menu->list; child; child = child->next) {
- prop = child->prompt;
- sym = child->sym;
- ptype = prop ? prop->type : P_UNKNOWN;
-
- if (sym)
- sym->flags &= ~SYMBOL_CHANGED;
-
- if ((view_mode == SPLIT_VIEW)
- && !(child->flags & MENU_ROOT) && (tree == tree1))
- continue;
-
- if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT)
- && (tree == tree2))
- continue;
-
- if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
- (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
- (opt_mode == OPT_ALL && menu_get_prompt(child)))
- place_node(child, fill_row(child), tree);
-#ifdef DEBUG
- printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
- printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
- printf("%s", prop_get_type_name(ptype));
- printf(" | ");
- if (sym) {
- printf("%s", sym_type_name(sym->type));
- printf(" | ");
- printf("%s", dbg_sym_flags(sym->flags));
- printf("\n");
- } else
- printf("\n");
-#endif
- if ((view_mode != FULL_VIEW) && (ptype == P_MENU)
- && (tree == tree2))
- continue;
-/*
- if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
- || (view_mode == FULL_VIEW)
- || (view_mode == SPLIT_VIEW))*/
+ GtkTreeModel* model1 = gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree1_w));
+ if (gtk_tree_selection_get_selected(selection, &model1, &iter)) {
+ gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1);
- /* Change paned position if the view is not in 'split mode' */
- if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
- gtk_paned_set_position(GTK_PANED(hpaned), 0);
- }
+ display_tree_part(menu);
+ text_insert_help(menu);
- if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
- || (view_mode == FULL_VIEW)
- || (view_mode == SPLIT_VIEW)) {
- indent++;
- display_tree(child, tree);
- indent--;
- }
+ gtk_widget_realize(gconfwindow.tree2_w);
+ gtk_widget_grab_focus(gconfwindow.tree2_w);
}
}
-/* Display a part of the tree starting at current node (single/split view) */
-static void display_tree_part(void)
-{
- GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree2_w)));
- gtk_tree_store_clear(tree2);
-
- if (view_mode == SINGLE_VIEW)
- display_tree(current, tree2);
- else if (view_mode == SPLIT_VIEW)
- display_tree(browsed, tree2);
- gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
-}
-
-/* Display the list in the left frame (split view) */
-static void display_list(void)
-{
- GtkTreeStore* tree1 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (tree1_w)));
- gtk_tree_store_clear(tree1);
-
- display_tree(&rootmenu, tree1);
- gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w));
-}
-
-void fixup_rootmenu(struct menu *menu)
+/* User clicked on checkbox in treeview 1. */
+void
+on_treeview1_checkbox_toggle(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data)
{
- struct menu *child;
- static int menu_cnt = 0;
-
- menu->flags |= MENU_ROOT;
- for (child = menu->list; child; child = child->next) {
- if (child->prompt && child->prompt->type == P_MENU) {
- menu_cnt++;
- fixup_rootmenu(child);
- menu_cnt--;
- } else if (!menu_cnt)
- fixup_rootmenu(child);
- }
+ GtkTreeIter iter;
+ struct menu *menu;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ if (path == NULL)
+ return;
+
+ GtkTreeModel* model1 = gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree1_w));
+ GtkTreeStore* tree1 = GTK_TREE_STORE(model1);
+ gtk_tree_model_get_iter (model1, &iter, path);
+ gtk_tree_path_free (path);
+ gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1); // get menu data
+ toggle_sym_value(menu, tree1); // toggle value internally
+ display_tree_part(menu); // show new tree
}
-
/* Main */
int main(int ac, char *av[])
{
@@ -1435,21 +727,24 @@ int main(int ac, char *av[])
printf("%s <config>\n", av[0]);
exit(0);
}
+ }
+
+ if (ac > 2 && av[1][0] == '-') {
name = av[2];
- } else
+ } else if(ac>1) {
name = av[1];
+ } else {
+ printf("No config file!\n");
+ exit(0);
+ }
conf_parse(name);
fixup_rootmenu(&rootmenu);
conf_read(NULL);
-
- /* Prepare GtkTreeIter */
- gint i;
- for (parents[0] = NULL, i = 1; i < 256; i++)
- parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter));
/* Load the interface and connect signals */
init_main_window(ui_file);
+ init_node_parents();
init_left_tree();
init_right_tree();
show_data();
@@ -1459,9 +754,3 @@ int main(int ac, char *av[])
return 0;
}
-static void conf_changed(void)
-{
- bool changed = conf_get_changed();
- gtk_widget_set_sensitive(save_btn, changed);
- gtk_widget_set_sensitive(save_menu_item, changed);
-}
diff --git a/scripts/kconfig/gconfig/gconf.h b/scripts/kconfig/gconfig/gconf.h
new file mode 100644
index 0000000..206c154
--- /dev/null
+++ b/scripts/kconfig/gconfig/gconf.h
@@ -0,0 +1,80 @@
+/*
+ *
+ * Copyright (C) 2013 David Gräff <david.graeff@web.de>
+ * Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ */
+
+#ifndef GCONF_H_
+#define GCONF_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <strings.h>
+#include <time.h>
+
+#include <gtk/gtk.h>
+#include <glib.h>
+#include <gdk/gdk.h>
+
+#include "../lkc.h"
+
+//#define DEBUG
+
+extern enum view_mode_enum {
+ SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
+} view_mode;
+
+enum {
+ OPT_NORMAL, OPT_ALL, OPT_PROMPT
+};
+enum {
+ COL_OPTION, COL_NAME,
+ COL_NO, COL_MOD, COL_YES,
+ COL_VALUE,
+ COL_MENU, COL_COLOR, COL_EDIT,
+ COL_PIXBUF, COL_PIXVIS,
+ COL_BTNVISIBLE, COL_BTNACT,
+ COL_BTNINC, COL_BTNRAD,
+ COL_NO_EN, COL_MOD_EN, COL_YES_EN,
+ COL_NUMBER
+};
+
+extern struct gconfwindow_s {
+ // widget pointer variables
+ GtkWidget *main_wnd;
+ GtkWidget *tree1_w; // left frame
+ GtkWidget *tree2_w; // right frame
+ GtkWidget *text_w;
+ GtkWidget *hpaned;
+ GtkWidget *back_btn;
+ GtkWidget *save_btn;
+ GtkWidget *save_menu_item;
+ // option variables
+ gboolean show_name;
+ gboolean show_range;
+ gboolean show_value;
+ gboolean resizeable;
+ int opt_mode;
+
+} gconfwindow;
+
+void on_treeview2_makeDisable_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data);
+void on_treeview2_makeModule_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data);
+void on_treeview2_makeEnable_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data);
+void on_treeview1_checkbox_toggle(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data);
+void on_treeview2_toggleEnable_clicked(GtkCellRendererToggle *cell, gchar *path_str,
+ gpointer data);
+#endif
\ No newline at end of file
diff --git a/scripts/kconfig/gconfig/gconf.ui b/scripts/kconfig/gconfig/gconf.ui
index 6aa29f7..0effd9f 100644
--- a/scripts/kconfig/gconfig/gconf.ui
+++ b/scripts/kconfig/gconfig/gconf.ui
@@ -19,7 +19,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">Gtk Kernel Configurator</property>
<property name="default_width">640</property>
- <property name="default_height">250</property>
+ <property name="default_height">480</property>
<signal name="destroy" handler="on_window1_destroy" swapped="no"/>
<signal name="delete-event" handler="on_window1_delete_event" swapped="no"/>
<child>
@@ -437,17 +437,18 @@
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_right">3</property>
+ <property name="margin_left">3</property>
<property name="shadow_type">in</property>
<property name="min_content_width">150</property>
<child>
<object class="GtkTreeView" id="treeview1">
+ <property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="events">GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK</property>
<property name="headers_clickable">False</property>
<property name="enable_search">False</property>
- <signal name="key-press-event" handler="on_treeview2_key_press_event" swapped="no"/>
+ <signal name="key-press-event" handler="on_treeviews_key_press_event" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection3">
<signal name="changed" handler="on_treeview1_selection_changed" swapped="no"/>
@@ -465,7 +466,7 @@
<object class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="margin_left">3</property>
+ <property name="margin_right">3</property>
<property name="hexpand">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
@@ -476,10 +477,10 @@
<object class="GtkTreeView" id="treeview2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="events">GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK</property>
<property name="enable_search">False</property>
<signal name="button-press-event" handler="on_treeview2_button_press_event" swapped="no"/>
- <signal name="key-press-event" handler="on_treeview2_key_press_event" swapped="no"/>
+ <signal name="key-press-event" handler="on_treeviews_key_press_event" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection4">
<signal name="changed" handler="on_treeview2_selection_changed" swapped="no"/>
@@ -500,6 +501,7 @@
<property name="can_focus">False</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
+ <property name="min_content_height">80</property>
<child>
<object class="GtkTextView" id="textview3">
<property name="visible">True</property>
diff --git a/scripts/kconfig/gconfig/gconf_treeview_model.c b/scripts/kconfig/gconfig/gconf_treeview_model.c
new file mode 100644
index 0000000..c7689b3
--- /dev/null
+++ b/scripts/kconfig/gconfig/gconf_treeview_model.c
@@ -0,0 +1,714 @@
+/*
+ *
+ * Copyright (C) 2013 David Gräff <david.graeff@web.de>
+ * Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ */
+
+#include "gconf_treeview_model.h"
+#define IMAGES_TREEVIEW
+#include "../images.c"
+
+static GtkTreeIter *parents[256];
+static gint indent;
+
+
+void init_left_tree(void)
+{
+ GtkTreeView *view = GTK_TREE_VIEW(gconfwindow.tree1_w);
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *sel;
+ GtkTreeViewColumn *column;
+
+ GtkTreeStore *tree1;
+ GtkTreeModel *model1;
+ tree1 = gtk_tree_store_new(COL_NUMBER,
+ G_TYPE_STRING, G_TYPE_STRING, //Option, Name
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, // COL_NO, COL_MOD, COL_YES
+ G_TYPE_STRING, // COL_VALUE
+ G_TYPE_POINTER, GDK_TYPE_COLOR, G_TYPE_BOOLEAN, // COL_MENU, COL_COLOR, COL_EDIT
+ GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, // COL_PIXBUF, COL_PIXVIS
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, //COL_BTNVISIBLE, COL_BTNACT
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, // COL_BTNINC, COL_BTNRAD,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN // COL_NO_EN, COL_MOD_EN, COL_YES_EN
+ );
+ model1 = GTK_TREE_MODEL(tree1);
+
+ gtk_tree_view_set_model(view, model1);
+ gtk_tree_view_set_headers_visible(view, TRUE);
+ gtk_tree_view_set_rules_hint(view, TRUE);
+
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_append_column(view, column);
+ gtk_tree_view_column_set_title(column, _("Options"));
+
+ renderer = gtk_cell_renderer_toggle_new();
+ g_signal_connect (G_OBJECT(renderer), "toggled", G_CALLBACK
+ (on_treeview1_checkbox_toggle), NULL);
+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
+ renderer, FALSE);
+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
+ renderer,
+ "active", COL_BTNACT,
+ "inconsistent", COL_BTNINC,
+ "visible", COL_BTNVISIBLE,
+ "radio", COL_BTNRAD, NULL);
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
+ renderer, FALSE);
+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
+ renderer,
+ "text", COL_OPTION,
+ "foreground-gdk",
+ COL_COLOR, NULL);
+
+ sel = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
+ gtk_widget_realize(gconfwindow.tree1_w);
+}
+
+void init_right_tree(void)
+{
+ GtkTreeView *view = GTK_TREE_VIEW(gconfwindow.tree2_w);
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ GtkTreeStore *tree2;
+ GtkTreeModel *model2;
+ tree2 = gtk_tree_store_new(COL_NUMBER,
+ G_TYPE_STRING, G_TYPE_STRING, //Option, Name
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, // COL_NO, COL_MOD, COL_YES
+ G_TYPE_STRING, // COL_VALUE
+ G_TYPE_POINTER, GDK_TYPE_COLOR, G_TYPE_BOOLEAN, // COL_MENU, COL_COLOR, COL_EDIT
+ GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, // COL_PIXBUF, COL_PIXVIS
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, //COL_BTNVISIBLE, COL_BTNACT
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, // COL_BTNINC, COL_BTNRAD,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN // COL_NO_EN, COL_MOD_EN, COL_YES_EN
+ );
+ model2 = GTK_TREE_MODEL(tree2);
+
+ gtk_tree_view_set_model(view, model2);
+ gtk_tree_view_set_headers_visible(view, TRUE);
+ gtk_tree_view_set_rules_hint(view, TRUE);
+
+ // The option name column with the expand icon and enabled checkbox
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_append_column(view, column);
+ gtk_tree_view_column_set_title(column, _("Options"));
+
+ // The expand icon
+ renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
+ renderer, FALSE);
+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
+ renderer,
+ "pixbuf", COL_PIXBUF,
+ "visible", COL_PIXVIS, NULL);
+ // The enabled/module/disabled checkbox
+ renderer = gtk_cell_renderer_toggle_new();
+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
+ renderer, FALSE);
+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
+ renderer,
+ "active", COL_BTNACT,
+ "inconsistent", COL_BTNINC,
+ "visible", COL_BTNVISIBLE,
+ "radio", COL_BTNRAD, NULL);
+ g_signal_connect (G_OBJECT(renderer), "toggled", G_CALLBACK
+ (on_treeview2_toggleEnable_clicked), NULL);
+ // The options name
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
+ renderer, FALSE);
+ gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
+ renderer,
+ "text", COL_OPTION,
+ "foreground-gdk",
+ COL_COLOR, NULL);
+
+ // The internal name column
+ // The internal name
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes(view, -1,
+ _("Name"), renderer,
+ "text", COL_NAME,
+ "foreground-gdk",
+ COL_COLOR, NULL);
+ column = gtk_tree_view_get_column(view, COL_NAME);
+ gtk_tree_view_column_set_visible(column, gconfwindow.show_name);
+
+ // Range column (Disable)
+ renderer = gtk_cell_renderer_toggle_new();
+ gtk_tree_view_insert_column_with_attributes(view, -1,
+ "N", renderer,
+ "active", COL_NO,
+ "visible", COL_NO_EN,
+ NULL);
+ column = gtk_tree_view_get_column(view, COL_NO);
+ gtk_tree_view_column_set_visible(column, gconfwindow.show_range);
+ gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(renderer), TRUE);
+ g_signal_connect (G_OBJECT(renderer), "toggled", G_CALLBACK
+ (on_treeview2_makeDisable_clicked), NULL);
+
+ // Range column (Module)
+ renderer = gtk_cell_renderer_toggle_new();
+ gtk_tree_view_insert_column_with_attributes(view, -1,
+ "M", renderer,
+ "active", COL_MOD,
+ "visible", COL_MOD_EN,
+ NULL);
+ column = gtk_tree_view_get_column(view, COL_MOD);
+ gtk_tree_view_column_set_visible(column, gconfwindow.show_range);
+ gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(renderer), TRUE);
+ g_signal_connect (G_OBJECT(renderer), "toggled", G_CALLBACK
+ (on_treeview2_makeModule_clicked), NULL);
+
+ // Range column (Enable)
+ renderer = gtk_cell_renderer_toggle_new();
+ gtk_tree_view_insert_column_with_attributes(view, -1,
+ "Y", renderer,
+ "active", COL_YES,
+ "visible", COL_YES_EN,
+ NULL);
+ column = gtk_tree_view_get_column(view, COL_YES);
+ gtk_tree_view_column_set_visible(column, gconfwindow.show_range);
+ gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(renderer), TRUE);
+ g_signal_connect (G_OBJECT(renderer), "toggled", G_CALLBACK
+ (on_treeview2_makeEnable_clicked), NULL);
+
+ // Current value column
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes(view, -1,
+ _("Value"), renderer,
+ "text", COL_VALUE,
+ "editable",
+ COL_EDIT,
+ "foreground-gdk",
+ COL_COLOR, NULL);
+ column = gtk_tree_view_get_column(view, COL_VALUE);
+ gtk_tree_view_column_set_visible(column, gconfwindow.show_value);
+ g_signal_connect(G_OBJECT(renderer), "edited",
+ G_CALLBACK(renderer_edited), NULL);
+
+ if (gconfwindow.resizeable) {
+ for (int i = 0; i < COL_VALUE; i++) {
+ column = gtk_tree_view_get_column(view, i);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ }
+ }
+
+ GtkTreeSelection *sel = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
+}
+
+/* CTree Callbacks */
+
+/* Change hex/int/string value in the cell */
+void renderer_edited(GtkCellRendererText * cell,
+ const gchar * path_string,
+ const gchar * new_text, gpointer user_data)
+{
+ GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
+ GtkTreeIter iter;
+ const char *old_def, *new_def;
+ struct menu *menu;
+ struct symbol *sym;
+
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w));
+ GtkTreeStore* tree2 = GTK_TREE_STORE(model2);
+
+ if (!gtk_tree_model_get_iter(model2, &iter, path))
+ return;
+
+ gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
+ sym = menu->sym;
+
+ gtk_tree_model_get(model2, &iter, COL_VALUE, &old_def, -1);
+ new_def = new_text;
+
+ sym_set_string_value(sym, new_def);
+
+ update_tree(&rootmenu, NULL, tree2);
+
+ gtk_tree_path_free(path);
+}
+
+struct menu *currentMenu = 0; // currentMenu node
+
+struct menu *getCurrentMenu(void) {
+ return currentMenu;
+}
+
+/* Change the value of a symbol and update the tree */
+void change_sym_value(struct menu *menu, gint col, GtkTreeStore* tree)
+{
+ struct symbol *sym = menu->sym;
+ tristate newval;
+
+ if (!sym)
+ return;
+
+ if (col == COL_NO)
+ newval = no;
+ else if (col == COL_MOD)
+ newval = mod;
+ else if (col == COL_YES)
+ newval = yes;
+ else
+ return;
+
+ switch (sym_get_type(sym)) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ if (!sym_tristate_within_range(sym, newval))
+ newval = yes;
+ sym_set_tristate_value(sym, newval);
+ if (view_mode == FULL_VIEW)
+ update_tree(&rootmenu, NULL, tree);
+ else if (view_mode == SPLIT_VIEW) {
+ update_tree(currentMenu, NULL, tree);
+ display_list();
+ }
+ else if (view_mode == SINGLE_VIEW)
+ display_tree_part(currentMenu); //fixme: keep exp/coll
+ break;
+ case S_INT:
+ case S_HEX:
+ case S_STRING:
+ default:
+ break;
+ }
+}
+
+void toggle_sym_value(struct menu *menu, GtkTreeStore* tree)
+{
+ if (!menu->sym)
+ return;
+
+ sym_toggle_tristate_value(menu->sym);
+ if (view_mode == FULL_VIEW)
+ update_tree(&rootmenu, NULL, tree);
+ else if (view_mode == SPLIT_VIEW) {
+ update_tree(currentMenu, NULL, tree);
+ display_list();
+ }
+ else if (view_mode == SINGLE_VIEW)
+ display_tree_part(currentMenu); //fixme: keep exp/coll
+}
+
+
+/* Fill a row of strings */
+gchar **fill_row(struct menu *menu)
+{
+ static gchar *row[COL_NUMBER];
+ struct symbol *sym = menu->sym;
+ const char *def;
+ int stype;
+ tristate val;
+ enum prop_type ptype;
+
+ g_free(row[COL_OPTION]);
+ g_free(row[COL_NAME]);
+ g_free(row[COL_VALUE]);
+ g_free(row[COL_MENU]);
+ g_free(row[COL_COLOR]);
+
+ bzero(row, sizeof(row));
+
+ row[COL_OPTION] =
+ g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
+ sym && !sym_has_value(sym) ? "(NEW)" : "");
+
+ if (gconfwindow.opt_mode == OPT_ALL && !menu_is_visible(menu))
+ row[COL_COLOR] = g_strdup("DarkGray");
+ else if (gconfwindow.opt_mode == OPT_PROMPT &&
+ menu_has_prompt(menu) && !menu_is_visible(menu))
+ row[COL_COLOR] = g_strdup("DarkGray");
+ else
+ row[COL_COLOR] = g_strdup("Black");
+
+ ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ switch (ptype) {
+ case P_MENU:
+ row[COL_PIXBUF] = (gchar *) xpm_menu;
+ if (view_mode == SINGLE_VIEW)
+ row[COL_PIXVIS] = GINT_TO_POINTER(TRUE);
+ row[COL_BTNVISIBLE] = GINT_TO_POINTER(FALSE);
+ break;
+ case P_COMMENT:
+ row[COL_PIXBUF] = (gchar *) xpm_void;
+ row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
+ row[COL_BTNVISIBLE] = GINT_TO_POINTER(FALSE);
+ break;
+ default:
+ row[COL_PIXBUF] = (gchar *) xpm_void;
+ row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
+ row[COL_BTNVISIBLE] = GINT_TO_POINTER(TRUE);
+ break;
+ }
+
+ if (!sym)
+ return row;
+ row[COL_NAME] = g_strdup(sym->name);
+
+ sym_calc_value(sym);
+ sym->flags &= ~SYMBOL_CHANGED;
+
+ if (sym_is_choice(sym)) { // parse childs for getting final value
+ struct menu *child;
+ struct symbol *def_sym = sym_get_choice_value(sym);
+ struct menu *def_menu = NULL;
+
+ row[COL_BTNVISIBLE] = GINT_TO_POINTER(FALSE);
+
+ for (child = menu->list; child; child = child->next) {
+ if (menu_is_visible(child)
+ && child->sym == def_sym)
+ def_menu = child;
+ }
+
+ if (def_menu)
+ row[COL_VALUE] =
+ g_strdup(_(menu_get_prompt(def_menu)));
+ }
+ if (sym->flags & SYMBOL_CHOICEVAL)
+ row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
+
+ stype = sym_get_type(sym);
+ switch (stype) {
+ case S_BOOLEAN:
+ if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE)
+ row[COL_BTNVISIBLE] = GINT_TO_POINTER(TRUE);
+ if (sym_is_choice(sym))
+ break;
+ /* fall through */
+ case S_TRISTATE:
+ val = sym_get_tristate_value(sym);
+ switch (val) {
+ case no:
+ row[COL_NO] = GINT_TO_POINTER(TRUE);
+ row[COL_VALUE] = g_strdup("[No]");
+ row[COL_BTNACT] = GINT_TO_POINTER(FALSE);
+ row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
+ break;
+ case mod:
+ row[COL_MOD] = GINT_TO_POINTER(TRUE);
+ row[COL_VALUE] = g_strdup("[Module]");
+ row[COL_BTNINC] = GINT_TO_POINTER(TRUE);
+ break;
+ case yes:
+ row[COL_YES] = GINT_TO_POINTER(TRUE);
+ row[COL_VALUE] = g_strdup("[Yes]");
+ row[COL_BTNACT] = GINT_TO_POINTER(TRUE);
+ row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
+ break;
+ }
+
+ row[COL_NO_EN] = GINT_TO_POINTER(sym_tristate_within_range(sym, no)); // No is allowed
+ row[COL_MOD_EN] = GINT_TO_POINTER(sym_tristate_within_range(sym, mod)); // Mod is allowed
+ row[COL_YES_EN] = GINT_TO_POINTER(sym_tristate_within_range(sym, yes)); // Yes is allowed
+ break;
+ case S_INT:
+ case S_HEX:
+ case S_STRING:
+ def = sym_get_string_value(sym);
+ row[COL_VALUE] = g_strdup(def);
+ row[COL_EDIT] = GINT_TO_POINTER(TRUE);
+ row[COL_BTNVISIBLE] = GINT_TO_POINTER(FALSE);
+ break;
+ }
+
+ return row;
+}
+
+
+/* Set the node content with a row of strings */
+void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row, GtkTreeStore* tree)
+{
+ GdkColor color;
+ GdkPixbuf *pix;
+
+ pix = gdk_pixbuf_new_from_xpm_data((const char **)
+ row[COL_PIXBUF]);
+
+ gdk_color_parse(row[COL_COLOR], &color);
+// gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1,
+// FALSE, FALSE, &success);
+
+ gtk_tree_store_set(tree, node,
+ COL_OPTION, row[COL_OPTION],
+ COL_NAME, row[COL_NAME],
+ COL_NO, row[COL_NO],
+ COL_MOD, row[COL_MOD],
+ COL_YES, row[COL_YES],
+ COL_VALUE, row[COL_VALUE],
+ COL_MENU, (gpointer) menu,
+ COL_COLOR, &color,
+ COL_EDIT, GPOINTER_TO_INT(row[COL_EDIT]),
+ COL_PIXBUF, pix,
+ COL_PIXVIS, GPOINTER_TO_INT(row[COL_PIXVIS]),
+ COL_BTNVISIBLE, GPOINTER_TO_INT(row[COL_BTNVISIBLE]),
+ COL_BTNACT, GPOINTER_TO_INT(row[COL_BTNACT]),
+ COL_BTNINC, GPOINTER_TO_INT(row[COL_BTNINC]),
+ COL_BTNRAD, GPOINTER_TO_INT(row[COL_BTNRAD]),
+ COL_NO_EN, GPOINTER_TO_INT(row[COL_NO_EN]),
+ COL_MOD_EN, GPOINTER_TO_INT(row[COL_MOD_EN]),
+ COL_YES_EN, GPOINTER_TO_INT(row[COL_YES_EN]),
+ -1);
+
+ g_object_unref(pix);
+}
+
+void init_node_parents(void)
+{
+ /* Prepare GtkTreeIter */
+ gint i;
+ for (parents[0] = NULL, i = 1; i < 256; i++)
+ parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter));
+
+}
+
+/* Add a node to the tree */
+void place_node(struct menu *menu, char **row, GtkTreeStore* tree)
+{
+ GtkTreeIter *parent = parents[indent - 1];
+ GtkTreeIter *node = parents[indent];
+
+ gtk_tree_store_append(tree, node, parent);
+ set_node(node, menu, row, tree);
+}
+
+/*
+ * Find a menu in the GtkTree starting at parent.
+ */
+GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent,
+ struct menu *tofind)
+{
+ static GtkTreeIter found;
+ GtkTreeIter iter;
+ GtkTreeIter *child = &iter;
+ gboolean valid;
+ GtkTreeIter *ret;
+
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w));
+ valid = gtk_tree_model_iter_children(model2, child, parent);
+ while (valid) {
+ struct menu *menu;
+
+ gtk_tree_model_get(model2, child, 6, &menu, -1);
+
+ if (menu == tofind) {
+ memcpy(&found, child, sizeof(GtkTreeIter));
+ return &found;
+ }
+
+ ret = gtktree_iter_find_node(child, tofind);
+ if (ret)
+ return ret;
+
+ valid = gtk_tree_model_iter_next(model2, child);
+ }
+
+ return NULL;
+}
+
+
+/*
+ * Update the tree by adding/removing entries
+ * Does not change other nodes
+ */
+void update_tree(struct menu *src, GtkTreeIter * dst, GtkTreeStore* tree)
+{
+ struct menu *child1;
+ GtkTreeIter iter, tmp;
+ GtkTreeIter *child2 = &iter;
+ gboolean valid;
+ GtkTreeIter *sibling;
+ struct symbol *sym;
+ struct menu *menu1, *menu2;
+
+ if (src == &rootmenu)
+ indent = 1;
+
+ GtkTreeModel* model2 = gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w));
+ valid = gtk_tree_model_iter_children(model2, child2, dst);
+ for (child1 = src->list; child1; child1 = child1->next) {
+
+ sym = child1->sym;
+
+ reparse:
+ menu1 = child1;
+ if (valid)
+ gtk_tree_model_get(model2, child2, COL_MENU,
+ &menu2, -1);
+ else
+ menu2 = NULL; // force adding of a first child
+
+#ifdef DEBUG
+ printf("%*c%s | %s\n", indent, ' ',
+ menu1 ? menu_get_prompt(menu1) : "nil",
+ menu2 ? menu_get_prompt(menu2) : "nil");
+#endif
+
+ if ((gconfwindow.opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
+ (gconfwindow.opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
+ (gconfwindow.opt_mode == OPT_ALL && !menu_get_prompt(child1))) {
+
+ /* remove node */
+ if (gtktree_iter_find_node(dst, menu1) != NULL) {
+ memcpy(&tmp, child2, sizeof(GtkTreeIter));
+ valid = gtk_tree_model_iter_next(model2,
+ child2);
+ gtk_tree_store_remove(tree, &tmp);
+ if (!valid)
+ return; /* next parent */
+ else
+ goto reparse; /* next child */
+ } else
+ continue;
+ }
+
+ if (menu1 != menu2) {
+ if (gtktree_iter_find_node(dst, menu1) == NULL) { // add node
+ if (!valid && !menu2)
+ sibling = NULL;
+ else
+ sibling = child2;
+ gtk_tree_store_insert_before(tree,
+ child2,
+ dst, sibling);
+ set_node(child2, menu1, fill_row(menu1), tree);
+ if (menu2 == NULL)
+ valid = TRUE;
+ } else { // remove node
+ memcpy(&tmp, child2, sizeof(GtkTreeIter));
+ valid = gtk_tree_model_iter_next(model2,
+ child2);
+ gtk_tree_store_remove(tree, &tmp);
+ if (!valid)
+ return; // next parent
+ else
+ goto reparse; // next child
+ }
+ } else if (sym && (sym->flags & SYMBOL_CHANGED)) {
+ set_node(child2, menu1, fill_row(menu1), tree);
+ }
+
+ indent++;
+ update_tree(child1, child2, tree);
+ indent--;
+
+ valid = gtk_tree_model_iter_next(model2, child2);
+ }
+}
+
+
+/* Display the whole tree (single/split/full view) */
+void display_tree(struct menu *menu, GtkTreeStore* tree)
+{
+ struct symbol *sym;
+ struct property *prop;
+ struct menu *child;
+ enum prop_type ptype;
+ GtkTreeStore* tree1 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree1_w)));
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
+
+ if (menu == &rootmenu) {
+ indent = 1;
+ currentMenu = &rootmenu;
+ }
+
+ for (child = menu->list; child; child = child->next) {
+ prop = child->prompt;
+ sym = child->sym;
+ ptype = prop ? prop->type : P_UNKNOWN;
+
+ if (sym)
+ sym->flags &= ~SYMBOL_CHANGED;
+
+ if ((view_mode == SPLIT_VIEW)
+ && !(child->flags & MENU_ROOT) && (tree == tree1))
+ continue;
+
+ if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT)
+ && (tree == tree2))
+ continue;
+
+ if ((gconfwindow.opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
+ (gconfwindow.opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
+ (gconfwindow.opt_mode == OPT_ALL && menu_get_prompt(child)))
+ place_node(child, fill_row(child), tree);
+#ifdef DEBUG
+ printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
+ printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
+ printf("%s", prop_get_type_name(ptype));
+ printf(" | ");
+ if (sym) {
+ printf("%s", sym_type_name(sym->type));
+ printf(" | ");
+ printf("%s", dbg_sym_flags(sym->flags));
+ printf("\n");
+ } else
+ printf("\n");
+#endif
+ if ((view_mode != FULL_VIEW) && (ptype == P_MENU)
+ && (tree == tree2))
+ continue;
+/*
+ if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
+ || (view_mode == FULL_VIEW)
+ || (view_mode == SPLIT_VIEW))*/
+
+ /* Change paned position if the view is not in 'split mode' */
+ if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
+ gtk_paned_set_position(GTK_PANED(gconfwindow.hpaned), 0);
+ }
+
+ if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
+ || (view_mode == FULL_VIEW)
+ || (view_mode == SPLIT_VIEW)) {
+ indent++;
+ display_tree(child, tree);
+ indent--;
+ }
+ }
+}
+
+/* Display a part of the tree starting at current node (single/split view) */
+void display_tree_part(struct menu *menu)
+{
+ GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
+ gtk_tree_store_clear(tree2);
+
+ currentMenu = menu;
+
+ display_tree(menu, tree2);
+ gtk_tree_view_expand_all(GTK_TREE_VIEW(gconfwindow.tree2_w));
+}
+
+/* Display the list in the left frame (split view) */
+void display_list(void)
+{
+ GtkTreeStore* tree1 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree1_w)));
+ gtk_tree_store_clear(tree1);
+
+ display_tree(&rootmenu, tree1);
+ gtk_tree_view_expand_all(GTK_TREE_VIEW(gconfwindow.tree1_w));
+}
+
+void fixup_rootmenu(struct menu *menu)
+{
+ struct menu *child;
+ static int menu_cnt = 0;
+
+ menu->flags |= MENU_ROOT;
+ for (child = menu->list; child; child = child->next) {
+ if (child->prompt && child->prompt->type == P_MENU) {
+ menu_cnt++;
+ fixup_rootmenu(child);
+ menu_cnt--;
+ } else if (!menu_cnt)
+ fixup_rootmenu(child);
+ }
+}
diff --git a/scripts/kconfig/gconfig/gconf_treeview_model.h b/scripts/kconfig/gconfig/gconf_treeview_model.h
new file mode 100644
index 0000000..7648da2
--- /dev/null
+++ b/scripts/kconfig/gconfig/gconf_treeview_model.h
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright (C) 2013 David Gräff <david.graeff@web.de>
+ * Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ */
+
+#ifndef GCONF_TREEVIEW_MODEL_H_
+#define GCONF_TREEVIEW_MODEL_H_
+
+#include "gconf.h"
+
+// tree and model init
+void init_right_tree(void);
+void init_left_tree(void);
+
+void renderer_edited(GtkCellRendererText * cell,
+ const gchar * path_string,
+ const gchar * new_text, gpointer user_data);
+
+// model update operations
+void change_sym_value(struct menu *menu, gint col, GtkTreeStore* tree);
+void toggle_sym_value(struct menu *menu, GtkTreeStore* tree);
+
+// node operations
+void init_node_parents(void);
+void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row, GtkTreeStore* tree);
+void place_node(struct menu *menu, char **row, GtkTreeStore* tree);
+GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent,
+ struct menu *tofind);
+gchar **fill_row(struct menu *menu);
+
+// tree operations
+void update_tree(struct menu *src, GtkTreeIter * dst, GtkTreeStore* tree);
+void display_tree(struct menu *menu, GtkTreeStore* tree);
+void display_tree_part(struct menu *menu);
+void display_list(void);
+void fixup_rootmenu(struct menu *menu);
+
+struct menu *getCurrentMenu(void);
+
+#endif
diff --git a/scripts/kconfig/gconfig/util.h b/scripts/kconfig/gconfig/util.h
new file mode 100644
index 0000000..876ec26
--- /dev/null
+++ b/scripts/kconfig/gconfig/util.h
@@ -0,0 +1,33 @@
+
+/* Helping/Debugging Functions */
+
+#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
+const char *dbg_sym_flags(int val)
+{
+ static char buf[256];
+
+ bzero(buf, 256);
+
+ if (val & SYMBOL_CONST)
+ strcat(buf, "const/");
+ if (val & SYMBOL_CHECK)
+ strcat(buf, "check/");
+ if (val & SYMBOL_CHOICE)
+ strcat(buf, "choice/");
+ if (val & SYMBOL_CHOICEVAL)
+ strcat(buf, "choiceval/");
+ if (val & SYMBOL_VALID)
+ strcat(buf, "valid/");
+ if (val & SYMBOL_OPTIONAL)
+ strcat(buf, "optional/");
+ if (val & SYMBOL_WRITE)
+ strcat(buf, "write/");
+ if (val & SYMBOL_CHANGED)
+ strcat(buf, "changed/");
+ if (val & SYMBOL_AUTO)
+ strcat(buf, "auto/");
+
+ buf[strlen(buf) - 1] = '\0';
+
+ return buf;
+}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH 5/9] kconfig: images.c for gtk/qt gui flavour reoganized
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
` (2 preceding siblings ...)
2013-07-02 15:22 ` [PATCH 4/9] kconfig: gtk interface: fix splitview, split code into two files davidgraeff
@ 2013-07-02 15:22 ` davidgraeff
2013-07-02 15:22 ` [PATCH 6/9] kconf: gtk: move relayout code out of a loop davidgraeff
` (4 subsequent siblings)
8 siblings, 0 replies; 33+ messages in thread
From: davidgraeff @ 2013-07-02 15:22 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, davidgraeff
Change order of xpm image constants to build up groups.
Make those groups optional via ifdefs.
---
scripts/kconfig/images.c | 309 ++++++++++++++++++++++++-----------------------
1 file changed, 161 insertions(+), 148 deletions(-)
diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c
index d4f84bd..c8563d9 100644
--- a/scripts/kconfig/images.c
+++ b/scripts/kconfig/images.c
@@ -3,6 +3,166 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#ifdef IMAGES_TOOLBAR
+static const char *xpm_tree_view[] = {
+"22 22 2 1",
+". c None",
+"# c #000000",
+"......................",
+"......................",
+"......#...............",
+"......#...............",
+"......#...............",
+"......#...............",
+"......#...............",
+"......########........",
+"......#...............",
+"......#...............",
+"......#...............",
+"......#...............",
+"......#...............",
+"......########........",
+"......#...............",
+"......#...............",
+"......#...............",
+"......#...............",
+"......#...............",
+"......########........",
+"......................",
+"......................"};
+
+static const char *xpm_single_view[] = {
+"22 22 2 1",
+". c None",
+"# c #000000",
+"......................",
+"......................",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"..........#...........",
+"......................",
+"......................"};
+
+static const char *xpm_split_view[] = {
+"22 22 2 1",
+". c None",
+"# c #000000",
+"......................",
+"......................",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......#......#........",
+"......................",
+"......................"};
+#endif
+
+#ifdef IMAGES_TREEVIEW
+static const char *xpm_void[] = {
+"12 12 2 1",
+" c white",
+". c black",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "};
+
+static const char *xpm_menu[] = {
+"12 12 2 1",
+" c white",
+". c black",
+" ",
+" .......... ",
+" . . ",
+" . .. . ",
+" . .... . ",
+" . ...... . ",
+" . ...... . ",
+" . .... . ",
+" . .. . ",
+" . . ",
+" .......... ",
+" "};
+#endif
+
+/* Most images are taken from the system icon theme
+ in modern gui toolkits nowadays.
+ Because we compile with -Wunused-variable, we hide
+ the following xmp image constants.
+*/
+#ifdef IMAGES_EXTENDED
+
+static const char *xpm_menu_inv[] = {
+"12 12 2 1",
+" c white",
+". c black",
+" ",
+" .......... ",
+" .......... ",
+" .. ...... ",
+" .. .... ",
+" .. .. ",
+" .. .. ",
+" .. .... ",
+" .. ...... ",
+" .......... ",
+" .......... ",
+" "};
+
+static const char *xpm_menuback[] = {
+"12 12 2 1",
+" c white",
+". c black",
+" ",
+" .......... ",
+" . . ",
+" . .. . ",
+" . .... . ",
+" . ...... . ",
+" . ...... . ",
+" . .... . ",
+" . .. . ",
+" . . ",
+" .......... ",
+" "};
+
static const char *xpm_load[] = {
"22 22 5 1",
". c None",
@@ -91,86 +251,6 @@ static const char *xpm_back[] = {
"......................",
"......................"};
-static const char *xpm_tree_view[] = {
-"22 22 2 1",
-". c None",
-"# c #000000",
-"......................",
-"......................",
-"......#...............",
-"......#...............",
-"......#...............",
-"......#...............",
-"......#...............",
-"......########........",
-"......#...............",
-"......#...............",
-"......#...............",
-"......#...............",
-"......#...............",
-"......########........",
-"......#...............",
-"......#...............",
-"......#...............",
-"......#...............",
-"......#...............",
-"......########........",
-"......................",
-"......................"};
-
-static const char *xpm_single_view[] = {
-"22 22 2 1",
-". c None",
-"# c #000000",
-"......................",
-"......................",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"..........#...........",
-"......................",
-"......................"};
-
-static const char *xpm_split_view[] = {
-"22 22 2 1",
-". c None",
-"# c #000000",
-"......................",
-"......................",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......#......#........",
-"......................",
-"......................"};
static const char *xpm_symbol_no[] = {
"12 12 2 1",
@@ -256,71 +336,4 @@ static const char *xpm_choice_yes[] = {
" .. .. ",
" .... ",
" "};
-
-static const char *xpm_menu[] = {
-"12 12 2 1",
-" c white",
-". c black",
-" ",
-" .......... ",
-" . . ",
-" . .. . ",
-" . .... . ",
-" . ...... . ",
-" . ...... . ",
-" . .... . ",
-" . .. . ",
-" . . ",
-" .......... ",
-" "};
-
-static const char *xpm_menu_inv[] = {
-"12 12 2 1",
-" c white",
-". c black",
-" ",
-" .......... ",
-" .......... ",
-" .. ...... ",
-" .. .... ",
-" .. .. ",
-" .. .. ",
-" .. .... ",
-" .. ...... ",
-" .......... ",
-" .......... ",
-" "};
-
-static const char *xpm_menuback[] = {
-"12 12 2 1",
-" c white",
-". c black",
-" ",
-" .......... ",
-" . . ",
-" . .. . ",
-" . .... . ",
-" . ...... . ",
-" . ...... . ",
-" . .... . ",
-" . .. . ",
-" . . ",
-" .......... ",
-" "};
-
-static const char *xpm_void[] = {
-"12 12 2 1",
-" c white",
-". c black",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
+#endif
--
1.8.1.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH 6/9] kconf: gtk: move relayout code out of a loop
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
` (3 preceding siblings ...)
2013-07-02 15:22 ` [PATCH 5/9] kconfig: images.c for gtk/qt gui flavour reoganized davidgraeff
@ 2013-07-02 15:22 ` davidgraeff
2013-07-13 8:56 ` Sam Ravnborg
2013-07-02 15:22 ` [PATCH 8/9] kconfig: qt flavour makefile fixes davidgraeff
` (3 subsequent siblings)
8 siblings, 1 reply; 33+ messages in thread
From: davidgraeff @ 2013-07-02 15:22 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, davidgraeff
---
scripts/kconfig/gconfig/gconf.c | 2 +
scripts/kconfig/gconfig/gconf_treeview_model.c | 10 +-
scripts/kconfig/qconfig/qconf.cc | 1768 ------------------------
scripts/kconfig/qconfig/qconf.cpp | 1768 ++++++++++++++++++++++++
4 files changed, 1771 insertions(+), 1777 deletions(-)
delete mode 100644 scripts/kconfig/qconfig/qconf.cc
create mode 100644 scripts/kconfig/qconfig/qconf.cpp
diff --git a/scripts/kconfig/gconfig/gconf.c b/scripts/kconfig/gconfig/gconf.c
index 9d7825e..dec1983 100644
--- a/scripts/kconfig/gconfig/gconf.c
+++ b/scripts/kconfig/gconfig/gconf.c
@@ -114,6 +114,7 @@ void show_data(void)
case SINGLE_VIEW:
gtk_widget_hide(gconfwindow.tree1_w);
display_tree_part(&rootmenu);
+ gtk_paned_set_position(GTK_PANED(gconfwindow.hpaned), 0);
break;
case SPLIT_VIEW:
{
@@ -137,6 +138,7 @@ void show_data(void)
GtkTreeStore* tree2 = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (gconfwindow.tree2_w)));
gtk_tree_store_clear(tree2);
display_tree(&rootmenu, tree2);
+ gtk_paned_set_position(GTK_PANED(gconfwindow.hpaned), 0);
gtk_widget_set_sensitive(gconfwindow.back_btn, FALSE);
break;
}
diff --git a/scripts/kconfig/gconfig/gconf_treeview_model.c b/scripts/kconfig/gconfig/gconf_treeview_model.c
index c7689b3..f57ef05 100644
--- a/scripts/kconfig/gconfig/gconf_treeview_model.c
+++ b/scripts/kconfig/gconfig/gconf_treeview_model.c
@@ -652,18 +652,10 @@ void display_tree(struct menu *menu, GtkTreeStore* tree)
} else
printf("\n");
#endif
+ /* Do not show P_MENU entries in the right view if not in full view mode */
if ((view_mode != FULL_VIEW) && (ptype == P_MENU)
&& (tree == tree2))
continue;
-/*
- if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
- || (view_mode == FULL_VIEW)
- || (view_mode == SPLIT_VIEW))*/
-
- /* Change paned position if the view is not in 'split mode' */
- if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
- gtk_paned_set_position(GTK_PANED(gconfwindow.hpaned), 0);
- }
if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
|| (view_mode == FULL_VIEW)
diff --git a/scripts/kconfig/qconfig/qconf.cc b/scripts/kconfig/qconfig/qconf.cc
deleted file mode 100644
index 43634fd..0000000
--- a/scripts/kconfig/qconfig/qconf.cc
+++ /dev/null
@@ -1,1768 +0,0 @@
-/*
- * Copyright (C) 2013 David Graeff <david.graeff@udo.edu>
- * Based on Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <qglobal.h>
-
-#include <q3mainwindow.h>
-#include <q3vbox.h>
-#include <q3valuelist.h>
-#include <q3textbrowser.h>
-#include <q3action.h>
-#include <q3header.h>
-#include <q3filedialog.h>
-#include <q3dragobject.h>
-#include <q3popupmenu.h>
-
-#include <qapplication.h>
-#include <qdesktopwidget.h>
-#include <qtoolbar.h>
-#include <qlayout.h>
-#include <qsplitter.h>
-#include <qlineedit.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qmenubar.h>
-#include <qmessagebox.h>
-#include <qregexp.h>
-#include <qevent.h>
-
-#include <stdlib.h>
-
-#include "qconf.h"
-#include "qconf.moc"
-
-#include "../lkc.h"
-#include "../images.c"
-
-#ifdef _
-# undef _
-# define _ qgettext
-#endif
-
-static QApplication *configApp;
-static ConfigSettings *configSettings;
-
-Q3Action *ConfigMainWindow::saveAction;
-
-static inline QString qgettext(const char* str)
-{
- return QString::fromLocal8Bit(gettext(str));
-}
-
-static inline QString qgettext(const QString& str)
-{
- return QString::fromLocal8Bit(gettext(str.latin1()));
-}
-
-/**
- * Reads a list of integer values from the application settings.
- */
-Q3ValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
-{
- Q3ValueList<int> result;
- QStringList entryList = readListEntry(key, ok);
- QStringList::Iterator it;
-
- for (it = entryList.begin(); it != entryList.end(); ++it)
- result.push_back((*it).toInt());
-
- return result;
-}
-
-/**
- * Writes a list of integer values to the application settings.
- */
-bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList<int>& value)
-{
- QStringList stringList;
- Q3ValueList<int>::ConstIterator it;
-
- for (it = value.begin(); it != value.end(); ++it)
- stringList.push_back(QString::number(*it));
- return writeEntry(key, stringList);
-}
-
-
-/*
- * set the new data
- * TODO check the value
- */
-void ConfigItem::okRename(int col)
-{
- Parent::okRename(col);
- sym_set_string_value(menu->sym, text(dataColIdx).latin1());
- listView()->updateList(this);
-}
-
-/*
- * update the displayed of a menu entry
- */
-void ConfigItem::updateMenu(void)
-{
- ConfigList* list;
- struct symbol* sym;
- struct property *prop;
- QString prompt;
- int type;
- tristate expr;
-
- list = listView();
- if (goParent) {
- setPixmap(promptColIdx, list->menuBackPix);
- prompt = "..";
- goto set_prompt;
- }
-
- sym = menu->sym;
- prop = menu->prompt;
- prompt = _(menu_get_prompt(menu));
-
- if (prop) switch (prop->type) {
- case P_MENU:
- if (list->mode == singleMode || list->mode == symbolMode) {
- /* a menuconfig entry is displayed differently
- * depending whether it's at the view root or a child.
- */
- if (sym && list->rootEntry == menu)
- break;
- setPixmap(promptColIdx, list->menuPix);
- } else {
- if (sym)
- break;
- setPixmap(promptColIdx, 0);
- }
- goto set_prompt;
- case P_COMMENT:
- setPixmap(promptColIdx, 0);
- goto set_prompt;
- default:
- ;
- }
- if (!sym)
- goto set_prompt;
-
- setText(nameColIdx, QString::fromLocal8Bit(sym->name));
-
- type = sym_get_type(sym);
- switch (type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- char ch;
-
- if (!sym_is_changable(sym) && list->optMode == normalOpt) {
- setPixmap(promptColIdx, 0);
- setText(noColIdx, QString::null);
- setText(modColIdx, QString::null);
- setText(yesColIdx, QString::null);
- break;
- }
- expr = sym_get_tristate_value(sym);
- switch (expr) {
- case yes:
- if (sym_is_choice_value(sym) && type == S_BOOLEAN)
- setPixmap(promptColIdx, list->choiceYesPix);
- else
- setPixmap(promptColIdx, list->symbolYesPix);
- setText(yesColIdx, "Y");
- ch = 'Y';
- break;
- case mod:
- setPixmap(promptColIdx, list->symbolModPix);
- setText(modColIdx, "M");
- ch = 'M';
- break;
- default:
- if (sym_is_choice_value(sym) && type == S_BOOLEAN)
- setPixmap(promptColIdx, list->choiceNoPix);
- else
- setPixmap(promptColIdx, list->symbolNoPix);
- setText(noColIdx, "N");
- ch = 'N';
- break;
- }
- if (expr != no)
- setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0);
- if (expr != mod)
- setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0);
- if (expr != yes)
- setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0);
-
- setText(dataColIdx, QChar(ch));
- break;
- case S_INT:
- case S_HEX:
- case S_STRING:
- const char* data;
-
- data = sym_get_string_value(sym);
-
- int i = list->mapIdx(dataColIdx);
- if (i >= 0)
- setRenameEnabled(i, TRUE);
- setText(dataColIdx, data);
- if (type == S_STRING)
- prompt = QString("%1: %2").arg(prompt).arg(data);
- else
- prompt = QString("(%2) %1").arg(prompt).arg(data);
- break;
- }
- if (!sym_has_value(sym) && visible)
- prompt += _(" (NEW)");
-set_prompt:
- setText(promptColIdx, prompt);
-}
-
-void ConfigItem::testUpdateMenu(bool v)
-{
- ConfigItem* i;
-
- visible = v;
- if (!menu)
- return;
-
- sym_calc_value(menu->sym);
- if (menu->flags & MENU_CHANGED) {
- /* the menu entry changed, so update all list items */
- menu->flags &= ~MENU_CHANGED;
- for (i = (ConfigItem*)menu->data; i; i = i->nextItem)
- i->updateMenu();
- } else if (listView()->updateAll)
- updateMenu();
-}
-
-void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align)
-{
- ConfigList* list = listView();
-
- if (visible) {
- if (isSelected() && !list->hasFocus() && list->mode == menuMode)
- Parent::paintCell(p, list->inactivedColorGroup, column, width, align);
- else
- Parent::paintCell(p, cg, column, width, align);
- } else
- Parent::paintCell(p, list->disabledColorGroup, column, width, align);
-}
-
-/*
- * construct a menu entry
- */
-void ConfigItem::init(void)
-{
- if (menu) {
- ConfigList* list = listView();
- nextItem = (ConfigItem*)menu->data;
- menu->data = this;
-
- if (list->mode != fullMode)
- setOpen(TRUE);
- sym_calc_value(menu->sym);
- }
- updateMenu();
-}
-
-/*
- * destruct a menu entry
- */
-ConfigItem::~ConfigItem(void)
-{
- if (menu) {
- ConfigItem** ip = (ConfigItem**)&menu->data;
- for (; *ip; ip = &(*ip)->nextItem) {
- if (*ip == this) {
- *ip = nextItem;
- break;
- }
- }
- }
-}
-
-ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
- : Parent(parent)
-{
- connect(this, SIGNAL(lostFocus()), SLOT(hide()));
-}
-
-void ConfigLineEdit::show(ConfigItem* i)
-{
- item = i;
- if (sym_get_string_value(item->menu->sym))
- setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym)));
- else
- setText(QString::null);
- Parent::show();
- setFocus();
-}
-
-void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
-{
- switch (e->key()) {
- case Qt::Key_Escape:
- break;
- case Qt::Key_Return:
- case Qt::Key_Enter:
- sym_set_string_value(item->menu->sym, text().latin1());
- parent()->updateList(item);
- break;
- default:
- Parent::keyPressEvent(e);
- return;
- }
- e->accept();
- parent()->list->setFocus();
- hide();
-}
-
-ConfigList::ConfigList(ConfigView* p, const char *name)
- : Parent(p, name),
- updateAll(false),
- symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
- choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
- menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
- showName(false), showRange(false), showData(false), optMode(normalOpt),
- rootEntry(0), headerPopup(0)
-{
- int i;
-
- setSorting(-1);
- setRootIsDecorated(TRUE);
- disabledColorGroup = palette().active();
- disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text());
- inactivedColorGroup = palette().active();
- inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight());
-
- connect(this, SIGNAL(selectionChanged(void)),
- SLOT(updateSelection(void)));
-
- if (name) {
- configSettings->beginGroup(name);
- showName = configSettings->readBoolEntry("/showName", false);
- showRange = configSettings->readBoolEntry("/showRange", false);
- showData = configSettings->readBoolEntry("/showData", false);
- optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false);
- configSettings->endGroup();
- connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
- }
-
- for (i = 0; i < colNr; i++)
- colMap[i] = colRevMap[i] = -1;
- addColumn(promptColIdx, _("Option"));
-
- reinit();
-}
-
-bool ConfigList::menuSkip(struct menu *menu)
-{
- if (optMode == normalOpt && menu_is_visible(menu))
- return false;
- if (optMode == promptOpt && menu_has_prompt(menu))
- return false;
- if (optMode == allOpt)
- return false;
- return true;
-}
-
-void ConfigList::reinit(void)
-{
- removeColumn(dataColIdx);
- removeColumn(yesColIdx);
- removeColumn(modColIdx);
- removeColumn(noColIdx);
- removeColumn(nameColIdx);
-
- if (showName)
- addColumn(nameColIdx, _("Name"));
- if (showRange) {
- addColumn(noColIdx, "N");
- addColumn(modColIdx, "M");
- addColumn(yesColIdx, "Y");
- }
- if (showData)
- addColumn(dataColIdx, _("Value"));
-
- updateListAll();
-}
-
-void ConfigList::saveSettings(void)
-{
- if (name()) {
- configSettings->beginGroup(name());
- configSettings->writeEntry("/showName", showName);
- configSettings->writeEntry("/showRange", showRange);
- configSettings->writeEntry("/showData", showData);
- configSettings->writeEntry("/optionMode", (int)optMode);
- configSettings->endGroup();
- }
-}
-
-ConfigItem* ConfigList::findConfigItem(struct menu *menu)
-{
- ConfigItem* item = (ConfigItem*)menu->data;
-
- for (; item; item = item->nextItem) {
- if (this == item->listView())
- break;
- }
-
- return item;
-}
-
-void ConfigList::updateSelection(void)
-{
- struct menu *menu;
- enum prop_type type;
-
- ConfigItem* item = (ConfigItem*)selectedItem();
- if (!item)
- return;
-
- menu = item->menu;
- emit menuChanged(menu);
- if (!menu)
- return;
- type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
- if (mode == menuMode && type == P_MENU)
- emit menuSelected(menu);
-}
-
-void ConfigList::updateList(ConfigItem* item)
-{
- ConfigItem* last = 0;
-
- if (!rootEntry) {
- if (mode != listMode)
- goto update;
- Q3ListViewItemIterator it(this);
- ConfigItem* item;
-
- for (; it.current(); ++it) {
- item = (ConfigItem*)it.current();
- if (!item->menu)
- continue;
- item->testUpdateMenu(menu_is_visible(item->menu));
- }
- return;
- }
-
- if (rootEntry != &rootmenu && (mode == singleMode ||
- (mode == symbolMode && rootEntry->parent != &rootmenu))) {
- item = firstChild();
- if (!item)
- item = new ConfigItem(this, 0, true);
- last = item;
- }
- if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&
- rootEntry->sym && rootEntry->prompt) {
- item = last ? last->nextSibling() : firstChild();
- if (!item)
- item = new ConfigItem(this, last, rootEntry, true);
- else
- item->testUpdateMenu(true);
-
- updateMenuList(item, rootEntry);
- triggerUpdate();
- return;
- }
-update:
- updateMenuList(this, rootEntry);
- triggerUpdate();
-}
-
-void ConfigList::setValue(ConfigItem* item, tristate val)
-{
- struct symbol* sym;
- int type;
- tristate oldval;
-
- sym = item->menu ? item->menu->sym : 0;
- if (!sym)
- return;
-
- type = sym_get_type(sym);
- switch (type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- oldval = sym_get_tristate_value(sym);
-
- if (!sym_set_tristate_value(sym, val))
- return;
- if (oldval == no && item->menu->list)
- item->setOpen(TRUE);
- parent()->updateList(item);
- break;
- }
-}
-
-void ConfigList::changeValue(ConfigItem* item)
-{
- struct symbol* sym;
- struct menu* menu;
- int type, oldexpr, newexpr;
-
- menu = item->menu;
- if (!menu)
- return;
- sym = menu->sym;
- if (!sym) {
- if (item->menu->list)
- item->setOpen(!item->isOpen());
- return;
- }
-
- type = sym_get_type(sym);
- switch (type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- oldexpr = sym_get_tristate_value(sym);
- newexpr = sym_toggle_tristate_value(sym);
- if (item->menu->list) {
- if (oldexpr == newexpr)
- item->setOpen(!item->isOpen());
- else if (oldexpr == no)
- item->setOpen(TRUE);
- }
- if (oldexpr != newexpr)
- parent()->updateList(item);
- break;
- case S_INT:
- case S_HEX:
- case S_STRING:
- if (colMap[dataColIdx] >= 0)
- item->startRename(colMap[dataColIdx]);
- else
- parent()->lineEdit->show(item);
- break;
- }
-}
-
-void ConfigList::setRootMenu(struct menu *menu)
-{
- enum prop_type type;
-
- if (rootEntry == menu)
- return;
- type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
- if (type != P_MENU)
- return;
- updateMenuList(this, 0);
- rootEntry = menu;
- updateListAll();
- setSelected(currentItem(), hasFocus());
- ensureItemVisible(currentItem());
-}
-
-void ConfigList::setParentMenu(void)
-{
- ConfigItem* item;
- struct menu *oldroot;
-
- oldroot = rootEntry;
- if (rootEntry == &rootmenu)
- return;
- setRootMenu(menu_get_parent_menu(rootEntry->parent));
-
- Q3ListViewItemIterator it(this);
- for (; (item = (ConfigItem*)it.current()); it++) {
- if (item->menu == oldroot) {
- setCurrentItem(item);
- ensureItemVisible(item);
- break;
- }
- }
-}
-
-/*
- * update all the children of a menu entry
- * removes/adds the entries from the parent widget as necessary
- *
- * parent: either the menu list widget or a menu entry widget
- * menu: entry to be updated
- */
-template <class P>
-void ConfigList::updateMenuList(P* parent, struct menu* menu)
-{
- struct menu* child;
- ConfigItem* item;
- ConfigItem* last;
- bool visible;
- enum prop_type type;
-
- if (!menu) {
- while ((item = parent->firstChild()))
- delete item;
- return;
- }
-
- last = parent->firstChild();
- if (last && !last->goParent)
- last = 0;
- for (child = menu->list; child; child = child->next) {
- item = last ? last->nextSibling() : parent->firstChild();
- type = child->prompt ? child->prompt->type : P_UNKNOWN;
-
- switch (mode) {
- case menuMode:
- if (!(child->flags & MENU_ROOT))
- goto hide;
- break;
- case symbolMode:
- if (child->flags & MENU_ROOT)
- goto hide;
- break;
- default:
- break;
- }
-
- visible = menu_is_visible(child);
- if (!menuSkip(child)) {
- if (!child->sym && !child->list && !child->prompt)
- continue;
- if (!item || item->menu != child)
- item = new ConfigItem(parent, last, child, visible);
- else
- item->testUpdateMenu(visible);
-
- if (mode == fullMode || mode == menuMode || type != P_MENU)
- updateMenuList(item, child);
- else
- updateMenuList(item, 0);
- last = item;
- continue;
- }
- hide:
- if (item && item->menu == child) {
- last = parent->firstChild();
- if (last == item)
- last = 0;
- else while (last->nextSibling() != item)
- last = last->nextSibling();
- delete item;
- }
- }
-}
-
-void ConfigList::keyPressEvent(QKeyEvent* ev)
-{
- Q3ListViewItem* i = currentItem();
- ConfigItem* item;
- struct menu *menu;
- enum prop_type type;
-
- if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
- emit parentSelected();
- ev->accept();
- return;
- }
-
- if (!i) {
- Parent::keyPressEvent(ev);
- return;
- }
- item = (ConfigItem*)i;
-
- switch (ev->key()) {
- case Qt::Key_Return:
- case Qt::Key_Enter:
- if (item->goParent) {
- emit parentSelected();
- break;
- }
- menu = item->menu;
- if (!menu)
- break;
- type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
- if (type == P_MENU && rootEntry != menu &&
- mode != fullMode && mode != menuMode) {
- emit menuSelected(menu);
- break;
- }
- case Qt::Key_Space:
- changeValue(item);
- break;
- case Qt::Key_N:
- setValue(item, no);
- break;
- case Qt::Key_M:
- setValue(item, mod);
- break;
- case Qt::Key_Y:
- setValue(item, yes);
- break;
- default:
- Parent::keyPressEvent(ev);
- return;
- }
- ev->accept();
-}
-
-void ConfigList::contentsMousePressEvent(QMouseEvent* e)
-{
- //QPoint p(contentsToViewport(e->pos()));
- //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
- Parent::contentsMousePressEvent(e);
-}
-
-void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
-{
- QPoint p(contentsToViewport(e->pos()));
- ConfigItem* item = (ConfigItem*)itemAt(p);
- struct menu *menu;
- enum prop_type ptype;
- const QPixmap* pm;
- int idx, x;
-
- if (!item)
- goto skip;
-
- menu = item->menu;
- x = header()->offset() + p.x();
- idx = colRevMap[header()->sectionAt(x)];
- switch (idx) {
- case promptColIdx:
- pm = item->pixmap(promptColIdx);
- if (pm) {
- int off = header()->sectionPos(0) + itemMargin() +
- treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0));
- if (x >= off && x < off + pm->width()) {
- if (item->goParent) {
- emit parentSelected();
- break;
- } else if (!menu)
- break;
- ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
- if (ptype == P_MENU && rootEntry != menu &&
- mode != fullMode && mode != menuMode)
- emit menuSelected(menu);
- else
- changeValue(item);
- }
- }
- break;
- case noColIdx:
- setValue(item, no);
- break;
- case modColIdx:
- setValue(item, mod);
- break;
- case yesColIdx:
- setValue(item, yes);
- break;
- case dataColIdx:
- changeValue(item);
- break;
- }
-
-skip:
- //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
- Parent::contentsMouseReleaseEvent(e);
-}
-
-void ConfigList::contentsMouseMoveEvent(QMouseEvent* e)
-{
- //QPoint p(contentsToViewport(e->pos()));
- //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
- Parent::contentsMouseMoveEvent(e);
-}
-
-void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
-{
- QPoint p(contentsToViewport(e->pos()));
- ConfigItem* item = (ConfigItem*)itemAt(p);
- struct menu *menu;
- enum prop_type ptype;
-
- if (!item)
- goto skip;
- if (item->goParent) {
- emit parentSelected();
- goto skip;
- }
- menu = item->menu;
- if (!menu)
- goto skip;
- ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
- if (ptype == P_MENU && (mode == singleMode || mode == symbolMode))
- emit menuSelected(menu);
- else if (menu->sym)
- changeValue(item);
-
-skip:
- //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
- Parent::contentsMouseDoubleClickEvent(e);
-}
-
-void ConfigList::focusInEvent(QFocusEvent *e)
-{
- struct menu *menu = NULL;
-
- Parent::focusInEvent(e);
-
- ConfigItem* item = (ConfigItem *)currentItem();
- if (item) {
- setSelected(item, TRUE);
- menu = item->menu;
- }
- emit gotFocus(menu);
-}
-
-void ConfigList::contextMenuEvent(QContextMenuEvent *e)
-{
- if (e->y() <= header()->geometry().bottom()) {
- if (!headerPopup) {
- Q3Action *action;
-
- headerPopup = new Q3PopupMenu(this);
- action = new Q3Action(NULL, _("Show Name"), 0, this);
- action->setToggleAction(TRUE);
- connect(action, SIGNAL(toggled(bool)),
- parent(), SLOT(setShowName(bool)));
- connect(parent(), SIGNAL(showNameChanged(bool)),
- action, SLOT(setOn(bool)));
- action->setOn(showName);
- action->addTo(headerPopup);
- action = new Q3Action(NULL, _("Show Range"), 0, this);
- action->setToggleAction(TRUE);
- connect(action, SIGNAL(toggled(bool)),
- parent(), SLOT(setShowRange(bool)));
- connect(parent(), SIGNAL(showRangeChanged(bool)),
- action, SLOT(setOn(bool)));
- action->setOn(showRange);
- action->addTo(headerPopup);
- action = new Q3Action(NULL, _("Show Data"), 0, this);
- action->setToggleAction(TRUE);
- connect(action, SIGNAL(toggled(bool)),
- parent(), SLOT(setShowData(bool)));
- connect(parent(), SIGNAL(showDataChanged(bool)),
- action, SLOT(setOn(bool)));
- action->setOn(showData);
- action->addTo(headerPopup);
- }
- headerPopup->exec(e->globalPos());
- e->accept();
- } else
- e->ignore();
-}
-
-ConfigView*ConfigView::viewList;
-QAction *ConfigView::showNormalAction;
-QAction *ConfigView::showAllAction;
-QAction *ConfigView::showPromptAction;
-
-ConfigView::ConfigView(QWidget* parent, const char *name)
- : Parent(parent, name)
-{
- list = new ConfigList(this, name);
- lineEdit = new ConfigLineEdit(this);
- lineEdit->hide();
-
- this->nextView = viewList;
- viewList = this;
-}
-
-ConfigView::~ConfigView(void)
-{
- ConfigView** vp;
-
- for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
- if (*vp == this) {
- *vp = nextView;
- break;
- }
- }
-}
-
-void ConfigView::setOptionMode(QAction *act)
-{
- if (act == showNormalAction)
- list->optMode = normalOpt;
- else if (act == showAllAction)
- list->optMode = allOpt;
- else
- list->optMode = promptOpt;
-
- list->updateListAll();
-}
-
-void ConfigView::setShowName(bool b)
-{
- if (list->showName != b) {
- list->showName = b;
- list->reinit();
- emit showNameChanged(b);
- }
-}
-
-void ConfigView::setShowRange(bool b)
-{
- if (list->showRange != b) {
- list->showRange = b;
- list->reinit();
- emit showRangeChanged(b);
- }
-}
-
-void ConfigView::setShowData(bool b)
-{
- if (list->showData != b) {
- list->showData = b;
- list->reinit();
- emit showDataChanged(b);
- }
-}
-
-void ConfigList::setAllOpen(bool open)
-{
- Q3ListViewItemIterator it(this);
-
- for (; it.current(); it++)
- it.current()->setOpen(open);
-}
-
-void ConfigView::updateList(ConfigItem* item)
-{
- ConfigView* v;
-
- for (v = viewList; v; v = v->nextView)
- v->list->updateList(item);
-}
-
-void ConfigView::updateListAll(void)
-{
- ConfigView* v;
-
- for (v = viewList; v; v = v->nextView)
- v->list->updateListAll();
-}
-
-ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
- : Parent(parent, name), sym(0), _menu(0)
-{
- if (name) {
- configSettings->beginGroup(name);
- _showDebug = configSettings->readBoolEntry("/showDebug", false);
- configSettings->endGroup();
- connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
- }
-}
-
-void ConfigInfoView::saveSettings(void)
-{
- if (name()) {
- configSettings->beginGroup(name());
- configSettings->writeEntry("/showDebug", showDebug());
- configSettings->endGroup();
- }
-}
-
-void ConfigInfoView::setShowDebug(bool b)
-{
- if (_showDebug != b) {
- _showDebug = b;
- if (_menu)
- menuInfo();
- else if (sym)
- symbolInfo();
- emit showDebugChanged(b);
- }
-}
-
-void ConfigInfoView::setInfo(struct menu *m)
-{
- if (_menu == m)
- return;
- _menu = m;
- sym = NULL;
- if (!_menu)
- clear();
- else
- menuInfo();
-}
-
-void ConfigInfoView::symbolInfo(void)
-{
- QString str;
-
- str += "<big>Symbol: <b>";
- str += print_filter(sym->name);
- str += "</b></big><br><br>value: ";
- str += print_filter(sym_get_string_value(sym));
- str += "<br>visibility: ";
- str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n";
- str += "<br>";
- str += debug_info(sym);
-
- setText(str);
-}
-
-void ConfigInfoView::menuInfo(void)
-{
- struct symbol* sym;
- QString head, debug, help;
-
- sym = _menu->sym;
- if (sym) {
- if (_menu->prompt) {
- head += "<big><b>";
- head += print_filter(_(_menu->prompt->text));
- head += "</b></big>";
- if (sym->name) {
- head += " (";
- if (showDebug())
- head += QString().sprintf("<a href=\"s%p\">", sym);
- head += print_filter(sym->name);
- if (showDebug())
- head += "</a>";
- head += ")";
- }
- } else if (sym->name) {
- head += "<big><b>";
- if (showDebug())
- head += QString().sprintf("<a href=\"s%p\">", sym);
- head += print_filter(sym->name);
- if (showDebug())
- head += "</a>";
- head += "</b></big>";
- }
- head += "<br><br>";
-
- if (showDebug())
- debug = debug_info(sym);
-
- struct gstr help_gstr = str_new();
- menu_get_ext_help(_menu, &help_gstr);
- help = print_filter(str_get(&help_gstr));
- str_free(&help_gstr);
- } else if (_menu->prompt) {
- head += "<big><b>";
- head += print_filter(_(_menu->prompt->text));
- head += "</b></big><br><br>";
- if (showDebug()) {
- if (_menu->prompt->visible.expr) {
- debug += " dep: ";
- expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
- debug += "<br><br>";
- }
- }
- }
- if (showDebug())
- debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
-
- setText(head + debug + help);
-}
-
-QString ConfigInfoView::debug_info(struct symbol *sym)
-{
- QString debug;
-
- debug += "type: ";
- debug += print_filter(sym_type_name(sym->type));
- if (sym_is_choice(sym))
- debug += " (choice)";
- debug += "<br>";
- if (sym->rev_dep.expr) {
- debug += "reverse dep: ";
- expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
- debug += "<br>";
- }
- for (struct property *prop = sym->prop; prop; prop = prop->next) {
- switch (prop->type) {
- case P_PROMPT:
- case P_MENU:
- debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
- debug += print_filter(_(prop->text));
- debug += "</a><br>";
- break;
- case P_DEFAULT:
- case P_SELECT:
- case P_RANGE:
- case P_ENV:
- debug += prop_get_type_name(prop->type);
- debug += ": ";
- expr_print(prop->expr, expr_print_help, &debug, E_NONE);
- debug += "<br>";
- break;
- case P_CHOICE:
- if (sym_is_choice(sym)) {
- debug += "choice: ";
- expr_print(prop->expr, expr_print_help, &debug, E_NONE);
- debug += "<br>";
- }
- break;
- default:
- debug += "unknown property: ";
- debug += prop_get_type_name(prop->type);
- debug += "<br>";
- }
- if (prop->visible.expr) {
- debug += " dep: ";
- expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
- debug += "<br>";
- }
- }
- debug += "<br>";
-
- return debug;
-}
-
-QString ConfigInfoView::print_filter(const QString &str)
-{
- QRegExp re("[<>&\"\\n]");
- QString res = str;
- for (int i = 0; (i = res.find(re, i)) >= 0;) {
- switch (res[i].latin1()) {
- case '<':
- res.replace(i, 1, "<");
- i += 4;
- break;
- case '>':
- res.replace(i, 1, ">");
- i += 4;
- break;
- case '&':
- res.replace(i, 1, "&");
- i += 5;
- break;
- case '"':
- res.replace(i, 1, """);
- i += 6;
- break;
- case '\n':
- res.replace(i, 1, "<br>");
- i += 4;
- break;
- }
- }
- return res;
-}
-
-void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
-{
- QString* text = reinterpret_cast<QString*>(data);
- QString str2 = print_filter(str);
-
- if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
- *text += QString().sprintf("<a href=\"s%p\">", sym);
- *text += str2;
- *text += "</a>";
- } else
- *text += str2;
-}
-
-Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
-{
- Q3PopupMenu* popup = Parent::createPopupMenu(pos);
- Q3Action* action = new Q3Action(NULL, _("Show Debug Info"), 0, popup);
- action->setToggleAction(TRUE);
- connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
- connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
- action->setOn(showDebug());
- popup->insertSeparator();
- action->addTo(popup);
- return popup;
-}
-
-void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e)
-{
- Parent::contentsContextMenuEvent(e);
-}
-
-ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
- : Parent(parent, name), result(NULL)
-{
- setCaption("Search Config");
-
- QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6);
- QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6);
- layout2->addWidget(new QLabel(_("Find:"), this));
- editField = new QLineEdit(this);
- connect(editField, SIGNAL(returnPressed()), SLOT(search()));
- layout2->addWidget(editField);
- searchButton = new QPushButton(_("Search"), this);
- searchButton->setAutoDefault(FALSE);
- connect(searchButton, SIGNAL(clicked()), SLOT(search()));
- layout2->addWidget(searchButton);
- layout1->addLayout(layout2);
-
- split = new QSplitter(this);
- split->setOrientation(Qt::Vertical);
- list = new ConfigView(split, name);
- list->list->mode = listMode;
- info = new ConfigInfoView(split, name);
- connect(list->list, SIGNAL(menuChanged(struct menu *)),
- info, SLOT(setInfo(struct menu *)));
- connect(list->list, SIGNAL(menuChanged(struct menu *)),
- parent, SLOT(setMenuLink(struct menu *)));
-
- layout1->addWidget(split);
-
- if (name) {
- int x, y, width, height;
- bool ok;
-
- configSettings->beginGroup(name);
- width = configSettings->readNumEntry("/window width", parent->width() / 2);
- height = configSettings->readNumEntry("/window height", parent->height() / 2);
- resize(width, height);
- x = configSettings->readNumEntry("/window x", 0, &ok);
- if (ok)
- y = configSettings->readNumEntry("/window y", 0, &ok);
- if (ok)
- move(x, y);
- Q3ValueList<int> sizes = configSettings->readSizes("/split", &ok);
- if (ok)
- split->setSizes(sizes);
- configSettings->endGroup();
- connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
- }
-}
-
-void ConfigSearchWindow::saveSettings(void)
-{
- if (name()) {
- configSettings->beginGroup(name());
- configSettings->writeEntry("/window x", pos().x());
- configSettings->writeEntry("/window y", pos().y());
- configSettings->writeEntry("/window width", size().width());
- configSettings->writeEntry("/window height", size().height());
- configSettings->writeSizes("/split", split->sizes());
- configSettings->endGroup();
- }
-}
-
-void ConfigSearchWindow::search(void)
-{
- struct symbol **p;
- struct property *prop;
- ConfigItem *lastItem = NULL;
-
- free(result);
- list->list->clear();
- info->clear();
-
- result = sym_re_search(editField->text().latin1());
- if (!result)
- return;
- for (p = result; *p; p++) {
- for_all_prompts((*p), prop)
- lastItem = new ConfigItem(list->list, lastItem, prop->menu,
- menu_is_visible(prop->menu));
- }
-}
-
-/*
- * Construct the complete config widget
- */
-ConfigMainWindow::ConfigMainWindow(void)
- : searchWindow(0)
-{
- QMenuBar* menu;
- bool ok;
- int x, y, width, height;
- char title[256];
-
- QDesktopWidget *d = configApp->desktop();
- snprintf(title, sizeof(title), "%s%s",
- rootmenu.prompt->text,
- ""
- );
- setCaption(title);
-
- width = configSettings->readNumEntry("/window width", d->width() - 64);
- height = configSettings->readNumEntry("/window height", d->height() - 64);
- resize(width, height);
- x = configSettings->readNumEntry("/window x", 0, &ok);
- if (ok)
- y = configSettings->readNumEntry("/window y", 0, &ok);
- if (ok)
- move(x, y);
-
- split1 = new QSplitter(this);
- split1->setOrientation(Qt::Horizontal);
- setCentralWidget(split1);
-
- menuView = new ConfigView(split1, "menu");
- menuList = menuView->list;
-
- split2 = new QSplitter(split1);
- split2->setOrientation(Qt::Vertical);
-
- // create config tree
- configView = new ConfigView(split2, "config");
- configList = configView->list;
-
- helpText = new ConfigInfoView(split2, "help");
- helpText->setTextFormat(Qt::RichText);
-
- setTabOrder(configList, helpText);
- configList->setFocus();
-
- menu = menuBar();
- toolBar = new Q3ToolBar("Tools", this);
-
- backAction = new Q3Action("Back", QPixmap(xpm_back), _("Back"), 0, this);
- connect(backAction, SIGNAL(activated()), SLOT(goBack()));
- backAction->setEnabled(FALSE);
- Q3Action *quitAction = new Q3Action("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this);
- connect(quitAction, SIGNAL(activated()), SLOT(close()));
- Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this);
- connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
- saveAction = new Q3Action("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this);
- connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
- conf_set_changed_callback(conf_changed);
- // Set saveAction's initial state
- conf_changed();
- Q3Action *saveAsAction = new Q3Action("Save As...", _("Save &As..."), 0, this);
- connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
- Q3Action *searchAction = new Q3Action("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this);
- connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
- Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
- connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
- Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
- connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
- Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
- connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
-
- Q3Action *showNameAction = new Q3Action(NULL, _("Show Name"), 0, this);
- showNameAction->setToggleAction(TRUE);
- connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
- connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
- showNameAction->setOn(configView->showName());
- Q3Action *showRangeAction = new Q3Action(NULL, _("Show Range"), 0, this);
- showRangeAction->setToggleAction(TRUE);
- connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
- connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
- showRangeAction->setOn(configList->showRange);
- Q3Action *showDataAction = new Q3Action(NULL, _("Show Data"), 0, this);
- showDataAction->setToggleAction(TRUE);
- connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
- connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
- showDataAction->setOn(configList->showData);
-
- QActionGroup *optGroup = new QActionGroup(this);
- optGroup->setExclusive(TRUE);
- connect(optGroup, SIGNAL(selected(QAction *)), configView,
- SLOT(setOptionMode(QAction *)));
- connect(optGroup, SIGNAL(selected(QAction *)), menuView,
- SLOT(setOptionMode(QAction *)));
-
- configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup);
- configView->showAllAction = new QAction(_("Show All Options"), optGroup);
- configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup);
- configView->showNormalAction->setToggleAction(TRUE);
- configView->showNormalAction->setOn(configList->optMode == normalOpt);
- configView->showAllAction->setToggleAction(TRUE);
- configView->showAllAction->setOn(configList->optMode == allOpt);
- configView->showPromptAction->setToggleAction(TRUE);
- configView->showPromptAction->setOn(configList->optMode == promptOpt);
-
- Q3Action *showDebugAction = new Q3Action(NULL, _("Show Debug Info"), 0, this);
- showDebugAction->setToggleAction(TRUE);
- connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
- connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
- showDebugAction->setOn(helpText->showDebug());
-
- Q3Action *showIntroAction = new Q3Action(NULL, _("Introduction"), 0, this);
- connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
- Q3Action *showAboutAction = new Q3Action(NULL, _("About"), 0, this);
- connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
-
- // init tool bar
- backAction->addTo(toolBar);
- toolBar->addSeparator();
- loadAction->addTo(toolBar);
- saveAction->addTo(toolBar);
- toolBar->addSeparator();
- singleViewAction->addTo(toolBar);
- splitViewAction->addTo(toolBar);
- fullViewAction->addTo(toolBar);
-
- // create config menu
- Q3PopupMenu* config = new Q3PopupMenu(this);
- menu->insertItem(_("&File"), config);
- loadAction->addTo(config);
- saveAction->addTo(config);
- saveAsAction->addTo(config);
- config->insertSeparator();
- quitAction->addTo(config);
-
- // create edit menu
- Q3PopupMenu* editMenu = new Q3PopupMenu(this);
- menu->insertItem(_("&Edit"), editMenu);
- searchAction->addTo(editMenu);
-
- // create options menu
- Q3PopupMenu* optionMenu = new Q3PopupMenu(this);
- menu->insertItem(_("&Option"), optionMenu);
- showNameAction->addTo(optionMenu);
- showRangeAction->addTo(optionMenu);
- showDataAction->addTo(optionMenu);
- optionMenu->insertSeparator();
- optGroup->addTo(optionMenu);
- optionMenu->insertSeparator();
-
- // create help menu
- Q3PopupMenu* helpMenu = new Q3PopupMenu(this);
- menu->insertSeparator();
- menu->insertItem(_("&Help"), helpMenu);
- showIntroAction->addTo(helpMenu);
- showAboutAction->addTo(helpMenu);
-
- connect(configList, SIGNAL(menuChanged(struct menu *)),
- helpText, SLOT(setInfo(struct menu *)));
- connect(configList, SIGNAL(menuSelected(struct menu *)),
- SLOT(changeMenu(struct menu *)));
- connect(configList, SIGNAL(parentSelected()),
- SLOT(goBack()));
- connect(menuList, SIGNAL(menuChanged(struct menu *)),
- helpText, SLOT(setInfo(struct menu *)));
- connect(menuList, SIGNAL(menuSelected(struct menu *)),
- SLOT(changeMenu(struct menu *)));
-
- connect(configList, SIGNAL(gotFocus(struct menu *)),
- helpText, SLOT(setInfo(struct menu *)));
- connect(menuList, SIGNAL(gotFocus(struct menu *)),
- helpText, SLOT(setInfo(struct menu *)));
- connect(menuList, SIGNAL(gotFocus(struct menu *)),
- SLOT(listFocusChanged(void)));
- connect(helpText, SIGNAL(menuSelected(struct menu *)),
- SLOT(setMenuLink(struct menu *)));
-
- QString listMode = configSettings->readEntry("/listMode", "symbol");
- if (listMode == "single")
- showSingleView();
- else if (listMode == "full")
- showFullView();
- else /*if (listMode == "split")*/
- showSplitView();
-
- // UI setup done, restore splitter positions
- Q3ValueList<int> sizes = configSettings->readSizes("/split1", &ok);
- if (ok)
- split1->setSizes(sizes);
-
- sizes = configSettings->readSizes("/split2", &ok);
- if (ok)
- split2->setSizes(sizes);
-}
-
-void ConfigMainWindow::loadConfig(void)
-{
- QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this);
- if (s.isNull())
- return;
- if (conf_read(QFile::encodeName(s)))
- QMessageBox::information(this, "qconf", _("Unable to load configuration!"));
- ConfigView::updateListAll();
-}
-
-bool ConfigMainWindow::saveConfig(void)
-{
- if (conf_write(NULL)) {
- QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
- return false;
- }
- return true;
-}
-
-void ConfigMainWindow::saveConfigAs(void)
-{
- QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this);
- if (s.isNull())
- return;
- saveConfig();
-}
-
-void ConfigMainWindow::searchConfig(void)
-{
- if (!searchWindow)
- searchWindow = new ConfigSearchWindow(this, "search");
- searchWindow->show();
-}
-
-void ConfigMainWindow::changeMenu(struct menu *menu)
-{
- configList->setRootMenu(menu);
- if (configList->rootEntry->parent == &rootmenu)
- backAction->setEnabled(FALSE);
- else
- backAction->setEnabled(TRUE);
-}
-
-void ConfigMainWindow::setMenuLink(struct menu *menu)
-{
- struct menu *parent;
- ConfigList* list = NULL;
- ConfigItem* item;
-
- if (configList->menuSkip(menu))
- return;
-
- switch (configList->mode) {
- case singleMode:
- list = configList;
- parent = menu_get_parent_menu(menu);
- if (!parent)
- return;
- list->setRootMenu(parent);
- break;
- case symbolMode:
- if (menu->flags & MENU_ROOT) {
- configList->setRootMenu(menu);
- configList->clearSelection();
- list = menuList;
- } else {
- list = configList;
- parent = menu_get_parent_menu(menu->parent);
- if (!parent)
- return;
- item = menuList->findConfigItem(parent);
- if (item) {
- menuList->setSelected(item, TRUE);
- menuList->ensureItemVisible(item);
- }
- list->setRootMenu(parent);
- }
- break;
- case fullMode:
- list = configList;
- break;
- default:
- break;
- }
-
- if (list) {
- item = list->findConfigItem(menu);
- if (item) {
- list->setSelected(item, TRUE);
- list->ensureItemVisible(item);
- list->setFocus();
- }
- }
-}
-
-void ConfigMainWindow::listFocusChanged(void)
-{
- if (menuList->mode == menuMode)
- configList->clearSelection();
-}
-
-void ConfigMainWindow::goBack(void)
-{
- ConfigItem* item;
-
- configList->setParentMenu();
- if (configList->rootEntry == &rootmenu)
- backAction->setEnabled(FALSE);
- item = (ConfigItem*)menuList->selectedItem();
- while (item) {
- if (item->menu == configList->rootEntry) {
- menuList->setSelected(item, TRUE);
- break;
- }
- item = (ConfigItem*)item->parent();
- }
-}
-
-void ConfigMainWindow::showSingleView(void)
-{
- menuView->hide();
- menuList->setRootMenu(0);
- configList->mode = singleMode;
- if (configList->rootEntry == &rootmenu)
- configList->updateListAll();
- else
- configList->setRootMenu(&rootmenu);
- configList->setAllOpen(TRUE);
- configList->setFocus();
-}
-
-void ConfigMainWindow::showSplitView(void)
-{
- configList->mode = symbolMode;
- if (configList->rootEntry == &rootmenu)
- configList->updateListAll();
- else
- configList->setRootMenu(&rootmenu);
- configList->setAllOpen(TRUE);
- configApp->processEvents();
- menuList->mode = menuMode;
- menuList->setRootMenu(&rootmenu);
- menuList->setAllOpen(TRUE);
- menuView->show();
- menuList->setFocus();
-}
-
-void ConfigMainWindow::showFullView(void)
-{
- menuView->hide();
- menuList->setRootMenu(0);
- configList->mode = fullMode;
- if (configList->rootEntry == &rootmenu)
- configList->updateListAll();
- else
- configList->setRootMenu(&rootmenu);
- configList->setAllOpen(FALSE);
- configList->setFocus();
-}
-
-/*
- * ask for saving configuration before quitting
- * TODO ask only when something changed
- */
-void ConfigMainWindow::closeEvent(QCloseEvent* e)
-{
- if (!conf_get_changed()) {
- e->accept();
- return;
- }
- QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning,
- QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
- mb.setButtonText(QMessageBox::Yes, _("&Save Changes"));
- mb.setButtonText(QMessageBox::No, _("&Discard Changes"));
- mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
- switch (mb.exec()) {
- case QMessageBox::Yes:
- if (saveConfig())
- e->accept();
- else
- e->ignore();
- break;
- case QMessageBox::No:
- e->accept();
- break;
- case QMessageBox::Cancel:
- e->ignore();
- break;
- }
-}
-
-void ConfigMainWindow::showIntro(void)
-{
- static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n"
- "For each option, a blank box indicates the feature is disabled, a check\n"
- "indicates it is enabled, and a dot indicates that it is to be compiled\n"
- "as a module. Clicking on the box will cycle through the three states.\n\n"
- "If you do not see an option (e.g., a device driver) that you believe\n"
- "should be present, try turning on Show All Options under the Options menu.\n"
- "Although there is no cross reference yet to help you figure out what other\n"
- "options must be enabled to support the option you are interested in, you can\n"
- "still view the help of a grayed-out option.\n\n"
- "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
- "which you can then match by examining other options.\n\n");
-
- QMessageBox::information(this, "qconf", str);
-}
-
-void ConfigMainWindow::showAbout(void)
-{
- static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
- "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n");
-
- QMessageBox::information(this, "qconf", str);
-}
-
-void ConfigMainWindow::saveSettings(void)
-{
- configSettings->writeEntry("/window x", pos().x());
- configSettings->writeEntry("/window y", pos().y());
- configSettings->writeEntry("/window width", size().width());
- configSettings->writeEntry("/window height", size().height());
-
- QString entry;
- switch(configList->mode) {
- case singleMode :
- entry = "single";
- break;
-
- case symbolMode :
- entry = "split";
- break;
-
- case fullMode :
- entry = "full";
- break;
-
- default:
- break;
- }
- configSettings->writeEntry("/listMode", entry);
-
- configSettings->writeSizes("/split1", split1->sizes());
- configSettings->writeSizes("/split2", split2->sizes());
-}
-
-void ConfigMainWindow::conf_changed(void)
-{
- if (saveAction)
- saveAction->setEnabled(conf_get_changed());
-}
-
-void fixup_rootmenu(struct menu *menu)
-{
- struct menu *child;
- static int menu_cnt = 0;
-
- menu->flags |= MENU_ROOT;
- for (child = menu->list; child; child = child->next) {
- if (child->prompt && child->prompt->type == P_MENU) {
- menu_cnt++;
- fixup_rootmenu(child);
- menu_cnt--;
- } else if (!menu_cnt)
- fixup_rootmenu(child);
- }
-}
-
-static const char *progname;
-
-static void usage(void)
-{
- printf(_("%s <config>\n"), progname);
- exit(0);
-}
-
-int main(int ac, char** av)
-{
- ConfigMainWindow* v;
- const char *name;
-
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- progname = av[0];
- configApp = new QApplication(ac, av);
- if (ac > 1 && av[1][0] == '-') {
- switch (av[1][1]) {
- case 'h':
- case '?':
- usage();
- }
- name = av[2];
- } else
- name = av[1];
- if (!name)
- usage();
-
- conf_parse(name);
- fixup_rootmenu(&rootmenu);
- conf_read(NULL);
- //zconfdump(stdout);
-
- configSettings = new ConfigSettings();
- configSettings->beginGroup("/kconfig/qconf");
- v = new ConfigMainWindow();
-
- //zconfdump(stdout);
- configApp->setMainWidget(v);
- configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
- configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
- v->show();
- configApp->exec();
-
- configSettings->endGroup();
- delete configSettings;
-
- return 0;
-}
diff --git a/scripts/kconfig/qconfig/qconf.cpp b/scripts/kconfig/qconfig/qconf.cpp
new file mode 100644
index 0000000..43634fd
--- /dev/null
+++ b/scripts/kconfig/qconfig/qconf.cpp
@@ -0,0 +1,1768 @@
+/*
+ * Copyright (C) 2013 David Graeff <david.graeff@udo.edu>
+ * Based on Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
+ * Released under the terms of the GNU GPL v2.0.
+ */
+
+#include <qglobal.h>
+
+#include <q3mainwindow.h>
+#include <q3vbox.h>
+#include <q3valuelist.h>
+#include <q3textbrowser.h>
+#include <q3action.h>
+#include <q3header.h>
+#include <q3filedialog.h>
+#include <q3dragobject.h>
+#include <q3popupmenu.h>
+
+#include <qapplication.h>
+#include <qdesktopwidget.h>
+#include <qtoolbar.h>
+#include <qlayout.h>
+#include <qsplitter.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qmenubar.h>
+#include <qmessagebox.h>
+#include <qregexp.h>
+#include <qevent.h>
+
+#include <stdlib.h>
+
+#include "qconf.h"
+#include "qconf.moc"
+
+#include "../lkc.h"
+#include "../images.c"
+
+#ifdef _
+# undef _
+# define _ qgettext
+#endif
+
+static QApplication *configApp;
+static ConfigSettings *configSettings;
+
+Q3Action *ConfigMainWindow::saveAction;
+
+static inline QString qgettext(const char* str)
+{
+ return QString::fromLocal8Bit(gettext(str));
+}
+
+static inline QString qgettext(const QString& str)
+{
+ return QString::fromLocal8Bit(gettext(str.latin1()));
+}
+
+/**
+ * Reads a list of integer values from the application settings.
+ */
+Q3ValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
+{
+ Q3ValueList<int> result;
+ QStringList entryList = readListEntry(key, ok);
+ QStringList::Iterator it;
+
+ for (it = entryList.begin(); it != entryList.end(); ++it)
+ result.push_back((*it).toInt());
+
+ return result;
+}
+
+/**
+ * Writes a list of integer values to the application settings.
+ */
+bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList<int>& value)
+{
+ QStringList stringList;
+ Q3ValueList<int>::ConstIterator it;
+
+ for (it = value.begin(); it != value.end(); ++it)
+ stringList.push_back(QString::number(*it));
+ return writeEntry(key, stringList);
+}
+
+
+/*
+ * set the new data
+ * TODO check the value
+ */
+void ConfigItem::okRename(int col)
+{
+ Parent::okRename(col);
+ sym_set_string_value(menu->sym, text(dataColIdx).latin1());
+ listView()->updateList(this);
+}
+
+/*
+ * update the displayed of a menu entry
+ */
+void ConfigItem::updateMenu(void)
+{
+ ConfigList* list;
+ struct symbol* sym;
+ struct property *prop;
+ QString prompt;
+ int type;
+ tristate expr;
+
+ list = listView();
+ if (goParent) {
+ setPixmap(promptColIdx, list->menuBackPix);
+ prompt = "..";
+ goto set_prompt;
+ }
+
+ sym = menu->sym;
+ prop = menu->prompt;
+ prompt = _(menu_get_prompt(menu));
+
+ if (prop) switch (prop->type) {
+ case P_MENU:
+ if (list->mode == singleMode || list->mode == symbolMode) {
+ /* a menuconfig entry is displayed differently
+ * depending whether it's at the view root or a child.
+ */
+ if (sym && list->rootEntry == menu)
+ break;
+ setPixmap(promptColIdx, list->menuPix);
+ } else {
+ if (sym)
+ break;
+ setPixmap(promptColIdx, 0);
+ }
+ goto set_prompt;
+ case P_COMMENT:
+ setPixmap(promptColIdx, 0);
+ goto set_prompt;
+ default:
+ ;
+ }
+ if (!sym)
+ goto set_prompt;
+
+ setText(nameColIdx, QString::fromLocal8Bit(sym->name));
+
+ type = sym_get_type(sym);
+ switch (type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ char ch;
+
+ if (!sym_is_changable(sym) && list->optMode == normalOpt) {
+ setPixmap(promptColIdx, 0);
+ setText(noColIdx, QString::null);
+ setText(modColIdx, QString::null);
+ setText(yesColIdx, QString::null);
+ break;
+ }
+ expr = sym_get_tristate_value(sym);
+ switch (expr) {
+ case yes:
+ if (sym_is_choice_value(sym) && type == S_BOOLEAN)
+ setPixmap(promptColIdx, list->choiceYesPix);
+ else
+ setPixmap(promptColIdx, list->symbolYesPix);
+ setText(yesColIdx, "Y");
+ ch = 'Y';
+ break;
+ case mod:
+ setPixmap(promptColIdx, list->symbolModPix);
+ setText(modColIdx, "M");
+ ch = 'M';
+ break;
+ default:
+ if (sym_is_choice_value(sym) && type == S_BOOLEAN)
+ setPixmap(promptColIdx, list->choiceNoPix);
+ else
+ setPixmap(promptColIdx, list->symbolNoPix);
+ setText(noColIdx, "N");
+ ch = 'N';
+ break;
+ }
+ if (expr != no)
+ setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0);
+ if (expr != mod)
+ setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0);
+ if (expr != yes)
+ setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0);
+
+ setText(dataColIdx, QChar(ch));
+ break;
+ case S_INT:
+ case S_HEX:
+ case S_STRING:
+ const char* data;
+
+ data = sym_get_string_value(sym);
+
+ int i = list->mapIdx(dataColIdx);
+ if (i >= 0)
+ setRenameEnabled(i, TRUE);
+ setText(dataColIdx, data);
+ if (type == S_STRING)
+ prompt = QString("%1: %2").arg(prompt).arg(data);
+ else
+ prompt = QString("(%2) %1").arg(prompt).arg(data);
+ break;
+ }
+ if (!sym_has_value(sym) && visible)
+ prompt += _(" (NEW)");
+set_prompt:
+ setText(promptColIdx, prompt);
+}
+
+void ConfigItem::testUpdateMenu(bool v)
+{
+ ConfigItem* i;
+
+ visible = v;
+ if (!menu)
+ return;
+
+ sym_calc_value(menu->sym);
+ if (menu->flags & MENU_CHANGED) {
+ /* the menu entry changed, so update all list items */
+ menu->flags &= ~MENU_CHANGED;
+ for (i = (ConfigItem*)menu->data; i; i = i->nextItem)
+ i->updateMenu();
+ } else if (listView()->updateAll)
+ updateMenu();
+}
+
+void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align)
+{
+ ConfigList* list = listView();
+
+ if (visible) {
+ if (isSelected() && !list->hasFocus() && list->mode == menuMode)
+ Parent::paintCell(p, list->inactivedColorGroup, column, width, align);
+ else
+ Parent::paintCell(p, cg, column, width, align);
+ } else
+ Parent::paintCell(p, list->disabledColorGroup, column, width, align);
+}
+
+/*
+ * construct a menu entry
+ */
+void ConfigItem::init(void)
+{
+ if (menu) {
+ ConfigList* list = listView();
+ nextItem = (ConfigItem*)menu->data;
+ menu->data = this;
+
+ if (list->mode != fullMode)
+ setOpen(TRUE);
+ sym_calc_value(menu->sym);
+ }
+ updateMenu();
+}
+
+/*
+ * destruct a menu entry
+ */
+ConfigItem::~ConfigItem(void)
+{
+ if (menu) {
+ ConfigItem** ip = (ConfigItem**)&menu->data;
+ for (; *ip; ip = &(*ip)->nextItem) {
+ if (*ip == this) {
+ *ip = nextItem;
+ break;
+ }
+ }
+ }
+}
+
+ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
+ : Parent(parent)
+{
+ connect(this, SIGNAL(lostFocus()), SLOT(hide()));
+}
+
+void ConfigLineEdit::show(ConfigItem* i)
+{
+ item = i;
+ if (sym_get_string_value(item->menu->sym))
+ setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym)));
+ else
+ setText(QString::null);
+ Parent::show();
+ setFocus();
+}
+
+void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
+{
+ switch (e->key()) {
+ case Qt::Key_Escape:
+ break;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ sym_set_string_value(item->menu->sym, text().latin1());
+ parent()->updateList(item);
+ break;
+ default:
+ Parent::keyPressEvent(e);
+ return;
+ }
+ e->accept();
+ parent()->list->setFocus();
+ hide();
+}
+
+ConfigList::ConfigList(ConfigView* p, const char *name)
+ : Parent(p, name),
+ updateAll(false),
+ symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
+ choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
+ menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
+ showName(false), showRange(false), showData(false), optMode(normalOpt),
+ rootEntry(0), headerPopup(0)
+{
+ int i;
+
+ setSorting(-1);
+ setRootIsDecorated(TRUE);
+ disabledColorGroup = palette().active();
+ disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text());
+ inactivedColorGroup = palette().active();
+ inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight());
+
+ connect(this, SIGNAL(selectionChanged(void)),
+ SLOT(updateSelection(void)));
+
+ if (name) {
+ configSettings->beginGroup(name);
+ showName = configSettings->readBoolEntry("/showName", false);
+ showRange = configSettings->readBoolEntry("/showRange", false);
+ showData = configSettings->readBoolEntry("/showData", false);
+ optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false);
+ configSettings->endGroup();
+ connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
+ }
+
+ for (i = 0; i < colNr; i++)
+ colMap[i] = colRevMap[i] = -1;
+ addColumn(promptColIdx, _("Option"));
+
+ reinit();
+}
+
+bool ConfigList::menuSkip(struct menu *menu)
+{
+ if (optMode == normalOpt && menu_is_visible(menu))
+ return false;
+ if (optMode == promptOpt && menu_has_prompt(menu))
+ return false;
+ if (optMode == allOpt)
+ return false;
+ return true;
+}
+
+void ConfigList::reinit(void)
+{
+ removeColumn(dataColIdx);
+ removeColumn(yesColIdx);
+ removeColumn(modColIdx);
+ removeColumn(noColIdx);
+ removeColumn(nameColIdx);
+
+ if (showName)
+ addColumn(nameColIdx, _("Name"));
+ if (showRange) {
+ addColumn(noColIdx, "N");
+ addColumn(modColIdx, "M");
+ addColumn(yesColIdx, "Y");
+ }
+ if (showData)
+ addColumn(dataColIdx, _("Value"));
+
+ updateListAll();
+}
+
+void ConfigList::saveSettings(void)
+{
+ if (name()) {
+ configSettings->beginGroup(name());
+ configSettings->writeEntry("/showName", showName);
+ configSettings->writeEntry("/showRange", showRange);
+ configSettings->writeEntry("/showData", showData);
+ configSettings->writeEntry("/optionMode", (int)optMode);
+ configSettings->endGroup();
+ }
+}
+
+ConfigItem* ConfigList::findConfigItem(struct menu *menu)
+{
+ ConfigItem* item = (ConfigItem*)menu->data;
+
+ for (; item; item = item->nextItem) {
+ if (this == item->listView())
+ break;
+ }
+
+ return item;
+}
+
+void ConfigList::updateSelection(void)
+{
+ struct menu *menu;
+ enum prop_type type;
+
+ ConfigItem* item = (ConfigItem*)selectedItem();
+ if (!item)
+ return;
+
+ menu = item->menu;
+ emit menuChanged(menu);
+ if (!menu)
+ return;
+ type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ if (mode == menuMode && type == P_MENU)
+ emit menuSelected(menu);
+}
+
+void ConfigList::updateList(ConfigItem* item)
+{
+ ConfigItem* last = 0;
+
+ if (!rootEntry) {
+ if (mode != listMode)
+ goto update;
+ Q3ListViewItemIterator it(this);
+ ConfigItem* item;
+
+ for (; it.current(); ++it) {
+ item = (ConfigItem*)it.current();
+ if (!item->menu)
+ continue;
+ item->testUpdateMenu(menu_is_visible(item->menu));
+ }
+ return;
+ }
+
+ if (rootEntry != &rootmenu && (mode == singleMode ||
+ (mode == symbolMode && rootEntry->parent != &rootmenu))) {
+ item = firstChild();
+ if (!item)
+ item = new ConfigItem(this, 0, true);
+ last = item;
+ }
+ if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&
+ rootEntry->sym && rootEntry->prompt) {
+ item = last ? last->nextSibling() : firstChild();
+ if (!item)
+ item = new ConfigItem(this, last, rootEntry, true);
+ else
+ item->testUpdateMenu(true);
+
+ updateMenuList(item, rootEntry);
+ triggerUpdate();
+ return;
+ }
+update:
+ updateMenuList(this, rootEntry);
+ triggerUpdate();
+}
+
+void ConfigList::setValue(ConfigItem* item, tristate val)
+{
+ struct symbol* sym;
+ int type;
+ tristate oldval;
+
+ sym = item->menu ? item->menu->sym : 0;
+ if (!sym)
+ return;
+
+ type = sym_get_type(sym);
+ switch (type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ oldval = sym_get_tristate_value(sym);
+
+ if (!sym_set_tristate_value(sym, val))
+ return;
+ if (oldval == no && item->menu->list)
+ item->setOpen(TRUE);
+ parent()->updateList(item);
+ break;
+ }
+}
+
+void ConfigList::changeValue(ConfigItem* item)
+{
+ struct symbol* sym;
+ struct menu* menu;
+ int type, oldexpr, newexpr;
+
+ menu = item->menu;
+ if (!menu)
+ return;
+ sym = menu->sym;
+ if (!sym) {
+ if (item->menu->list)
+ item->setOpen(!item->isOpen());
+ return;
+ }
+
+ type = sym_get_type(sym);
+ switch (type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ oldexpr = sym_get_tristate_value(sym);
+ newexpr = sym_toggle_tristate_value(sym);
+ if (item->menu->list) {
+ if (oldexpr == newexpr)
+ item->setOpen(!item->isOpen());
+ else if (oldexpr == no)
+ item->setOpen(TRUE);
+ }
+ if (oldexpr != newexpr)
+ parent()->updateList(item);
+ break;
+ case S_INT:
+ case S_HEX:
+ case S_STRING:
+ if (colMap[dataColIdx] >= 0)
+ item->startRename(colMap[dataColIdx]);
+ else
+ parent()->lineEdit->show(item);
+ break;
+ }
+}
+
+void ConfigList::setRootMenu(struct menu *menu)
+{
+ enum prop_type type;
+
+ if (rootEntry == menu)
+ return;
+ type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ if (type != P_MENU)
+ return;
+ updateMenuList(this, 0);
+ rootEntry = menu;
+ updateListAll();
+ setSelected(currentItem(), hasFocus());
+ ensureItemVisible(currentItem());
+}
+
+void ConfigList::setParentMenu(void)
+{
+ ConfigItem* item;
+ struct menu *oldroot;
+
+ oldroot = rootEntry;
+ if (rootEntry == &rootmenu)
+ return;
+ setRootMenu(menu_get_parent_menu(rootEntry->parent));
+
+ Q3ListViewItemIterator it(this);
+ for (; (item = (ConfigItem*)it.current()); it++) {
+ if (item->menu == oldroot) {
+ setCurrentItem(item);
+ ensureItemVisible(item);
+ break;
+ }
+ }
+}
+
+/*
+ * update all the children of a menu entry
+ * removes/adds the entries from the parent widget as necessary
+ *
+ * parent: either the menu list widget or a menu entry widget
+ * menu: entry to be updated
+ */
+template <class P>
+void ConfigList::updateMenuList(P* parent, struct menu* menu)
+{
+ struct menu* child;
+ ConfigItem* item;
+ ConfigItem* last;
+ bool visible;
+ enum prop_type type;
+
+ if (!menu) {
+ while ((item = parent->firstChild()))
+ delete item;
+ return;
+ }
+
+ last = parent->firstChild();
+ if (last && !last->goParent)
+ last = 0;
+ for (child = menu->list; child; child = child->next) {
+ item = last ? last->nextSibling() : parent->firstChild();
+ type = child->prompt ? child->prompt->type : P_UNKNOWN;
+
+ switch (mode) {
+ case menuMode:
+ if (!(child->flags & MENU_ROOT))
+ goto hide;
+ break;
+ case symbolMode:
+ if (child->flags & MENU_ROOT)
+ goto hide;
+ break;
+ default:
+ break;
+ }
+
+ visible = menu_is_visible(child);
+ if (!menuSkip(child)) {
+ if (!child->sym && !child->list && !child->prompt)
+ continue;
+ if (!item || item->menu != child)
+ item = new ConfigItem(parent, last, child, visible);
+ else
+ item->testUpdateMenu(visible);
+
+ if (mode == fullMode || mode == menuMode || type != P_MENU)
+ updateMenuList(item, child);
+ else
+ updateMenuList(item, 0);
+ last = item;
+ continue;
+ }
+ hide:
+ if (item && item->menu == child) {
+ last = parent->firstChild();
+ if (last == item)
+ last = 0;
+ else while (last->nextSibling() != item)
+ last = last->nextSibling();
+ delete item;
+ }
+ }
+}
+
+void ConfigList::keyPressEvent(QKeyEvent* ev)
+{
+ Q3ListViewItem* i = currentItem();
+ ConfigItem* item;
+ struct menu *menu;
+ enum prop_type type;
+
+ if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
+ emit parentSelected();
+ ev->accept();
+ return;
+ }
+
+ if (!i) {
+ Parent::keyPressEvent(ev);
+ return;
+ }
+ item = (ConfigItem*)i;
+
+ switch (ev->key()) {
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ if (item->goParent) {
+ emit parentSelected();
+ break;
+ }
+ menu = item->menu;
+ if (!menu)
+ break;
+ type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ if (type == P_MENU && rootEntry != menu &&
+ mode != fullMode && mode != menuMode) {
+ emit menuSelected(menu);
+ break;
+ }
+ case Qt::Key_Space:
+ changeValue(item);
+ break;
+ case Qt::Key_N:
+ setValue(item, no);
+ break;
+ case Qt::Key_M:
+ setValue(item, mod);
+ break;
+ case Qt::Key_Y:
+ setValue(item, yes);
+ break;
+ default:
+ Parent::keyPressEvent(ev);
+ return;
+ }
+ ev->accept();
+}
+
+void ConfigList::contentsMousePressEvent(QMouseEvent* e)
+{
+ //QPoint p(contentsToViewport(e->pos()));
+ //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
+ Parent::contentsMousePressEvent(e);
+}
+
+void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
+{
+ QPoint p(contentsToViewport(e->pos()));
+ ConfigItem* item = (ConfigItem*)itemAt(p);
+ struct menu *menu;
+ enum prop_type ptype;
+ const QPixmap* pm;
+ int idx, x;
+
+ if (!item)
+ goto skip;
+
+ menu = item->menu;
+ x = header()->offset() + p.x();
+ idx = colRevMap[header()->sectionAt(x)];
+ switch (idx) {
+ case promptColIdx:
+ pm = item->pixmap(promptColIdx);
+ if (pm) {
+ int off = header()->sectionPos(0) + itemMargin() +
+ treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0));
+ if (x >= off && x < off + pm->width()) {
+ if (item->goParent) {
+ emit parentSelected();
+ break;
+ } else if (!menu)
+ break;
+ ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ if (ptype == P_MENU && rootEntry != menu &&
+ mode != fullMode && mode != menuMode)
+ emit menuSelected(menu);
+ else
+ changeValue(item);
+ }
+ }
+ break;
+ case noColIdx:
+ setValue(item, no);
+ break;
+ case modColIdx:
+ setValue(item, mod);
+ break;
+ case yesColIdx:
+ setValue(item, yes);
+ break;
+ case dataColIdx:
+ changeValue(item);
+ break;
+ }
+
+skip:
+ //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
+ Parent::contentsMouseReleaseEvent(e);
+}
+
+void ConfigList::contentsMouseMoveEvent(QMouseEvent* e)
+{
+ //QPoint p(contentsToViewport(e->pos()));
+ //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
+ Parent::contentsMouseMoveEvent(e);
+}
+
+void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
+{
+ QPoint p(contentsToViewport(e->pos()));
+ ConfigItem* item = (ConfigItem*)itemAt(p);
+ struct menu *menu;
+ enum prop_type ptype;
+
+ if (!item)
+ goto skip;
+ if (item->goParent) {
+ emit parentSelected();
+ goto skip;
+ }
+ menu = item->menu;
+ if (!menu)
+ goto skip;
+ ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ if (ptype == P_MENU && (mode == singleMode || mode == symbolMode))
+ emit menuSelected(menu);
+ else if (menu->sym)
+ changeValue(item);
+
+skip:
+ //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
+ Parent::contentsMouseDoubleClickEvent(e);
+}
+
+void ConfigList::focusInEvent(QFocusEvent *e)
+{
+ struct menu *menu = NULL;
+
+ Parent::focusInEvent(e);
+
+ ConfigItem* item = (ConfigItem *)currentItem();
+ if (item) {
+ setSelected(item, TRUE);
+ menu = item->menu;
+ }
+ emit gotFocus(menu);
+}
+
+void ConfigList::contextMenuEvent(QContextMenuEvent *e)
+{
+ if (e->y() <= header()->geometry().bottom()) {
+ if (!headerPopup) {
+ Q3Action *action;
+
+ headerPopup = new Q3PopupMenu(this);
+ action = new Q3Action(NULL, _("Show Name"), 0, this);
+ action->setToggleAction(TRUE);
+ connect(action, SIGNAL(toggled(bool)),
+ parent(), SLOT(setShowName(bool)));
+ connect(parent(), SIGNAL(showNameChanged(bool)),
+ action, SLOT(setOn(bool)));
+ action->setOn(showName);
+ action->addTo(headerPopup);
+ action = new Q3Action(NULL, _("Show Range"), 0, this);
+ action->setToggleAction(TRUE);
+ connect(action, SIGNAL(toggled(bool)),
+ parent(), SLOT(setShowRange(bool)));
+ connect(parent(), SIGNAL(showRangeChanged(bool)),
+ action, SLOT(setOn(bool)));
+ action->setOn(showRange);
+ action->addTo(headerPopup);
+ action = new Q3Action(NULL, _("Show Data"), 0, this);
+ action->setToggleAction(TRUE);
+ connect(action, SIGNAL(toggled(bool)),
+ parent(), SLOT(setShowData(bool)));
+ connect(parent(), SIGNAL(showDataChanged(bool)),
+ action, SLOT(setOn(bool)));
+ action->setOn(showData);
+ action->addTo(headerPopup);
+ }
+ headerPopup->exec(e->globalPos());
+ e->accept();
+ } else
+ e->ignore();
+}
+
+ConfigView*ConfigView::viewList;
+QAction *ConfigView::showNormalAction;
+QAction *ConfigView::showAllAction;
+QAction *ConfigView::showPromptAction;
+
+ConfigView::ConfigView(QWidget* parent, const char *name)
+ : Parent(parent, name)
+{
+ list = new ConfigList(this, name);
+ lineEdit = new ConfigLineEdit(this);
+ lineEdit->hide();
+
+ this->nextView = viewList;
+ viewList = this;
+}
+
+ConfigView::~ConfigView(void)
+{
+ ConfigView** vp;
+
+ for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
+ if (*vp == this) {
+ *vp = nextView;
+ break;
+ }
+ }
+}
+
+void ConfigView::setOptionMode(QAction *act)
+{
+ if (act == showNormalAction)
+ list->optMode = normalOpt;
+ else if (act == showAllAction)
+ list->optMode = allOpt;
+ else
+ list->optMode = promptOpt;
+
+ list->updateListAll();
+}
+
+void ConfigView::setShowName(bool b)
+{
+ if (list->showName != b) {
+ list->showName = b;
+ list->reinit();
+ emit showNameChanged(b);
+ }
+}
+
+void ConfigView::setShowRange(bool b)
+{
+ if (list->showRange != b) {
+ list->showRange = b;
+ list->reinit();
+ emit showRangeChanged(b);
+ }
+}
+
+void ConfigView::setShowData(bool b)
+{
+ if (list->showData != b) {
+ list->showData = b;
+ list->reinit();
+ emit showDataChanged(b);
+ }
+}
+
+void ConfigList::setAllOpen(bool open)
+{
+ Q3ListViewItemIterator it(this);
+
+ for (; it.current(); it++)
+ it.current()->setOpen(open);
+}
+
+void ConfigView::updateList(ConfigItem* item)
+{
+ ConfigView* v;
+
+ for (v = viewList; v; v = v->nextView)
+ v->list->updateList(item);
+}
+
+void ConfigView::updateListAll(void)
+{
+ ConfigView* v;
+
+ for (v = viewList; v; v = v->nextView)
+ v->list->updateListAll();
+}
+
+ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
+ : Parent(parent, name), sym(0), _menu(0)
+{
+ if (name) {
+ configSettings->beginGroup(name);
+ _showDebug = configSettings->readBoolEntry("/showDebug", false);
+ configSettings->endGroup();
+ connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
+ }
+}
+
+void ConfigInfoView::saveSettings(void)
+{
+ if (name()) {
+ configSettings->beginGroup(name());
+ configSettings->writeEntry("/showDebug", showDebug());
+ configSettings->endGroup();
+ }
+}
+
+void ConfigInfoView::setShowDebug(bool b)
+{
+ if (_showDebug != b) {
+ _showDebug = b;
+ if (_menu)
+ menuInfo();
+ else if (sym)
+ symbolInfo();
+ emit showDebugChanged(b);
+ }
+}
+
+void ConfigInfoView::setInfo(struct menu *m)
+{
+ if (_menu == m)
+ return;
+ _menu = m;
+ sym = NULL;
+ if (!_menu)
+ clear();
+ else
+ menuInfo();
+}
+
+void ConfigInfoView::symbolInfo(void)
+{
+ QString str;
+
+ str += "<big>Symbol: <b>";
+ str += print_filter(sym->name);
+ str += "</b></big><br><br>value: ";
+ str += print_filter(sym_get_string_value(sym));
+ str += "<br>visibility: ";
+ str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n";
+ str += "<br>";
+ str += debug_info(sym);
+
+ setText(str);
+}
+
+void ConfigInfoView::menuInfo(void)
+{
+ struct symbol* sym;
+ QString head, debug, help;
+
+ sym = _menu->sym;
+ if (sym) {
+ if (_menu->prompt) {
+ head += "<big><b>";
+ head += print_filter(_(_menu->prompt->text));
+ head += "</b></big>";
+ if (sym->name) {
+ head += " (";
+ if (showDebug())
+ head += QString().sprintf("<a href=\"s%p\">", sym);
+ head += print_filter(sym->name);
+ if (showDebug())
+ head += "</a>";
+ head += ")";
+ }
+ } else if (sym->name) {
+ head += "<big><b>";
+ if (showDebug())
+ head += QString().sprintf("<a href=\"s%p\">", sym);
+ head += print_filter(sym->name);
+ if (showDebug())
+ head += "</a>";
+ head += "</b></big>";
+ }
+ head += "<br><br>";
+
+ if (showDebug())
+ debug = debug_info(sym);
+
+ struct gstr help_gstr = str_new();
+ menu_get_ext_help(_menu, &help_gstr);
+ help = print_filter(str_get(&help_gstr));
+ str_free(&help_gstr);
+ } else if (_menu->prompt) {
+ head += "<big><b>";
+ head += print_filter(_(_menu->prompt->text));
+ head += "</b></big><br><br>";
+ if (showDebug()) {
+ if (_menu->prompt->visible.expr) {
+ debug += " dep: ";
+ expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
+ debug += "<br><br>";
+ }
+ }
+ }
+ if (showDebug())
+ debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
+
+ setText(head + debug + help);
+}
+
+QString ConfigInfoView::debug_info(struct symbol *sym)
+{
+ QString debug;
+
+ debug += "type: ";
+ debug += print_filter(sym_type_name(sym->type));
+ if (sym_is_choice(sym))
+ debug += " (choice)";
+ debug += "<br>";
+ if (sym->rev_dep.expr) {
+ debug += "reverse dep: ";
+ expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
+ debug += "<br>";
+ }
+ for (struct property *prop = sym->prop; prop; prop = prop->next) {
+ switch (prop->type) {
+ case P_PROMPT:
+ case P_MENU:
+ debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
+ debug += print_filter(_(prop->text));
+ debug += "</a><br>";
+ break;
+ case P_DEFAULT:
+ case P_SELECT:
+ case P_RANGE:
+ case P_ENV:
+ debug += prop_get_type_name(prop->type);
+ debug += ": ";
+ expr_print(prop->expr, expr_print_help, &debug, E_NONE);
+ debug += "<br>";
+ break;
+ case P_CHOICE:
+ if (sym_is_choice(sym)) {
+ debug += "choice: ";
+ expr_print(prop->expr, expr_print_help, &debug, E_NONE);
+ debug += "<br>";
+ }
+ break;
+ default:
+ debug += "unknown property: ";
+ debug += prop_get_type_name(prop->type);
+ debug += "<br>";
+ }
+ if (prop->visible.expr) {
+ debug += " dep: ";
+ expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
+ debug += "<br>";
+ }
+ }
+ debug += "<br>";
+
+ return debug;
+}
+
+QString ConfigInfoView::print_filter(const QString &str)
+{
+ QRegExp re("[<>&\"\\n]");
+ QString res = str;
+ for (int i = 0; (i = res.find(re, i)) >= 0;) {
+ switch (res[i].latin1()) {
+ case '<':
+ res.replace(i, 1, "<");
+ i += 4;
+ break;
+ case '>':
+ res.replace(i, 1, ">");
+ i += 4;
+ break;
+ case '&':
+ res.replace(i, 1, "&");
+ i += 5;
+ break;
+ case '"':
+ res.replace(i, 1, """);
+ i += 6;
+ break;
+ case '\n':
+ res.replace(i, 1, "<br>");
+ i += 4;
+ break;
+ }
+ }
+ return res;
+}
+
+void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
+{
+ QString* text = reinterpret_cast<QString*>(data);
+ QString str2 = print_filter(str);
+
+ if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
+ *text += QString().sprintf("<a href=\"s%p\">", sym);
+ *text += str2;
+ *text += "</a>";
+ } else
+ *text += str2;
+}
+
+Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
+{
+ Q3PopupMenu* popup = Parent::createPopupMenu(pos);
+ Q3Action* action = new Q3Action(NULL, _("Show Debug Info"), 0, popup);
+ action->setToggleAction(TRUE);
+ connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
+ connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
+ action->setOn(showDebug());
+ popup->insertSeparator();
+ action->addTo(popup);
+ return popup;
+}
+
+void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e)
+{
+ Parent::contentsContextMenuEvent(e);
+}
+
+ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
+ : Parent(parent, name), result(NULL)
+{
+ setCaption("Search Config");
+
+ QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6);
+ QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6);
+ layout2->addWidget(new QLabel(_("Find:"), this));
+ editField = new QLineEdit(this);
+ connect(editField, SIGNAL(returnPressed()), SLOT(search()));
+ layout2->addWidget(editField);
+ searchButton = new QPushButton(_("Search"), this);
+ searchButton->setAutoDefault(FALSE);
+ connect(searchButton, SIGNAL(clicked()), SLOT(search()));
+ layout2->addWidget(searchButton);
+ layout1->addLayout(layout2);
+
+ split = new QSplitter(this);
+ split->setOrientation(Qt::Vertical);
+ list = new ConfigView(split, name);
+ list->list->mode = listMode;
+ info = new ConfigInfoView(split, name);
+ connect(list->list, SIGNAL(menuChanged(struct menu *)),
+ info, SLOT(setInfo(struct menu *)));
+ connect(list->list, SIGNAL(menuChanged(struct menu *)),
+ parent, SLOT(setMenuLink(struct menu *)));
+
+ layout1->addWidget(split);
+
+ if (name) {
+ int x, y, width, height;
+ bool ok;
+
+ configSettings->beginGroup(name);
+ width = configSettings->readNumEntry("/window width", parent->width() / 2);
+ height = configSettings->readNumEntry("/window height", parent->height() / 2);
+ resize(width, height);
+ x = configSettings->readNumEntry("/window x", 0, &ok);
+ if (ok)
+ y = configSettings->readNumEntry("/window y", 0, &ok);
+ if (ok)
+ move(x, y);
+ Q3ValueList<int> sizes = configSettings->readSizes("/split", &ok);
+ if (ok)
+ split->setSizes(sizes);
+ configSettings->endGroup();
+ connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
+ }
+}
+
+void ConfigSearchWindow::saveSettings(void)
+{
+ if (name()) {
+ configSettings->beginGroup(name());
+ configSettings->writeEntry("/window x", pos().x());
+ configSettings->writeEntry("/window y", pos().y());
+ configSettings->writeEntry("/window width", size().width());
+ configSettings->writeEntry("/window height", size().height());
+ configSettings->writeSizes("/split", split->sizes());
+ configSettings->endGroup();
+ }
+}
+
+void ConfigSearchWindow::search(void)
+{
+ struct symbol **p;
+ struct property *prop;
+ ConfigItem *lastItem = NULL;
+
+ free(result);
+ list->list->clear();
+ info->clear();
+
+ result = sym_re_search(editField->text().latin1());
+ if (!result)
+ return;
+ for (p = result; *p; p++) {
+ for_all_prompts((*p), prop)
+ lastItem = new ConfigItem(list->list, lastItem, prop->menu,
+ menu_is_visible(prop->menu));
+ }
+}
+
+/*
+ * Construct the complete config widget
+ */
+ConfigMainWindow::ConfigMainWindow(void)
+ : searchWindow(0)
+{
+ QMenuBar* menu;
+ bool ok;
+ int x, y, width, height;
+ char title[256];
+
+ QDesktopWidget *d = configApp->desktop();
+ snprintf(title, sizeof(title), "%s%s",
+ rootmenu.prompt->text,
+ ""
+ );
+ setCaption(title);
+
+ width = configSettings->readNumEntry("/window width", d->width() - 64);
+ height = configSettings->readNumEntry("/window height", d->height() - 64);
+ resize(width, height);
+ x = configSettings->readNumEntry("/window x", 0, &ok);
+ if (ok)
+ y = configSettings->readNumEntry("/window y", 0, &ok);
+ if (ok)
+ move(x, y);
+
+ split1 = new QSplitter(this);
+ split1->setOrientation(Qt::Horizontal);
+ setCentralWidget(split1);
+
+ menuView = new ConfigView(split1, "menu");
+ menuList = menuView->list;
+
+ split2 = new QSplitter(split1);
+ split2->setOrientation(Qt::Vertical);
+
+ // create config tree
+ configView = new ConfigView(split2, "config");
+ configList = configView->list;
+
+ helpText = new ConfigInfoView(split2, "help");
+ helpText->setTextFormat(Qt::RichText);
+
+ setTabOrder(configList, helpText);
+ configList->setFocus();
+
+ menu = menuBar();
+ toolBar = new Q3ToolBar("Tools", this);
+
+ backAction = new Q3Action("Back", QPixmap(xpm_back), _("Back"), 0, this);
+ connect(backAction, SIGNAL(activated()), SLOT(goBack()));
+ backAction->setEnabled(FALSE);
+ Q3Action *quitAction = new Q3Action("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this);
+ connect(quitAction, SIGNAL(activated()), SLOT(close()));
+ Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this);
+ connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
+ saveAction = new Q3Action("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this);
+ connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
+ conf_set_changed_callback(conf_changed);
+ // Set saveAction's initial state
+ conf_changed();
+ Q3Action *saveAsAction = new Q3Action("Save As...", _("Save &As..."), 0, this);
+ connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
+ Q3Action *searchAction = new Q3Action("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this);
+ connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
+ Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
+ connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
+ Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
+ connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
+ Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
+ connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
+
+ Q3Action *showNameAction = new Q3Action(NULL, _("Show Name"), 0, this);
+ showNameAction->setToggleAction(TRUE);
+ connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
+ connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
+ showNameAction->setOn(configView->showName());
+ Q3Action *showRangeAction = new Q3Action(NULL, _("Show Range"), 0, this);
+ showRangeAction->setToggleAction(TRUE);
+ connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
+ connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
+ showRangeAction->setOn(configList->showRange);
+ Q3Action *showDataAction = new Q3Action(NULL, _("Show Data"), 0, this);
+ showDataAction->setToggleAction(TRUE);
+ connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
+ connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
+ showDataAction->setOn(configList->showData);
+
+ QActionGroup *optGroup = new QActionGroup(this);
+ optGroup->setExclusive(TRUE);
+ connect(optGroup, SIGNAL(selected(QAction *)), configView,
+ SLOT(setOptionMode(QAction *)));
+ connect(optGroup, SIGNAL(selected(QAction *)), menuView,
+ SLOT(setOptionMode(QAction *)));
+
+ configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup);
+ configView->showAllAction = new QAction(_("Show All Options"), optGroup);
+ configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup);
+ configView->showNormalAction->setToggleAction(TRUE);
+ configView->showNormalAction->setOn(configList->optMode == normalOpt);
+ configView->showAllAction->setToggleAction(TRUE);
+ configView->showAllAction->setOn(configList->optMode == allOpt);
+ configView->showPromptAction->setToggleAction(TRUE);
+ configView->showPromptAction->setOn(configList->optMode == promptOpt);
+
+ Q3Action *showDebugAction = new Q3Action(NULL, _("Show Debug Info"), 0, this);
+ showDebugAction->setToggleAction(TRUE);
+ connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
+ connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
+ showDebugAction->setOn(helpText->showDebug());
+
+ Q3Action *showIntroAction = new Q3Action(NULL, _("Introduction"), 0, this);
+ connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
+ Q3Action *showAboutAction = new Q3Action(NULL, _("About"), 0, this);
+ connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
+
+ // init tool bar
+ backAction->addTo(toolBar);
+ toolBar->addSeparator();
+ loadAction->addTo(toolBar);
+ saveAction->addTo(toolBar);
+ toolBar->addSeparator();
+ singleViewAction->addTo(toolBar);
+ splitViewAction->addTo(toolBar);
+ fullViewAction->addTo(toolBar);
+
+ // create config menu
+ Q3PopupMenu* config = new Q3PopupMenu(this);
+ menu->insertItem(_("&File"), config);
+ loadAction->addTo(config);
+ saveAction->addTo(config);
+ saveAsAction->addTo(config);
+ config->insertSeparator();
+ quitAction->addTo(config);
+
+ // create edit menu
+ Q3PopupMenu* editMenu = new Q3PopupMenu(this);
+ menu->insertItem(_("&Edit"), editMenu);
+ searchAction->addTo(editMenu);
+
+ // create options menu
+ Q3PopupMenu* optionMenu = new Q3PopupMenu(this);
+ menu->insertItem(_("&Option"), optionMenu);
+ showNameAction->addTo(optionMenu);
+ showRangeAction->addTo(optionMenu);
+ showDataAction->addTo(optionMenu);
+ optionMenu->insertSeparator();
+ optGroup->addTo(optionMenu);
+ optionMenu->insertSeparator();
+
+ // create help menu
+ Q3PopupMenu* helpMenu = new Q3PopupMenu(this);
+ menu->insertSeparator();
+ menu->insertItem(_("&Help"), helpMenu);
+ showIntroAction->addTo(helpMenu);
+ showAboutAction->addTo(helpMenu);
+
+ connect(configList, SIGNAL(menuChanged(struct menu *)),
+ helpText, SLOT(setInfo(struct menu *)));
+ connect(configList, SIGNAL(menuSelected(struct menu *)),
+ SLOT(changeMenu(struct menu *)));
+ connect(configList, SIGNAL(parentSelected()),
+ SLOT(goBack()));
+ connect(menuList, SIGNAL(menuChanged(struct menu *)),
+ helpText, SLOT(setInfo(struct menu *)));
+ connect(menuList, SIGNAL(menuSelected(struct menu *)),
+ SLOT(changeMenu(struct menu *)));
+
+ connect(configList, SIGNAL(gotFocus(struct menu *)),
+ helpText, SLOT(setInfo(struct menu *)));
+ connect(menuList, SIGNAL(gotFocus(struct menu *)),
+ helpText, SLOT(setInfo(struct menu *)));
+ connect(menuList, SIGNAL(gotFocus(struct menu *)),
+ SLOT(listFocusChanged(void)));
+ connect(helpText, SIGNAL(menuSelected(struct menu *)),
+ SLOT(setMenuLink(struct menu *)));
+
+ QString listMode = configSettings->readEntry("/listMode", "symbol");
+ if (listMode == "single")
+ showSingleView();
+ else if (listMode == "full")
+ showFullView();
+ else /*if (listMode == "split")*/
+ showSplitView();
+
+ // UI setup done, restore splitter positions
+ Q3ValueList<int> sizes = configSettings->readSizes("/split1", &ok);
+ if (ok)
+ split1->setSizes(sizes);
+
+ sizes = configSettings->readSizes("/split2", &ok);
+ if (ok)
+ split2->setSizes(sizes);
+}
+
+void ConfigMainWindow::loadConfig(void)
+{
+ QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this);
+ if (s.isNull())
+ return;
+ if (conf_read(QFile::encodeName(s)))
+ QMessageBox::information(this, "qconf", _("Unable to load configuration!"));
+ ConfigView::updateListAll();
+}
+
+bool ConfigMainWindow::saveConfig(void)
+{
+ if (conf_write(NULL)) {
+ QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
+ return false;
+ }
+ return true;
+}
+
+void ConfigMainWindow::saveConfigAs(void)
+{
+ QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this);
+ if (s.isNull())
+ return;
+ saveConfig();
+}
+
+void ConfigMainWindow::searchConfig(void)
+{
+ if (!searchWindow)
+ searchWindow = new ConfigSearchWindow(this, "search");
+ searchWindow->show();
+}
+
+void ConfigMainWindow::changeMenu(struct menu *menu)
+{
+ configList->setRootMenu(menu);
+ if (configList->rootEntry->parent == &rootmenu)
+ backAction->setEnabled(FALSE);
+ else
+ backAction->setEnabled(TRUE);
+}
+
+void ConfigMainWindow::setMenuLink(struct menu *menu)
+{
+ struct menu *parent;
+ ConfigList* list = NULL;
+ ConfigItem* item;
+
+ if (configList->menuSkip(menu))
+ return;
+
+ switch (configList->mode) {
+ case singleMode:
+ list = configList;
+ parent = menu_get_parent_menu(menu);
+ if (!parent)
+ return;
+ list->setRootMenu(parent);
+ break;
+ case symbolMode:
+ if (menu->flags & MENU_ROOT) {
+ configList->setRootMenu(menu);
+ configList->clearSelection();
+ list = menuList;
+ } else {
+ list = configList;
+ parent = menu_get_parent_menu(menu->parent);
+ if (!parent)
+ return;
+ item = menuList->findConfigItem(parent);
+ if (item) {
+ menuList->setSelected(item, TRUE);
+ menuList->ensureItemVisible(item);
+ }
+ list->setRootMenu(parent);
+ }
+ break;
+ case fullMode:
+ list = configList;
+ break;
+ default:
+ break;
+ }
+
+ if (list) {
+ item = list->findConfigItem(menu);
+ if (item) {
+ list->setSelected(item, TRUE);
+ list->ensureItemVisible(item);
+ list->setFocus();
+ }
+ }
+}
+
+void ConfigMainWindow::listFocusChanged(void)
+{
+ if (menuList->mode == menuMode)
+ configList->clearSelection();
+}
+
+void ConfigMainWindow::goBack(void)
+{
+ ConfigItem* item;
+
+ configList->setParentMenu();
+ if (configList->rootEntry == &rootmenu)
+ backAction->setEnabled(FALSE);
+ item = (ConfigItem*)menuList->selectedItem();
+ while (item) {
+ if (item->menu == configList->rootEntry) {
+ menuList->setSelected(item, TRUE);
+ break;
+ }
+ item = (ConfigItem*)item->parent();
+ }
+}
+
+void ConfigMainWindow::showSingleView(void)
+{
+ menuView->hide();
+ menuList->setRootMenu(0);
+ configList->mode = singleMode;
+ if (configList->rootEntry == &rootmenu)
+ configList->updateListAll();
+ else
+ configList->setRootMenu(&rootmenu);
+ configList->setAllOpen(TRUE);
+ configList->setFocus();
+}
+
+void ConfigMainWindow::showSplitView(void)
+{
+ configList->mode = symbolMode;
+ if (configList->rootEntry == &rootmenu)
+ configList->updateListAll();
+ else
+ configList->setRootMenu(&rootmenu);
+ configList->setAllOpen(TRUE);
+ configApp->processEvents();
+ menuList->mode = menuMode;
+ menuList->setRootMenu(&rootmenu);
+ menuList->setAllOpen(TRUE);
+ menuView->show();
+ menuList->setFocus();
+}
+
+void ConfigMainWindow::showFullView(void)
+{
+ menuView->hide();
+ menuList->setRootMenu(0);
+ configList->mode = fullMode;
+ if (configList->rootEntry == &rootmenu)
+ configList->updateListAll();
+ else
+ configList->setRootMenu(&rootmenu);
+ configList->setAllOpen(FALSE);
+ configList->setFocus();
+}
+
+/*
+ * ask for saving configuration before quitting
+ * TODO ask only when something changed
+ */
+void ConfigMainWindow::closeEvent(QCloseEvent* e)
+{
+ if (!conf_get_changed()) {
+ e->accept();
+ return;
+ }
+ QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
+ mb.setButtonText(QMessageBox::Yes, _("&Save Changes"));
+ mb.setButtonText(QMessageBox::No, _("&Discard Changes"));
+ mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
+ switch (mb.exec()) {
+ case QMessageBox::Yes:
+ if (saveConfig())
+ e->accept();
+ else
+ e->ignore();
+ break;
+ case QMessageBox::No:
+ e->accept();
+ break;
+ case QMessageBox::Cancel:
+ e->ignore();
+ break;
+ }
+}
+
+void ConfigMainWindow::showIntro(void)
+{
+ static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n"
+ "For each option, a blank box indicates the feature is disabled, a check\n"
+ "indicates it is enabled, and a dot indicates that it is to be compiled\n"
+ "as a module. Clicking on the box will cycle through the three states.\n\n"
+ "If you do not see an option (e.g., a device driver) that you believe\n"
+ "should be present, try turning on Show All Options under the Options menu.\n"
+ "Although there is no cross reference yet to help you figure out what other\n"
+ "options must be enabled to support the option you are interested in, you can\n"
+ "still view the help of a grayed-out option.\n\n"
+ "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
+ "which you can then match by examining other options.\n\n");
+
+ QMessageBox::information(this, "qconf", str);
+}
+
+void ConfigMainWindow::showAbout(void)
+{
+ static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
+ "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n");
+
+ QMessageBox::information(this, "qconf", str);
+}
+
+void ConfigMainWindow::saveSettings(void)
+{
+ configSettings->writeEntry("/window x", pos().x());
+ configSettings->writeEntry("/window y", pos().y());
+ configSettings->writeEntry("/window width", size().width());
+ configSettings->writeEntry("/window height", size().height());
+
+ QString entry;
+ switch(configList->mode) {
+ case singleMode :
+ entry = "single";
+ break;
+
+ case symbolMode :
+ entry = "split";
+ break;
+
+ case fullMode :
+ entry = "full";
+ break;
+
+ default:
+ break;
+ }
+ configSettings->writeEntry("/listMode", entry);
+
+ configSettings->writeSizes("/split1", split1->sizes());
+ configSettings->writeSizes("/split2", split2->sizes());
+}
+
+void ConfigMainWindow::conf_changed(void)
+{
+ if (saveAction)
+ saveAction->setEnabled(conf_get_changed());
+}
+
+void fixup_rootmenu(struct menu *menu)
+{
+ struct menu *child;
+ static int menu_cnt = 0;
+
+ menu->flags |= MENU_ROOT;
+ for (child = menu->list; child; child = child->next) {
+ if (child->prompt && child->prompt->type == P_MENU) {
+ menu_cnt++;
+ fixup_rootmenu(child);
+ menu_cnt--;
+ } else if (!menu_cnt)
+ fixup_rootmenu(child);
+ }
+}
+
+static const char *progname;
+
+static void usage(void)
+{
+ printf(_("%s <config>\n"), progname);
+ exit(0);
+}
+
+int main(int ac, char** av)
+{
+ ConfigMainWindow* v;
+ const char *name;
+
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ progname = av[0];
+ configApp = new QApplication(ac, av);
+ if (ac > 1 && av[1][0] == '-') {
+ switch (av[1][1]) {
+ case 'h':
+ case '?':
+ usage();
+ }
+ name = av[2];
+ } else
+ name = av[1];
+ if (!name)
+ usage();
+
+ conf_parse(name);
+ fixup_rootmenu(&rootmenu);
+ conf_read(NULL);
+ //zconfdump(stdout);
+
+ configSettings = new ConfigSettings();
+ configSettings->beginGroup("/kconfig/qconf");
+ v = new ConfigMainWindow();
+
+ //zconfdump(stdout);
+ configApp->setMainWidget(v);
+ configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
+ configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
+ v->show();
+ configApp->exec();
+
+ configSettings->endGroup();
+ delete configSettings;
+
+ return 0;
+}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH 8/9] kconfig: qt flavour makefile fixes
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
` (4 preceding siblings ...)
2013-07-02 15:22 ` [PATCH 6/9] kconf: gtk: move relayout code out of a loop davidgraeff
@ 2013-07-02 15:22 ` davidgraeff
2013-07-02 15:22 ` [PATCH 9/9] kconfig: qt flavour, add missing updateTree davidgraeff
` (2 subsequent siblings)
8 siblings, 0 replies; 33+ messages in thread
From: davidgraeff @ 2013-07-02 15:22 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, davidgraeff
* Add comments to the makefile
* fix moc/uic invocation
* Compile moc classes as objects and link to qconf instead of including with #include.
This is more compliant to the way IDEs like QtCreator work.
---
scripts/kconfig/qconfig/Makefile | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/scripts/kconfig/qconfig/Makefile b/scripts/kconfig/qconfig/Makefile
index 72e0bd1..b9857c3 100644
--- a/scripts/kconfig/qconfig/Makefile
+++ b/scripts/kconfig/qconfig/Makefile
@@ -4,9 +4,6 @@
PHONY += xconfig qconfig
-MOC_HEADERS := $(wildcard $(obj)/qconfig/*.h)
-MOCS := $(patsubst %.h,%.moc,$(MOC_HEADERS))
-
xconfig: $(obj)/qconf
$< $(Kconfig)
@@ -14,12 +11,24 @@ qconfig: $(obj)/qconf
$< $(Kconfig)
# ===========================================================================
-# qconf: Used for the xconfig target
-# Based on QT which needs to be installed to compile it
-# object files used by all kconfig flavours listed above
+# qconf: Used for the xconfig/qconfig target
+# Based on Qt4+ which needs to be installed to compile it
+
+# Meta object files (moc files) have to be considered for every class that uses the Q_OBJECT macro.
+# We collect all class header files below, build moc_[filename].o object filenames and store those in "MOCS".
+# Assumtion: All header files in this directory contain c++ code.
+MOC_HEADERS := $(wildcard $(obj)/qconfig/*.h)
+MOC_SOURCE_FILES := $(patsubst $(obj)/qconfig/%,%,$(MOC_HEADERS)) # remove directory part
+MOC_DEST_FILES := $(patsubst %.h,moc_%.o,$(MOC_SOURCE_FILES)) # add moc_ prefix
+MOCS := $(patsubst %,qconfig/%,$(MOC_DEST_FILES)) # add directory part
+# Object files used by this kconfig flavours listed below. Meta object files (moc files) are generated by
+# the Qt moc tool. We have to build and link those generated files, too.
qconf-cxxobjs := qconfig/qconf.o qconfig/configItem.o qconfig/configModel.o qconfig/configmodeldelegate.o \
- qconfig/infoViewWidget.o qconfig/mainwindow.o qconfig/searchfiltermodelproxy.o qconfig/searchmodel.o
+ qconfig/infoViewWidget.o qconfig/mainwindow.o qconfig/searchfiltermodelproxy.o qconfig/searchmodel.o \
+ $(MOCS)
+
+# Object files used by all kconfig flavours listed below
qconf-objs := zconf.tab.o
ifeq ($(MAKECMDGOALS),qconfig)
@@ -34,12 +43,12 @@ ifeq ($(qconf-target),1)
hostprogs-y += qconf
endif
-clean-files += qconfig/*.moc qconfig/ui_*.h qconfig/.tmp_qtcheck qconf
+clean-files += qconfig/moc_*.cc qconfig/ui_*.h qconfig/.tmp_qtcheck qconf
HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
-HOSTCXXFLAGS = $(KC_QT_CFLAGS) -DINCLUDEMOC
+HOSTCXXFLAGS = $(KC_QT_CFLAGS)
-$(obj)/qconfig/qconf.o: $(MOCS) $(UIS) $(src)/qconfig/.tmp_qtcheck
+$(obj)/qconfig/qconf.o: $(src)/qconfig/.tmp_qtcheck
$(obj)/qconfig/mainwindow.o: $(obj)/qconfig/ui_mainwindow.h
ifeq ($(qconf-target),1)
@@ -71,15 +80,15 @@ $(obj)/qconfig/.tmp_qtcheck:
echo "KC_QT_UIC=$$uic" >> $@
endif
-$(obj)/qconfig/%.o: $(obj)/qconfig/%.moc
-
quiet_cmd_moc = MOC $@
- cmd_moc = $(KC_QT_MOC) -nn -i $< -o $@
+ cmd_moc = $(KC_QT_MOC) -nn $< -o $@
quiet_cmd_uic = UIC $@
cmd_uic = $(KC_QT_UIC) -n $< -o $@
-$(obj)/qconfig/%.moc: $(obj)/qconfig/%.h $(obj)/qconfig/.tmp_qtcheck
+$(obj)/qconfig/moc_%.cc: $(obj)/qconfig/%.h
$(call cmd,moc)
-$(obj)/qconfig/ui_%.h: $(obj)/qconfig/%.ui $(obj)/qconfig/.tmp_qtcheck
+$(obj)/qconfig/ui_%.h: $(obj)/qconfig/%.ui
$(call cmd,uic)
+
+$(obj)/qconfig/%.o: $(obj)/qconfig/moc_%.o
--
1.8.1.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH 9/9] kconfig: qt flavour, add missing updateTree
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
` (5 preceding siblings ...)
2013-07-02 15:22 ` [PATCH 8/9] kconfig: qt flavour makefile fixes davidgraeff
@ 2013-07-02 15:22 ` davidgraeff
2013-07-03 16:30 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions Yann E. MORIN
2013-07-11 21:06 ` Sam Ravnborg
8 siblings, 0 replies; 33+ messages in thread
From: davidgraeff @ 2013-07-02 15:22 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, davidgraeff
* Remove all #includes for moc files
* Add ui option to show/hide subtrees of disabled options.
* Update the entire model on current item change like gconf
---
scripts/kconfig/qconfig/infoViewWidget.cc | 4 +---
scripts/kconfig/qconfig/mainwindow.cc | 22 +++++++++++++---------
scripts/kconfig/qconfig/mainwindow.h | 2 ++
scripts/kconfig/qconfig/mainwindow.ui | 16 ++++++++++++++++
scripts/kconfig/qconfig/searchfiltermodelproxy.cc | 4 +---
scripts/kconfig/qconfig/searchmodel.cc | 4 +---
6 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/scripts/kconfig/qconfig/infoViewWidget.cc b/scripts/kconfig/qconfig/infoViewWidget.cc
index 21024a8..abcfa09 100644
--- a/scripts/kconfig/qconfig/infoViewWidget.cc
+++ b/scripts/kconfig/qconfig/infoViewWidget.cc
@@ -10,9 +10,7 @@
#include <QSettings>
#include "../expr.h"
#include "../lkc.h"
-#ifdef INCLUDEMOC
-#include "infoViewWidget.moc"
-#endif
+
InfoViewWidget::InfoViewWidget(QWidget* parent)
: Parent(parent), sym(0), _menu(0)
{
diff --git a/scripts/kconfig/qconfig/mainwindow.cc b/scripts/kconfig/qconfig/mainwindow.cc
index 04216f9..bb7870e 100644
--- a/scripts/kconfig/qconfig/mainwindow.cc
+++ b/scripts/kconfig/qconfig/mainwindow.cc
@@ -20,9 +20,7 @@
#include "../images.c"
#include "../expr.h"
#include "../lkc.h"
-#ifdef INCLUDEMOC
-#include "mainwindow.moc"
-#endif
+
bool qconf_MainWindow::check_conf_changed()
{
bool changed = conf_get_changed();
@@ -291,12 +289,13 @@ void qconf_MainWindow::on_actionLoad_triggered()
void qconf_MainWindow::on_actionBack_triggered()
{
- QModelIndex parent = ui->treeAll->rootIndex().parent();
- if (view_mode==SINGLE_VIEW) {
- ui->treeAll->setRootIndex(parent);
- ui->actionBack->setEnabled(parent.isValid());
- updateCurrentPositionLabel();
- }
+ // if (view_mode==SINGLE_VIEW)
+ QModelIndex current = ui->treeAll->rootIndex();
+ QModelIndex parent = current.parent();
+ ui->treeAll->setRootIndex(parent);
+ ui->actionBack->setEnabled(parent.isValid());
+ ui->treeAll->scrollTo(current);
+ updateCurrentPositionLabel();
}
void qconf_MainWindow::on_actionSingleView_triggered()
@@ -376,3 +375,8 @@ void qconf_MainWindow::updateCurrentPositionLabel()
}
ui->labelPosition->setText(t);
}
+
+void qconf_MainWindow::on_actionHide_disabled_subtrees_triggered()
+{
+ mBaseModel->setHideChildren(ui->actionHide_disabled_subtrees->isChecked());
+}
diff --git a/scripts/kconfig/qconfig/mainwindow.h b/scripts/kconfig/qconfig/mainwindow.h
index e741386..c52db88 100644
--- a/scripts/kconfig/qconfig/mainwindow.h
+++ b/scripts/kconfig/qconfig/mainwindow.h
@@ -45,6 +45,8 @@ private Q_SLOTS:
void on_treeAll_activated(const QModelIndex &index);
void on_listSearch_clicked(const QModelIndex &index);
+ void on_actionHide_disabled_subtrees_triggered();
+
private:
Ui::qconf_MainWindow *ui;
ConfigModel* mBaseModel;
diff --git a/scripts/kconfig/qconfig/mainwindow.ui b/scripts/kconfig/qconfig/mainwindow.ui
index c6662af..0f548c8 100644
--- a/scripts/kconfig/qconfig/mainwindow.ui
+++ b/scripts/kconfig/qconfig/mainwindow.ui
@@ -20,6 +20,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
+ <property name="childrenCollapsible">
+ <bool>false</bool>
+ </property>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
@@ -149,6 +152,8 @@
<property name="title">
<string>Option</string>
</property>
+ <addaction name="actionHide_disabled_subtrees"/>
+ <addaction name="separator"/>
<addaction name="actionShow_Name"/>
<addaction name="actionShow_Range"/>
<addaction name="actionShow_Data_Value"/>
@@ -380,6 +385,17 @@
<string>FullView</string>
</property>
</action>
+ <action name="actionHide_disabled_subtrees">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Hide disabled subtrees</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
diff --git a/scripts/kconfig/qconfig/searchfiltermodelproxy.cc b/scripts/kconfig/qconfig/searchfiltermodelproxy.cc
index daebe9f..5cf9377 100644
--- a/scripts/kconfig/qconfig/searchfiltermodelproxy.cc
+++ b/scripts/kconfig/qconfig/searchfiltermodelproxy.cc
@@ -4,9 +4,7 @@
*/
#include "searchfiltermodelproxy.h"
#include "configModel.h"
-#ifdef INCLUDEMOC
-#include "searchfiltermodelproxy.moc"
-#endif
+
SearchFilterModelProxy::SearchFilterModelProxy(QObject *parent) :
QSortFilterProxyModel(parent)
{
diff --git a/scripts/kconfig/qconfig/searchmodel.cc b/scripts/kconfig/qconfig/searchmodel.cc
index 974ad53..b98311a 100644
--- a/scripts/kconfig/qconfig/searchmodel.cc
+++ b/scripts/kconfig/qconfig/searchmodel.cc
@@ -2,9 +2,7 @@
#include <QPalette>
#include "../expr.h"
#include "../lkc.h"
-#ifdef INCLUDEMOC
-#include "searchmodel.moc"
-#endif
+
SearchModel::item::item(struct menu* menu) {
this->menu = menu;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: Kconfig Gtk/Qt interface flavours ported to newest toolkit versions
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
` (6 preceding siblings ...)
2013-07-02 15:22 ` [PATCH 9/9] kconfig: qt flavour, add missing updateTree davidgraeff
@ 2013-07-03 16:30 ` Yann E. MORIN
2013-07-06 0:13 ` David Gräff
2013-07-11 20:56 ` Sam Ravnborg
2013-07-11 21:06 ` Sam Ravnborg
8 siblings, 2 replies; 33+ messages in thread
From: Yann E. MORIN @ 2013-07-03 16:30 UTC (permalink / raw)
To: davidgraeff; +Cc: Michal Marek, linux-kbuild
David, All,
On 2013-07-02 17:22 +0200, davidgraeff spake thusly:
> I've no idea if this is the right way to send patches. I'm kind of new to this.
It seems you're doing mostly fine! :-)
However, since you asked: your patches are numberedd 2 to 9. It seems
you considered the intro mail (the one I'm replying to here) as the
number one. Is that right, or is patch #1 missing?
Usually, patch series are sent as thus:
[PATCH 0/N] Subject for intro mail, aka "cover letter"
[PATCH 1/N] Subject for first actual patch
[PATCH 2/N] Subject for second actual patch
[...]
[PATCH N-1/N] Subject for penultimate actual patch
[PATCH N/N] Subject for last actual patch
You can achieve this using 'git send-email'. See:
git help send-email
Also, see (albeit not totaly up-to-date):
Documentation/SubmittingPatches
Nit-picking: please keep your mails and commit messages below 80-chars
per line, it's easier to read. Thanks! :-)
> Attached is a patchset basically for porting the graphical Gtk and Qt flavours
> to their latest toolkit versions (Gtk3 and Qt4 with compatibility to Qt5 respectively).
I did not do any review of the patches, since I have a concern about the
series. It happens very often that, in enterprise ecosystems, the host
build machines are running rather aging distro, such as RHEL 5 (or even
RHEL 4 in some cases), so I think we still want the new kernels to be
buildable (and thus configurable) on such machines (eg. for
cross-compilation).
I have no idea when such enterprise distros have started bundling GTK3
or Qt4/5, but given RHEL-4 (which is still use in some places) is 8
years old, I doubt the new frontends would build on those distros.
> I do not know if it was on purpose to keep all flavours except lxdialog in one single directory,
Historical artifact, I think... :-(
[--SNIP--]
> Those newer graphical kconfig flavours will be used by a project I'm involved in so
> I will maintain it for the next couple of months.
Could you please explain what this project of yours is about?
> If I did anything wrong, please instruct me or provide me a link please.
As I said above, mostly good. I've seen far worse submnissions, don't
worry! ;-)
Regards,
Yann E. MORIN.
PS. Sorry for not answering earlier, I had connection issues yesterday,
during all the evening & night. :-(
YEM.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Kconfig Gtk/Qt interface flavours ported to newest toolkit versions
2013-07-03 16:30 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions Yann E. MORIN
@ 2013-07-06 0:13 ` David Gräff
2013-07-10 21:32 ` Yann E. MORIN
2013-07-11 20:56 ` Sam Ravnborg
1 sibling, 1 reply; 33+ messages in thread
From: David Gräff @ 2013-07-06 0:13 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild
Yem, All,
Am 03.07.2013 18:30, schrieb Yann E. MORIN:
> However, since you asked: your patches are numberedd 2 to 9. It seems
> you considered the intro mail (the one I'm replying to here) as the
> number one. Is that right, or is patch #1 missing?
>
> [...]
>
> You can achieve this using 'git send-email'. See:
> git help send-email
I'm sorry for the missing first patch, actually I used git send-email, but
had initial problems with perl and its smtp module. I guess perl ate
this missing first patch mail, I'm not sure.
> Nit-picking: please keep your mails and commit messages below 80-chars
> per line, it's easier to read. Thanks! :-)
I will do my best :) One of my intentions to use git send-email was
because I thought it would automatically format patches in a way
that reviewing them would be easier. Likely I'm too much used, should I
say 'spoiled', by the github or gerrit review UI :)
I will change my proposed code accordingly.
> I did not do any review of the patches, since I have a concern about the
> series. It happens very often that, in enterprise ecosystems, the host
> build machines are running rather aging distro, such as RHEL 5 (or even
> RHEL 4 in some cases), so I think we still want the new kernels to be
> buildable (and thus configurable) on such machines (eg. for
> cross-compilation).
A serious concern, you're absolutly right. Let me tell you some
background information and my concerns regarding the current
code.
Although the Gtk2->3 port was less effort than the Qt-flavour port,
it is the more important one in my opinion. The current code definitly
does not compile with gtk3 and some used libraries (e.g. libglade)
are depreated for a while now.
Of just a cosmetic nature: In my experience, on newer systems
gtk2 applications additionally look somewhat outdated.
Maybe it is a good idea, to have the current gtk implementation
and the ported one side-by-side. What do you think?
Regarding the Qt-flavour port, I would classify it as an almost
complete rewrite. I'm more into C++/Qt and personally I always
used xconfig for kconf. The current implementation is more a Qt3
application that still compiles with Qt4 due of heavy usage of
the deprecated Qt3support layer. For the new implementation,
I adopted Qt4 techniques like the Qt MVC pattern
and the Qt interface designer (similar to the kconf-Gtk solution),
while paying attention to a Qt5 compatibilty.
It's more likely that I introducted bugs in this kconf flavour port,
of course. But I'd assume it's a good starting point for a discussion
of a more future-proof and probably more easy to maintain implementation.
Your concern about those aging distros certainly applies to this ported
kconf
flavour, too. So I'm not sure how to proceed. Options, I can thing of
are:
* Remove the Qt3/4-flavour and use the new Qt4/5 one, keep the Gtk2-flavour
for aging distros.
* Keep both Qt-flavour implementations (maybe with make targets like
xconfig and qconfig).
* Don't change the Qt3/4-flavour and do not introduce this proposed
Qt-flavour.
I would prepare a v2 patch series consisting of three patches only:
1) Directory structure. For each kconf ui flavour a separate one.
2) gtk3-flavour as side-by-side solution to the existing gtk2 one.
3) Qt4/5-flavour as side-by-side solution to the existing Qt3/4 one.
Far less intrusive :)
>> Those newer graphical kconfig flavours will be used by a project I'm involved in so
>> I will maintain it for the next couple of months.
> Could you please explain what this project of yours is about?
* A configurable firmware for atmega processors (we are using the menuconfig
kconf interface only) [github: ethersex].
* CiAO: Highly configurable aspect oriented research operating-system.
Configuration
is realised by kconf. We are using the Qt interface mainly.
* And two other configurable operating systems, that are used for teaching.
I guess there are way more projects using the famous kconf and users who
like to use
the graphical interface flavours :)
> PS. Sorry for not answering earlier, I had connection issues yesterday,
> during all the evening & night. :-(
> YEM.
So now it's my time to say sorry, took a few days to respond.
David.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Kconfig Gtk/Qt interface flavours ported to newest toolkit versions
2013-07-06 0:13 ` David Gräff
@ 2013-07-10 21:32 ` Yann E. MORIN
2013-07-11 21:02 ` Sam Ravnborg
0 siblings, 1 reply; 33+ messages in thread
From: Yann E. MORIN @ 2013-07-10 21:32 UTC (permalink / raw)
To: David Gräff; +Cc: linux-kbuild
David, All,
On 2013-07-06 02:13 +0200, David Gräff spake thusly:
> Am 03.07.2013 18:30, schrieb Yann E. MORIN:
> >I did not do any review of the patches, since I have a concern about the
> >series. It happens very often that, in enterprise ecosystems, the host
> >build machines are running rather aging distro, such as RHEL 5 (or even
> >RHEL 4 in some cases), so I think we still want the new kernels to be
> >buildable (and thus configurable) on such machines (eg. for
> >cross-compilation).
> A serious concern, you're absolutly right. Let me tell you some
> background information and my concerns regarding the current
> code.
> Although the Gtk2->3 port was less effort than the Qt-flavour port,
> it is the more important one in my opinion. The current code definitly
> does not compile with gtk3 and some used libraries (e.g. libglade)
> are depreated for a while now.
> Of just a cosmetic nature: In my experience, on newer systems
> gtk2 applications additionally look somewhat outdated.
>
> Maybe it is a good idea, to have the current gtk implementation
> and the ported one side-by-side. What do you think?
>
> Regarding the Qt-flavour port, I would classify it as an almost
> complete rewrite. I'm more into C++/Qt and personally I always
> used xconfig for kconf. The current implementation is more a Qt3
> application that still compiles with Qt4 due of heavy usage of
> the deprecated Qt3support layer. For the new implementation,
> I adopted Qt4 techniques like the Qt MVC pattern
> and the Qt interface designer (similar to the kconf-Gtk solution),
> while paying attention to a Qt5 compatibilty.
> It's more likely that I introducted bugs in this kconf flavour port,
> of course. But I'd assume it's a good starting point for a discussion
> of a more future-proof and probably more easy to maintain implementation.
>
> Your concern about those aging distros certainly applies to this ported
> kconf
> flavour, too. So I'm not sure how to proceed. Options, I can thing of
> are:
>
> * Remove the Qt3/4-flavour and use the new Qt4/5 one, keep the Gtk2-flavour
> for aging distros.
> * Keep both Qt-flavour implementations (maybe with make targets like
> xconfig and qconfig).
> * Don't change the Qt3/4-flavour and do not introduce this proposed
> Qt-flavour.
>
> I would prepare a v2 patch series consisting of three patches only:
> 1) Directory structure. For each kconf ui flavour a separate one.
> 2) gtk3-flavour as side-by-side solution to the existing gtk2 one.
> 3) Qt4/5-flavour as side-by-side solution to the existing Qt3/4 one.
> Far less intrusive :)
I personnally don't use any of the two GUIs, so I can't really tell what
their status is. However, there are users of these, so I think we do not
want to leave them out in the cold.
I really don't know what to do about this.
One idea would be to have two new goals: g3config and q5config, and kepp
the existing ones in place. I don't like it much, since the two old ones
will ultimately no longer work, so may dusrupt users' expectations, and
it's double maintenance on non-GUI related changes.
An alternate route would be to add the two new frontends, and keep
xconfig and gconfig as-is, but decide which to build depending on
availability of the libraries:
- xconfig: if Qt5 is present, then build and run the new Qt5-based
frontend, otherwise build the current Qt3/4 frontend
- gconfig: ditto, but with Gtk3 vs. Gtk2.
This still means double maintenance, but means we can easily drop the
old frontends in the future when Gtk2 and Qt3/4 are virtually no longer
meaningful, since this does not break users' experience.
So as a summarry, here are the three options:
- update existing frontends against their respective framework
- add two new frontends, and two new goals to call them
- add two new frontends, and decide whether to call them or the old ones
Really, I have no idea what is best.
[--SNIP--]
> I guess there are way more projects using the famous kconf and users who
> like to use the graphical interface flavours :)
Yes, countless other projects use that: busybox, uClibc, Buildroot,
crosstool-NG, OpenBricks, NuttX, openWRT... to name a few I know of.
BTW, you may be interested in:
http://ymorin.is-a-geek.org/projects/kconfig-frontends
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Kconfig Gtk/Qt interface flavours ported to newest toolkit versions
2013-07-10 21:32 ` Yann E. MORIN
@ 2013-07-11 21:02 ` Sam Ravnborg
0 siblings, 0 replies; 33+ messages in thread
From: Sam Ravnborg @ 2013-07-11 21:02 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: David Gräff, linux-kbuild
>
> So as a summarry, here are the three options:
> - update existing frontends against their respective framework
> - add two new frontends, and two new goals to call them
> - add two new frontends, and decide whether to call them or the old ones
>
> Really, I have no idea what is best.
As per my other mail the best candidate is
"- update existing frontends against their respective framework".
Because:
- There exist a fallback for users that do not have the never libs available
- The gtk/qt frontends see only little love&care - so coming up with something
that require more love&care is not good
- And we know that we have a person to look after the problems that is introduced
at lest for a few months.
We should carefully review the patches to make sure the resulting code is maintainable
in the long term. I assume this is more or less a no-brainer.
Sam
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Kconfig Gtk/Qt interface flavours ported to newest toolkit versions
2013-07-03 16:30 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions Yann E. MORIN
2013-07-06 0:13 ` David Gräff
@ 2013-07-11 20:56 ` Sam Ravnborg
1 sibling, 0 replies; 33+ messages in thread
From: Sam Ravnborg @ 2013-07-11 20:56 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: davidgraeff, Michal Marek, linux-kbuild
>
> I did not do any review of the patches, since I have a concern about the
> series. It happens very often that, in enterprise ecosystems, the host
> build machines are running rather aging distro, such as RHEL 5 (or even
> RHEL 4 in some cases), so I think we still want the new kernels to be
> buildable (and thus configurable) on such machines (eg. for
> cross-compilation).
>
> I have no idea when such enterprise distros have started bundling GTK3
> or Qt4/5, but given RHEL-4 (which is still use in some places) is 8
> years old, I doubt the new frontends would build on those distros.
IMO users restricted to these systems - if required to look at / modify the kernel
configuration can use one of the other frontends.
In other words - I do not think we shall stick to the old gtk / qt versions due to this.
> > I do not know if it was on purpose to keep all flavours except lxdialog in one single directory,
>
> Historical artifact, I think... :-(
lxdialog was one a separate binary - later we did a very rough conversion
so it is now a single binary. But there are many left-overs from when it was
separated.
Sam
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Kconfig Gtk/Qt interface flavours ported to newest toolkit versions
2013-07-02 15:22 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions davidgraeff
` (7 preceding siblings ...)
2013-07-03 16:30 ` Kconfig Gtk/Qt interface flavours ported to newest toolkit versions Yann E. MORIN
@ 2013-07-11 21:06 ` Sam Ravnborg
8 siblings, 0 replies; 33+ messages in thread
From: Sam Ravnborg @ 2013-07-11 21:06 UTC (permalink / raw)
To: davidgraeff; +Cc: Michal Marek, linux-kbuild
On Tue, Jul 02, 2013 at 05:22:21PM +0200, davidgraeff wrote:
> Hello all,
>
> I've no idea if this is the right way to send patches. I'm kind of new to this.
> Attached is a patchset basically for porting the graphical Gtk and Qt flavours
> to their latest toolkit versions (Gtk3 and Qt4 with compatibility to Qt5 respectively).
> It took a day or so to get into the code -> Newly inserted and changed source code
> is commented in many/some places now.
>
> I do not know if it was on purpose to keep all flavours except lxdialog in one single directory,
> but for presumably easier maintenance the first patch split of each flavours into its
> own subdirectory. Additionally I ripped out flavour specific makefile targets. Each subdirectory
> contains a separate makefile now.
> An advantage is a more simple makefile for e.g. all the C++/Qt stuff, where Qt specific moc and uic
> tools are necessary.
>
> The 2nd to 6th patch port the Gtk2 ui to the modern Gtk3 toolkit including the conversion
> from a libglade (deprecated) interface to a gtkbuilder interface.
>
> The 7th to 9th patch port the Qt3/Qt4+Qt3support ui to the current version 4 of the Qt toolkit.
> The gui is no longer realised by handwritten c++ code but by the Qt Designer for a much easier
> user interface design and less code.
> The Model/View concept of Qt is heavily used and no Qt3 support classes are used anymore,
> as a result the code should work with the newest Qt5, too.
>
> Those newer graphical kconfig flavours will be used by a project I'm involved in so
> I will maintain it for the next couple of months.
>
> If I did anything wrong, please instruct me or provide me a link please.
It seems patch [1/9] is missing. Maybe the size as too big.
Did you specify "-D -M" when you ran "git format-patch"?
This will show file relocatiosn in a very efficent and reviewable way.
Sam
^ permalink raw reply [flat|nested] 33+ messages in thread