Commit bafd2df5 authored by Joachim Nilsson's avatar Joachim Nilsson Committed by Linus Torvalds

[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: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2ac6608c
...@@ -178,17 +178,31 @@ const char *dbg_print_ptype(int val) ...@@ -178,17 +178,31 @@ const char *dbg_print_ptype(int val)
} }
/* Main Window Initialization */ void replace_button_icon(GladeXML * xml, GdkDrawable * window,
GtkStyle * style, gchar * btn_name, gchar ** xpm)
{
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkToolButton *button;
GtkWidget *image;
pixmap = gdk_pixmap_create_from_xpm_d(window, &mask,
&style->bg[GTK_STATE_NORMAL],
xpm);
button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name));
image = gtk_image_new_from_pixmap(pixmap, mask);
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 * glade_file)
{ {
GladeXML *xml; GladeXML *xml;
GtkWidget *widget; GtkWidget *widget;
GtkTextBuffer *txtbuf; GtkTextBuffer *txtbuf;
char title[256]; char title[256];
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style; GtkStyle *style;
xml = glade_xml_new(glade_file, "window1", NULL); xml = glade_xml_new(glade_file, "window1", NULL);
...@@ -221,36 +235,22 @@ void init_main_window(const gchar * glade_file) ...@@ -221,36 +235,22 @@ void init_main_window(const gchar * glade_file)
style = gtk_widget_get_style(main_wnd); style = gtk_widget_get_style(main_wnd);
widget = glade_xml_get_widget(xml, "toolbar1"); widget = glade_xml_get_widget(xml, "toolbar1");
pixmap = gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask, #if 0 /* Use stock Gtk icons instead */
&style->bg[GTK_STATE_NORMAL], replace_button_icon(xml, main_wnd->window, style,
(gchar **) xpm_single_view); "button1", (gchar **) xpm_back);
gtk_image_set_from_pixmap(GTK_IMAGE replace_button_icon(xml, main_wnd->window, style,
(((GtkToolbarChild "button2", (gchar **) xpm_load);
*) (g_list_nth(GTK_TOOLBAR(widget)-> replace_button_icon(xml, main_wnd->window, style,
children, "button3", (gchar **) xpm_save);
5)->data))->icon), #endif
pixmap, mask); replace_button_icon(xml, main_wnd->window, style,
pixmap = "button4", (gchar **) xpm_single_view);
gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask, replace_button_icon(xml, main_wnd->window, style,
&style->bg[GTK_STATE_NORMAL], "button5", (gchar **) xpm_split_view);
(gchar **) xpm_split_view); replace_button_icon(xml, main_wnd->window, style,
gtk_image_set_from_pixmap(GTK_IMAGE "button6", (gchar **) xpm_tree_view);
(((GtkToolbarChild
*) (g_list_nth(GTK_TOOLBAR(widget)-> #if 0
children,
6)->data))->icon),
pixmap, mask);
pixmap =
gdk_pixmap_create_from_xpm_d(main_wnd->window, &mask,
&style->bg[GTK_STATE_NORMAL],
(gchar **) xpm_tree_view);
gtk_image_set_from_pixmap(GTK_IMAGE
(((GtkToolbarChild
*) (g_list_nth(GTK_TOOLBAR(widget)->
children,
7)->data))->icon),
pixmap, mask);
switch (view_mode) { switch (view_mode) {
case SINGLE_VIEW: case SINGLE_VIEW:
widget = glade_xml_get_widget(xml, "button4"); widget = glade_xml_get_widget(xml, "button4");
...@@ -265,7 +265,7 @@ void init_main_window(const gchar * glade_file) ...@@ -265,7 +265,7 @@ void init_main_window(const gchar * glade_file)
g_signal_emit_by_name(widget, "clicked"); g_signal_emit_by_name(widget, "clicked");
break; break;
} }
#endif
txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1", tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
"foreground", "red", "foreground", "red",
...@@ -806,7 +806,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data) ...@@ -806,7 +806,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
} }
void on_back_pressed(GtkButton * button, gpointer user_data) void on_back_clicked(GtkButton * button, gpointer user_data)
{ {
enum prop_type ptype; enum prop_type ptype;
...@@ -821,13 +821,13 @@ void on_back_pressed(GtkButton * button, gpointer user_data) ...@@ -821,13 +821,13 @@ void on_back_pressed(GtkButton * button, gpointer user_data)
} }
void on_load_pressed(GtkButton * button, gpointer user_data) void on_load_clicked(GtkButton * button, gpointer user_data)
{ {
on_load1_activate(NULL, user_data); on_load1_activate(NULL, user_data);
} }
void on_save_pressed(GtkButton * button, gpointer user_data) void on_save_clicked(GtkButton * button, gpointer user_data)
{ {
on_save1_activate(NULL, user_data); on_save1_activate(NULL, user_data);
} }
...@@ -853,6 +853,9 @@ void on_split_clicked(GtkButton * button, gpointer user_data) ...@@ -853,6 +853,9 @@ void on_split_clicked(GtkButton * button, gpointer user_data)
if (tree2) if (tree2)
gtk_tree_store_clear(tree2); gtk_tree_store_clear(tree2);
display_list(); display_list();
/* Disable back btn, like in full mode. */
gtk_widget_set_sensitive(back_btn, FALSE);
} }
...@@ -868,13 +871,13 @@ void on_full_clicked(GtkButton * button, gpointer user_data) ...@@ -868,13 +871,13 @@ void on_full_clicked(GtkButton * button, gpointer user_data)
} }
void on_collapse_pressed(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(tree2_w));
} }
void on_expand_pressed(GtkButton * button, gpointer user_data) 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(tree2_w));
} }
...@@ -1242,13 +1245,13 @@ static gchar **fill_row(struct menu *menu) ...@@ -1242,13 +1245,13 @@ static gchar **fill_row(struct menu *menu)
row[COL_VALUE] = row[COL_VALUE] =
g_strdup(menu_get_prompt(def_menu)); g_strdup(menu_get_prompt(def_menu));
} }
if(sym->flags & SYMBOL_CHOICEVAL) if (sym->flags & SYMBOL_CHOICEVAL)
row[COL_BTNRAD] = GINT_TO_POINTER(TRUE); row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
stype = sym_get_type(sym); stype = sym_get_type(sym);
switch (stype) { switch (stype) {
case S_BOOLEAN: case S_BOOLEAN:
if(GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE) if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE)
row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
if (sym_is_choice(sym)) if (sym_is_choice(sym))
break; break;
...@@ -1486,12 +1489,12 @@ static void display_tree(struct menu *menu) ...@@ -1486,12 +1489,12 @@ static void display_tree(struct menu *menu)
if (sym) if (sym)
sym->flags &= ~SYMBOL_CHANGED; sym->flags &= ~SYMBOL_CHANGED;
if ((view_mode == SPLIT_VIEW) && !(child->flags & MENU_ROOT) && if ((view_mode == SPLIT_VIEW)
(tree == tree1)) && !(child->flags & MENU_ROOT) && (tree == tree1))
continue; continue;
if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT) && if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT)
(tree == tree2)) && (tree == tree2))
continue; continue;
if (menu_is_visible(child) || show_all) if (menu_is_visible(child) || show_all)
...@@ -1513,11 +1516,12 @@ static void display_tree(struct menu *menu) ...@@ -1513,11 +1516,12 @@ static void display_tree(struct menu *menu)
&& (tree == tree2)) && (tree == tree2))
continue; continue;
/* /*
if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) || if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
(view_mode == FULL_VIEW) || (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW))*/ || (view_mode == SPLIT_VIEW))*/
if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT)) if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
|| (view_mode == FULL_VIEW) || (view_mode == SPLIT_VIEW)) { || (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW)) {
indent++; indent++;
display_tree(child); display_tree(child);
indent--; indent--;
...@@ -1530,9 +1534,9 @@ static void display_tree_part(void) ...@@ -1530,9 +1534,9 @@ static void display_tree_part(void)
{ {
if (tree2) if (tree2)
gtk_tree_store_clear(tree2); gtk_tree_store_clear(tree2);
if(view_mode == SINGLE_VIEW) if (view_mode == SINGLE_VIEW)
display_tree(current); display_tree(current);
else if(view_mode == SPLIT_VIEW) else if (view_mode == SPLIT_VIEW)
display_tree(browsed); display_tree(browsed);
gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w)); gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
} }
...@@ -1567,8 +1571,6 @@ void fixup_rootmenu(struct menu *menu) ...@@ -1567,8 +1571,6 @@ void fixup_rootmenu(struct menu *menu)
/* Main */ /* Main */
int main(int ac, char *av[]) int main(int ac, char *av[])
{ {
const char *name; const char *name;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment