2 * prefs.c - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * Preferences dialog support functions.
29 * New 'simple' prefs should use Stash code in keyfile.c - init_pref_groups().
34 #include <gdk/gdkkeysyms.h>
43 #include "sciwrappers.h"
45 #include "documentprivate.h"
46 #include "msgwindow.h"
48 #include "keybindings.h"
49 #include "encodings.h"
55 #include "geanywraplabel.h"
56 #include "templates.h"
62 #include "filetypes.h"
71 GeanyToolPrefs tool_prefs
;
74 /* keybinding globals, should be put in a struct */
75 static GtkTreeIter g_iter
;
76 static GtkTreeStore
*store
= NULL
;
77 static GtkTreeView
*tree
= NULL
;
78 static GtkWidget
*dialog_label
;
79 static gboolean edited
= FALSE
;
81 static GtkTreeView
*various_treeview
= NULL
;
83 static GeanyKeyBinding
*kb_index(guint gidx
, guint kid
);
84 static void kb_cell_edited_cb(GtkCellRendererText
*cellrenderertext
, gchar
*path
, gchar
*new_text
, gpointer user_data
);
85 static gboolean
kb_grab_key_dialog_key_press_cb(GtkWidget
*dialog
, GdkEventKey
*event
, gpointer user_data
);
86 static void kb_grab_key_dialog_response_cb(GtkWidget
*dialog
, gint response
, gpointer user_data
);
87 static gboolean
kb_find_duplicate(GtkWidget
*parent
, GtkTreeIter
*old_iter
,
88 guint key
, GdkModifierType mods
, const gchar
*shortcut
);
89 static void on_toolbar_show_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
90 static void on_show_notebook_tabs_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
91 static void on_enable_plugins_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
92 static void on_use_folding_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
93 static void on_open_encoding_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
94 static void on_sidebar_visible_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
95 static void on_prefs_print_radio_button_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
96 static void on_prefs_print_page_header_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
);
97 static void open_preferences_help(void);
100 typedef enum PrefCallbackAction
108 /* Synchronize Stash settings with widgets (see keyfile.c - init_pref_groups()). */
109 static void prefs_action(PrefCallbackAction action
)
114 foreach_ptr_array(group
, i
, pref_groups
)
119 stash_group_display(group
, ui_widgets
.prefs_dialog
);
122 stash_group_update(group
, ui_widgets
.prefs_dialog
);
130 stash_tree_display(various_treeview
);
133 stash_tree_update(various_treeview
);
150 static void kb_tree_view_change_button_clicked_cb(GtkWidget
*button
, gpointer data
)
153 GtkTreeSelection
*selection
;
156 selection
= gtk_tree_view_get_selection(tree
);
157 if (gtk_tree_selection_get_selected(selection
, &model
, &g_iter
))
159 if (gtk_tree_model_iter_has_child(model
, &g_iter
))
160 { /* double click on a section to expand or collapse it */
161 GtkTreePath
*path
= gtk_tree_model_get_path(model
, &g_iter
);
163 if (gtk_tree_view_row_expanded(tree
, path
))
164 gtk_tree_view_collapse_row(tree
, path
);
166 gtk_tree_view_expand_row(tree
, path
, FALSE
);
168 gtk_tree_path_free(path
);
172 gtk_tree_model_get(model
, &g_iter
, KB_TREE_ACTION
, &name
, -1);
179 dialog
= gtk_dialog_new_with_buttons(_("Grab Key"), GTK_WINDOW(ui_widgets
.prefs_dialog
),
180 GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT
| GTK_DIALOG_NO_SEPARATOR
,
181 GTK_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
,
182 GTK_STOCK_OK
, GTK_RESPONSE_ACCEPT
, NULL
);
184 str
= g_strdup_printf(
185 _("Press the combination of the keys you want to use for \"%s\"."), name
);
186 label
= gtk_label_new(str
);
187 gtk_misc_set_padding(GTK_MISC(label
), 5, 10);
188 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog
))), label
);
190 dialog_label
= gtk_label_new("");
191 gtk_misc_set_padding(GTK_MISC(dialog_label
), 5, 10);
192 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog
))), dialog_label
);
194 g_signal_connect(dialog
, "key-press-event",
195 G_CALLBACK(kb_grab_key_dialog_key_press_cb
), NULL
);
196 g_signal_connect(dialog
, "response", G_CALLBACK(kb_grab_key_dialog_response_cb
), NULL
);
198 gtk_widget_show_all(dialog
);
206 static void kb_expand_collapse_cb(GtkWidget
*item
, gpointer user_data
)
208 if (user_data
!= NULL
)
209 gtk_tree_view_expand_all(tree
);
211 gtk_tree_view_collapse_all(tree
);
215 static void kb_show_popup_menu(GtkWidget
*widget
, GdkEventButton
*event
)
218 static GtkWidget
*menu
= NULL
;
224 menu
= gtk_menu_new();
226 item
= ui_image_menu_item_new(GTK_STOCK_ADD
, _("_Expand All"));
227 gtk_widget_show(item
);
228 gtk_container_add(GTK_CONTAINER(menu
), item
);
229 g_signal_connect(item
, "activate", G_CALLBACK(kb_expand_collapse_cb
), GINT_TO_POINTER(TRUE
));
231 item
= ui_image_menu_item_new(GTK_STOCK_REMOVE
, _("_Collapse All"));
232 gtk_widget_show(item
);
233 gtk_container_add(GTK_CONTAINER(menu
), item
);
234 g_signal_connect(item
, "activate", G_CALLBACK(kb_expand_collapse_cb
), NULL
);
236 gtk_menu_attach_to_widget(GTK_MENU(menu
), widget
, NULL
);
241 button
= event
->button
;
242 event_time
= event
->time
;
247 event_time
= gtk_get_current_event_time();
250 gtk_menu_popup(GTK_MENU(menu
), NULL
, NULL
, NULL
, NULL
, button
, event_time
);
254 static gboolean
kb_popup_menu_cb(GtkWidget
*widget
, gpointer data
)
256 kb_show_popup_menu(widget
, NULL
);
261 static gboolean
kb_tree_view_button_press_event_cb(GtkWidget
*widget
, GdkEventButton
*event
,
264 if (event
->button
== 3 && event
->type
== GDK_BUTTON_PRESS
)
266 kb_show_popup_menu(widget
, event
);
269 else if (event
->type
== GDK_2BUTTON_PRESS
)
271 kb_tree_view_change_button_clicked_cb(NULL
, NULL
);
278 static void kb_init_tree(void)
280 GtkCellRenderer
*renderer
;
281 GtkTreeViewColumn
*column
;
283 tree
= GTK_TREE_VIEW(ui_lookup_widget(ui_widgets
.prefs_dialog
, "treeview7"));
285 store
= gtk_tree_store_new(KB_TREE_COLUMNS
,
286 G_TYPE_STRING
, G_TYPE_STRING
, G_TYPE_INT
, G_TYPE_BOOLEAN
, G_TYPE_INT
);
287 gtk_tree_view_set_model(GTK_TREE_VIEW(tree
), GTK_TREE_MODEL(store
));
288 g_object_unref(store
);
290 renderer
= gtk_cell_renderer_text_new();
291 column
= gtk_tree_view_column_new_with_attributes(_("Action"), renderer
,
292 "text", KB_TREE_ACTION
, "weight", KB_TREE_WEIGHT
, NULL
);
293 gtk_tree_view_append_column(GTK_TREE_VIEW(tree
), column
);
295 renderer
= gtk_cell_renderer_text_new();
296 column
= gtk_tree_view_column_new_with_attributes(_("Shortcut"), renderer
,
297 "text", KB_TREE_SHORTCUT
, "editable", KB_TREE_EDITABLE
,
298 "weight", KB_TREE_WEIGHT
, NULL
);
299 gtk_tree_view_append_column(GTK_TREE_VIEW(tree
), column
);
301 /* set policy settings for the scrolled window around the treeview again, because glade
302 * doesn't keep the settings */
303 gtk_scrolled_window_set_policy(
304 GTK_SCROLLED_WINDOW(ui_lookup_widget(ui_widgets
.prefs_dialog
, "scrolledwindow8")),
305 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
307 g_signal_connect(renderer
, "edited", G_CALLBACK(kb_cell_edited_cb
), NULL
);
308 g_signal_connect(tree
, "button-press-event", G_CALLBACK(kb_tree_view_button_press_event_cb
), NULL
);
309 g_signal_connect(tree
, "popup-menu", G_CALLBACK(kb_popup_menu_cb
), NULL
);
310 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "button2"), "clicked",
311 G_CALLBACK(kb_tree_view_change_button_clicked_cb
), NULL
);
315 static void kb_set_shortcut(GtkTreeStore
*store
, GtkTreeIter
*iter
,
316 guint key
, GdkModifierType mods
)
318 gchar
*key_string
= gtk_accelerator_name(key
, mods
);
324 gtk_tree_store_set(store
, iter
, KB_TREE_SHORTCUT
, key_string
, -1);
327 gtk_tree_model_get(GTK_TREE_MODEL(store
), iter
, KB_TREE_INDEX
, &kid
, -1);
328 gtk_tree_model_iter_parent(GTK_TREE_MODEL(store
), &parent
, iter
);
329 gtk_tree_model_get(GTK_TREE_MODEL(store
), &parent
, KB_TREE_INDEX
, &gid
, -1);
330 kb
= kb_index(gid
, kid
);
331 bold
= key
!= kb
->default_key
|| mods
!= kb
->default_mods
;
332 gtk_tree_store_set(store
, iter
, KB_TREE_WEIGHT
,
333 bold
? PANGO_WEIGHT_BOLD
: PANGO_WEIGHT_NORMAL
, -1);
337 void prefs_kb_search_name(const gchar
*search
)
343 model
= gtk_tree_view_get_model(tree
);
344 valid
= gtk_tree_model_get_iter_first(model
, &iter
);
347 gtk_tree_model_get(model
, &iter
, KB_TREE_ACTION
, &name
, -1);
348 if(g_strcmp0(name
, search
) == 0)
350 GtkTreePath
*path
= gtk_tree_model_get_path(model
, &iter
);
351 gtk_tree_view_scroll_to_cell(tree
, path
, NULL
, FALSE
, .0f
, .0f
);
352 gtk_tree_path_free(path
);
355 valid
= gtk_tree_model_iter_next(model
, &iter
);
360 static void kb_init(void)
362 GtkTreeIter parent
, iter
;
365 GeanyKeyGroup
*group
;
371 foreach_ptr_array(group
, g
, keybinding_groups
)
373 gtk_tree_store_append(store
, &parent
, NULL
);
374 gtk_tree_store_set(store
, &parent
, KB_TREE_ACTION
, group
->label
,
375 KB_TREE_INDEX
, g
, -1);
377 foreach_ptr_array(kb
, i
, group
->key_items
)
379 label
= keybindings_get_label(kb
);
380 gtk_tree_store_append(store
, &iter
, &parent
);
381 gtk_tree_store_set(store
, &iter
, KB_TREE_ACTION
, label
,
382 KB_TREE_EDITABLE
, TRUE
, KB_TREE_INDEX
, kb
->id
, -1);
383 kb_set_shortcut(store
, &iter
, kb
->key
, kb
->mods
);
387 gtk_tree_view_expand_all(GTK_TREE_VIEW(tree
));
391 /* note: new 'simple' prefs should use Stash code in keyfile.c */
392 static void prefs_init_dialog(void)
397 /* Synchronize with Stash settings */
398 prefs_action(PREF_DISPLAY
);
400 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "label_project_indent_warning");
401 ui_widget_show_hide(widget
, app
->project
!= NULL
);
403 /* General settings */
405 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_load_session");
406 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), prefs
.load_session
);
408 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_project_session");
409 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), project_prefs
.project_session
);
411 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_project_file_in_basedir");
412 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), project_prefs
.project_file_in_basedir
);
414 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_save_win_pos");
415 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), prefs
.save_winpos
);
417 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_ask_for_quit");
418 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), prefs
.confirm_exit
);
421 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_beep");
422 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), prefs
.beep_on_errors
);
424 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_switch_pages");
425 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), prefs
.switch_to_status
);
427 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_suppress_status_msgs");
428 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), prefs
.suppress_status_messages
);
430 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_auto_focus");
431 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), prefs
.auto_focus
);
433 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_native_windows_dialogs");
434 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
),
435 interface_prefs
.use_native_windows_dialogs
);
437 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_contextaction");
438 gtk_entry_set_text(GTK_ENTRY(widget
), tool_prefs
.context_action_cmd
);
440 project_setup_prefs(); /* project files path */
443 /* Interface settings */
444 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_sidebar_visible");
445 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), ui_prefs
.sidebar_visible
);
446 on_sidebar_visible_toggled(GTK_TOGGLE_BUTTON(widget
), NULL
);
448 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_list_symbol");
449 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), interface_prefs
.sidebar_symbol_visible
);
451 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_list_openfiles");
452 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), interface_prefs
.sidebar_openfiles_visible
);
454 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "tagbar_font");
455 gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget
), interface_prefs
.tagbar_font
);
457 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "msgwin_font");
458 gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget
), interface_prefs
.msgwin_font
);
460 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "editor_font");
461 gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget
), interface_prefs
.editor_font
);
463 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_long_line");
464 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget
), editor_prefs
.long_line_column
);
466 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_long_line");
467 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.long_line_enabled
);
469 switch (editor_prefs
.long_line_type
)
471 case 0: widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_long_line_line"); break;
472 case 1: widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_long_line_background"); break;
474 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), TRUE
);
476 color
= g_new0(GdkColor
, 1);
477 gdk_color_parse(editor_prefs
.long_line_color
, color
);
478 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "long_line_color");
479 gtk_color_button_set_color(GTK_COLOR_BUTTON(widget
), color
);
482 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_show_notebook_tabs");
483 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), interface_prefs
.show_notebook_tabs
);
484 /* disable following setting if notebook tabs are hidden */
485 on_show_notebook_tabs_toggled(GTK_TOGGLE_BUTTON(
486 ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_show_notebook_tabs")), NULL
);
488 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_show_tab_cross");
489 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), file_prefs
.show_tab_cross
);
491 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_tab_editor");
492 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), interface_prefs
.tab_pos_editor
);
494 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_tab_msgwin");
495 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), interface_prefs
.tab_pos_msgwin
);
497 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_tab_sidebar");
498 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), interface_prefs
.tab_pos_sidebar
);
500 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_statusbar_visible");
501 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), interface_prefs
.statusbar_visible
);
504 /* Toolbar settings */
505 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_toolbar_show");
506 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), toolbar_prefs
.visible
);
507 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_toolbar_in_menu");
508 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), toolbar_prefs
.append_to_menu
);
510 switch (toolbar_prefs
.icon_style
)
512 case 0: widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_image"); break;
513 case 1: widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_text"); break;
514 default: widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_imagetext"); break;
516 if (toolbar_prefs
.use_gtk_default_style
)
517 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_style_default");
518 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), TRUE
);
520 switch (toolbar_prefs
.icon_size
)
522 case GTK_ICON_SIZE_LARGE_TOOLBAR
:
523 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_large"); break;
524 case GTK_ICON_SIZE_SMALL_TOOLBAR
:
525 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_small"); break;
526 default: widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_verysmall"); break;
528 if (toolbar_prefs
.use_gtk_default_icon
)
529 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_icon_default");
530 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), TRUE
);
532 /* disable elements if toolbar is hidden */
533 on_toolbar_show_toggled(GTK_TOGGLE_BUTTON(
534 ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_toolbar_show")), NULL
);
538 if (file_prefs
.tab_order_ltr
)
539 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_tab_right");
541 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_tab_left");
542 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), TRUE
);
544 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_tab_beside");
545 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), file_prefs
.tab_order_beside
);
547 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_new_encoding");
548 /* luckily the index of the combo box items match the index of the encodings array */
549 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), file_prefs
.default_new_encoding
);
551 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_open_encoding");
552 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
),
553 (file_prefs
.default_open_encoding
>= 0) ? TRUE
: FALSE
);
554 on_open_encoding_toggled(GTK_TOGGLE_BUTTON(widget
), NULL
);
556 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_open_encoding");
557 if (file_prefs
.default_open_encoding
>= 0)
559 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), file_prefs
.default_open_encoding
);
562 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), GEANY_ENCODING_UTF_8
);
564 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_eol");
565 if (file_prefs
.default_eol_character
>= 0 && file_prefs
.default_eol_character
< 3)
567 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), file_prefs
.default_eol_character
);
570 gtk_combo_box_set_active(GTK_COMBO_BOX(widget
), GEANY_DEFAULT_EOL_CHARACTER
);
572 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_trailing_spaces");
573 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), file_prefs
.strip_trailing_spaces
);
575 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_new_line");
576 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), file_prefs
.final_new_line
);
578 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_ensure_convert_new_lines");
579 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), file_prefs
.ensure_convert_new_lines
);
581 /* Editor settings */
582 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_toggle_mark");
583 gtk_entry_set_text(GTK_ENTRY(widget
), editor_prefs
.comment_toggle_mark
);
585 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_replace_tabs");
586 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), file_prefs
.replace_tabs
);
588 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_indent");
589 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.show_indent_guide
);
591 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_white_space");
592 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.show_white_space
);
594 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_line_end");
595 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.show_line_endings
);
597 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_line_numbers");
598 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.show_linenumber_margin
);
600 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_markers_margin");
601 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.show_markers_margin
);
603 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_scroll_stop_at_last_line");
604 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.scroll_stop_at_last_line
);
606 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_line_wrapping");
607 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.line_wrapping
);
609 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_complete_snippets");
610 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.complete_snippets
);
612 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_xmltag");
613 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.auto_close_xml_tags
);
615 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_folding");
616 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.folding
);
618 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_unfold_children");
619 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.unfold_all_children
);
620 on_use_folding_toggled(GTK_TOGGLE_BUTTON(
621 ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_folding")), NULL
);
623 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_disable_dnd");
624 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.disable_dnd
);
626 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_smart_home");
627 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.smart_home_key
);
629 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_newline_strip");
630 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.newline_strip
);
632 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_indicators");
633 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.use_indicators
);
635 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_auto_multiline");
636 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.auto_continue_multiline
);
638 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_symbol_auto_completion");
639 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), editor_prefs
.auto_complete_symbols
);
641 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_symbollistheight");
642 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget
), editor_prefs
.symbolcompletion_max_height
);
644 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_symbol_complete_chars");
645 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget
), editor_prefs
.symbolcompletion_min_chars
);
647 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_line_break");
648 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget
), editor_prefs
.line_break_column
);
650 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_parenthesis");
651 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
),
652 (editor_prefs
.autoclose_chars
& GEANY_AC_PARENTHESIS
));
654 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_cbracket");
655 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
),
656 (editor_prefs
.autoclose_chars
& GEANY_AC_CBRACKET
));
658 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_sbracket");
659 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
),
660 (editor_prefs
.autoclose_chars
& GEANY_AC_SBRACKET
));
662 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_squote");
663 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
),
664 (editor_prefs
.autoclose_chars
& GEANY_AC_SQUOTE
));
666 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_dquote");
667 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
),
668 (editor_prefs
.autoclose_chars
& GEANY_AC_DQUOTE
));
672 if (tool_prefs
.term_cmd
)
673 gtk_entry_set_text(GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_com_term")), tool_prefs
.term_cmd
);
675 if (tool_prefs
.browser_cmd
)
676 gtk_entry_set_text(GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_browser")), tool_prefs
.browser_cmd
);
678 if (tool_prefs
.grep_cmd
)
679 gtk_entry_set_text(GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_grep")), tool_prefs
.grep_cmd
);
682 /* Template settings */
683 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_developer");
684 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.developer
);
686 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_company");
687 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.company
);
689 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_mail");
690 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.mail
);
692 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_initial");
693 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.initials
);
695 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_version");
696 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.version
);
698 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_year");
699 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.year_format
);
701 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_date");
702 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.date_format
);
704 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_datetime");
705 gtk_entry_set_text(GTK_ENTRY(widget
), template_prefs
.datetime_format
);
713 GtkWidget
*widget_gtk
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_print_gtk");
714 if (printing_prefs
.use_gtk_printing
)
717 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_print_external");
719 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), TRUE
);
721 on_prefs_print_radio_button_toggled(GTK_TOGGLE_BUTTON(widget_gtk
), NULL
);
723 if (printing_prefs
.external_print_cmd
)
725 GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_print_external_cmd")),
726 printing_prefs
.external_print_cmd
);
728 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_linenumbers");
729 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), printing_prefs
.print_line_numbers
);
731 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_pagenumbers");
732 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), printing_prefs
.print_page_numbers
);
734 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_pageheader");
735 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), printing_prefs
.print_page_header
);
736 on_prefs_print_page_header_toggled(GTK_TOGGLE_BUTTON(widget
), NULL
);
738 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_basename");
739 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), printing_prefs
.page_header_basename
);
741 if (printing_prefs
.page_header_datefmt
)
743 GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_print_dateformat")),
744 printing_prefs
.page_header_datefmt
);
748 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_plugins"), FALSE
);
750 on_enable_plugins_toggled(GTK_TOGGLE_BUTTON( ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_plugins")), NULL
);
753 /* make VTE switch visible only when VTE is compiled in, it is hidden by default */
754 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_vte");
755 gtk_widget_show(widget
);
756 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vte_info
.load_vte
);
759 if (vte_info
.have_vte
)
761 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "font_term");
762 gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget
), vc
->font
);
764 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "color_fore");
765 gtk_color_button_set_color(GTK_COLOR_BUTTON(widget
), vc
->colour_fore
);
767 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "color_back");
768 gtk_color_button_set_color(GTK_COLOR_BUTTON(widget
), vc
->colour_back
);
770 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_image");
771 gtk_entry_set_text(GTK_ENTRY(widget
), vc
->image
);
773 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_scrollback");
774 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget
), vc
->scrollback_lines
);
776 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_shell");
777 gtk_entry_set_text(GTK_ENTRY(widget
), vc
->shell
);
779 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_scroll_key");
780 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->scroll_on_key
);
782 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_scroll_out");
783 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->scroll_on_out
);
785 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_enable_bash_keys");
786 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->enable_bash_keys
);
788 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_ignore_menu_key");
789 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->ignore_menu_bar_accel
);
791 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_follow_path");
792 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->follow_path
);
794 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_run_in_vte");
795 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->run_in_vte
);
797 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_skip_script");
798 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->skip_run_script
);
800 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_cursor_blinks");
801 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget
), vc
->cursor_blinks
);
807 /* note: uses group index, not group id, unlike keybindings_lookup_item(). */
808 static GeanyKeyBinding
*kb_index(guint gidx
, guint kid
)
810 GeanyKeyGroup
*group
;
812 group
= g_ptr_array_index(keybinding_groups
, gidx
);
813 return keybindings_get_item(group
, kid
);
817 /* read the treeview shortcut fields into keybindings */
818 static void kb_update(void)
820 GtkTreeModel
*model
= GTK_TREE_MODEL(store
);
821 GtkTreeIter child
, parent
;
824 /* get first parent */
825 if (! gtk_tree_model_iter_children(model
, &parent
, NULL
))
831 /* get first child */
832 if (! gtk_tree_model_iter_children(model
, &child
, &parent
))
841 GdkModifierType mods
;
844 gtk_tree_model_get(model
, &child
, KB_TREE_INDEX
, &kid
, KB_TREE_SHORTCUT
, &str
, -1);
845 gtk_accelerator_parse(str
, &key
, &mods
);
847 kb
= kb_index(gid
, kid
);
848 if (kb
->key
!= key
|| kb
->mods
!= mods
)
849 keybindings_update_combo(kb
, key
, mods
);
851 if (! gtk_tree_model_iter_next(model
, &child
))
854 if (! gtk_tree_model_iter_next(model
, &parent
))
864 /* note: new 'simple' prefs should use Stash code in keyfile.c */
866 on_prefs_dialog_response(GtkDialog
*dialog
, gint response
, gpointer user_data
)
868 if (response
== GTK_RESPONSE_OK
|| response
== GTK_RESPONSE_APPLY
)
872 gboolean autoclose_brackets
[5];
873 gboolean old_invert_all
= interface_prefs
.highlighting_invert_all
;
874 gboolean old_sidebar_pos
= interface_prefs
.sidebar_pos
;
875 GeanyDocument
*doc
= document_get_current();
877 /* Synchronize Stash settings */
878 prefs_action(PREF_UPDATE
);
880 if (interface_prefs
.highlighting_invert_all
!= old_invert_all
)
883 if (interface_prefs
.sidebar_pos
!= old_sidebar_pos
)
884 ui_swap_sidebar_pos();
886 widget
= ui_lookup_widget(main_widgets
.window
, "vpaned1");
887 gtk_orientable_set_orientation(GTK_ORIENTABLE(widget
), interface_prefs
.msgwin_orientation
);
889 /* General settings */
891 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_load_session");
892 prefs
.load_session
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
894 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_project_session");
895 project_prefs
.project_session
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
897 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_project_file_in_basedir");
898 project_prefs
.project_file_in_basedir
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
900 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_save_win_pos");
901 prefs
.save_winpos
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
903 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_ask_for_quit");
904 prefs
.confirm_exit
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
907 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_beep");
908 prefs
.beep_on_errors
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
910 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_switch_pages");
911 prefs
.switch_to_status
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
913 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_suppress_status_msgs");
914 prefs
.suppress_status_messages
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
916 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_auto_focus");
917 prefs
.auto_focus
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
919 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_native_windows_dialogs");
920 interface_prefs
.use_native_windows_dialogs
=
921 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
923 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_contextaction");
924 g_free(tool_prefs
.context_action_cmd
);
925 tool_prefs
.context_action_cmd
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
927 project_apply_prefs(); /* project file path */
930 /* Interface settings */
931 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_sidebar_visible");
932 ui_prefs
.sidebar_visible
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
934 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_list_symbol");
935 interface_prefs
.sidebar_symbol_visible
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
937 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_list_openfiles");
938 interface_prefs
.sidebar_openfiles_visible
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
940 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_long_line");
941 editor_prefs
.long_line_enabled
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
943 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_long_line_line");
944 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
)))
945 editor_prefs
.long_line_type
= 0;
947 /* now only the "background" radio remains */
948 editor_prefs
.long_line_type
= 1;
950 if (editor_prefs
.long_line_column
== 0)
951 editor_prefs
.long_line_enabled
= FALSE
;
953 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_show_notebook_tabs");
954 interface_prefs
.show_notebook_tabs
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
956 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_show_tab_cross");
957 file_prefs
.show_tab_cross
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
959 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_tab_editor");
960 interface_prefs
.tab_pos_editor
= gtk_combo_box_get_active(GTK_COMBO_BOX(widget
));
962 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_tab_msgwin");
963 interface_prefs
.tab_pos_msgwin
= gtk_combo_box_get_active(GTK_COMBO_BOX(widget
));
965 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_tab_sidebar");
966 interface_prefs
.tab_pos_sidebar
= gtk_combo_box_get_active(GTK_COMBO_BOX(widget
));
968 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_statusbar_visible");
969 interface_prefs
.statusbar_visible
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
972 /* Toolbar settings */
973 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_toolbar_show");
974 toolbar_prefs
.visible
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
975 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_toolbar_in_menu");
976 toolbar_prefs
.append_to_menu
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
978 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_style_default");
979 toolbar_prefs
.use_gtk_default_style
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
980 if (! toolbar_prefs
.use_gtk_default_style
)
982 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_imagetext");
983 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
)))
984 toolbar_prefs
.icon_style
= 2;
987 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_image");
988 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
)))
989 toolbar_prefs
.icon_style
= 0;
991 /* now only the text only radio remains, so set text only */
992 toolbar_prefs
.icon_style
= 1;
996 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_icon_default");
997 toolbar_prefs
.use_gtk_default_icon
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
998 if (! toolbar_prefs
.use_gtk_default_icon
)
999 { toolbar_prefs
.icon_size
= GTK_ICON_SIZE_LARGE_TOOLBAR
;
1000 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_large");
1001 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
)))
1002 toolbar_prefs
.icon_size
= GTK_ICON_SIZE_LARGE_TOOLBAR
;
1005 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_toolbar_small");
1006 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
)))
1007 toolbar_prefs
.icon_size
= GTK_ICON_SIZE_SMALL_TOOLBAR
;
1009 toolbar_prefs
.icon_size
= GTK_ICON_SIZE_MENU
;
1013 /* Files settings */
1014 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_tab_right");
1015 file_prefs
.tab_order_ltr
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1017 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_tab_beside");
1018 file_prefs
.tab_order_beside
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1020 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_new_encoding");
1021 file_prefs
.default_new_encoding
= gtk_combo_box_get_active(GTK_COMBO_BOX(widget
));
1023 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_open_encoding");
1024 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
)))
1026 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_open_encoding");
1027 file_prefs
.default_open_encoding
= gtk_combo_box_get_active(GTK_COMBO_BOX(widget
));
1030 file_prefs
.default_open_encoding
= -1;
1032 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_eol");
1033 file_prefs
.default_eol_character
= gtk_combo_box_get_active(GTK_COMBO_BOX(widget
));
1035 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_trailing_spaces");
1036 file_prefs
.strip_trailing_spaces
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1038 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_new_line");
1039 file_prefs
.final_new_line
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1041 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_ensure_convert_new_lines");
1042 file_prefs
.ensure_convert_new_lines
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1044 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_replace_tabs");
1045 file_prefs
.replace_tabs
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1048 /* Editor settings */
1049 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_toggle_mark");
1050 SETPTR(editor_prefs
.comment_toggle_mark
,
1051 gtk_editable_get_chars(GTK_EDITABLE(widget
), 0, -1));
1053 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_long_line");
1054 /* note: use stash for new code - it updates spin buttons itself */
1055 gtk_spin_button_update(GTK_SPIN_BUTTON(widget
));
1056 editor_prefs
.long_line_column
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget
));
1058 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_folding");
1059 editor_prefs
.folding
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1060 ui_update_fold_items();
1062 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_unfold_children");
1063 editor_prefs
.unfold_all_children
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1065 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_indent");
1066 editor_prefs
.show_indent_guide
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1068 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_white_space");
1069 editor_prefs
.show_white_space
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1071 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_line_end");
1072 editor_prefs
.show_line_endings
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1074 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_line_numbers");
1075 editor_prefs
.show_linenumber_margin
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1077 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_markers_margin");
1078 editor_prefs
.show_markers_margin
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1080 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_scroll_stop_at_last_line");
1081 editor_prefs
.scroll_stop_at_last_line
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1083 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_line_wrapping");
1084 editor_prefs
.line_wrapping
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1086 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_complete_snippets");
1087 editor_prefs
.complete_snippets
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1089 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_xmltag");
1090 editor_prefs
.auto_close_xml_tags
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1092 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_indicators");
1093 editor_prefs
.use_indicators
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1095 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_disable_dnd");
1096 editor_prefs
.disable_dnd
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1098 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_smart_home");
1099 editor_prefs
.smart_home_key
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1101 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_newline_strip");
1102 editor_prefs
.newline_strip
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1104 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_auto_multiline");
1105 editor_prefs
.auto_continue_multiline
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1107 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_symbol_auto_completion");
1108 editor_prefs
.auto_complete_symbols
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1110 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_symbol_complete_chars");
1111 gtk_spin_button_update(GTK_SPIN_BUTTON(widget
));
1112 editor_prefs
.symbolcompletion_min_chars
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget
));
1114 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_symbollistheight");
1115 gtk_spin_button_update(GTK_SPIN_BUTTON(widget
));
1116 editor_prefs
.symbolcompletion_max_height
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget
));
1118 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_line_break");
1119 gtk_spin_button_update(GTK_SPIN_BUTTON(widget
));
1120 editor_prefs
.line_break_column
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget
));
1122 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_parenthesis");
1123 autoclose_brackets
[0] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1125 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_cbracket");
1126 autoclose_brackets
[1] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1128 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_sbracket");
1129 autoclose_brackets
[2] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1131 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_squote");
1132 autoclose_brackets
[3] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1134 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_autoclose_dquote");
1135 autoclose_brackets
[4] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1137 editor_prefs
.autoclose_chars
=
1138 (autoclose_brackets
[0] ? GEANY_AC_PARENTHESIS
: 0u)
1139 | (autoclose_brackets
[1] ? GEANY_AC_CBRACKET
: 0u)
1140 | (autoclose_brackets
[2] ? GEANY_AC_SBRACKET
: 0u)
1141 | (autoclose_brackets
[3] ? GEANY_AC_SQUOTE
: 0u)
1142 | (autoclose_brackets
[4] ? GEANY_AC_DQUOTE
: 0u);
1144 /* Tools Settings */
1146 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_com_term");
1147 g_free(tool_prefs
.term_cmd
);
1148 tool_prefs
.term_cmd
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1150 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_browser");
1151 g_free(tool_prefs
.browser_cmd
);
1152 tool_prefs
.browser_cmd
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1154 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_grep");
1155 g_free(tool_prefs
.grep_cmd
);
1156 tool_prefs
.grep_cmd
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1159 /* Template settings */
1160 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_developer");
1161 g_free(template_prefs
.developer
);
1162 template_prefs
.developer
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1164 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_company");
1165 g_free(template_prefs
.company
);
1166 template_prefs
.company
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1168 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_mail");
1169 g_free(template_prefs
.mail
);
1170 template_prefs
.mail
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1172 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_initial");
1173 g_free(template_prefs
.initials
);
1174 template_prefs
.initials
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1176 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_version");
1177 g_free(template_prefs
.version
);
1178 template_prefs
.version
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1180 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_year");
1181 g_free(template_prefs
.year_format
);
1182 template_prefs
.year_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1184 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_date");
1185 g_free(template_prefs
.date_format
);
1186 template_prefs
.date_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1188 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_template_datetime");
1189 g_free(template_prefs
.datetime_format
);
1190 template_prefs
.datetime_format
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1197 tools_create_insert_custom_command_menu_items();
1198 keybindings_write_to_file();
1202 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_print_gtk");
1203 printing_prefs
.use_gtk_printing
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1205 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_print_external_cmd");
1206 g_free(printing_prefs
.external_print_cmd
);
1207 printing_prefs
.external_print_cmd
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1209 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_linenumbers");
1210 printing_prefs
.print_line_numbers
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1212 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_pagenumbers");
1213 printing_prefs
.print_page_numbers
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1215 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_pageheader");
1216 printing_prefs
.print_page_header
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1218 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_basename");
1219 printing_prefs
.page_header_basename
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1221 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_print_dateformat");
1222 g_free(printing_prefs
.page_header_datefmt
);
1223 printing_prefs
.page_header_datefmt
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1227 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_vte");
1228 vte_info
.load_vte
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1231 if (vte_info
.have_vte
)
1233 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "spin_scrollback");
1234 gtk_spin_button_update(GTK_SPIN_BUTTON(widget
));
1235 vc
->scrollback_lines
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget
));
1237 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_image");
1239 vc
->image
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1241 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_shell");
1243 vc
->shell
= g_strdup(gtk_entry_get_text(GTK_ENTRY(widget
)));
1245 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_scroll_key");
1246 vc
->scroll_on_key
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1248 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_scroll_out");
1249 vc
->scroll_on_out
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1251 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_enable_bash_keys");
1252 vc
->enable_bash_keys
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1254 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_ignore_menu_key");
1255 vc
->ignore_menu_bar_accel
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1257 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_follow_path");
1258 vc
->follow_path
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1260 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_run_in_vte");
1261 vc
->run_in_vte
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1263 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_skip_script");
1264 vc
->skip_run_script
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1266 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_cursor_blinks");
1267 vc
->cursor_blinks
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
1269 vte_apply_user_settings();
1273 /* apply the changes made */
1274 ui_statusbar_showhide(interface_prefs
.statusbar_visible
);
1275 sidebar_openfiles_update_all(); /* to update if full path setting has changed */
1276 toolbar_apply_settings();
1277 toolbar_update_ui();
1278 toolbar_show_hide();
1279 ui_sidebar_show_hide();
1280 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets
.notebook
), interface_prefs
.show_notebook_tabs
);
1282 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(main_widgets
.notebook
), interface_prefs
.tab_pos_editor
);
1283 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow
.notebook
), interface_prefs
.tab_pos_msgwin
);
1284 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(main_widgets
.sidebar_notebook
), interface_prefs
.tab_pos_sidebar
);
1286 /* re-colourise all open documents, if tab width or long line settings have changed */
1287 for (i
= 0; i
< documents_array
->len
; i
++)
1289 if (documents
[i
]->is_valid
)
1291 editor_apply_update_prefs(documents
[i
]->editor
);
1292 if (! editor_prefs
.folding
)
1293 editor_unfold_all(documents
[i
]->editor
);
1296 ui_document_show_hide(NULL
);
1297 ui_update_view_editor_menu_items();
1299 /* various preferences */
1300 ui_save_buttons_toggle((doc
!= NULL
) ? doc
->changed
: FALSE
);
1301 msgwin_show_hide_tabs();
1302 ui_update_statusbar(doc
, -1);
1304 /* store all settings */
1305 configuration_save();
1308 if (response
== GTK_RESPONSE_HELP
)
1310 open_preferences_help();
1312 else if (response
!= GTK_RESPONSE_APPLY
)
1314 gtk_tree_store_clear(store
);
1315 gtk_widget_hide(GTK_WIDGET(dialog
));
1320 static void on_color_button_choose_cb(GtkColorButton
*widget
, gpointer user_data
)
1324 gtk_color_button_get_color(widget
, &color
);
1325 SETPTR(editor_prefs
.long_line_color
, utils_get_hex_from_color(&color
));
1329 static void on_prefs_font_choosed(GtkFontButton
*widget
, gpointer user_data
)
1331 const gchar
*fontbtn
= gtk_font_button_get_font_name(widget
);
1334 switch (GPOINTER_TO_INT(user_data
))
1338 if (strcmp(fontbtn
, interface_prefs
.tagbar_font
) == 0)
1341 SETPTR(interface_prefs
.tagbar_font
, g_strdup(fontbtn
));
1342 for (i
= 0; i
< documents_array
->len
; i
++)
1344 GeanyDocument
*doc
= documents
[i
];
1346 if (documents
[i
]->is_valid
&& GTK_IS_WIDGET(doc
->priv
->tag_tree
))
1347 ui_widget_modify_font_from_string(doc
->priv
->tag_tree
,
1348 interface_prefs
.tagbar_font
);
1350 if (GTK_IS_WIDGET(tv
.default_tag_tree
))
1351 ui_widget_modify_font_from_string(tv
.default_tag_tree
, interface_prefs
.tagbar_font
);
1352 ui_widget_modify_font_from_string(tv
.tree_openfiles
, interface_prefs
.tagbar_font
);
1357 if (strcmp(fontbtn
, interface_prefs
.msgwin_font
) == 0)
1359 SETPTR(interface_prefs
.msgwin_font
, g_strdup(fontbtn
));
1360 ui_widget_modify_font_from_string(msgwindow
.tree_compiler
, interface_prefs
.msgwin_font
);
1361 ui_widget_modify_font_from_string(msgwindow
.tree_msg
, interface_prefs
.msgwin_font
);
1362 ui_widget_modify_font_from_string(msgwindow
.tree_status
, interface_prefs
.msgwin_font
);
1363 ui_widget_modify_font_from_string(msgwindow
.scribble
, interface_prefs
.msgwin_font
);
1368 ui_set_editor_font(fontbtn
);
1375 static void kb_change_iter_shortcut(GtkTreeIter
*iter
, const gchar
*new_text
)
1378 GdkModifierType lmods
;
1380 gtk_accelerator_parse(new_text
, &lkey
, &lmods
);
1382 if (kb_find_duplicate(ui_widgets
.prefs_dialog
, iter
, lkey
, lmods
, new_text
))
1385 /* set the values here, because of the above check, setting it in
1386 * gtk_accelerator_parse would return a wrong key combination if it is duplicate */
1387 kb_set_shortcut(store
, iter
, lkey
, lmods
);
1393 static void kb_cell_edited_cb(GtkCellRendererText
*cellrenderertext
,
1394 gchar
*path
, gchar
*new_text
, gpointer user_data
)
1396 if (path
!= NULL
&& new_text
!= NULL
)
1400 gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store
), &iter
, path
);
1401 if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store
), &iter
))
1402 return; /* ignore group items */
1404 kb_change_iter_shortcut(&iter
, new_text
);
1409 static gboolean
kb_grab_key_dialog_key_press_cb(GtkWidget
*dialog
, GdkEventKey
*event
, gpointer user_data
)
1414 state
= event
->state
& gtk_accelerator_get_default_mod_mask();
1416 if (event
->keyval
== GDK_Escape
)
1417 return FALSE
; /* close the dialog, don't allow escape when detecting keybindings. */
1419 str
= gtk_accelerator_name(event
->keyval
, state
);
1421 gtk_label_set_text(GTK_LABEL(dialog_label
), str
);
1428 static void kb_grab_key_dialog_response_cb(GtkWidget
*dialog
, gint response
, G_GNUC_UNUSED gpointer iter
)
1430 if (response
== GTK_RESPONSE_ACCEPT
)
1432 const gchar
*new_text
= gtk_label_get_text(GTK_LABEL(dialog_label
));
1434 kb_change_iter_shortcut(&g_iter
, new_text
);
1436 gtk_widget_destroy(dialog
);
1440 /* test if the entered key combination is already used
1441 * returns true if cancelling duplicate */
1442 static gboolean
kb_find_duplicate(GtkWidget
*parent
, GtkTreeIter
*old_iter
,
1443 guint key
, GdkModifierType mods
, const gchar
*shortcut
)
1445 GtkTreeModel
*model
= GTK_TREE_MODEL(store
);
1446 GtkTreeIter parent_iter
;
1449 GdkModifierType kb_mods
;
1451 /* allow duplicate if there is no key combination */
1452 if (key
== 0 && mods
== 0)
1455 /* don't check if the new keybinding is the same as the old one */
1456 gtk_tree_model_get(model
, old_iter
, KB_TREE_SHORTCUT
, &kb_str
, -1);
1459 gtk_accelerator_parse(kb_str
, &kb_key
, &kb_mods
);
1461 if (key
== kb_key
&& mods
== kb_mods
)
1465 if (! gtk_tree_model_get_iter_first(model
, &parent_iter
))
1467 do /* foreach top level */
1471 if (! gtk_tree_model_iter_children(model
, &iter
, &parent_iter
))
1473 do /* foreach children */
1475 gtk_tree_model_get(model
, &iter
, KB_TREE_SHORTCUT
, &kb_str
, -1);
1479 gtk_accelerator_parse(kb_str
, &kb_key
, &kb_mods
);
1481 /* search another item with the same key and modifiers */
1482 if (kb_key
== key
&& kb_mods
== mods
)
1487 gtk_tree_model_get(model
, &iter
, KB_TREE_ACTION
, &label
, -1);
1488 ret
= dialogs_show_prompt(parent
,
1489 _("_Allow"), GTK_RESPONSE_APPLY
,
1490 GTK_STOCK_CANCEL
, GTK_RESPONSE_NO
,
1491 _("_Override"), GTK_RESPONSE_YES
,
1492 _("Override that keybinding?"),
1493 _("The combination '%s' is already used for \"%s\"."),
1498 if (ret
== GTK_RESPONSE_YES
)
1500 kb_set_shortcut(store
, &iter
, 0, 0); /* clear shortcut */
1501 /* carry on looking for other duplicates if overriding */
1504 return ret
== GTK_RESPONSE_NO
;
1507 while (gtk_tree_model_iter_next(model
, &iter
));
1509 while (gtk_tree_model_iter_next(model
, &parent_iter
));
1515 static void on_toolbar_show_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1517 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1519 gtk_widget_set_sensitive(
1520 ui_lookup_widget(ui_widgets
.prefs_dialog
, "frame_toolbar_style"), sens
);
1521 gtk_widget_set_sensitive(
1522 ui_lookup_widget(ui_widgets
.prefs_dialog
, "frame_toolbar_icon"), sens
);
1523 gtk_widget_set_sensitive(
1524 ui_lookup_widget(ui_widgets
.prefs_dialog
, "button_customize_toolbar"), sens
);
1525 gtk_widget_set_sensitive(
1526 ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_toolbar_in_menu"), sens
);
1530 static void on_show_notebook_tabs_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1532 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1534 /* tab placement only enabled when tabs are visible */
1535 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "combo_tab_editor"), sens
);
1536 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_show_tab_cross"), sens
);
1540 static void on_use_folding_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1542 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1544 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_unfold_children"), sens
);
1548 static void on_enable_plugins_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1550 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1552 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "extra_plugin_path_entry"), sens
);
1553 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "extra_plugin_path_button"), sens
);
1557 static void on_open_encoding_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1559 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1561 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "eventbox3"), sens
);
1562 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "label_open_encoding"), sens
);
1566 static void on_sidebar_visible_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1568 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1570 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_list_openfiles"), sens
);
1571 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_list_symbol"), sens
);
1575 static void on_prefs_print_radio_button_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1577 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1579 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "vbox29"), sens
);
1580 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "hbox9"), ! sens
);
1584 static void on_prefs_print_page_header_toggled(GtkToggleButton
*togglebutton
, gpointer user_data
)
1586 gboolean sens
= gtk_toggle_button_get_active(togglebutton
);
1588 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_basename"), sens
);
1589 gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_print_dateformat"), sens
);
1593 static void open_preferences_help(void)
1596 const gchar
*label
, *suffix
= NULL
;
1597 GtkNotebook
*notebook
= GTK_NOTEBOOK(
1598 ui_lookup_widget(ui_widgets
.prefs_dialog
, "notebook2"));
1599 gint page_nr
= gtk_notebook_get_current_page(notebook
);
1600 GtkWidget
*page
= gtk_notebook_get_nth_page(notebook
, page_nr
);
1602 label
= gtk_notebook_get_tab_label_text(notebook
, page
);
1604 /* TODO Find a better way to map the current notebook page to the
1605 * corresponding chapter in the documentation, comparing translatable
1606 * strings is easy to break. Maybe attach an identifying string to the
1607 * tab label object. */
1608 if (utils_str_equal(label
, _("General")))
1609 suffix
= "#general-startup-preferences";
1610 else if (utils_str_equal(label
, _("Interface")))
1611 suffix
= "#interface-preferences";
1612 else if (utils_str_equal(label
, _("Toolbar")))
1613 suffix
= "#toolbar-preferences";
1614 else if (utils_str_equal(label
, _("Editor")))
1615 suffix
= "#editor-features-preferences";
1616 else if (utils_str_equal(label
, _("Files")))
1617 suffix
= "#files-preferences";
1618 else if (utils_str_equal(label
, _("Tools")))
1619 suffix
= "#tools-preferences";
1620 else if (utils_str_equal(label
, _("Templates")))
1621 suffix
= "#template-preferences";
1622 else if (utils_str_equal(label
, _("Keybindings")))
1623 suffix
= "#keybinding-preferences";
1624 else if (utils_str_equal(label
, _("Printing")))
1625 suffix
= "#printing-preferences";
1626 else if (utils_str_equal(label
, _("Various")))
1627 suffix
= "#various-preferences";
1628 else if (utils_str_equal(label
, _("Terminal")))
1629 suffix
= "#terminal-vte-preferences";
1631 uri
= utils_get_help_url(suffix
);
1632 utils_open_browser(uri
);
1637 static gboolean
prefs_dialog_key_press_response_cb(GtkWidget
*dialog
, GdkEventKey
*event
,
1640 GeanyKeyBinding
*kb
= keybindings_lookup_item(GEANY_KEY_GROUP_HELP
, GEANY_KEYS_HELP_HELP
);
1642 if (keybindings_check_event(event
, kb
))
1644 open_preferences_help();
1651 static void list_store_append_text(GtkListStore
*list
, const gchar
*text
)
1655 gtk_list_store_append(list
, &iter
);
1656 gtk_list_store_set(list
, &iter
, 0, text
, -1);
1660 void prefs_show_dialog(void)
1662 if (ui_widgets
.prefs_dialog
== NULL
)
1664 GtkListStore
*encoding_list
, *eol_list
;
1667 gchar
*encoding_string
;
1669 ui_widgets
.prefs_dialog
= create_prefs_dialog();
1670 gtk_widget_set_name(ui_widgets
.prefs_dialog
, "GeanyPrefsDialog");
1671 gtk_window_set_transient_for(GTK_WINDOW(ui_widgets
.prefs_dialog
), GTK_WINDOW(main_widgets
.window
));
1673 /* init the file encoding combo boxes */
1674 encoding_list
= ui_builder_get_object("encoding_list");
1675 for (i
= 0; i
< GEANY_ENCODINGS_MAX
; i
++)
1677 encoding_string
= encodings_to_string(&encodings
[i
]);
1678 list_store_append_text(encoding_list
, encoding_string
);
1679 g_free(encoding_string
);
1682 /* init the eol character combo box */
1683 eol_list
= ui_builder_get_object("eol_list");
1684 list_store_append_text(eol_list
, utils_get_eol_name(SC_EOL_CRLF
));
1685 list_store_append_text(eol_list
, utils_get_eol_name(SC_EOL_CR
));
1686 list_store_append_text(eol_list
, utils_get_eol_name(SC_EOL_LF
));
1688 /* add manually GeanyWrapLabels because they can't be added with Glade */
1690 label
= geany_wrap_label_new(_("Enter tool paths below. Tools you do not need can be left blank."));
1691 gtk_widget_show(label
);
1692 gtk_box_pack_start(GTK_BOX(ui_lookup_widget(ui_widgets
.prefs_dialog
, "vbox33")),
1693 label
, FALSE
, TRUE
, 5);
1694 /* page Templates */
1695 label
= geany_wrap_label_new(_("Set the information to be used in templates. See the documentation for details."));
1696 gtk_widget_show(label
);
1697 gtk_box_pack_start(GTK_BOX(ui_lookup_widget(ui_widgets
.prefs_dialog
, "vbox31")),
1698 label
, FALSE
, TRUE
, 5);
1699 /* page Keybindings */
1700 label
= geany_wrap_label_new(_("Here you can change keyboard shortcuts for various actions. Select one and press the Change button to enter a new shortcut, or double click on an action to edit the string representation of the shortcut directly."));
1701 gtk_widget_show(label
);
1702 gtk_box_pack_start(GTK_BOX(ui_lookup_widget(ui_widgets
.prefs_dialog
, "vbox32")),
1703 label
, FALSE
, TRUE
, 5);
1704 /* page Editor->Indentation */
1705 label
= geany_wrap_label_new(_("<i>Warning: these settings are overridden by the current project. See <b>Project->Properties</b>.</i>"));
1706 gtk_widget_show(label
);
1707 gtk_label_set_use_markup(GTK_LABEL(label
), TRUE
);
1708 gtk_misc_set_padding(GTK_MISC(label
), 6, 0);
1709 gtk_box_pack_start(GTK_BOX(ui_lookup_widget(ui_widgets
.prefs_dialog
,
1710 "label_project_indent_warning")), label
, FALSE
, TRUE
, 5);
1712 /* add the clear icon to GtkEntry widgets in the dialog */
1714 const gchar
*names
[] = {
1715 "startup_path_entry",
1716 "project_file_path_entry",
1717 "extra_plugin_path_entry",
1718 "entry_toggle_mark",
1719 /* "entry_com_make", */
1723 "entry_contextaction",
1724 "entry_template_developer",
1725 "entry_template_initial",
1726 "entry_template_mail",
1727 "entry_template_company",
1728 "entry_template_version",
1729 "entry_template_year",
1730 "entry_template_date",
1731 "entry_template_datetime",
1732 "entry_print_external_cmd",
1733 "entry_print_dateformat"};
1736 foreach_c_array(name
, names
, G_N_ELEMENTS(names
))
1737 ui_entry_add_clear_icon(GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, *name
)));
1741 various_treeview
= GTK_TREE_VIEW(ui_lookup_widget(ui_widgets
.prefs_dialog
,
1742 "various_treeview"));
1743 stash_tree_setup(pref_groups
, various_treeview
);
1746 vte_append_preferences_tab();
1750 gtk_widget_hide(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_native_windows_dialogs"));
1752 ui_setup_open_button_callback(ui_lookup_widget(ui_widgets
.prefs_dialog
, "startup_path_button"), NULL
,
1753 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
, GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "startup_path_entry")));
1754 ui_setup_open_button_callback(ui_lookup_widget(ui_widgets
.prefs_dialog
, "extra_plugin_path_button"), NULL
,
1755 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
, GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "extra_plugin_path_entry")));
1757 g_signal_connect(ui_widgets
.prefs_dialog
, "response",
1758 G_CALLBACK(on_prefs_dialog_response
), NULL
);
1759 g_signal_connect(ui_widgets
.prefs_dialog
, "delete-event",
1760 G_CALLBACK(gtk_widget_hide_on_delete
), NULL
);
1762 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "tagbar_font"),
1763 "font-set", G_CALLBACK(on_prefs_font_choosed
), GINT_TO_POINTER(1));
1764 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "msgwin_font"),
1765 "font-set", G_CALLBACK(on_prefs_font_choosed
), GINT_TO_POINTER(2));
1766 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "editor_font"),
1767 "font-set", G_CALLBACK(on_prefs_font_choosed
), GINT_TO_POINTER(3));
1768 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "long_line_color"),
1769 "color-set", G_CALLBACK(on_color_button_choose_cb
), NULL
);
1770 /* file chooser buttons in the tools tab */
1771 ui_setup_open_button_callback(ui_lookup_widget(ui_widgets
.prefs_dialog
, "button_term"),
1773 GTK_FILE_CHOOSER_ACTION_OPEN
,
1774 GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_com_term")));
1775 ui_setup_open_button_callback(ui_lookup_widget(ui_widgets
.prefs_dialog
, "button_browser"),
1777 GTK_FILE_CHOOSER_ACTION_OPEN
,
1778 GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_browser")));
1779 ui_setup_open_button_callback(ui_lookup_widget(ui_widgets
.prefs_dialog
, "button_grep"),
1781 GTK_FILE_CHOOSER_ACTION_OPEN
,
1782 GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_grep")));
1784 /* tools commands */
1785 ui_setup_open_button_callback(ui_lookup_widget(ui_widgets
.prefs_dialog
, "button_contextaction"),
1787 GTK_FILE_CHOOSER_ACTION_OPEN
,
1788 GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_contextaction")));
1791 ui_setup_open_button_callback(ui_lookup_widget(ui_widgets
.prefs_dialog
, "button_print_external_cmd"),
1793 GTK_FILE_CHOOSER_ACTION_OPEN
,
1794 GTK_ENTRY(ui_lookup_widget(ui_widgets
.prefs_dialog
, "entry_print_external_cmd")));
1796 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "radio_print_gtk"),
1797 "toggled", G_CALLBACK(on_prefs_print_radio_button_toggled
), NULL
);
1798 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_print_pageheader"),
1799 "toggled", G_CALLBACK(on_prefs_print_page_header_toggled
), NULL
);
1801 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_plugins"),
1802 "toggled", G_CALLBACK(on_enable_plugins_toggled
), NULL
);
1803 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_toolbar_show"),
1804 "toggled", G_CALLBACK(on_toolbar_show_toggled
), NULL
);
1805 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_show_notebook_tabs"),
1806 "toggled", G_CALLBACK(on_show_notebook_tabs_toggled
), NULL
);
1807 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_folding"),
1808 "toggled", G_CALLBACK(on_use_folding_toggled
), NULL
);
1809 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_open_encoding"),
1810 "toggled", G_CALLBACK(on_open_encoding_toggled
), NULL
);
1811 g_signal_connect(ui_lookup_widget(ui_widgets
.prefs_dialog
, "check_sidebar_visible"),
1812 "toggled", G_CALLBACK(on_sidebar_visible_toggled
), NULL
);
1814 g_signal_connect(ui_widgets
.prefs_dialog
,
1815 "key-press-event", G_CALLBACK(prefs_dialog_key_press_response_cb
), NULL
);
1818 prefs_init_dialog();
1819 gtk_window_present(GTK_WINDOW(ui_widgets
.prefs_dialog
));