1 /* Hey EMACS -*- linux-c -*- */
4 * Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
5 * Released under the terms of the GNU GPL v2.0.
16 #include <glade/glade.h>
19 #include <gdk/gdkkeysyms.h>
30 SINGLE_VIEW
, SPLIT_VIEW
, FULL_VIEW
34 OPT_NORMAL
, OPT_ALL
, OPT_PROMPT
37 static gint view_mode
= FULL_VIEW
;
38 static gboolean show_name
= TRUE
;
39 static gboolean show_range
= TRUE
;
40 static gboolean show_value
= TRUE
;
41 static gboolean resizeable
= FALSE
;
42 static int opt_mode
= OPT_NORMAL
;
44 GtkWidget
*main_wnd
= NULL
;
45 GtkWidget
*tree1_w
= NULL
; // left frame
46 GtkWidget
*tree2_w
= NULL
; // right frame
47 GtkWidget
*text_w
= NULL
;
48 GtkWidget
*hpaned
= NULL
;
49 GtkWidget
*vpaned
= NULL
;
50 GtkWidget
*back_btn
= NULL
;
51 GtkWidget
*save_btn
= NULL
;
52 GtkWidget
*save_menu_item
= NULL
;
54 GtkTextTag
*tag1
, *tag2
;
57 GtkTreeStore
*tree1
, *tree2
, *tree
;
58 GtkTreeModel
*model1
, *model2
;
59 static GtkTreeIter
*parents
[256];
62 static struct menu
*current
; // current node for SINGLE view
63 static struct menu
*browsed
; // browsed node for SPLIT view
66 COL_OPTION
, COL_NAME
, COL_NO
, COL_MOD
, COL_YES
, COL_VALUE
,
67 COL_MENU
, COL_COLOR
, COL_EDIT
, COL_PIXBUF
,
68 COL_PIXVIS
, COL_BTNVIS
, COL_BTNACT
, COL_BTNINC
, COL_BTNRAD
,
72 static void display_list(void);
73 static void display_tree(struct menu
*menu
);
74 static void display_tree_part(void);
75 static void update_tree(struct menu
*src
, GtkTreeIter
* dst
);
76 static void set_node(GtkTreeIter
* node
, struct menu
*menu
, gchar
** row
);
77 static gchar
**fill_row(struct menu
*menu
);
78 static void conf_changed(void);
80 /* Helping/Debugging Functions */
82 const char *dbg_sym_flags(int val
)
88 if (val
& SYMBOL_CONST
)
89 strcat(buf
, "const/");
90 if (val
& SYMBOL_CHECK
)
91 strcat(buf
, "check/");
92 if (val
& SYMBOL_CHOICE
)
93 strcat(buf
, "choice/");
94 if (val
& SYMBOL_CHOICEVAL
)
95 strcat(buf
, "choiceval/");
96 if (val
& SYMBOL_VALID
)
97 strcat(buf
, "valid/");
98 if (val
& SYMBOL_OPTIONAL
)
99 strcat(buf
, "optional/");
100 if (val
& SYMBOL_WRITE
)
101 strcat(buf
, "write/");
102 if (val
& SYMBOL_CHANGED
)
103 strcat(buf
, "changed/");
104 if (val
& SYMBOL_AUTO
)
105 strcat(buf
, "auto/");
107 buf
[strlen(buf
) - 1] = '\0';
112 void replace_button_icon(GladeXML
* xml
, GdkDrawable
* window
,
113 GtkStyle
* style
, gchar
* btn_name
, gchar
** xpm
)
117 GtkToolButton
*button
;
120 pixmap
= gdk_pixmap_create_from_xpm_d(window
, &mask
,
121 &style
->bg
[GTK_STATE_NORMAL
],
124 button
= GTK_TOOL_BUTTON(glade_xml_get_widget(xml
, btn_name
));
125 image
= gtk_image_new_from_pixmap(pixmap
, mask
);
126 gtk_widget_show(image
);
127 gtk_tool_button_set_icon_widget(button
, image
);
130 /* Main Window Initialization */
131 void init_main_window(const gchar
* glade_file
)
135 GtkTextBuffer
*txtbuf
;
138 xml
= glade_xml_new(glade_file
, "window1", NULL
);
140 g_error(_("GUI loading failed !\n"));
141 glade_xml_signal_autoconnect(xml
);
143 main_wnd
= glade_xml_get_widget(xml
, "window1");
144 hpaned
= glade_xml_get_widget(xml
, "hpaned1");
145 vpaned
= glade_xml_get_widget(xml
, "vpaned1");
146 tree1_w
= glade_xml_get_widget(xml
, "treeview1");
147 tree2_w
= glade_xml_get_widget(xml
, "treeview2");
148 text_w
= glade_xml_get_widget(xml
, "textview3");
150 back_btn
= glade_xml_get_widget(xml
, "button1");
151 gtk_widget_set_sensitive(back_btn
, FALSE
);
153 widget
= glade_xml_get_widget(xml
, "show_name1");
154 gtk_check_menu_item_set_active((GtkCheckMenuItem
*) widget
,
157 widget
= glade_xml_get_widget(xml
, "show_range1");
158 gtk_check_menu_item_set_active((GtkCheckMenuItem
*) widget
,
161 widget
= glade_xml_get_widget(xml
, "show_data1");
162 gtk_check_menu_item_set_active((GtkCheckMenuItem
*) widget
,
165 save_btn
= glade_xml_get_widget(xml
, "button3");
166 save_menu_item
= glade_xml_get_widget(xml
, "save1");
167 conf_set_changed_callback(conf_changed
);
169 style
= gtk_widget_get_style(main_wnd
);
170 widget
= glade_xml_get_widget(xml
, "toolbar1");
172 #if 0 /* Use stock Gtk icons instead */
173 replace_button_icon(xml
, main_wnd
->window
, style
,
174 "button1", (gchar
**) xpm_back
);
175 replace_button_icon(xml
, main_wnd
->window
, style
,
176 "button2", (gchar
**) xpm_load
);
177 replace_button_icon(xml
, main_wnd
->window
, style
,
178 "button3", (gchar
**) xpm_save
);
180 replace_button_icon(xml
, main_wnd
->window
, style
,
181 "button4", (gchar
**) xpm_single_view
);
182 replace_button_icon(xml
, main_wnd
->window
, style
,
183 "button5", (gchar
**) xpm_split_view
);
184 replace_button_icon(xml
, main_wnd
->window
, style
,
185 "button6", (gchar
**) xpm_tree_view
);
190 widget
= glade_xml_get_widget(xml
, "button4");
191 g_signal_emit_by_name(widget
, "clicked");
194 widget
= glade_xml_get_widget(xml
, "button5");
195 g_signal_emit_by_name(widget
, "clicked");
198 widget
= glade_xml_get_widget(xml
, "button6");
199 g_signal_emit_by_name(widget
, "clicked");
203 txtbuf
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w
));
204 tag1
= gtk_text_buffer_create_tag(txtbuf
, "mytag1",
206 "weight", PANGO_WEIGHT_BOLD
,
208 tag2
= gtk_text_buffer_create_tag(txtbuf
, "mytag2",
209 /*"style", PANGO_STYLE_OBLIQUE, */
212 gtk_window_set_title(GTK_WINDOW(main_wnd
), rootmenu
.prompt
->text
);
214 gtk_widget_show(main_wnd
);
217 void init_tree_model(void)
221 tree
= tree2
= gtk_tree_store_new(COL_NUMBER
,
222 G_TYPE_STRING
, G_TYPE_STRING
,
223 G_TYPE_STRING
, G_TYPE_STRING
,
224 G_TYPE_STRING
, G_TYPE_STRING
,
225 G_TYPE_POINTER
, GDK_TYPE_COLOR
,
226 G_TYPE_BOOLEAN
, GDK_TYPE_PIXBUF
,
227 G_TYPE_BOOLEAN
, G_TYPE_BOOLEAN
,
228 G_TYPE_BOOLEAN
, G_TYPE_BOOLEAN
,
230 model2
= GTK_TREE_MODEL(tree2
);
232 for (parents
[0] = NULL
, i
= 1; i
< 256; i
++)
233 parents
[i
] = (GtkTreeIter
*) g_malloc(sizeof(GtkTreeIter
));
235 tree1
= gtk_tree_store_new(COL_NUMBER
,
236 G_TYPE_STRING
, G_TYPE_STRING
,
237 G_TYPE_STRING
, G_TYPE_STRING
,
238 G_TYPE_STRING
, G_TYPE_STRING
,
239 G_TYPE_POINTER
, GDK_TYPE_COLOR
,
240 G_TYPE_BOOLEAN
, GDK_TYPE_PIXBUF
,
241 G_TYPE_BOOLEAN
, G_TYPE_BOOLEAN
,
242 G_TYPE_BOOLEAN
, G_TYPE_BOOLEAN
,
244 model1
= GTK_TREE_MODEL(tree1
);
247 void init_left_tree(void)
249 GtkTreeView
*view
= GTK_TREE_VIEW(tree1_w
);
250 GtkCellRenderer
*renderer
;
251 GtkTreeSelection
*sel
;
252 GtkTreeViewColumn
*column
;
254 gtk_tree_view_set_model(view
, model1
);
255 gtk_tree_view_set_headers_visible(view
, TRUE
);
256 gtk_tree_view_set_rules_hint(view
, FALSE
);
258 column
= gtk_tree_view_column_new();
259 gtk_tree_view_append_column(view
, column
);
260 gtk_tree_view_column_set_title(column
, _("Options"));
262 renderer
= gtk_cell_renderer_toggle_new();
263 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column
),
265 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column
),
267 "active", COL_BTNACT
,
268 "inconsistent", COL_BTNINC
,
269 "visible", COL_BTNVIS
,
270 "radio", COL_BTNRAD
, NULL
);
271 renderer
= gtk_cell_renderer_text_new();
272 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column
),
274 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column
),
280 sel
= gtk_tree_view_get_selection(view
);
281 gtk_tree_selection_set_mode(sel
, GTK_SELECTION_SINGLE
);
282 gtk_widget_realize(tree1_w
);
285 static void renderer_edited(GtkCellRendererText
* cell
,
286 const gchar
* path_string
,
287 const gchar
* new_text
, gpointer user_data
);
288 static void renderer_toggled(GtkCellRendererToggle
* cellrenderertoggle
,
289 gchar
* arg1
, gpointer user_data
);
291 void init_right_tree(void)
293 GtkTreeView
*view
= GTK_TREE_VIEW(tree2_w
);
294 GtkCellRenderer
*renderer
;
295 GtkTreeSelection
*sel
;
296 GtkTreeViewColumn
*column
;
299 gtk_tree_view_set_model(view
, model2
);
300 gtk_tree_view_set_headers_visible(view
, TRUE
);
301 gtk_tree_view_set_rules_hint(view
, FALSE
);
303 column
= gtk_tree_view_column_new();
304 gtk_tree_view_append_column(view
, column
);
305 gtk_tree_view_column_set_title(column
, _("Options"));
307 renderer
= gtk_cell_renderer_pixbuf_new();
308 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column
),
310 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column
),
312 "pixbuf", COL_PIXBUF
,
313 "visible", COL_PIXVIS
, NULL
);
314 renderer
= gtk_cell_renderer_toggle_new();
315 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column
),
317 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column
),
319 "active", COL_BTNACT
,
320 "inconsistent", COL_BTNINC
,
321 "visible", COL_BTNVIS
,
322 "radio", COL_BTNRAD
, NULL
);
323 /*g_signal_connect(G_OBJECT(renderer), "toggled",
324 G_CALLBACK(renderer_toggled), NULL); */
325 renderer
= gtk_cell_renderer_text_new();
326 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column
),
328 gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column
),
334 renderer
= gtk_cell_renderer_text_new();
335 gtk_tree_view_insert_column_with_attributes(view
, -1,
340 renderer
= gtk_cell_renderer_text_new();
341 gtk_tree_view_insert_column_with_attributes(view
, -1,
346 renderer
= gtk_cell_renderer_text_new();
347 gtk_tree_view_insert_column_with_attributes(view
, -1,
352 renderer
= gtk_cell_renderer_text_new();
353 gtk_tree_view_insert_column_with_attributes(view
, -1,
358 renderer
= gtk_cell_renderer_text_new();
359 gtk_tree_view_insert_column_with_attributes(view
, -1,
360 _("Value"), renderer
,
366 g_signal_connect(G_OBJECT(renderer
), "edited",
367 G_CALLBACK(renderer_edited
), NULL
);
369 column
= gtk_tree_view_get_column(view
, COL_NAME
);
370 gtk_tree_view_column_set_visible(column
, show_name
);
371 column
= gtk_tree_view_get_column(view
, COL_NO
);
372 gtk_tree_view_column_set_visible(column
, show_range
);
373 column
= gtk_tree_view_get_column(view
, COL_MOD
);
374 gtk_tree_view_column_set_visible(column
, show_range
);
375 column
= gtk_tree_view_get_column(view
, COL_YES
);
376 gtk_tree_view_column_set_visible(column
, show_range
);
377 column
= gtk_tree_view_get_column(view
, COL_VALUE
);
378 gtk_tree_view_column_set_visible(column
, show_value
);
381 for (i
= 0; i
< COL_VALUE
; i
++) {
382 column
= gtk_tree_view_get_column(view
, i
);
383 gtk_tree_view_column_set_resizable(column
, TRUE
);
387 sel
= gtk_tree_view_get_selection(view
);
388 gtk_tree_selection_set_mode(sel
, GTK_SELECTION_SINGLE
);
392 /* Utility Functions */
395 static void text_insert_help(struct menu
*menu
)
397 GtkTextBuffer
*buffer
;
398 GtkTextIter start
, end
;
399 const char *prompt
= _(menu_get_prompt(menu
));
400 struct gstr help
= str_new();
402 menu_get_ext_help(menu
, &help
);
404 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w
));
405 gtk_text_buffer_get_bounds(buffer
, &start
, &end
);
406 gtk_text_buffer_delete(buffer
, &start
, &end
);
407 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w
), 15);
409 gtk_text_buffer_get_end_iter(buffer
, &end
);
410 gtk_text_buffer_insert_with_tags(buffer
, &end
, prompt
, -1, tag1
,
412 gtk_text_buffer_insert_at_cursor(buffer
, "\n\n", 2);
413 gtk_text_buffer_get_end_iter(buffer
, &end
);
414 gtk_text_buffer_insert_with_tags(buffer
, &end
, str_get(&help
), -1, tag2
,
420 static void text_insert_msg(const char *title
, const char *message
)
422 GtkTextBuffer
*buffer
;
423 GtkTextIter start
, end
;
424 const char *msg
= message
;
426 buffer
= gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w
));
427 gtk_text_buffer_get_bounds(buffer
, &start
, &end
);
428 gtk_text_buffer_delete(buffer
, &start
, &end
);
429 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w
), 15);
431 gtk_text_buffer_get_end_iter(buffer
, &end
);
432 gtk_text_buffer_insert_with_tags(buffer
, &end
, title
, -1, tag1
,
434 gtk_text_buffer_insert_at_cursor(buffer
, "\n\n", 2);
435 gtk_text_buffer_get_end_iter(buffer
, &end
);
436 gtk_text_buffer_insert_with_tags(buffer
, &end
, msg
, -1, tag2
,
441 /* Main Windows Callbacks */
443 void on_save_activate(GtkMenuItem
* menuitem
, gpointer user_data
);
444 gboolean
on_window1_delete_event(GtkWidget
* widget
, GdkEvent
* event
,
447 GtkWidget
*dialog
, *label
;
450 if (!conf_get_changed())
453 dialog
= gtk_dialog_new_with_buttons(_("Warning !"),
454 GTK_WINDOW(main_wnd
),
457 GTK_DIALOG_DESTROY_WITH_PARENT
),
463 GTK_RESPONSE_CANCEL
, NULL
);
464 gtk_dialog_set_default_response(GTK_DIALOG(dialog
),
465 GTK_RESPONSE_CANCEL
);
467 label
= gtk_label_new(_("\nSave configuration ?\n"));
468 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog
)->vbox
), label
);
469 gtk_widget_show(label
);
471 result
= gtk_dialog_run(GTK_DIALOG(dialog
));
473 case GTK_RESPONSE_YES
:
474 on_save_activate(NULL
, NULL
);
476 case GTK_RESPONSE_NO
:
478 case GTK_RESPONSE_CANCEL
:
479 case GTK_RESPONSE_DELETE_EVENT
:
481 gtk_widget_destroy(dialog
);
489 void on_window1_destroy(GtkObject
* object
, gpointer user_data
)
496 on_window1_size_request(GtkWidget
* widget
,
497 GtkRequisition
* requisition
, gpointer user_data
)
502 if (widget
->window
== NULL
)
503 gtk_window_get_default_size(GTK_WINDOW(main_wnd
), &w
, &h
);
505 gdk_window_get_size(widget
->window
, &w
, &h
);
511 gtk_paned_set_position(GTK_PANED(vpaned
), 2 * h
/ 3);
515 /* Menu & Toolbar Callbacks */
519 load_filename(GtkFileSelection
* file_selector
, gpointer user_data
)
523 fn
= gtk_file_selection_get_filename(GTK_FILE_SELECTION
527 text_insert_msg(_("Error"), _("Unable to load configuration !"));
529 display_tree(&rootmenu
);
532 void on_load1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
536 fs
= gtk_file_selection_new(_("Load file..."));
537 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs
)->ok_button
),
539 G_CALLBACK(load_filename
), (gpointer
) fs
);
540 g_signal_connect_swapped(GTK_OBJECT
541 (GTK_FILE_SELECTION(fs
)->ok_button
),
542 "clicked", G_CALLBACK(gtk_widget_destroy
),
544 g_signal_connect_swapped(GTK_OBJECT
545 (GTK_FILE_SELECTION(fs
)->cancel_button
),
546 "clicked", G_CALLBACK(gtk_widget_destroy
),
552 void on_save_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
554 if (conf_write(NULL
))
555 text_insert_msg(_("Error"), _("Unable to save configuration !"));
560 store_filename(GtkFileSelection
* file_selector
, gpointer user_data
)
564 fn
= gtk_file_selection_get_filename(GTK_FILE_SELECTION
568 text_insert_msg(_("Error"), _("Unable to save configuration !"));
570 gtk_widget_destroy(GTK_WIDGET(user_data
));
573 void on_save_as1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
577 fs
= gtk_file_selection_new(_("Save file as..."));
578 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs
)->ok_button
),
580 G_CALLBACK(store_filename
), (gpointer
) fs
);
581 g_signal_connect_swapped(GTK_OBJECT
582 (GTK_FILE_SELECTION(fs
)->ok_button
),
583 "clicked", G_CALLBACK(gtk_widget_destroy
),
585 g_signal_connect_swapped(GTK_OBJECT
586 (GTK_FILE_SELECTION(fs
)->cancel_button
),
587 "clicked", G_CALLBACK(gtk_widget_destroy
),
593 void on_quit1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
595 if (!on_window1_delete_event(NULL
, NULL
, NULL
))
596 gtk_widget_destroy(GTK_WIDGET(main_wnd
));
600 void on_show_name1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
602 GtkTreeViewColumn
*col
;
604 show_name
= GTK_CHECK_MENU_ITEM(menuitem
)->active
;
605 col
= gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w
), COL_NAME
);
607 gtk_tree_view_column_set_visible(col
, show_name
);
611 void on_show_range1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
613 GtkTreeViewColumn
*col
;
615 show_range
= GTK_CHECK_MENU_ITEM(menuitem
)->active
;
616 col
= gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w
), COL_NO
);
618 gtk_tree_view_column_set_visible(col
, show_range
);
619 col
= gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w
), COL_MOD
);
621 gtk_tree_view_column_set_visible(col
, show_range
);
622 col
= gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w
), COL_YES
);
624 gtk_tree_view_column_set_visible(col
, show_range
);
629 void on_show_data1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
631 GtkTreeViewColumn
*col
;
633 show_value
= GTK_CHECK_MENU_ITEM(menuitem
)->active
;
634 col
= gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w
), COL_VALUE
);
636 gtk_tree_view_column_set_visible(col
, show_value
);
641 on_set_option_mode1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
643 opt_mode
= OPT_NORMAL
;
644 gtk_tree_store_clear(tree2
);
645 display_tree(&rootmenu
); /* instead of update_tree to speed-up */
650 on_set_option_mode2_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
653 gtk_tree_store_clear(tree2
);
654 display_tree(&rootmenu
); /* instead of update_tree to speed-up */
659 on_set_option_mode3_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
661 opt_mode
= OPT_PROMPT
;
662 gtk_tree_store_clear(tree2
);
663 display_tree(&rootmenu
); /* instead of update_tree to speed-up */
667 void on_introduction1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
670 const gchar
*intro_text
= _(
671 "Welcome to gkc, the GTK+ graphical configuration tool\n"
672 "For each option, a blank box indicates the feature is disabled, a\n"
673 "check indicates it is enabled, and a dot indicates that it is to\n"
674 "be compiled as a module. Clicking on the box will cycle through the three states.\n"
676 "If you do not see an option (e.g., a device driver) that you\n"
677 "believe should be present, try turning on Show All Options\n"
678 "under the Options menu.\n"
679 "Although there is no cross reference yet to help you figure out\n"
680 "what other options must be enabled to support the option you\n"
681 "are interested in, you can still view the help of a grayed-out\n"
684 "Toggling Show Debug Info under the Options menu will show \n"
685 "the dependencies, which you can then match by examining other options.");
687 dialog
= gtk_message_dialog_new(GTK_WINDOW(main_wnd
),
688 GTK_DIALOG_DESTROY_WITH_PARENT
,
690 GTK_BUTTONS_CLOSE
, intro_text
);
691 g_signal_connect_swapped(GTK_OBJECT(dialog
), "response",
692 G_CALLBACK(gtk_widget_destroy
),
694 gtk_widget_show_all(dialog
);
698 void on_about1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
701 const gchar
*about_text
=
702 _("gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
703 "Based on the source code from Roman Zippel.\n");
705 dialog
= gtk_message_dialog_new(GTK_WINDOW(main_wnd
),
706 GTK_DIALOG_DESTROY_WITH_PARENT
,
708 GTK_BUTTONS_CLOSE
, about_text
);
709 g_signal_connect_swapped(GTK_OBJECT(dialog
), "response",
710 G_CALLBACK(gtk_widget_destroy
),
712 gtk_widget_show_all(dialog
);
716 void on_license1_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
719 const gchar
*license_text
=
720 _("gkc is released under the terms of the GNU GPL v2.\n"
721 "For more information, please see the source code or\n"
722 "visit http://www.fsf.org/licenses/licenses.html\n");
724 dialog
= gtk_message_dialog_new(GTK_WINDOW(main_wnd
),
725 GTK_DIALOG_DESTROY_WITH_PARENT
,
727 GTK_BUTTONS_CLOSE
, license_text
);
728 g_signal_connect_swapped(GTK_OBJECT(dialog
), "response",
729 G_CALLBACK(gtk_widget_destroy
),
731 gtk_widget_show_all(dialog
);
735 void on_back_clicked(GtkButton
* button
, gpointer user_data
)
737 enum prop_type ptype
;
739 current
= current
->parent
;
740 ptype
= current
->prompt
? current
->prompt
->type
: P_UNKNOWN
;
742 current
= current
->parent
;
745 if (current
== &rootmenu
)
746 gtk_widget_set_sensitive(back_btn
, FALSE
);
750 void on_load_clicked(GtkButton
* button
, gpointer user_data
)
752 on_load1_activate(NULL
, user_data
);
756 void on_single_clicked(GtkButton
* button
, gpointer user_data
)
758 view_mode
= SINGLE_VIEW
;
759 gtk_paned_set_position(GTK_PANED(hpaned
), 0);
760 gtk_widget_hide(tree1_w
);
766 void on_split_clicked(GtkButton
* button
, gpointer user_data
)
769 view_mode
= SPLIT_VIEW
;
770 gtk_widget_show(tree1_w
);
771 gtk_window_get_default_size(GTK_WINDOW(main_wnd
), &w
, &h
);
772 gtk_paned_set_position(GTK_PANED(hpaned
), w
/ 2);
774 gtk_tree_store_clear(tree2
);
777 /* Disable back btn, like in full mode. */
778 gtk_widget_set_sensitive(back_btn
, FALSE
);
782 void on_full_clicked(GtkButton
* button
, gpointer user_data
)
784 view_mode
= FULL_VIEW
;
785 gtk_paned_set_position(GTK_PANED(hpaned
), 0);
786 gtk_widget_hide(tree1_w
);
788 gtk_tree_store_clear(tree2
);
789 display_tree(&rootmenu
);
790 gtk_widget_set_sensitive(back_btn
, FALSE
);
794 void on_collapse_clicked(GtkButton
* button
, gpointer user_data
)
796 gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w
));
800 void on_expand_clicked(GtkButton
* button
, gpointer user_data
)
802 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w
));
806 /* CTree Callbacks */
808 /* Change hex/int/string value in the cell */
809 static void renderer_edited(GtkCellRendererText
* cell
,
810 const gchar
* path_string
,
811 const gchar
* new_text
, gpointer user_data
)
813 GtkTreePath
*path
= gtk_tree_path_new_from_string(path_string
);
815 const char *old_def
, *new_def
;
819 if (!gtk_tree_model_get_iter(model2
, &iter
, path
))
822 gtk_tree_model_get(model2
, &iter
, COL_MENU
, &menu
, -1);
825 gtk_tree_model_get(model2
, &iter
, COL_VALUE
, &old_def
, -1);
828 sym_set_string_value(sym
, new_def
);
830 update_tree(&rootmenu
, NULL
);
832 gtk_tree_path_free(path
);
835 /* Change the value of a symbol and update the tree */
836 static void change_sym_value(struct menu
*menu
, gint col
)
838 struct symbol
*sym
= menu
->sym
;
839 tristate oldval
, newval
;
846 else if (col
== COL_MOD
)
848 else if (col
== COL_YES
)
853 switch (sym_get_type(sym
)) {
856 oldval
= sym_get_tristate_value(sym
);
857 if (!sym_tristate_within_range(sym
, newval
))
859 sym_set_tristate_value(sym
, newval
);
860 if (view_mode
== FULL_VIEW
)
861 update_tree(&rootmenu
, NULL
);
862 else if (view_mode
== SPLIT_VIEW
) {
863 update_tree(browsed
, NULL
);
866 else if (view_mode
== SINGLE_VIEW
)
867 display_tree_part(); //fixme: keep exp/coll
877 static void toggle_sym_value(struct menu
*menu
)
882 sym_toggle_tristate_value(menu
->sym
);
883 if (view_mode
== FULL_VIEW
)
884 update_tree(&rootmenu
, NULL
);
885 else if (view_mode
== SPLIT_VIEW
) {
886 update_tree(browsed
, NULL
);
889 else if (view_mode
== SINGLE_VIEW
)
890 display_tree_part(); //fixme: keep exp/coll
893 static void renderer_toggled(GtkCellRendererToggle
* cell
,
894 gchar
* path_string
, gpointer user_data
)
896 GtkTreePath
*path
, *sel_path
= NULL
;
897 GtkTreeIter iter
, sel_iter
;
898 GtkTreeSelection
*sel
;
901 path
= gtk_tree_path_new_from_string(path_string
);
902 if (!gtk_tree_model_get_iter(model2
, &iter
, path
))
905 sel
= gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w
));
906 if (gtk_tree_selection_get_selected(sel
, NULL
, &sel_iter
))
907 sel_path
= gtk_tree_model_get_path(model2
, &sel_iter
);
910 if (gtk_tree_path_compare(path
, sel_path
))
913 gtk_tree_model_get(model2
, &iter
, COL_MENU
, &menu
, -1);
914 toggle_sym_value(menu
);
917 gtk_tree_path_free(sel_path
);
919 gtk_tree_path_free(path
);
922 static gint
column2index(GtkTreeViewColumn
* column
)
926 for (i
= 0; i
< COL_NUMBER
; i
++) {
927 GtkTreeViewColumn
*col
;
929 col
= gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w
), i
);
938 /* User click: update choice (full) or goes down (single) */
940 on_treeview2_button_press_event(GtkWidget
* widget
,
941 GdkEventButton
* event
, gpointer user_data
)
943 GtkTreeView
*view
= GTK_TREE_VIEW(widget
);
945 GtkTreeViewColumn
*column
;
950 #if GTK_CHECK_VERSION(2,1,4) // bug in ctree with earlier version of GTK
951 gint tx
= (gint
) event
->x
;
952 gint ty
= (gint
) event
->y
;
955 gtk_tree_view_get_path_at_pos(view
, tx
, ty
, &path
, &column
, &cx
,
958 gtk_tree_view_get_cursor(view
, &path
, &column
);
963 if (!gtk_tree_model_get_iter(model2
, &iter
, path
))
965 gtk_tree_model_get(model2
, &iter
, COL_MENU
, &menu
, -1);
967 col
= column2index(column
);
968 if (event
->type
== GDK_2BUTTON_PRESS
) {
969 enum prop_type ptype
;
970 ptype
= menu
->prompt
? menu
->prompt
->type
: P_UNKNOWN
;
972 if (ptype
== P_MENU
&& view_mode
!= FULL_VIEW
&& col
== COL_OPTION
) {
973 // goes down into menu
976 gtk_widget_set_sensitive(back_btn
, TRUE
);
977 } else if ((col
== COL_OPTION
)) {
978 toggle_sym_value(menu
);
979 gtk_tree_view_expand_row(view
, path
, TRUE
);
982 if (col
== COL_VALUE
) {
983 toggle_sym_value(menu
);
984 gtk_tree_view_expand_row(view
, path
, TRUE
);
985 } else if (col
== COL_NO
|| col
== COL_MOD
987 change_sym_value(menu
, col
);
988 gtk_tree_view_expand_row(view
, path
, TRUE
);
995 /* Key pressed: update choice */
997 on_treeview2_key_press_event(GtkWidget
* widget
,
998 GdkEventKey
* event
, gpointer user_data
)
1000 GtkTreeView
*view
= GTK_TREE_VIEW(widget
);
1002 GtkTreeViewColumn
*column
;
1007 gtk_tree_view_get_cursor(view
, &path
, &column
);
1011 if (event
->keyval
== GDK_space
) {
1012 if (gtk_tree_view_row_expanded(view
, path
))
1013 gtk_tree_view_collapse_row(view
, path
);
1015 gtk_tree_view_expand_row(view
, path
, FALSE
);
1018 if (event
->keyval
== GDK_KP_Enter
) {
1020 if (widget
== tree1_w
)
1023 gtk_tree_model_get_iter(model2
, &iter
, path
);
1024 gtk_tree_model_get(model2
, &iter
, COL_MENU
, &menu
, -1);
1026 if (!strcasecmp(event
->string
, "n"))
1028 else if (!strcasecmp(event
->string
, "m"))
1030 else if (!strcasecmp(event
->string
, "y"))
1034 change_sym_value(menu
, col
);
1040 /* Row selection changed: update help */
1042 on_treeview2_cursor_changed(GtkTreeView
* treeview
, gpointer user_data
)
1044 GtkTreeSelection
*selection
;
1048 selection
= gtk_tree_view_get_selection(treeview
);
1049 if (gtk_tree_selection_get_selected(selection
, &model2
, &iter
)) {
1050 gtk_tree_model_get(model2
, &iter
, COL_MENU
, &menu
, -1);
1051 text_insert_help(menu
);
1056 /* User click: display sub-tree in the right frame. */
1058 on_treeview1_button_press_event(GtkWidget
* widget
,
1059 GdkEventButton
* event
, gpointer user_data
)
1061 GtkTreeView
*view
= GTK_TREE_VIEW(widget
);
1063 GtkTreeViewColumn
*column
;
1067 gint tx
= (gint
) event
->x
;
1068 gint ty
= (gint
) event
->y
;
1071 gtk_tree_view_get_path_at_pos(view
, tx
, ty
, &path
, &column
, &cx
,
1076 gtk_tree_model_get_iter(model1
, &iter
, path
);
1077 gtk_tree_model_get(model1
, &iter
, COL_MENU
, &menu
, -1);
1079 if (event
->type
== GDK_2BUTTON_PRESS
) {
1080 toggle_sym_value(menu
);
1082 display_tree_part();
1085 display_tree_part();
1088 gtk_widget_realize(tree2_w
);
1089 gtk_tree_view_set_cursor(view
, path
, NULL
, FALSE
);
1090 gtk_widget_grab_focus(tree2_w
);
1096 /* Fill a row of strings */
1097 static gchar
**fill_row(struct menu
*menu
)
1099 static gchar
*row
[COL_NUMBER
];
1100 struct symbol
*sym
= menu
->sym
;
1104 enum prop_type ptype
;
1107 for (i
= COL_OPTION
; i
<= COL_COLOR
; i
++)
1109 bzero(row
, sizeof(row
));
1112 g_strdup_printf("%s %s", _(menu_get_prompt(menu
)),
1113 sym
&& !sym_has_value(sym
) ? "(NEW)" : "");
1115 if (opt_mode
== OPT_ALL
&& !menu_is_visible(menu
))
1116 row
[COL_COLOR
] = g_strdup("DarkGray");
1117 else if (opt_mode
== OPT_PROMPT
&&
1118 menu_has_prompt(menu
) && !menu_is_visible(menu
))
1119 row
[COL_COLOR
] = g_strdup("DarkGray");
1121 row
[COL_COLOR
] = g_strdup("Black");
1123 ptype
= menu
->prompt
? menu
->prompt
->type
: P_UNKNOWN
;
1126 row
[COL_PIXBUF
] = (gchar
*) xpm_menu
;
1127 if (view_mode
== SINGLE_VIEW
)
1128 row
[COL_PIXVIS
] = GINT_TO_POINTER(TRUE
);
1129 row
[COL_BTNVIS
] = GINT_TO_POINTER(FALSE
);
1132 row
[COL_PIXBUF
] = (gchar
*) xpm_void
;
1133 row
[COL_PIXVIS
] = GINT_TO_POINTER(FALSE
);
1134 row
[COL_BTNVIS
] = GINT_TO_POINTER(FALSE
);
1137 row
[COL_PIXBUF
] = (gchar
*) xpm_void
;
1138 row
[COL_PIXVIS
] = GINT_TO_POINTER(FALSE
);
1139 row
[COL_BTNVIS
] = GINT_TO_POINTER(TRUE
);
1145 row
[COL_NAME
] = g_strdup(sym
->name
);
1147 sym_calc_value(sym
);
1148 sym
->flags
&= ~SYMBOL_CHANGED
;
1150 if (sym_is_choice(sym
)) { // parse childs for getting final value
1152 struct symbol
*def_sym
= sym_get_choice_value(sym
);
1153 struct menu
*def_menu
= NULL
;
1155 row
[COL_BTNVIS
] = GINT_TO_POINTER(FALSE
);
1157 for (child
= menu
->list
; child
; child
= child
->next
) {
1158 if (menu_is_visible(child
)
1159 && child
->sym
== def_sym
)
1165 g_strdup(_(menu_get_prompt(def_menu
)));
1167 if (sym
->flags
& SYMBOL_CHOICEVAL
)
1168 row
[COL_BTNRAD
] = GINT_TO_POINTER(TRUE
);
1170 stype
= sym_get_type(sym
);
1173 if (GPOINTER_TO_INT(row
[COL_PIXVIS
]) == FALSE
)
1174 row
[COL_BTNVIS
] = GINT_TO_POINTER(TRUE
);
1175 if (sym_is_choice(sym
))
1178 val
= sym_get_tristate_value(sym
);
1181 row
[COL_NO
] = g_strdup("N");
1182 row
[COL_VALUE
] = g_strdup("N");
1183 row
[COL_BTNACT
] = GINT_TO_POINTER(FALSE
);
1184 row
[COL_BTNINC
] = GINT_TO_POINTER(FALSE
);
1187 row
[COL_MOD
] = g_strdup("M");
1188 row
[COL_VALUE
] = g_strdup("M");
1189 row
[COL_BTNINC
] = GINT_TO_POINTER(TRUE
);
1192 row
[COL_YES
] = g_strdup("Y");
1193 row
[COL_VALUE
] = g_strdup("Y");
1194 row
[COL_BTNACT
] = GINT_TO_POINTER(TRUE
);
1195 row
[COL_BTNINC
] = GINT_TO_POINTER(FALSE
);
1199 if (val
!= no
&& sym_tristate_within_range(sym
, no
))
1200 row
[COL_NO
] = g_strdup("_");
1201 if (val
!= mod
&& sym_tristate_within_range(sym
, mod
))
1202 row
[COL_MOD
] = g_strdup("_");
1203 if (val
!= yes
&& sym_tristate_within_range(sym
, yes
))
1204 row
[COL_YES
] = g_strdup("_");
1209 def
= sym_get_string_value(sym
);
1210 row
[COL_VALUE
] = g_strdup(def
);
1211 row
[COL_EDIT
] = GINT_TO_POINTER(TRUE
);
1212 row
[COL_BTNVIS
] = GINT_TO_POINTER(FALSE
);
1220 /* Set the node content with a row of strings */
1221 static void set_node(GtkTreeIter
* node
, struct menu
*menu
, gchar
** row
)
1227 pix
= gdk_pixbuf_new_from_xpm_data((const char **)
1230 gdk_color_parse(row
[COL_COLOR
], &color
);
1231 gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color
, 1,
1232 FALSE
, FALSE
, &success
);
1234 gtk_tree_store_set(tree
, node
,
1235 COL_OPTION
, row
[COL_OPTION
],
1236 COL_NAME
, row
[COL_NAME
],
1237 COL_NO
, row
[COL_NO
],
1238 COL_MOD
, row
[COL_MOD
],
1239 COL_YES
, row
[COL_YES
],
1240 COL_VALUE
, row
[COL_VALUE
],
1241 COL_MENU
, (gpointer
) menu
,
1243 COL_EDIT
, GPOINTER_TO_INT(row
[COL_EDIT
]),
1245 COL_PIXVIS
, GPOINTER_TO_INT(row
[COL_PIXVIS
]),
1246 COL_BTNVIS
, GPOINTER_TO_INT(row
[COL_BTNVIS
]),
1247 COL_BTNACT
, GPOINTER_TO_INT(row
[COL_BTNACT
]),
1248 COL_BTNINC
, GPOINTER_TO_INT(row
[COL_BTNINC
]),
1249 COL_BTNRAD
, GPOINTER_TO_INT(row
[COL_BTNRAD
]),
1252 g_object_unref(pix
);
1256 /* Add a node to the tree */
1257 static void place_node(struct menu
*menu
, char **row
)
1259 GtkTreeIter
*parent
= parents
[indent
- 1];
1260 GtkTreeIter
*node
= parents
[indent
];
1262 gtk_tree_store_append(tree
, node
, parent
);
1263 set_node(node
, menu
, row
);
1267 /* Find a node in the GTK+ tree */
1268 static GtkTreeIter found
;
1271 * Find a menu in the GtkTree starting at parent.
1273 GtkTreeIter
*gtktree_iter_find_node(GtkTreeIter
* parent
,
1274 struct menu
*tofind
)
1277 GtkTreeIter
*child
= &iter
;
1281 valid
= gtk_tree_model_iter_children(model2
, child
, parent
);
1285 gtk_tree_model_get(model2
, child
, 6, &menu
, -1);
1287 if (menu
== tofind
) {
1288 memcpy(&found
, child
, sizeof(GtkTreeIter
));
1292 ret
= gtktree_iter_find_node(child
, tofind
);
1296 valid
= gtk_tree_model_iter_next(model2
, child
);
1304 * Update the tree by adding/removing entries
1305 * Does not change other nodes
1307 static void update_tree(struct menu
*src
, GtkTreeIter
* dst
)
1309 struct menu
*child1
;
1310 GtkTreeIter iter
, tmp
;
1311 GtkTreeIter
*child2
= &iter
;
1313 GtkTreeIter
*sibling
;
1315 struct property
*prop
;
1316 struct menu
*menu1
, *menu2
;
1318 if (src
== &rootmenu
)
1321 valid
= gtk_tree_model_iter_children(model2
, child2
, dst
);
1322 for (child1
= src
->list
; child1
; child1
= child1
->next
) {
1324 prop
= child1
->prompt
;
1330 gtk_tree_model_get(model2
, child2
, COL_MENU
,
1333 menu2
= NULL
; // force adding of a first child
1336 printf("%*c%s | %s\n", indent
, ' ',
1337 menu1
? menu_get_prompt(menu1
) : "nil",
1338 menu2
? menu_get_prompt(menu2
) : "nil");
1341 if ((opt_mode
== OPT_NORMAL
&& !menu_is_visible(child1
)) ||
1342 (opt_mode
== OPT_PROMPT
&& !menu_has_prompt(child1
)) ||
1343 (opt_mode
== OPT_ALL
&& !menu_get_prompt(child1
))) {
1346 if (gtktree_iter_find_node(dst
, menu1
) != NULL
) {
1347 memcpy(&tmp
, child2
, sizeof(GtkTreeIter
));
1348 valid
= gtk_tree_model_iter_next(model2
,
1350 gtk_tree_store_remove(tree2
, &tmp
);
1352 return; /* next parent */
1354 goto reparse
; /* next child */
1359 if (menu1
!= menu2
) {
1360 if (gtktree_iter_find_node(dst
, menu1
) == NULL
) { // add node
1361 if (!valid
&& !menu2
)
1365 gtk_tree_store_insert_before(tree2
,
1368 set_node(child2
, menu1
, fill_row(menu1
));
1371 } else { // remove node
1372 memcpy(&tmp
, child2
, sizeof(GtkTreeIter
));
1373 valid
= gtk_tree_model_iter_next(model2
,
1375 gtk_tree_store_remove(tree2
, &tmp
);
1377 return; // next parent
1379 goto reparse
; // next child
1381 } else if (sym
&& (sym
->flags
& SYMBOL_CHANGED
)) {
1382 set_node(child2
, menu1
, fill_row(menu1
));
1386 update_tree(child1
, child2
);
1389 valid
= gtk_tree_model_iter_next(model2
, child2
);
1394 /* Display the whole tree (single/split/full view) */
1395 static void display_tree(struct menu
*menu
)
1398 struct property
*prop
;
1400 enum prop_type ptype
;
1402 if (menu
== &rootmenu
) {
1404 current
= &rootmenu
;
1407 for (child
= menu
->list
; child
; child
= child
->next
) {
1408 prop
= child
->prompt
;
1410 ptype
= prop
? prop
->type
: P_UNKNOWN
;
1413 sym
->flags
&= ~SYMBOL_CHANGED
;
1415 if ((view_mode
== SPLIT_VIEW
)
1416 && !(child
->flags
& MENU_ROOT
) && (tree
== tree1
))
1419 if ((view_mode
== SPLIT_VIEW
) && (child
->flags
& MENU_ROOT
)
1423 if ((opt_mode
== OPT_NORMAL
&& menu_is_visible(child
)) ||
1424 (opt_mode
== OPT_PROMPT
&& menu_has_prompt(child
)) ||
1425 (opt_mode
== OPT_ALL
&& menu_get_prompt(child
)))
1426 place_node(child
, fill_row(child
));
1428 printf("%*c%s: ", indent
, ' ', menu_get_prompt(child
));
1429 printf("%s", child
->flags
& MENU_ROOT
? "rootmenu | " : "");
1430 printf("%s", prop_get_type_name(ptype
));
1433 printf("%s", sym_type_name(sym
->type
));
1435 printf("%s", dbg_sym_flags(sym
->flags
));
1440 if ((view_mode
!= FULL_VIEW
) && (ptype
== P_MENU
)
1444 if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
1445 || (view_mode == FULL_VIEW)
1446 || (view_mode == SPLIT_VIEW))*/
1447 if (((view_mode
== SINGLE_VIEW
) && (menu
->flags
& MENU_ROOT
))
1448 || (view_mode
== FULL_VIEW
)
1449 || (view_mode
== SPLIT_VIEW
)) {
1451 display_tree(child
);
1457 /* Display a part of the tree starting at current node (single/split view) */
1458 static void display_tree_part(void)
1461 gtk_tree_store_clear(tree2
);
1462 if (view_mode
== SINGLE_VIEW
)
1463 display_tree(current
);
1464 else if (view_mode
== SPLIT_VIEW
)
1465 display_tree(browsed
);
1466 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w
));
1469 /* Display the list in the left frame (split view) */
1470 static void display_list(void)
1473 gtk_tree_store_clear(tree1
);
1476 display_tree(&rootmenu
);
1477 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w
));
1481 void fixup_rootmenu(struct menu
*menu
)
1484 static int menu_cnt
= 0;
1486 menu
->flags
|= MENU_ROOT
;
1487 for (child
= menu
->list
; child
; child
= child
->next
) {
1488 if (child
->prompt
&& child
->prompt
->type
== P_MENU
) {
1490 fixup_rootmenu(child
);
1492 } else if (!menu_cnt
)
1493 fixup_rootmenu(child
);
1499 int main(int ac
, char *av
[])
1505 #ifndef LKC_DIRECT_LINK
1509 bindtextdomain(PACKAGE
, LOCALEDIR
);
1510 bind_textdomain_codeset(PACKAGE
, "UTF-8");
1511 textdomain(PACKAGE
);
1518 //add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
1519 //add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");
1521 /* Determine GUI path */
1522 env
= getenv(SRCTREE
);
1524 glade_file
= g_strconcat(env
, "/scripts/kconfig/gconf.glade", NULL
);
1525 else if (av
[0][0] == '/')
1526 glade_file
= g_strconcat(av
[0], ".glade", NULL
);
1528 glade_file
= g_strconcat(g_get_current_dir(), "/", av
[0], ".glade", NULL
);
1531 if (ac
> 1 && av
[1][0] == '-') {
1538 printf("%s <config>\n", av
[0]);
1546 fixup_rootmenu(&rootmenu
);
1549 /* Load the interface and connect signals */
1550 init_main_window(glade_file
);
1555 switch (view_mode
) {
1557 display_tree_part();
1563 display_tree(&rootmenu
);
1572 static void conf_changed(void)
1574 bool changed
= conf_get_changed();
1575 gtk_widget_set_sensitive(save_btn
, changed
);
1576 gtk_widget_set_sensitive(save_menu_item
, changed
);