]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - scripts/kconfig/gconf.c
kconfig: annotate non-trivial fall-trough
[linux-2.6.git] / scripts / kconfig / gconf.c
index dfe748c38b7276b7c47eb026fc0521af8d316c9e..c406bde28dbe6428819fb2719d7c5aa8c7aa97bf 100644 (file)
@@ -30,13 +30,16 @@ 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 show_all = FALSE;
-static gboolean show_debug = FALSE;
 static gboolean resizeable = FALSE;
+static int opt_mode = OPT_NORMAL;
 
 GtkWidget *main_wnd = NULL;
 GtkWidget *tree1_w = NULL;     // left  frame
@@ -76,36 +79,7 @@ static void conf_changed(void);
 
 /* Helping/Debugging Functions */
 
-
-const char *dbg_print_stype(int val)
-{
-       static char buf[256];
-
-       bzero(buf, 256);
-
-       if (val == S_UNKNOWN)
-               strcpy(buf, "unknown");
-       if (val == S_BOOLEAN)
-               strcpy(buf, "boolean");
-       if (val == S_TRISTATE)
-               strcpy(buf, "tristate");
-       if (val == S_INT)
-               strcpy(buf, "int");
-       if (val == S_HEX)
-               strcpy(buf, "hex");
-       if (val == S_STRING)
-               strcpy(buf, "string");
-       if (val == S_OTHER)
-               strcpy(buf, "other");
-
-#ifdef DEBUG
-       printf("%s", buf);
-#endif
-
-       return buf;
-}
-
-const char *dbg_print_flags(int val)
+const char *dbg_sym_flags(int val)
 {
        static char buf[256];
 
@@ -131,40 +105,10 @@ const char *dbg_print_flags(int val)
                strcat(buf, "auto/");
 
        buf[strlen(buf) - 1] = '\0';
-#ifdef DEBUG
-       printf("%s", buf);
-#endif
 
        return buf;
 }
 
-const char *dbg_print_ptype(int val)
-{
-       static char buf[256];
-
-       bzero(buf, 256);
-
-       if (val == P_UNKNOWN)
-               strcpy(buf, "unknown");
-       if (val == P_PROMPT)
-               strcpy(buf, "prompt");
-       if (val == P_COMMENT)
-               strcpy(buf, "comment");
-       if (val == P_MENU)
-               strcpy(buf, "menu");
-       if (val == P_DEFAULT)
-               strcpy(buf, "default");
-       if (val == P_CHOICE)
-               strcpy(buf, "choice");
-
-#ifdef DEBUG
-       printf("%s", buf);
-#endif
-
-       return buf;
-}
-
-
 void replace_button_icon(GladeXML * xml, GdkDrawable * window,
                         GtkStyle * style, gchar * btn_name, gchar ** xpm)
 {
@@ -189,7 +133,6 @@ void init_main_window(const gchar * glade_file)
        GladeXML *xml;
        GtkWidget *widget;
        GtkTextBuffer *txtbuf;
-       char title[256];
        GtkStyle *style;
 
        xml = glade_xml_new(glade_file, "window1", NULL);
@@ -266,9 +209,7 @@ void init_main_window(const gchar * glade_file)
                                          /*"style", PANGO_STYLE_OBLIQUE, */
                                          NULL);
 
-       sprintf(title, _("Linux Kernel v%s Configuration"),
-               getenv("KERNELVERSION"));
-       gtk_window_set_title(GTK_WINDOW(main_wnd), title);
+       gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
 
        gtk_widget_show(main_wnd);
 }
@@ -312,7 +253,7 @@ void init_left_tree(void)
 
        gtk_tree_view_set_model(view, model1);
        gtk_tree_view_set_headers_visible(view, TRUE);
-       gtk_tree_view_set_rules_hint(view, FALSE);
+       gtk_tree_view_set_rules_hint(view, TRUE);
 
        column = gtk_tree_view_column_new();
        gtk_tree_view_append_column(view, column);
@@ -357,7 +298,7 @@ void init_right_tree(void)
 
        gtk_tree_view_set_model(view, model2);
        gtk_tree_view_set_headers_visible(view, TRUE);
-       gtk_tree_view_set_rules_hint(view, FALSE);
+       gtk_tree_view_set_rules_hint(view, TRUE);
 
        column = gtk_tree_view_column_new();
        gtk_tree_view_append_column(view, column);
@@ -456,19 +397,9 @@ static void text_insert_help(struct menu *menu)
        GtkTextBuffer *buffer;
        GtkTextIter start, end;
        const char *prompt = _(menu_get_prompt(menu));
-       gchar *name;
-       const char *help;
+       struct gstr help = str_new();
 
-       help = menu_get_help(menu);
-
-       /* Gettextize if the help text not empty */
-       if ((help != 0) && (help[0] != 0))
-               help = _(help);
-
-       if (menu->sym && menu->sym->name)
-               name = g_strdup_printf(_(menu->sym->name));
-       else
-               name = g_strdup("");
+       menu_get_ext_help(menu, &help);
 
        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
        gtk_text_buffer_get_bounds(buffer, &start, &end);
@@ -478,14 +409,11 @@ static void text_insert_help(struct menu *menu)
        gtk_text_buffer_get_end_iter(buffer, &end);
        gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
                                         NULL);
-       gtk_text_buffer_insert_at_cursor(buffer, " ", 1);
-       gtk_text_buffer_get_end_iter(buffer, &end);
-       gtk_text_buffer_insert_with_tags(buffer, &end, name, -1, tag1,
-                                        NULL);
        gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
        gtk_text_buffer_get_end_iter(buffer, &end);
