Skip to content

Commit bafd2df

Browse files
Joachim NilssonLinus Torvalds
authored andcommitted
[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>
1 parent 2ac6608 commit bafd2df

2 files changed

Lines changed: 209 additions & 102 deletions

File tree

‎scripts/kconfig/gconf.c‎

Lines changed: 73 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,31 @@ const char *dbg_print_ptype(int val)
178178
}
179179

180180

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;
182188

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+
}
183198

199+
/* Main Window Initialization */
184200
void init_main_window(const gchar * glade_file)
185201
{
186202
GladeXML *xml;
187203
GtkWidget *widget;
188204
GtkTextBuffer *txtbuf;
189205
char title[256];
190-
GdkPixmap *pixmap;
191-
GdkBitmap *mask;
192206
GtkStyle *style;
193207

194208
xml = glade_xml_new(glade_file, "window1", NULL);
@@ -221,36 +235,22 @@ void init_main_window(const gchar * glade_file)
221235
style = gtk_widget_get_style(main_wnd);
222236
widget = glade_xml_get_widget(xml, "toolbar1");
223237

224-
pixmap = gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask,
225-
&style->bg[GTK_STATE_NORMAL],
226-
(gchar **) xpm_single_view);
227-
gtk_image_set_from_pixmap(GTK_IMAGE
228-
(((GtkToolbarChild
229-
*) (g_list_nth(GTK_TOOLBAR(widget)->
230-
children,
231-
5)->data))->icon),
232-
pixmap, mask);
233-
pixmap =
234-
gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask,
235-
&style->bg[GTK_STATE_NORMAL],
236-
(gchar **) xpm_split_view);
237-
gtk_image_set_from_pixmap(GTK_IMAGE
238-
(((GtkToolbarChild
239-
*) (g_list_nth(GTK_TOOLBAR(widget)->
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-
238+
#if 0 /* Use stock Gtk icons instead */
239+
replace_button_icon(xml, main_wnd->window, style,
240+
"button1", (gchar **) xpm_back);
241+
replace_button_icon(xml, main_wnd->window, style,
242+
"button2", (gchar **) xpm_load);
243+
replace_button_icon(xml, main_wnd->window, style,
244+
"button3", (gchar **) xpm_save);
245+
#endif
246+
replace_button_icon(xml, main_wnd->window, style,
247+
"button4", (gchar **) xpm_single_view);
248+
replace_button_icon(xml, main_wnd->window, style,
249+
"button5", (gchar **) xpm_split_view);
250+
replace_button_icon(xml, main_wnd->window, style,
251+
"button6", (gchar **) xpm_tree_view);
252+
253+
#if 0
254254
switch (view_mode) {
255255
case SINGLE_VIEW:
256256
widget = glade_xml_get_widget(xml, "button4");
@@ -265,7 +265,7 @@ void init_main_window(const gchar * glade_file)
265265
g_signal_emit_by_name(widget, "clicked");
266266
break;
267267
}
268-
268+
#endif
269269
txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
270270
tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
271271
"foreground", "red",
@@ -322,7 +322,7 @@ void init_left_tree(void)
322322
gtk_tree_view_set_model(view, model1);
323323
gtk_tree_view_set_headers_visible(view, TRUE);
324324
gtk_tree_view_set_rules_hint(view, FALSE);
325-
325+
326326
column = gtk_tree_view_column_new();
327327
gtk_tree_view_append_column(view, column);
328328
gtk_tree_view_column_set_title(column, _("Options"));
@@ -334,11 +334,11 @@ void init_left_tree(void)
334334
renderer,
335335
"active", COL_BTNACT,
336336
"inconsistent", COL_BTNINC,
337-
"visible", COL_BTNVIS,
337+
"visible", COL_BTNVIS,
338338
"radio", COL_BTNRAD, NULL);
339339
renderer = gtk_cell_renderer_text_new();
340340
gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
341-
renderer, FALSE);
341+
renderer, FALSE);
342342
gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
343343
renderer,
344344
"text", COL_OPTION,
@@ -386,7 +386,7 @@ void init_right_tree(void)
386386
renderer,
387387
"active", COL_BTNACT,
388388
"inconsistent", COL_BTNINC,
389-
"visible", COL_BTNVIS,
389+
"visible", COL_BTNVIS,
390390
"radio", COL_BTNRAD, NULL);
391391
/*g_signal_connect(G_OBJECT(renderer), "toggled",
392392
G_CALLBACK(renderer_toggled), NULL); */
@@ -806,7 +806,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
806806
}
807807

808808

809-
void on_back_pressed(GtkButton * button, gpointer user_data)
809+
void on_back_clicked(GtkButton * button, gpointer user_data)
810810
{
811811
enum prop_type ptype;
812812

@@ -821,13 +821,13 @@ void on_back_pressed(GtkButton * button, gpointer user_data)
821821
}
822822

823823

824-
void on_load_pressed(GtkButton * button, gpointer user_data)
824+
void on_load_clicked(GtkButton * button, gpointer user_data)
825825
{
826826
on_load1_activate(NULL, user_data);
827827
}
828828

829829

