diff options
author | Joachim Nilsson <joachim.nilsson@vmlinux.org> | 2005-07-28 18:18:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-28 18:43:58 -0400 |
commit | bafd2df5d0049bccc74947fece37963e3f68fadc (patch) | |
tree | 5a110870f96f842049f8cc9ffd10bf24fb108206 /scripts/kconfig/gconf.c | |
parent | 2ac6608c41f8c45371ea9dddae7f99bc2c15d5cf (diff) |
[PATCH] fix gconfig crash
I ran glade-2 on the glade file, fixed two missing stock icons and
cleaned up the C code that inserts the single/split/full modes. The
rest of the patch is minor cleanups only. I refrained from using all
the included xpm icons in images.c (like qconf.cc does) in favour of
using the stock Gtk+ icons instead. Oh, yes there was a "back" bug
in split mode that I also removed, oh well...
It has been tested with success by several people, including
Jesper Juhl, Randy Dunlap and myself.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts/kconfig/gconf.c')
-rw-r--r-- | scripts/kconfig/gconf.c | 144 |
1 files changed, 73 insertions, 71 deletions
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index ad6b12043874..9f5aabd58fa9 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
@@ -178,17 +178,31 @@ const char *dbg_print_ptype(int val) | |||
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | /* Main Window Initialization */ | 181 | void replace_button_icon(GladeXML * xml, GdkDrawable * window, |
182 | GtkStyle * style, gchar * btn_name, gchar ** xpm) | ||
183 | { | ||
184 | GdkPixmap *pixmap; | ||
185 | GdkBitmap *mask; | ||
186 | GtkToolButton *button; | ||
187 | GtkWidget *image; | ||
182 | 188 | ||
189 | pixmap = gdk_pixmap_create_from_xpm_d(window, &mask, | ||
190 | &style->bg[GTK_STATE_NORMAL], | ||
191 | xpm); | ||
192 | |||
193 | button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name)); | ||
194 | image = gtk_image_new_from_pixmap(pixmap, mask); | ||
195 | gtk_widget_show(image); | ||
196 | gtk_tool_button_set_icon_widget(button, image); | ||
197 | } | ||
183 | 198 | ||
199 | /* Main Window Initialization */ | ||
184 | void init_main_window(const gchar * glade_file) | 200 | void init_main_window(const gchar * glade_file) |
185 | { | 201 | { |
186 | GladeXML *xml; | 202 | GladeXML *xml; |
187 | GtkWidget *widget; | 203 | GtkWidget *widget; |
188 | GtkTextBuffer *txtbuf; | 204 | GtkTextBuffer *txtbuf; |
189 | char title[256]; | 205 | char title[256]; |
190 | GdkPixmap *pixmap; | ||
191 | GdkBitmap *mask; | ||
192 | GtkStyle *style; | 206 | GtkStyle *style; |
193 | 207 | ||
194 | xml = glade_xml_new(glade_file, "window1", NULL); | 208 | xml = glade_xml_new(glade_file, "window1", NULL); |
@@ -221,36 +235,22 @@ void init_main_window(const gchar * glade_file) | |||
221 | style = gtk_widget_get_style(main_wnd); | 235 | style = gtk_widget_get_style(main_wnd); |
222 | widget = glade_xml_get_widget(xml, "toolbar1"); | 236 | widget = glade_xml_get_widget(xml, "toolbar1"); |
223 | 237 | ||
224 | pixmap = gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask, | 238 | #if 0 /* Use stock Gtk icons instead */ |
225 | &style->bg[GTK_STATE_NORMAL], | 239 | replace_button_icon(xml, main_wnd->window, style, |
226 | (gchar **) xpm_single_view); | 240 | "button1", (gchar **) xpm_back); |
227 | gtk_image_set_from_pixmap(GTK_IMAGE | 241 | replace_button_icon(xml, main_wnd->window, style, |
228 | (((GtkToolbarChild | 242 | "button2", (gchar **) xpm_load); |
229 | *) (g_list_nth(GTK_TOOLBAR(widget)-> | 243 | replace_button_icon(xml, main_wnd->window, style, |
230 | children, | 244 | "button3", (gchar **) xpm_save); |
231 | 5)->data))->icon), | 245 | #endif |
232 | pixmap, mask); | 246 | replace_button_icon(xml, main_wnd->window, style, |
233 | pixmap = | 247 | "button4", (gchar **) xpm_single_view); |
234 | gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask, | 248 | replace_button_icon(xml, main_wnd->window, style, |
235 | &style->bg[GTK_STATE_NORMAL], | 249 | "button5", (gchar **) xpm_split_view); |
236 | (gchar **) xpm_split_view); | 250 | replace_button_icon(xml, main_wnd->window, style, |
237 | gtk_image_set_from_pixmap(GTK_IMAGE | 251 | "button6", (gchar **) xpm_tree_view); |
238 | (((GtkToolbarChild | 252 | |
239 | *) (g_list_nth(GTK_TOOLBAR(widget)-> | 253 | #if 0 |
240 | children, | ||
241 | 6)->data))->icon), | ||
242 | pixmap, mask); | ||
243 | pixmap = | ||
244 | gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask, | ||
245 | &style->bg[GTK_STATE_NORMAL], | ||
246 | (gchar **) xpm_tree_view); | ||
247 | gtk_image_set_from_pixmap(GTK_IMAGE | ||
248 | (((GtkToolbarChild | ||
249 | *) (g_list_nth(GTK_TOOLBAR(widget)-> | ||
250 | children, | ||
251 | 7)->data))->icon), | ||
252 | pixmap, mask); | ||
253 | |||
254 | switch (view_mode) { | 254 | switch (view_mode) { |
255 | case SINGLE_VIEW: | 255 | case SINGLE_VIEW: |
256 | widget = glade_xml_get_widget(xml, "button4"); | 256 | widget = glade_xml_get_widget(xml, "button4"); |
@@ -265,7 +265,7 @@ void init_main_window(const gchar * glade_file) | |||
265 | g_signal_emit_by_name(widget, "clicked"); | 265 | g_signal_emit_by_name(widget, "clicked"); |
266 | break; | 266 | break; |
267 | } | 267 | } |
268 | 268 | #endif | |
269 | txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); | 269 | txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); |
270 | tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1", | 270 | tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1", |
271 | "foreground", "red", | 271 | "foreground", "red", |
@@ -322,7 +322,7 @@ void init_left_tree(void) | |||
322 | gtk_tree_view_set_model(view, model1); | 322 | gtk_tree_view_set_model(view, model1); |
323 | gtk_tree_view_set_headers_visible(view, TRUE); | 323 | gtk_tree_view_set_headers_visible(view, TRUE); |
324 | gtk_tree_view_set_rules_hint(view, FALSE); | 324 | gtk_tree_view_set_rules_hint(view, FALSE); |
325 | 325 | ||
326 | column = gtk_tree_view_column_new(); | 326 | column = gtk_tree_view_column_new(); |
327 | gtk_tree_view_append_column(view, column); | 327 | gtk_tree_view_append_column(view, column); |
328 | gtk_tree_view_column_set_title(column, _("Options")); | 328 | gtk_tree_view_column_set_title(column, _("Options")); |
@@ -334,11 +334,11 @@ void init_left_tree(void) | |||
334 | renderer, | 334 | renderer, |
335 | "active", COL_BTNACT, | 335 | "active", COL_BTNACT, |
336 | "inconsistent", COL_BTNINC, | 336 | "inconsistent", COL_BTNINC, |
337 | "visible", COL_BTNVIS, | 337 | "visible", COL_BTNVIS, |
338 | "radio", COL_BTNRAD, NULL); | 338 | "radio", COL_BTNRAD, NULL); |
339 | renderer = gtk_cell_renderer_text_new(); | 339 | renderer = gtk_cell_renderer_text_new(); |
340 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), | 340 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), |
341 | renderer, FALSE); | 341 | renderer, FALSE); |
342 | gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column), | 342 | gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column), |
343 | renderer, | 343 | renderer, |
344 | "text", COL_OPTION, | 344 | "text", COL_OPTION, |
@@ -386,7 +386,7 @@ void init_right_tree(void) | |||
386 | renderer, | 386 | renderer, |
387 | "active", COL_BTNACT, | 387 | "active", COL_BTNACT, |
388 | "inconsistent", COL_BTNINC, | 388 | "inconsistent", COL_BTNINC, |
389 | "visible", COL_BTNVIS, | 389 | "visible", COL_BTNVIS, |
390 | "radio", COL_BTNRAD, NULL); | 390 | "radio", COL_BTNRAD, NULL); |
391 | /*g_signal_connect(G_OBJECT(renderer), "toggled", | 391 | /*g_signal_connect(G_OBJECT(renderer), "toggled", |
392 | G_CALLBACK(renderer_toggled), NULL); */ | 392 | G_CALLBACK(renderer_toggled), NULL); */ |
@@ -806,7 +806,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data) | |||
806 | } | 806 | } |
807 | 807 | ||
808 | 808 | ||
809 | void on_back_pressed(GtkButton * button, gpointer user_data) | 809 | void on_back_clicked(GtkButton * button, gpointer user_data) |
810 | { | 810 | { |
811 | enum prop_type ptype; | 811 | enum prop_type ptype; |
812 | 812 | ||
@@ -821,13 +821,13 @@ void on_back_pressed(GtkButton * button, gpointer user_data) | |||
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | void on_load_pressed(GtkButton * button, gpointer user_data) | 824 | void on_load_clicked(GtkButton * button, gpointer user_data) |
825 | { | 825 | { |
826 | on_load1_activate(NULL, user_data); | 826 | on_load1_activate(NULL, user_data); |
827 | } | 827 | } |
828 | 828 | ||
829 | 829 | ||
830 | void on_save_pressed(GtkButton * button, gpointer user_data) | 830 | void on_save_clicked(GtkButton * button, gpointer user_data) |
831 | { | 831 | { |
832 | on_save1_activate(NULL, user_data); | 832 | on_save1_activate(NULL, user_data); |
833 | } | 833 | } |
@@ -850,9 +850,12 @@ void on_split_clicked(GtkButton * button, gpointer user_data) | |||
850 | gtk_widget_show(tree1_w); | 850 | gtk_widget_show(tree1_w); |
851 | gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h); | 851 | gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h); |
852 | gtk_paned_set_position(GTK_PANED(hpaned), w / 2); | 852 | gtk_paned_set_position(GTK_PANED(hpaned), w / 2); |
853 | if (tree2) | 853 | if (tree2) |
854 | gtk_tree_store_clear(tree2); | 854 | gtk_tree_store_clear(tree2); |
855 | display_list(); | 855 | display_list(); |
856 | |||
857 | /* Disable back btn, like in full mode. */ | ||
858 | gtk_widget_set_sensitive(back_btn, FALSE); | ||
856 | } | 859 | } |
857 | 860 | ||
858 | 861 | ||
@@ -868,13 +871,13 @@ void on_full_clicked(GtkButton * button, gpointer user_data) | |||
868 | } | 871 | } |
869 | 872 | ||
870 | 873 | ||
871 | void on_collapse_pressed(GtkButton * button, gpointer user_data) | 874 | void on_collapse_clicked(GtkButton * button, gpointer user_data) |
872 | { | 875 | { |
873 | gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w)); | 876 | gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w)); |
874 | } | 877 | } |
875 | 878 | ||
876 | 879 | ||
877 | void on_expand_pressed(GtkButton * button, gpointer user_data) | 880 | void on_expand_clicked(GtkButton * button, gpointer user_data) |
878 | { | 881 | { |
879 | gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w)); | 882 | gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w)); |
880 | } | 883 | } |
@@ -1242,13 +1245,13 @@ static gchar **fill_row(struct menu *menu) | |||
1242 | row[COL_VALUE] = | 1245 | row[COL_VALUE] = |
1243 | g_strdup(menu_get_prompt(def_menu)); | 1246 | g_strdup(menu_get_prompt(def_menu)); |
1244 | } | 1247 | } |
1245 | if(sym->flags & SYMBOL_CHOICEVAL) | 1248 | if (sym->flags & SYMBOL_CHOICEVAL) |
1246 | row[COL_BTNRAD] = GINT_TO_POINTER(TRUE); | 1249 | row[COL_BTNRAD] = GINT_TO_POINTER(TRUE); |
1247 | 1250 | ||
1248 | stype = sym_get_type(sym); | 1251 | stype = sym_get_type(sym); |
1249 | switch (stype) { | 1252 | switch (stype) { |
1250 | case S_BOOLEAN: | 1253 | case S_BOOLEAN: |
1251 | if(GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE) | 1254 | if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE) |
1252 | row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); | 1255 | row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); |
1253 | if (sym_is_choice(sym)) | 1256 | if (sym_is_choice(sym)) |
1254 | break; | 1257 | break; |
@@ -1423,7 +1426,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst) | |||
1423 | child2); | 1426 | child2); |
1424 | gtk_tree_store_remove(tree2, &tmp); | 1427 | gtk_tree_store_remove(tree2, &tmp); |
1425 | if (!valid) | 1428 | if (!valid) |
1426 | return; // next parent | 1429 | return; // next parent |
1427 | else | 1430 | else |
1428 | goto reparse; // next child | 1431 | goto reparse; // next child |
1429 | } else | 1432 | } else |
@@ -1448,7 +1451,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst) | |||
1448 | child2); | 1451 | child2); |
1449 | gtk_tree_store_remove(tree2, &tmp); | 1452 | gtk_tree_store_remove(tree2, &tmp); |
1450 | if (!valid) | 1453 | if (!valid) |
1451 | return; // next parent | 1454 | return; // next parent |
1452 | else | 1455 | else |
1453 | goto reparse; // next child | 1456 | goto reparse; // next child |
1454 | } | 1457 | } |
@@ -1486,12 +1489,12 @@ static void display_tree(struct menu *menu) | |||
1486 | if (sym) | 1489 | if (sym) |
1487 | sym->flags &= ~SYMBOL_CHANGED; | 1490 | sym->flags &= ~SYMBOL_CHANGED; |
1488 | 1491 | ||
1489 | if ((view_mode == SPLIT_VIEW) && !(child->flags & MENU_ROOT) && | 1492 | if ((view_mode == SPLIT_VIEW) |
1490 | (tree == tree1)) | 1493 | && !(child->flags & MENU_ROOT) && (tree == tree1)) |
1491 | continue; | 1494 | continue; |
1492 | 1495 | ||
1493 | if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT) && | 1496 | if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT) |
1494 | (tree == tree2)) | 1497 | && (tree == tree2)) |
1495 | continue; | 1498 | continue; |
1496 | 1499 | ||
1497 | if (menu_is_visible(child) || show_all) | 1500 | if (menu_is_visible(child) || show_all) |
@@ -1513,11 +1516,12 @@ static void display_tree(struct menu *menu) | |||
1513 | && (tree == tree2)) | 1516 | && (tree == tree2)) |
1514 | continue; | 1517 | continue; |
1515 | /* | 1518 | /* |
1516 | if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) || | 1519 | if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) |
1517 | (view_mode == FULL_VIEW) | 1520 | || (view_mode == FULL_VIEW) |
1518 | || (view_mode == SPLIT_VIEW))*/ | 1521 | || (view_mode == SPLIT_VIEW))*/ |
1519 | if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT)) | 1522 | if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT)) |
1520 | || (view_mode == FULL_VIEW) || (view_mode == SPLIT_VIEW)) { | 1523 | || (view_mode == FULL_VIEW) |
1524 | || (view_mode == SPLIT_VIEW)) { | ||
1521 | indent++; | 1525 | indent++; |
1522 | display_tree(child); | 1526 | display_tree(child); |
1523 | indent--; | 1527 | indent--; |
@@ -1530,9 +1534,9 @@ static void display_tree_part(void) | |||
1530 | { | 1534 | { |
1531 | if (tree2) | 1535 | if (tree2) |
1532 | gtk_tree_store_clear(tree2); | 1536 | gtk_tree_store_clear(tree2); |
1533 | if(view_mode == SINGLE_VIEW) | 1537 | if (view_mode == SINGLE_VIEW) |
1534 | display_tree(current); | 1538 | display_tree(current); |
1535 | else if(view_mode == SPLIT_VIEW) | 1539 | else if (view_mode == SPLIT_VIEW) |
1536 | display_tree(browsed); | 1540 | display_tree(browsed); |
1537 | gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w)); | 1541 | gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w)); |
1538 | } | 1542 | } |
@@ -1551,24 +1555,22 @@ static void display_list(void) | |||
1551 | 1555 | ||
1552 | void fixup_rootmenu(struct menu *menu) | 1556 | void fixup_rootmenu(struct menu *menu) |
1553 | { | 1557 | { |
1554 | struct menu *child; | 1558 | struct menu *child; |
1555 | static int menu_cnt = 0; | 1559 | static int menu_cnt = 0; |
1556 | 1560 | ||
1557 | menu->flags |= MENU_ROOT; | 1561 | menu->flags |= MENU_ROOT; |
1558 | for (child = menu->list; child; child = child->next) { | 1562 | for (child = menu->list; child; child = child->next) { |
1559 | if (child->prompt && child->prompt->type == P_MENU) { | 1563 | if (child->prompt && child->prompt->type == P_MENU) { |
1560 | menu_cnt++; | 1564 | menu_cnt++; |
1561 | fixup_rootmenu(child); | 1565 | fixup_rootmenu(child); |
1562 | menu_cnt--; | 1566 | menu_cnt--; |
1563 | } else if (!menu_cnt) | 1567 | } else if (!menu_cnt) |
1564 | fixup_rootmenu(child); | 1568 | fixup_rootmenu(child); |
1565 | } | 1569 | } |
1566 | } | 1570 | } |
1567 | 1571 | ||
1568 | 1572 | ||
1569 | /* Main */ | 1573 | /* Main */ |
1570 | |||
1571 | |||
1572 | int main(int ac, char *av[]) | 1574 | int main(int ac, char *av[]) |
1573 | { | 1575 | { |
1574 | const char *name; | 1576 | const char *name; |