-       gtk_text_buffer_insert_with_tags(buffer, &end, help, -1, tag2,
+       gtk_text_buffer_insert_with_tags(buffer, &end, str_get(&help), -1, tag2,
                                         NULL);
+       str_free(&help);
 }
 
 
@@ -710,20 +638,29 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
 
 
 void
-on_show_all_options1_activate(GtkMenuItem * menuitem, gpointer user_data)
+on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
-       show_all = GTK_CHECK_MENU_ITEM(menuitem)->active;
+       opt_mode = OPT_NORMAL;
+       gtk_tree_store_clear(tree2);
+       display_tree(&rootmenu);        /* instead of update_tree to speed-up */
+}
+
 
+void
+on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
+{
+       opt_mode = OPT_ALL;
        gtk_tree_store_clear(tree2);
-       display_tree(&rootmenu);        // instead of update_tree to speed-up
+       display_tree(&rootmenu);        /* instead of update_tree to speed-up */
 }
 
 
 void
-on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data)
+on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
-       show_debug = GTK_CHECK_MENU_ITEM(menuitem)->active;
-       update_tree(&rootmenu, NULL);
+       opt_mode = OPT_PROMPT;
+       gtk_tree_store_clear(tree2);
+       display_tree(&rootmenu);        /* instead of update_tree to speed-up */
 }
 
 
@@ -731,8 +668,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
 {
        GtkWidget *dialog;
        const gchar *intro_text = _(
-           "Welcome to gkc, the GTK+ graphical kernel configuration tool\n"
-           "for Linux.\n"
+           "Welcome to gkc, the GTK+ graphical configuration tool\n"
            "For each option, a blank box indicates the feature is disabled, a\n"
            "check indicates it is enabled, and a dot indicates that it is to\n"
            "be compiled as a module.  Clicking on the box will cycle through the three states.\n"
@@ -820,7 +756,6 @@ void on_load_clicked(GtkButton * button, gpointer user_data)
 void on_single_clicked(GtkButton * button, gpointer user_data)
 {
        view_mode = SINGLE_VIEW;
-       gtk_paned_set_position(GTK_PANED(hpaned), 0);
        gtk_widget_hide(tree1_w);
        current = &rootmenu;
        display_tree_part();
@@ -846,7 +781,6 @@ void on_split_clicked(GtkButton * button, gpointer user_data)
 void on_full_clicked(GtkButton * button, gpointer user_data)
 {
        view_mode = FULL_VIEW;
-       gtk_paned_set_position(GTK_PANED(hpaned), 0);
        gtk_widget_hide(tree1_w);
        if (tree2)
                gtk_tree_store_clear(tree2);
@@ -1174,9 +1108,12 @@ static gchar **fill_row(struct menu *menu)
 
        row[COL_OPTION] =
            g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
-                           sym && sym_has_value(sym) ? "(NEW)" : "");
+                           sym && !sym_has_value(sym) ? "(NEW)" : "");
 
-       if (show_all && !menu_is_visible(menu))
+       if (opt_mode == OPT_ALL && !menu_is_visible(menu))
+               row[COL_COLOR] = g_strdup("DarkGray");
+       else if (opt_mode == OPT_PROMPT &&
+                       menu_has_prompt(menu) && !menu_is_visible(menu))
                row[COL_COLOR] = g_strdup("DarkGray");
        else
                row[COL_COLOR] = g_strdup("Black");
@@ -1235,6 +1172,7 @@ static gchar **fill_row(struct menu *menu)
                        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) {
@@ -1399,16 +1337,20 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
                       menu2 ? menu_get_prompt(menu2) : "nil");
 #endif
 
-               if (!menu_is_visible(child1) && !show_all) {    // remove node
+               if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
+                   (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
+                   (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(tree2, &tmp);
                                if (!valid)
-                                       return; // next parent
+                                       return;         /* next parent */
                                else
-                                       goto reparse;   // next child
+                                       goto reparse;   /* next child */
                        } else
                                continue;
                }
@@ -1477,17 +1419,19 @@ static void display_tree(struct menu *menu)
                    && (tree == tree2))
                        continue;
 
-               if (menu_is_visible(child) || show_all)
+               if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
+                   (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
+                   (opt_mode == OPT_ALL    && menu_get_prompt(child)))
                        place_node(child, fill_row(child));
 #ifdef DEBUG
                printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
                printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
-               dbg_print_ptype(ptype);
+               printf("%s", prop_get_type_name(ptype));
                printf(" | ");
                if (sym) {
-                       dbg_print_stype(sym->type);
+                       printf("%s", sym_type_name(sym->type));
                        printf(" | ");
-                       dbg_print_flags(sym->flags);
+                       printf("%s", dbg_sym_flags(sym->flags));
                        printf("\n");
                } else
                        printf("\n");
@@ -1499,6 +1443,12 @@ static void display_tree(struct menu *menu)
                 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(hpaned), 0);
+               }
+
                if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
                    || (view_mode == FULL_VIEW)
                    || (view_mode == SPLIT_VIEW)) {
@@ -1582,12 +1532,6 @@ int main(int ac, char *av[])
        else
                glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
 
-       /* Load the interface and connect signals */
-       init_main_window(glade_file);
-       init_tree_model();
-       init_left_tree();
-       init_right_tree();
-
        /* Conf stuffs */
        if (ac > 1 && av[1][0] == '-') {
                switch (av[1][1]) {
@@ -1607,6 +1551,12 @@ int main(int ac, char *av[])
        fixup_rootmenu(&rootmenu);
        conf_read(NULL);
 
+       /* Load the interface and connect signals */
+       init_main_window(glade_file);
+       init_tree_model();
+       init_left_tree();
+       init_right_tree();
+
        switch (view_mode) {
        case SINGLE_VIEW:
                display_tree_part();