From patchwork Tue Jul 2 15:22:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: davidgraeff X-Patchwork-Id: 2813421 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C0A7E9F755 for ; Tue, 2 Jul 2013 15:23:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3818120153 for ; Tue, 2 Jul 2013 15:23:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F2F220152 for ; Tue, 2 Jul 2013 15:23:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753093Ab3GBPXg (ORCPT ); Tue, 2 Jul 2013 11:23:36 -0400 Received: from mail-ee0-f52.google.com ([74.125.83.52]:35105 "EHLO mail-ee0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753089Ab3GBPXf (ORCPT ); Tue, 2 Jul 2013 11:23:35 -0400 Received: by mail-ee0-f52.google.com with SMTP id c50so2856603eek.11 for ; Tue, 02 Jul 2013 08:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=p2Jdb+eIk1h3ZsyYkUm+fxfCpLf7k81oS332LfVILRI=; b=wm6xbDBytpX3ghsGdQPh052kBY1bo+GLHvOrJLv8hEzZJo+A3bGSVQ4jeETfaXM5WG bQ+2tBourBi17ukgtQklAivnlV+bedqPaOikV6KxRJjfYZuR9sGUkN5N1YZI49VFbzcw iuU8PlkmxzgLuO3K+tn0XxID75TD0DOa2cRJEmlBQ6ZL3hG5iCUNk8h0WnWFXNjrlZBx WLSP9hyGkv75LDDmijWPLGT98AIFS0Y2P5tmVkR8yXk5yPI/f5kpLqI8oyGTJ3te5yHV 7Yt1J9n11MOH64ghiSCddOEOoN3BbbJT/7vV39G8ue/AkO7VC7Pml8nRteknlCKvHzka Omjw== X-Received: by 10.14.251.202 with SMTP id b50mr26667537ees.85.1372778611909; Tue, 02 Jul 2013 08:23:31 -0700 (PDT) Received: from localhost.localdomain (ip-95-223-112-226.unitymediagroup.de. [95.223.112.226]) by mx.google.com with ESMTPSA id l42sm37233028eeo.14.2013.07.02.08.23.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jul 2013 08:23:31 -0700 (PDT) From: davidgraeff To: Michal Marek Cc: linux-kbuild@vger.kernel.org, davidgraeff Subject: [PATCH 3/9] kconfig: gtk interface port to Gtk3 Date: Tue, 2 Jul 2013 17:22:24 +0200 Message-Id: <1372778550-22110-4-git-send-email-david.graeff@web.de> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1372778550-22110-1-git-send-email-david.graeff@web.de> References: <1372778550-22110-1-git-send-email-david.graeff@web.de> MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 -#include "../lkc.h" -#include "../images.c" +#include +#include +#include +#include +#include -#include #include #include #include -#include -#include -#include -#include -#include +#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 .\n" + _("Updated to gtk3, copyright (c) 2013 David Gräff .\n" + "gkc is copyright (c) 2002 Romain Lievin .\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 @@ - - - - - - True - Gtk Kernel Configurator - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 640 - 480 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - - - - - - - True - False - 0 - - - - True - - - - True - _File - True - - - - - - - True - Load a config file - _Load - True - - - - - - True - gtk-open - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - Save the config in .config - _Save - True - - - - - - True - gtk-save - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - Save the config in a file - Save _as - True - - - - - True - gtk-save-as - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - - - - - - True - _Quit - True - - - - - - True - gtk-quit - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - - - - - True - _Options - True - - - - - - - True - Show name - Show _name - True - False - - - - - - - True - Show range (Y/M/N) - Show _range - True - False - - - - - - - True - Show value of the option - Show _data - True - False - - - - - - - True - - - - - - True - Show normal options - Show normal options - True - True - - - - - - - True - Show all options - Show all _options - True - False - set_option_mode1 - - - - - - - True - Show all options with prompts - Show all prompt options - True - False - set_option_mode1 - - - - - - - - - - - - True - _Help - True - - - - - - - True - _Introduction - True - - - - - - True - gtk-dialog-question - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - _About - True - - - - - - True - gtk-properties - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - _License - True - - - - - True - gtk-justify-fill - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - - - - 0 - False - False - - - - - - True - GTK_SHADOW_OUT - GTK_POS_LEFT - GTK_POS_TOP - - - - True - GTK_ORIENTATION_HORIZONTAL - GTK_TOOLBAR_BOTH - True - True - - - - True - Goes up of one level (single view) - Back - True - gtk-undo - True - True - False - - - - False - True - - - - - - True - True - True - False - - - - True - - - - - False - False - - - - - - True - Load a config file - Load - True - gtk-open - True - True - False - - - - False - True - - - - - - True - Save a config file - Save - True - gtk-save - True - True - False - - - - False - True - - - - - - True - True - True - False - - - - True - - - - - False - False - - - - - - True - Single view - Single - True - gtk-missing-image - True - True - False - - - - False - True - - - - - - True - Split view - Split - True - gtk-missing-image - True - True - False - - - - False - True - - - - - - True - Full view - Full - True - gtk-missing-image - True - True - False - - - - False - True - - - - - - True - True - True - False - - - - True - - - - - False - False - - - - - - True - Collapse the whole tree in the right frame - Collapse - True - gtk-remove - True - True - False - - - - False - True - - - - - - True - Expand the whole tree in the right frame - Expand - True - gtk-add - True - True - False - - - - False - True - - - - - - - 0 - False - False - - - - - - 1 - True - True - 0 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - False - - - - - - - - True - False - - - - - - True - True - 0 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - True - False - False - False - - - - - - - - True - False - - - - - - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - False - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - Sorry, no help available for this option yet. - - - - - True - True - - - - - True - True - - - - - 0 - True - True - - - - - - - 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 @@ + + + + + True + False + 0.47999998927116394 + gtk-dialog-question + + + True + False + gtk-justify-fill + + + Sorry, no help available for this option yet. + + + False + Gtk Kernel Configurator + 640 + 250 + + + + + True + False + + + True + False + + + True + False + _File + True + + + True + False + + + gtk-open + True + False + Load a config file + True + True + + + + + + gtk-save + True + False + Save the config in .config + True + True + + + + + + gtk-save-as + True + False + Save the config in a file + True + True + + + + + + True + False + + + + + gtk-quit + True + False + True + True + + + + + + + + + + True + False + _Options + True + + + True + False + + + True + False + Show name + Show _name + True + + + + + + True + False + Show range (Y/M/N) + Show _range + True + + + + + + True + False + Show value of the option + Show _data + True + + + + + + True + False + + + + + True + False + Show normal options + Show normal options + True + True + + + + + + True + False + Show all options + Show all _options + True + set_option_mode1 + + + + + + True + False + Show all options with prompts + Show all prompt options + True + set_option_mode1 + + + + + + + + + + True + False + _Hilfe + True + + + True + False + + + _Introduction + True + False + True + image1 + False + + + + + + gtk-about + True + False + True + True + + + + + + _License + True + False + True + image2 + False + + + + + + + + + + False + True + 0 + + + + + True + False + + + True + False + both + + + True + False + True + Goes up of one level (single view) + Goes up of one level (single view) + Back + True + gtk-undo + + + + False + True + + + + + True + False + + + True + False + + + + + False + + + + + True + False + True + Load a config file + Load a config file + Load + True + gtk-open + + + + False + True + + + + + True + False + True + Save a config file + Save a config file + Save + True + gtk-save + + + + False + True + + + + + True + False + + + True + False + + + + + False + + + + + True + False + True + Single view + Single view + Single + True + gtk-missing-image + + + + False + True + + + + + True + False + True + Split view + Split view + Split + True + gtk-missing-image + + + + False + True + + + + + True + False + True + Full view + Full view + Full + True + gtk-missing-image + + + + False + True + + + + + True + False + + + True + False + + + + + False + + + + + True + False + True + Collapse the whole tree in the right frame + Collapse the whole tree in the right frame + Collapse + True + gtk-remove + + + + False + True + + + + + True + False + True + Expand the whole tree in the right frame + Expand the whole tree in the right frame + Expand + True + gtk-add + + + + False + True + + + + + + + False + False + 1 + + + + + True + True + + + 100 + True + False + 3 + in + 150 + + + True + True + GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK + False + False + + + + + + + + + + + True + True + + + + + True + True + 3 + True + + + True + False + True + + + True + True + GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK + False + + + + + + + + + + + + True + False + + + + + 80 + True + False + never + in + + + True + True + False + word + textbuffer1 + + + + + True + True + + + + + True + True + + + + + True + True + 2 + + + + + +