830-
void on_save_pressed(GtkButton * button, gpointer user_data)
830+
void on_save_clicked(GtkButton * button, gpointer user_data)
831831
{
832832
on_save1_activate(NULL, user_data);
833833
}
@@ -850,9 +850,12 @@ void on_split_clicked(GtkButton * button, gpointer user_data)
850850
gtk_widget_show(tree1_w);
851851
gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
852852
gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
853-
if (tree2)
853+
if (tree2)
854854
gtk_tree_store_clear(tree2);
855855
display_list();
856+
857+
/* Disable back btn, like in full mode. */
858+
gtk_widget_set_sensitive(back_btn, FALSE);
856859
}
857860

858861

@@ -868,13 +871,13 @@ void on_full_clicked(GtkButton * button, gpointer user_data)
868871
}
869872

870873

871-
void on_collapse_pressed(GtkButton * button, gpointer user_data)
874+
void on_collapse_clicked(GtkButton * button, gpointer user_data)
872875
{
873876
gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w));
874877
}
875878

876879

877-
void on_expand_pressed(GtkButton * button, gpointer user_data)
880+
void on_expand_clicked(GtkButton * button, gpointer user_data)
878881
{
879882
gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
880883
}
@@ -1242,13 +1245,13 @@ static gchar **fill_row(struct menu *menu)
12421245
row[COL_VALUE] =
12431246
g_strdup(menu_get_prompt(def_menu));
12441247
}
1245-
if(sym->flags & SYMBOL_CHOICEVAL)
1248+
if (sym->flags & SYMBOL_CHOICEVAL)
12461249
row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
12471250

12481251
stype = sym_get_type(sym);
12491252
switch (stype) {
12501253
case S_BOOLEAN:
1251-
if(GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE)
1254+
if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE)
12521255
row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
12531256
if (sym_is_choice(sym))
12541257
break;
@@ -1423,7 +1426,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
14231426
child2);
14241427
gtk_tree_store_remove(tree2, &tmp);
14251428
if (!valid)
1426-
return; // next parent
1429+
return; // next parent
14271430
else
14281431
goto reparse; // next child
14291432
} else
@@ -1448,7 +1451,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
14481451
child2);
14491452
gtk_tree_store_remove(tree2, &tmp);
14501453
if (!valid)
1451-
return; // next parent
1454+
return; // next parent
14521455
else
14531456
goto reparse; // next child
14541457
}
@@ -1486,12 +1489,12 @@ static void display_tree(struct menu *menu)
14861489
if (sym)
14871490
sym->flags &= ~SYMBOL_CHANGED;
14881491

1489-
if ((view_mode == SPLIT_VIEW) && !(child->flags & MENU_ROOT) &&
1490-
(tree == tree1))
1492+
if ((view_mode == SPLIT_VIEW)
1493+
&& !(child->flags & MENU_ROOT) && (tree == tree1))
14911494
continue;
14921495

1493-
if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT) &&
1494-
(tree == tree2))
1496+
if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT)
1497+
&& (tree == tree2))
14951498
continue;
14961499

14971500
if (menu_is_visible(child) || show_all)
@@ -1513,11 +1516,12 @@ static void display_tree(struct menu *menu)
15131516
&& (tree == tree2))
15141517
continue;
15151518
/*
1516-
if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) ||
1517-
(view_mode == FULL_VIEW)
1519+
if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
1520+
|| (view_mode == FULL_VIEW)
15181521
|| (view_mode == SPLIT_VIEW))*/
15191522
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)) {
15211525
indent++;
15221526
display_tree(child);
15231527
indent--;
@@ -1530,9 +1534,9 @@ static void display_tree_part(void)
15301534
{
15311535
if (tree2)
15321536
gtk_tree_store_clear(tree2);
1533-
if(view_mode == SINGLE_VIEW)
1537+
if (view_mode == SINGLE_VIEW)
15341538
display_tree(current);
1535-
else if(view_mode == SPLIT_VIEW)
1539+
else if (view_mode == SPLIT_VIEW)
15361540
display_tree(browsed);
15371541
gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
15381542
}
@@ -1551,24 +1555,22 @@ static void display_list(void)
15511555

15521556
void fixup_rootmenu(struct menu *menu)
15531557
{
1554-
struct menu *child;
1555-
static int menu_cnt = 0;
1556-
1557-
menu->flags |= MENU_ROOT;
1558-
for (child = menu->list; child; child = child->next) {
1559-
if (child->prompt && child->prompt->type == P_MENU) {
1560-
menu_cnt++;
1561-
fixup_rootmenu(child);
1562-
menu_cnt--;
1563-
} else if (!menu_cnt)
1564-
fixup_rootmenu(child);
1565-
}
1558+
struct menu *child;
1559+
static int menu_cnt = 0;
1560+
1561+
menu->flags |= MENU_ROOT;
1562+
for (child = menu->list; child; child = child->next) {
1563+
if (child->prompt && child->prompt->type == P_MENU) {
1564+
menu_cnt++;
1565+
fixup_rootmenu(child);
1566+
menu_cnt--;
1567+
} else if (!menu_cnt)
1568+
fixup_rootmenu(child);
1569+
}
15661570
}
15671571

15681572

15691573
/* Main */
1570-
1571-
15721574
int main(int ac, char *av[])
15731575
{
15741576
const char *name;

0 commit comments

Comments
 (0)