From 3a12da9dafac173b032ade3a5c165fd40f2eef70 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 16 May 2008 12:08:39 +0000 Subject: [PATCH] Note: this commit breaks the plugin API (but is necessary so that in future the ABI can stay stable when adding preferences). Split up prefs into interface_prefs, toolbar_prefs, file_prefs, search_prefs, tool_prefs, template_prefs, and add these to the plugin API. Move suppress_search_dialogs and search_use_current_word to search_prefs, and rename accordingly. Rename switch_msgwin_pages pref to switch_to_status. Remove toolbar_ prefix for toolbar_prefs items. Remove tool_ prefix for tool_prefs items. Remove template_ prefix for template_prefs items. Add Geany prefix for EditorPrefs. Add Geany prefix for SearchPrefs. Initialize search_prefs to zero in main.c. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2591 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 25 ++++ plugins/export.c | 3 +- plugins/filebrowser.c | 3 +- src/build.c | 10 +- src/callbacks.c | 38 +++--- src/dialogs.c | 3 +- src/document.c | 26 +++-- src/document.h | 18 +++ src/editor.c | 2 +- src/editor.h | 6 +- src/keybindings.c | 8 +- src/keyfile.c | 211 +++++++++++++++++----------------- src/main.c | 59 +++++----- src/msgwindow.c | 8 +- src/notebook.c | 7 +- src/plugindata.h | 24 ++-- src/plugins.c | 12 ++ src/prefs.c | 262 +++++++++++++++++++++--------------------- src/prefs.h | 76 ++---------- src/printing.c | 3 +- src/search.c | 21 ++-- src/search.h | 14 ++- src/templates.c | 13 ++- src/templates.h | 14 +++ src/treeviews.c | 31 +++-- src/ui_utils.c | 114 +++++++++--------- src/ui_utils.h | 41 +++++++ src/utils.c | 2 +- 28 files changed, 567 insertions(+), 487 deletions(-) diff --git a/ChangeLog b/ChangeLog index d65f2e31..7cf0e3e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2008-05-16 Nick Treleaven + + * src/templates.c, src/build.c, src/utils.c, src/ui_utils.h, + src/templates.h, src/keybindings.c, src/printing.c, src/prefs.c, + src/dialogs.c, src/prefs.h, src/plugindata.h, src/treeviews.c, + src/msgwindow.c, src/callbacks.c, src/notebook.c, src/keyfile.c, + src/search.c, src/search.h, src/document.c, src/plugins.c, + src/document.h, src/main.c, src/editor.c, src/editor.h, src/ui_utils.c, + plugins/export.c, plugins/filebrowser.c: + Note: this commit breaks the plugin API (but is necessary so that in + future the ABI can stay stable when adding preferences). + Split up prefs into interface_prefs, toolbar_prefs, file_prefs, + search_prefs, tool_prefs, template_prefs, and add these to the + plugin API. + Move suppress_search_dialogs and search_use_current_word to + search_prefs, and rename accordingly. + Rename switch_msgwin_pages pref to switch_to_status. + Remove toolbar_ prefix for toolbar_prefs items. + Remove tool_ prefix for tool_prefs items. + Remove template_ prefix for template_prefs items. + Add Geany prefix for EditorPrefs. + Add Geany prefix for SearchPrefs. + Initialize search_prefs to zero in main.c. + + 2008-05-15 Enrico Tröger * src/*.c src/*.h: diff --git a/plugins/export.c b/plugins/export.c index a8ecc78f..31cbb8a1 100644 --- a/plugins/export.c +++ b/plugins/export.c @@ -34,6 +34,7 @@ #include "document.h" #include "prefs.h" #include "utils.h" +#include "ui_utils.h" #include "pluginmacros.h" @@ -575,7 +576,7 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom) } /* read Geany's font and font size */ - font_desc = pango_font_description_from_string(prefs->editor_font); + font_desc = pango_font_description_from_string(geany_data->interface_prefs->editor_font); font_name = pango_font_description_get_family(font_desc); /*font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE;*/ /* take the zoom level also into account */ diff --git a/plugins/filebrowser.c b/plugins/filebrowser.c index 40275429..a450e37b 100644 --- a/plugins/filebrowser.c +++ b/plugins/filebrowser.c @@ -34,6 +34,7 @@ #include "utils.h" #include "keybindings.h" #include "project.h" +#include "ui_utils.h" #include "plugindata.h" #include "pluginmacros.h" @@ -712,7 +713,7 @@ static void prepare_file_view(void) gtk_tree_view_set_enable_search(GTK_TREE_VIEW(file_view), TRUE); gtk_tree_view_set_search_column(GTK_TREE_VIEW(file_view), FILEVIEW_COLUMN_NAME); - pfd = pango_font_description_from_string(prefs->tagbar_font); + pfd = pango_font_description_from_string(geany_data->interface_prefs->tagbar_font); gtk_widget_modify_font(file_view, pfd); pango_font_description_free(pfd); diff --git a/src/build.c b/src/build.c index 1d7959fb..fa1e0724 100644 --- a/src/build.c +++ b/src/build.c @@ -192,7 +192,7 @@ static GPid build_view_tex_file(gint idx, gint mode) locale_cmd_string = utils_get_locale_from_utf8(cmd_string); /* get the terminal path */ - locale_term_cmd = utils_get_locale_from_utf8(prefs.tools_term_cmd); + locale_term_cmd = utils_get_locale_from_utf8(tool_prefs.term_cmd); /* split the term_cmd, so arguments will work too */ term_argv = g_strsplit(locale_term_cmd, " ", -1); term_argv_len = g_strv_length(term_argv); @@ -209,7 +209,7 @@ static GPid build_view_tex_file(gint idx, gint mode) { ui_set_statusbar(TRUE, _("Could not find terminal \"%s\" " - "(check path for Terminal tool setting in Preferences)"), prefs.tools_term_cmd); + "(check path for Terminal tool setting in Preferences)"), tool_prefs.term_cmd); utils_free_pointers(executable, view_file, locale_filename, cmd_string, locale_cmd_string, locale_term_cmd, NULL); @@ -317,7 +317,7 @@ static GPid build_make_file(gint idx, gint build_opts) if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1; - cmdstr = g_string_new(prefs.tools_make_cmd); + cmdstr = g_string_new(tool_prefs.make_cmd); g_string_append_c(cmdstr, ' '); if (build_opts == GBO_MAKE_OBJECT) @@ -751,7 +751,7 @@ static GPid build_run_cmd(gint idx) gchar **argv = NULL; /* get the terminal path */ - locale_term_cmd = utils_get_locale_from_utf8(prefs.tools_term_cmd); + locale_term_cmd = utils_get_locale_from_utf8(tool_prefs.term_cmd); /* split the term_cmd, so arguments will work too */ term_argv = g_strsplit(locale_term_cmd, " ", -1); term_argv_len = g_strv_length(term_argv); @@ -768,7 +768,7 @@ static GPid build_run_cmd(gint idx) { ui_set_statusbar(TRUE, _("Could not find terminal \"%s\" " - "(check path for Terminal tool setting in Preferences)"), prefs.tools_term_cmd); + "(check path for Terminal tool setting in Preferences)"), tool_prefs.term_cmd); run_info.pid = (GPid) 1; goto free_strings; } diff --git a/src/callbacks.c b/src/callbacks.c index 67cd287e..ee08d11d 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -485,7 +485,7 @@ on_images_and_text2_activate (GtkMenuItem *menuitem, if (ignore_toolbar_toggle) return; gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), GTK_TOOLBAR_BOTH); - prefs.toolbar_icon_style = GTK_TOOLBAR_BOTH; + toolbar_prefs.icon_style = GTK_TOOLBAR_BOTH; } @@ -496,7 +496,7 @@ on_images_only2_activate (GtkMenuItem *menuitem, if (ignore_toolbar_toggle) return; gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), GTK_TOOLBAR_ICONS); - prefs.toolbar_icon_style = GTK_TOOLBAR_ICONS; + toolbar_prefs.icon_style = GTK_TOOLBAR_ICONS; } @@ -507,7 +507,7 @@ on_text_only2_activate (GtkMenuItem *menuitem, if (ignore_toolbar_toggle) return; gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), GTK_TOOLBAR_TEXT); - prefs.toolbar_icon_style = GTK_TOOLBAR_TEXT; + toolbar_prefs.icon_style = GTK_TOOLBAR_TEXT; } @@ -623,7 +623,7 @@ on_toolbar_large_icons1_activate (GtkMenuItem *menuitem, { if (ignore_toolbar_toggle) return; - prefs.toolbar_icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR; + toolbar_prefs.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR; ui_update_toolbar_icons(GTK_ICON_SIZE_LARGE_TOOLBAR); } @@ -634,7 +634,7 @@ on_toolbar_small_icons1_activate (GtkMenuItem *menuitem, { if (ignore_toolbar_toggle) return; - prefs.toolbar_icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR; + toolbar_prefs.icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR; ui_update_toolbar_icons(GTK_ICON_SIZE_SMALL_TOOLBAR); } @@ -829,7 +829,7 @@ toolbar_popup_menu (GtkWidget *widget, ignore_toolbar_toggle = TRUE; - switch (prefs.toolbar_icon_style) + switch (toolbar_prefs.icon_style) { case 0: w = lookup_widget(ui_widgets.toolbar_menu, "images_only2"); break; case 1: w = lookup_widget(ui_widgets.toolbar_menu, "text_only2"); break; @@ -837,7 +837,7 @@ toolbar_popup_menu (GtkWidget *widget, } gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), TRUE); - switch (prefs.toolbar_icon_size) + switch (toolbar_prefs.icon_size) { case GTK_ICON_SIZE_LARGE_TOOLBAR: w = lookup_widget(ui_widgets.toolbar_menu, "large_icons1"); break; @@ -920,8 +920,8 @@ on_show_toolbar1_toggled (GtkCheckMenuItem *checkmenuitem, { if (app->ignore_callback) return; - prefs.toolbar_visible = (prefs.toolbar_visible) ? FALSE : TRUE;; - ui_widget_show_hide(GTK_WIDGET(app->toolbar), prefs.toolbar_visible); + toolbar_prefs.visible = (toolbar_prefs.visible) ? FALSE : TRUE;; + ui_widget_show_hide(GTK_WIDGET(app->toolbar), toolbar_prefs.visible); } @@ -1357,7 +1357,7 @@ on_comments_changelog_activate (GtkMenuItem *menuitem, sci_insert_text(doc_list[idx].sci, 0, text); /* sets the cursor to the right position to type the changelog text, * the template has 21 chars + length of name and email */ - sci_goto_pos(doc_list[idx].sci, 21 + strlen(prefs.template_developer) + strlen(prefs.template_mail), TRUE); + sci_goto_pos(doc_list[idx].sci, 21 + strlen(template_prefs.developer) + strlen(template_prefs.mail), TRUE); g_free(text); } @@ -1600,10 +1600,10 @@ on_menu_show_sidebar1_toggled (GtkCheckMenuItem *checkmenuitem, ui_prefs.sidebar_visible = ! ui_prefs.sidebar_visible; - if ((! prefs.sidebar_openfiles_visible && ! prefs.sidebar_symbol_visible)) + if ((! interface_prefs.sidebar_openfiles_visible && ! interface_prefs.sidebar_symbol_visible)) { - prefs.sidebar_openfiles_visible = TRUE; - prefs.sidebar_symbol_visible = TRUE; + interface_prefs.sidebar_openfiles_visible = TRUE; + interface_prefs.sidebar_symbol_visible = TRUE; } ui_sidebar_show_hide(); @@ -1940,7 +1940,7 @@ on_context_action1_activate (GtkMenuItem *menuitem, } else { - command = g_strdup(prefs.context_action_cmd); + command = g_strdup(tool_prefs.context_action_cmd); } /* substitute the wildcard %s and run the command if it is non empty */ @@ -1974,7 +1974,7 @@ on_menu_toggle_all_additional_widgets1_activate if (hide_all == -1) { if (! gtk_check_menu_item_get_active(msgw) && - ! prefs.show_notebook_tabs && + ! interface_prefs.show_notebook_tabs && ! gtk_check_menu_item_get_active(toolbari)) { hide_all = TRUE; @@ -1990,8 +1990,8 @@ on_menu_toggle_all_additional_widgets1_activate if (gtk_check_menu_item_get_active(msgw)) gtk_check_menu_item_set_active(msgw, ! gtk_check_menu_item_get_active(msgw)); - prefs.show_notebook_tabs = FALSE; - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), prefs.show_notebook_tabs); + interface_prefs.show_notebook_tabs = FALSE; + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), interface_prefs.show_notebook_tabs); ui_statusbar_showhide(FALSE); @@ -2004,8 +2004,8 @@ on_menu_toggle_all_additional_widgets1_activate if (! gtk_check_menu_item_get_active(msgw)) gtk_check_menu_item_set_active(msgw, ! gtk_check_menu_item_get_active(msgw)); - prefs.show_notebook_tabs = TRUE; - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), prefs.show_notebook_tabs); + interface_prefs.show_notebook_tabs = TRUE; + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), interface_prefs.show_notebook_tabs); ui_statusbar_showhide(TRUE); diff --git a/src/dialogs.c b/src/dialogs.c index e7080760..da9930c1 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -43,7 +43,6 @@ #include "dialogs.h" -#include "prefs.h" #include "callbacks.h" #include "document.h" #include "filetypes.h" @@ -789,7 +788,7 @@ void dialogs_show_open_font() "clicked", G_CALLBACK(on_font_apply_button_clicked), NULL); gtk_font_selection_dialog_set_font_name( - GTK_FONT_SELECTION_DIALOG(ui_widgets.open_fontsel), prefs.editor_font); + GTK_FONT_SELECTION_DIALOG(ui_widgets.open_fontsel), interface_prefs.editor_font); gtk_window_set_transient_for(GTK_WINDOW(ui_widgets.open_fontsel), GTK_WINDOW(app->window)); } /* We make sure the dialog is visible. */ diff --git a/src/document.c b/src/document.c index e9a88b32..fbc6be10 100644 --- a/src/document.c +++ b/src/document.c @@ -51,7 +51,6 @@ #include #include "document.h" -#include "prefs.h" #include "filetypes.h" #include "support.h" #include "sciwrappers.h" @@ -73,8 +72,11 @@ #include "highlighting.h" #include "navqueue.h" #include "win32.h" +#include "search.h" +GeanyFilePrefs file_prefs; + /* dynamic array of document elements to hold all information of the notebook tabs */ GArray *doc_array; @@ -457,7 +459,7 @@ static gint document_create(const gchar *utf8_filename) document_apply_update_prefs(new_idx); - pfd = pango_font_description_from_string(prefs.editor_font); + pfd = pango_font_description_from_string(interface_prefs.editor_font); fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd)); editor_set_font(new_idx, fname, pango_font_description_get_size(pfd) / PANGO_SCALE); pango_font_description_free(pfd); @@ -583,11 +585,11 @@ gint document_new_file(const gchar *filename, filetype *ft, const gchar *text) else sci_clear_all(doc_list[idx].sci); - sci_set_eol_mode(doc_list[idx].sci, prefs.default_eol_character); + sci_set_eol_mode(doc_list[idx].sci, file_prefs.default_eol_character); /* convert the eol chars in the template text in case they are different from - * from prefs.default_eol */ + * from file_prefs.default_eol */ if (text != NULL) - sci_convert_eols(doc_list[idx].sci, prefs.default_eol_character); + sci_convert_eols(doc_list[idx].sci, file_prefs.default_eol_character); editor_set_use_tabs(idx, editor_prefs.use_tabs); sci_set_undo_collection(doc_list[idx].sci, TRUE); @@ -596,7 +598,7 @@ gint document_new_file(const gchar *filename, filetype *ft, const gchar *text) doc_list[idx].mtime = time(NULL); doc_list[idx].changed = FALSE; - doc_list[idx].encoding = g_strdup(encodings[prefs.default_new_encoding].charset); + doc_list[idx].encoding = g_strdup(encodings[file_prefs.default_new_encoding].charset); /* store the opened encoding for undo/redo */ store_saved_encoding(idx); @@ -1011,8 +1013,8 @@ gint document_open_file_full(gint idx, const gchar *filename, gint pos, gboolean } /* if default encoding for opening files is set, use it if no forced encoding is set */ - if (prefs.default_open_encoding >= 0 && forced_enc == NULL) - forced_enc = encodings[prefs.default_open_encoding].charset; + if (file_prefs.default_open_encoding >= 0 && forced_enc == NULL) + forced_enc = encodings[file_prefs.default_open_encoding].charset; if (! load_text_file(locale_filename, utf8_filename, &filedata, forced_enc)) { @@ -1413,11 +1415,11 @@ gboolean document_save_file(gint idx, gboolean force) } /* replaces tabs by spaces */ - if (prefs.replace_tabs) editor_replace_tabs(idx); + if (file_prefs.replace_tabs) editor_replace_tabs(idx); /* strip trailing spaces */ - if (prefs.strip_trailing_spaces) editor_strip_trailing_spaces(idx); + if (file_prefs.strip_trailing_spaces) editor_strip_trailing_spaces(idx); /* ensure the file has a newline at the end */ - if (prefs.final_new_line) editor_ensure_final_newline(idx); + if (file_prefs.final_new_line) editor_ensure_final_newline(idx); len = sci_get_length(doc_list[idx].sci) + 1; if (doc_list[idx].has_bom && encodings_is_unicode_charset(doc_list[idx].encoding)) @@ -1616,7 +1618,7 @@ gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search } /* we searched only part of the document, so ask whether to wraparound. */ - if (prefs.suppress_search_dialogs || + if (search_prefs.suppress_dialogs || dialogs_show_question_full(parent, GTK_STOCK_FIND, GTK_STOCK_CANCEL, _("Wrap search and find again?"), _("\"%s\" was not found."), text)) { diff --git a/src/document.h b/src/document.h index d8001382..3dae7fab 100644 --- a/src/document.h +++ b/src/document.h @@ -43,6 +43,24 @@ #endif +typedef struct GeanyFilePrefs +{ + gint default_new_encoding; + gint default_open_encoding; + gboolean final_new_line; + gboolean strip_trailing_spaces; + gboolean replace_tabs; + gboolean tab_order_ltr; + gboolean show_tab_cross; + guint mru_length; + gint default_eol_character; + gint disk_check_timeout; +} +GeanyFilePrefs; + +extern GeanyFilePrefs file_prefs; + + typedef struct FileEncoding { gchar *encoding; diff --git a/src/editor.c b/src/editor.c index df4a572e..4dec735c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -50,7 +50,7 @@ static gchar current_word[GEANY_MAX_WORD_LENGTH]; /* Initialised in keyfile.c. */ -EditorPrefs editor_prefs; +GeanyEditorPrefs editor_prefs; EditorInfo editor_info = {current_word, -1}; diff --git a/src/editor.h b/src/editor.h index 3d65c66e..f6aa09d3 100644 --- a/src/editor.h +++ b/src/editor.h @@ -56,7 +56,7 @@ typedef enum /* These are the default prefs when creating a new editor window. * Some of these can be overridden per document. * Remember to increment abi_version in plugindata.h when changing items. */ -typedef struct EditorPrefs +typedef struct GeanyEditorPrefs { /* display */ gboolean show_white_space; @@ -94,9 +94,9 @@ typedef struct EditorPrefs gboolean detect_tab_mode; gint line_break_column; gboolean auto_continue_multiline; -} EditorPrefs; +} GeanyEditorPrefs; -extern EditorPrefs editor_prefs; +extern GeanyEditorPrefs editor_prefs; typedef struct diff --git a/src/keybindings.c b/src/keybindings.c index c6ae055e..14c03ed4 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -751,7 +751,7 @@ static gboolean check_fixed_kb(guint keyval, guint state) if (keyval == GDK_0) page = npages - 1; /* invert the order if tabs are added on the other side */ - if (swap_alt_tab_order && ! prefs.tab_order_ltr) + if (swap_alt_tab_order && ! file_prefs.tab_order_ltr) page = (npages - 1) - page; gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), page); @@ -1174,7 +1174,7 @@ static void cb_func_switch_scribble(G_GNUC_UNUSED guint key_id) static void cb_func_switch_search_bar(G_GNUC_UNUSED guint key_id) { - if (prefs.toolbar_visible && prefs.toolbar_show_search) + if (toolbar_prefs.visible && toolbar_prefs.show_search) gtk_widget_grab_focus(lookup_widget(app->window, "entry1")); } @@ -1239,10 +1239,10 @@ static void cb_func_move_tab(guint key_id) break; } case GEANY_KEYS_NOTEBOOK_MOVETABFIRST: - gtk_notebook_reorder_child(nb, sci, (prefs.tab_order_ltr) ? 0 : -1); + gtk_notebook_reorder_child(nb, sci, (file_prefs.tab_order_ltr) ? 0 : -1); break; case GEANY_KEYS_NOTEBOOK_MOVETABLAST: - gtk_notebook_reorder_child(nb, sci, (prefs.tab_order_ltr) ? -1 : 0); + gtk_notebook_reorder_child(nb, sci, (file_prefs.tab_order_ltr) ? -1 : 0); break; } return; diff --git a/src/keyfile.c b/src/keyfile.c index 85761b4b..e14c7086 100644 --- a/src/keyfile.c +++ b/src/keyfile.c @@ -58,6 +58,7 @@ #include "editor.h" #include "printing.h" #include "plugins.h" +#include "templates.h" /* some default settings which are used at the very first start of Geany to fill @@ -90,10 +91,10 @@ static gint vpan_position; static void save_recent_files(GKeyFile *config) { - gchar **recent_files = g_new0(gchar*, prefs.mru_length + 1); + gchar **recent_files = g_new0(gchar*, file_prefs.mru_length + 1); guint i; - for (i = 0; i < prefs.mru_length; i++) + for (i = 0; i < file_prefs.mru_length; i++) { if (! g_queue_is_empty(ui_prefs.recent_queue)) { @@ -108,9 +109,9 @@ static void save_recent_files(GKeyFile *config) } } /* There is a bug in GTK 2.6 g_key_file_set_string_list, we must NULL terminate. */ - recent_files[prefs.mru_length] = NULL; + recent_files[file_prefs.mru_length] = NULL; g_key_file_set_string_list(config, "files", "recent_files", - (const gchar**)recent_files, prefs.mru_length); + (const gchar**)recent_files, file_prefs.mru_length); g_strfreev(recent_files); } @@ -191,27 +192,27 @@ static void save_dialog_prefs(GKeyFile *config) g_key_file_set_boolean(config, PACKAGE, "pref_main_project_session", project_prefs.project_session); g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos); g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", prefs.confirm_exit); - g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", prefs.suppress_search_dialogs); - g_key_file_set_boolean(config, PACKAGE, "pref_main_search_use_current_word", prefs.search_use_current_word); + g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", search_prefs.suppress_dialogs); + g_key_file_set_boolean(config, PACKAGE, "pref_main_search_use_current_word", search_prefs.use_current_word); g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_status_messages", prefs.suppress_status_messages); - g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_msgwin_pages); + g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_to_status); g_key_file_set_boolean(config, PACKAGE, "beep_on_errors", prefs.beep_on_errors); g_key_file_set_boolean(config, PACKAGE, "auto_focus", prefs.auto_focus); g_key_file_set_string(config, PACKAGE, "default_open_path", prefs.default_open_path); /* interface */ - g_key_file_set_boolean(config, PACKAGE, "sidebar_symbol_visible", prefs.sidebar_symbol_visible); - g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_visible", prefs.sidebar_openfiles_visible); - g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", prefs.sidebar_openfiles_fullpath); - g_key_file_set_string(config, PACKAGE, "editor_font", prefs.editor_font); - g_key_file_set_string(config, PACKAGE, "tagbar_font", prefs.tagbar_font); - g_key_file_set_string(config, PACKAGE, "msgwin_font", prefs.msgwin_font); - g_key_file_set_boolean(config, PACKAGE, "show_notebook_tabs", prefs.show_notebook_tabs); - g_key_file_set_boolean(config, PACKAGE, "show_tab_cross", prefs.show_tab_cross); - g_key_file_set_boolean(config, PACKAGE, "tab_order_ltr", prefs.tab_order_ltr); - g_key_file_set_integer(config, PACKAGE, "tab_pos_editor", prefs.tab_pos_editor); - g_key_file_set_integer(config, PACKAGE, "tab_pos_msgwin", prefs.tab_pos_msgwin); - g_key_file_set_integer(config, PACKAGE, "tab_pos_sidebar", prefs.tab_pos_sidebar); + g_key_file_set_boolean(config, PACKAGE, "sidebar_symbol_visible", interface_prefs.sidebar_symbol_visible); + g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_visible", interface_prefs.sidebar_openfiles_visible); + g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", interface_prefs.sidebar_openfiles_fullpath); + g_key_file_set_string(config, PACKAGE, "editor_font", interface_prefs.editor_font); + g_key_file_set_string(config, PACKAGE, "tagbar_font", interface_prefs.tagbar_font); + g_key_file_set_string(config, PACKAGE, "msgwin_font", interface_prefs.msgwin_font); + g_key_file_set_boolean(config, PACKAGE, "show_notebook_tabs", interface_prefs.show_notebook_tabs); + g_key_file_set_boolean(config, PACKAGE, "show_tab_cross", file_prefs.show_tab_cross); + g_key_file_set_boolean(config, PACKAGE, "tab_order_ltr", file_prefs.tab_order_ltr); + g_key_file_set_integer(config, PACKAGE, "tab_pos_editor", interface_prefs.tab_pos_editor); + g_key_file_set_integer(config, PACKAGE, "tab_pos_msgwin", interface_prefs.tab_pos_msgwin); + g_key_file_set_integer(config, PACKAGE, "tab_pos_sidebar", interface_prefs.tab_pos_sidebar); /* display */ g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", editor_prefs.show_indent_guide); @@ -244,46 +245,46 @@ static void save_dialog_prefs(GKeyFile *config) g_key_file_set_boolean(config, PACKAGE, "auto_continue_multiline", editor_prefs.auto_continue_multiline); /* files */ - g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[prefs.default_new_encoding].charset); - if (prefs.default_open_encoding == -1) + g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[file_prefs.default_new_encoding].charset); + if (file_prefs.default_open_encoding == -1) g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", "none"); else - g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", encodings[prefs.default_open_encoding].charset); - g_key_file_set_integer(config, PACKAGE, "default_eol_character", prefs.default_eol_character); - g_key_file_set_boolean(config, PACKAGE, "pref_editor_new_line", prefs.final_new_line); - g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", prefs.replace_tabs); - g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", prefs.strip_trailing_spaces); - g_key_file_set_integer(config, PACKAGE, "mru_length", prefs.mru_length); + g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", encodings[file_prefs.default_open_encoding].charset); + g_key_file_set_integer(config, PACKAGE, "default_eol_character", file_prefs.default_eol_character); + g_key_file_set_boolean(config, PACKAGE, "pref_editor_new_line", file_prefs.final_new_line); + g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", file_prefs.replace_tabs); + g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", file_prefs.strip_trailing_spaces); + g_key_file_set_integer(config, PACKAGE, "mru_length", file_prefs.mru_length); g_key_file_set_integer(config, PACKAGE, "disk_check_timeout", file_prefs.disk_check_timeout); /* toolbar */ - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", prefs.toolbar_visible); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_search", prefs.toolbar_show_search); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_goto", prefs.toolbar_show_goto); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_zoom", prefs.toolbar_show_zoom); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_indent", prefs.toolbar_show_indent); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_undo", prefs.toolbar_show_undo); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_navigation", prefs.toolbar_show_navigation); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_compile", prefs.toolbar_show_compile); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_colour", prefs.toolbar_show_colour); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_fileops", prefs.toolbar_show_fileops); - g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_quit", prefs.toolbar_show_quit); - g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_style", prefs.toolbar_icon_style); - g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_size", prefs.toolbar_icon_size); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", toolbar_prefs.visible); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_search", toolbar_prefs.show_search); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_goto", toolbar_prefs.show_goto); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_zoom", toolbar_prefs.show_zoom); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_indent", toolbar_prefs.show_indent); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_undo", toolbar_prefs.show_undo); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_navigation", toolbar_prefs.show_navigation); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_compile", toolbar_prefs.show_compile); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_colour", toolbar_prefs.show_colour); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_fileops", toolbar_prefs.show_fileops); + g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_quit", toolbar_prefs.show_quit); + g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_style", toolbar_prefs.icon_style); + g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_size", toolbar_prefs.icon_size); /* templates */ - g_key_file_set_string(config, PACKAGE, "pref_template_developer", prefs.template_developer); - g_key_file_set_string(config, PACKAGE, "pref_template_company", prefs.template_company); - g_key_file_set_string(config, PACKAGE, "pref_template_mail", prefs.template_mail); - g_key_file_set_string(config, PACKAGE, "pref_template_initial", prefs.template_initial); - g_key_file_set_string(config, PACKAGE, "pref_template_version", prefs.template_version); + g_key_file_set_string(config, PACKAGE, "pref_template_developer", template_prefs.developer); + g_key_file_set_string(config, PACKAGE, "pref_template_company", template_prefs.company); + g_key_file_set_string(config, PACKAGE, "pref_template_mail", template_prefs.mail); + g_key_file_set_string(config, PACKAGE, "pref_template_initial", template_prefs.initials); + g_key_file_set_string(config, PACKAGE, "pref_template_version", template_prefs.version); /* tools settings */ - g_key_file_set_string(config, "tools", "make_cmd", prefs.tools_make_cmd ? prefs.tools_make_cmd : ""); - g_key_file_set_string(config, "tools", "term_cmd", prefs.tools_term_cmd ? prefs.tools_term_cmd : ""); - g_key_file_set_string(config, "tools", "browser_cmd", prefs.tools_browser_cmd ? prefs.tools_browser_cmd : ""); - g_key_file_set_string(config, "tools", "grep_cmd", prefs.tools_grep_cmd ? prefs.tools_grep_cmd : ""); - g_key_file_set_string(config, PACKAGE, "context_action_cmd", prefs.context_action_cmd); + g_key_file_set_string(config, "tools", "make_cmd", tool_prefs.make_cmd ? tool_prefs.make_cmd : ""); + g_key_file_set_string(config, "tools", "term_cmd", tool_prefs.term_cmd ? tool_prefs.term_cmd : ""); + g_key_file_set_string(config, "tools", "browser_cmd", tool_prefs.browser_cmd ? tool_prefs.browser_cmd : ""); + g_key_file_set_string(config, "tools", "grep_cmd", tool_prefs.grep_cmd ? tool_prefs.grep_cmd : ""); + g_key_file_set_string(config, PACKAGE, "context_action_cmd", tool_prefs.context_action_cmd); /* printing */ g_key_file_set_string(config, "printing", "print_cmd", printing_prefs.external_print_cmd ? printing_prefs.external_print_cmd : ""); @@ -329,7 +330,7 @@ static void save_dialog_prefs(GKeyFile *config) static void save_ui_prefs(GKeyFile *config) { g_key_file_set_boolean(config, PACKAGE, "sidebar_visible", ui_prefs.sidebar_visible); - g_key_file_set_boolean(config, PACKAGE, "statusbar_visible", prefs.statusbar_visible); + g_key_file_set_boolean(config, PACKAGE, "statusbar_visible", interface_prefs.statusbar_visible); g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", ui_prefs.msgwindow_visible); g_key_file_set_boolean(config, PACKAGE, "fullscreen", ui_prefs.fullscreen); @@ -391,7 +392,7 @@ static void save_hidden_prefs(GKeyFile *config) write_hidden_pref_boolean(config, PACKAGE, "complete_snippets_whilst_editing", editor_prefs.complete_snippets_whilst_editing); write_hidden_pref_boolean(config, PACKAGE, "scroll_stop_at_last_line", editor_prefs.scroll_stop_at_last_line); #if GTK_CHECK_VERSION(2, 12, 0) - write_hidden_pref_boolean(config, PACKAGE, "show_symbol_list_expanders", prefs.show_symbol_list_expanders); + write_hidden_pref_boolean(config, PACKAGE, "show_symbol_list_expanders", interface_prefs.show_symbol_list_expanders); #endif } @@ -443,7 +444,7 @@ void configuration_load_session_files(GKeyFile *config) recent_files = g_key_file_get_string_list(config, "files", "recent_files", &len, NULL); if (recent_files != NULL) { - for (i = 0; (i < len) && (i < prefs.mru_length); i++) + for (i = 0; (i < len) && (i < file_prefs.mru_length); i++) { gchar *filename = g_strdup(recent_files[i]); g_queue_push_tail(ui_prefs.recent_queue, filename); @@ -489,33 +490,33 @@ static void load_dialog_prefs(GKeyFile *config) /* general */ prefs.confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", FALSE); - prefs.suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE); - prefs.search_use_current_word = utils_get_setting_boolean(config, PACKAGE, "pref_main_search_use_current_word", TRUE); + search_prefs.suppress_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE); + search_prefs.use_current_word = utils_get_setting_boolean(config, PACKAGE, "pref_main_search_use_current_word", TRUE); prefs.suppress_status_messages = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_status_messages", FALSE); prefs.load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE); project_prefs.project_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_session", TRUE); prefs.save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE); prefs.beep_on_errors = utils_get_setting_boolean(config, PACKAGE, "beep_on_errors", TRUE); - prefs.switch_msgwin_pages = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE); + prefs.switch_to_status = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE); prefs.auto_focus = utils_get_setting_boolean(config, PACKAGE, "auto_focus", FALSE); prefs.default_open_path = utils_get_setting_string(config, PACKAGE, "default_open_path", ""); /* interface */ - prefs.tab_pos_editor = utils_get_setting_integer(config, PACKAGE, "tab_pos_editor", GTK_POS_TOP); - prefs.tab_pos_msgwin = utils_get_setting_integer(config, PACKAGE, "tab_pos_msgwin",GTK_POS_LEFT); - prefs.tab_pos_sidebar = utils_get_setting_integer(config, PACKAGE, "tab_pos_sidebar", GTK_POS_TOP); - prefs.sidebar_symbol_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_symbol_visible", TRUE); - prefs.sidebar_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_visible", TRUE); - prefs.sidebar_openfiles_fullpath = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", FALSE); - prefs.statusbar_visible = utils_get_setting_boolean(config, PACKAGE, "statusbar_visible", TRUE); - prefs.tab_order_ltr = utils_get_setting_boolean(config, PACKAGE, "tab_order_ltr", TRUE); - prefs.show_notebook_tabs = utils_get_setting_boolean(config, PACKAGE, "show_notebook_tabs", TRUE); - prefs.show_tab_cross = utils_get_setting_boolean(config, PACKAGE, "show_tab_cross", TRUE); - prefs.editor_font = utils_get_setting_string(config, PACKAGE, "editor_font", GEANY_DEFAULT_FONT_EDITOR); - prefs.tagbar_font = utils_get_setting_string(config, PACKAGE, "tagbar_font", GEANY_DEFAULT_FONT_SYMBOL_LIST); - prefs.msgwin_font = utils_get_setting_string(config, PACKAGE, "msgwin_font", GEANY_DEFAULT_FONT_MSG_WINDOW); + interface_prefs.tab_pos_editor = utils_get_setting_integer(config, PACKAGE, "tab_pos_editor", GTK_POS_TOP); + interface_prefs.tab_pos_msgwin = utils_get_setting_integer(config, PACKAGE, "tab_pos_msgwin",GTK_POS_LEFT); + interface_prefs.tab_pos_sidebar = utils_get_setting_integer(config, PACKAGE, "tab_pos_sidebar", GTK_POS_TOP); + interface_prefs.sidebar_symbol_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_symbol_visible", TRUE); + interface_prefs.sidebar_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_visible", TRUE); + interface_prefs.sidebar_openfiles_fullpath = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", FALSE); + interface_prefs.statusbar_visible = utils_get_setting_boolean(config, PACKAGE, "statusbar_visible", TRUE); + file_prefs.tab_order_ltr = utils_get_setting_boolean(config, PACKAGE, "tab_order_ltr", TRUE); + interface_prefs.show_notebook_tabs = utils_get_setting_boolean(config, PACKAGE, "show_notebook_tabs", TRUE); + file_prefs.show_tab_cross = utils_get_setting_boolean(config, PACKAGE, "show_tab_cross", TRUE); + interface_prefs.editor_font = utils_get_setting_string(config, PACKAGE, "editor_font", GEANY_DEFAULT_FONT_EDITOR); + interface_prefs.tagbar_font = utils_get_setting_string(config, PACKAGE, "tagbar_font", GEANY_DEFAULT_FONT_SYMBOL_LIST); + interface_prefs.msgwin_font = utils_get_setting_string(config, PACKAGE, "msgwin_font", GEANY_DEFAULT_FONT_MSG_WINDOW); #if GTK_CHECK_VERSION(2, 12, 0) - prefs.show_symbol_list_expanders = utils_get_setting_boolean(config, PACKAGE, "show_symbol_list_expanders", TRUE); + interface_prefs.show_symbol_list_expanders = utils_get_setting_boolean(config, PACKAGE, "show_symbol_list_expanders", TRUE); #endif /* display, editor */ @@ -561,9 +562,9 @@ static void load_dialog_prefs(GKeyFile *config) { const GeanyEncoding *enc = encodings_get_from_charset(tmp_string); if (enc != NULL) - prefs.default_new_encoding = enc->idx; + file_prefs.default_new_encoding = enc->idx; else - prefs.default_new_encoding = GEANY_ENCODING_UTF_8; + file_prefs.default_new_encoding = GEANY_ENCODING_UTF_8; g_free(tmp_string); } @@ -573,39 +574,39 @@ static void load_dialog_prefs(GKeyFile *config) { const GeanyEncoding *enc = encodings_get_from_charset(tmp_string); if (enc != NULL) - prefs.default_open_encoding = enc->idx; + file_prefs.default_open_encoding = enc->idx; else - prefs.default_open_encoding = -1; + file_prefs.default_open_encoding = -1; g_free(tmp_string); } - prefs.default_eol_character = utils_get_setting_integer(config, PACKAGE, "default_eol_character", GEANY_DEFAULT_EOL_CHARACTER); - prefs.replace_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_replace_tabs", FALSE); - prefs.final_new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE); - prefs.strip_trailing_spaces = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE); - prefs.mru_length = utils_get_setting_integer(config, PACKAGE, "mru_length", GEANY_DEFAULT_MRU_LENGTH); + file_prefs.default_eol_character = utils_get_setting_integer(config, PACKAGE, "default_eol_character", GEANY_DEFAULT_EOL_CHARACTER); + file_prefs.replace_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_replace_tabs", FALSE); + file_prefs.final_new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE); + file_prefs.strip_trailing_spaces = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE); + file_prefs.mru_length = utils_get_setting_integer(config, PACKAGE, "mru_length", GEANY_DEFAULT_MRU_LENGTH); file_prefs.disk_check_timeout = utils_get_setting_integer(config, PACKAGE, "disk_check_timeout", GEANY_DISK_CHECK_TIMEOUT); /* toolbar */ - prefs.toolbar_visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE); - prefs.toolbar_show_search = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_search", TRUE); - prefs.toolbar_show_goto = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_goto", TRUE); - prefs.toolbar_show_zoom = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_zoom", FALSE); - prefs.toolbar_show_indent = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_indent", FALSE); - prefs.toolbar_show_compile = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_compile", TRUE); - prefs.toolbar_show_undo = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_undo", FALSE); - prefs.toolbar_show_navigation = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_navigation", TRUE); - prefs.toolbar_show_colour = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_colour", TRUE); - prefs.toolbar_show_fileops = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_fileops", TRUE); - prefs.toolbar_show_quit = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_quit", TRUE); + toolbar_prefs.visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE); + toolbar_prefs.show_search = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_search", TRUE); + toolbar_prefs.show_goto = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_goto", TRUE); + toolbar_prefs.show_zoom = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_zoom", FALSE); + toolbar_prefs.show_indent = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_indent", FALSE); + toolbar_prefs.show_compile = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_compile", TRUE); + toolbar_prefs.show_undo = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_undo", FALSE); + toolbar_prefs.show_navigation = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_navigation", TRUE); + toolbar_prefs.show_colour = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_colour", TRUE); + toolbar_prefs.show_fileops = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_fileops", TRUE); + toolbar_prefs.show_quit = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_quit", TRUE); { GtkIconSize tb_iconsize; GtkToolbarStyle tb_style; GEANY_GET_SETTING("gtk-toolbar-style", tb_style, GTK_TOOLBAR_ICONS); GEANY_GET_SETTING("gtk-toolbar-icon-size", tb_iconsize, GTK_ICON_SIZE_LARGE_TOOLBAR); - prefs.toolbar_icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", tb_style); - prefs.toolbar_icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", tb_iconsize); + toolbar_prefs.icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", tb_style); + toolbar_prefs.icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", tb_iconsize); } /* VTE */ @@ -647,27 +648,27 @@ static void load_dialog_prefs(GKeyFile *config) } #endif /* templates */ - prefs.template_developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name()); - prefs.template_company = utils_get_setting_string(config, PACKAGE, "pref_template_company", ""); - tmp_string = utils_get_initials(prefs.template_developer); - prefs.template_initial = utils_get_setting_string(config, PACKAGE, "pref_template_initial", tmp_string); + template_prefs.developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name()); + template_prefs.company = utils_get_setting_string(config, PACKAGE, "pref_template_company", ""); + tmp_string = utils_get_initials(template_prefs.developer); + template_prefs.initials = utils_get_setting_string(config, PACKAGE, "pref_template_initial", tmp_string); g_free(tmp_string); - prefs.template_version = utils_get_setting_string(config, PACKAGE, "pref_template_version", "1.0"); + template_prefs.version = utils_get_setting_string(config, PACKAGE, "pref_template_version", "1.0"); tmp_string2 = utils_get_hostname(); tmp_string = g_strdup_printf("%s@%s", g_get_user_name(), tmp_string2); - prefs.template_mail = utils_get_setting_string(config, PACKAGE, "pref_template_mail", tmp_string); + template_prefs.mail = utils_get_setting_string(config, PACKAGE, "pref_template_mail", tmp_string); g_free(tmp_string); g_free(tmp_string2); /* tools */ - prefs.tools_make_cmd = utils_get_setting_string(config, "tools", "make_cmd", GEANY_DEFAULT_TOOLS_MAKE); - prefs.tools_term_cmd = utils_get_setting_string(config, "tools", "term_cmd", GEANY_DEFAULT_TOOLS_TERMINAL); - prefs.tools_browser_cmd = utils_get_setting_string(config, "tools", "browser_cmd", GEANY_DEFAULT_TOOLS_BROWSER); - prefs.tools_grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", GEANY_DEFAULT_TOOLS_GREP); + tool_prefs.make_cmd = utils_get_setting_string(config, "tools", "make_cmd", GEANY_DEFAULT_TOOLS_MAKE); + tool_prefs.term_cmd = utils_get_setting_string(config, "tools", "term_cmd", GEANY_DEFAULT_TOOLS_TERMINAL); + tool_prefs.browser_cmd = utils_get_setting_string(config, "tools", "browser_cmd", GEANY_DEFAULT_TOOLS_BROWSER); + tool_prefs.grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", GEANY_DEFAULT_TOOLS_GREP); - prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", ""); + tool_prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", ""); /* printing */ tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD); @@ -875,7 +876,7 @@ void configuration_open_files(void) document_delay_colourise(); - i = prefs.tab_order_ltr ? 0 : (session_files->len - 1); + i = file_prefs.tab_order_ltr ? 0 : (session_files->len - 1); while (TRUE) { gchar **tmp = g_ptr_array_index(session_files, i); @@ -887,7 +888,7 @@ void configuration_open_files(void) } g_strfreev(tmp); - if (prefs.tab_order_ltr) + if (file_prefs.tab_order_ltr) { i++; if (i >= (gint)session_files->len) break; diff --git a/src/main.c b/src/main.c index a3f52a99..bd1d43c9 100644 --- a/src/main.c +++ b/src/main.c @@ -169,7 +169,7 @@ static void apply_settings(void) ui_update_fold_items(); /* toolbar, message window and sidebar are by default visible, so don't change it if it is true */ - if (! prefs.toolbar_visible) + if (! toolbar_prefs.visible) { app->ignore_callback = TRUE; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_show_toolbar1")), FALSE); @@ -191,7 +191,7 @@ static void apply_settings(void) } ui_sidebar_show_hide(); /* sets the icon style of the toolbar */ - switch (prefs.toolbar_icon_style) + switch (toolbar_prefs.icon_style) { case GTK_TOOLBAR_BOTH: { @@ -212,15 +212,15 @@ static void apply_settings(void) break; } } - gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), prefs.toolbar_icon_style); + gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), toolbar_prefs.icon_style); /* sets the icon size of the toolbar, use user preferences (.gtkrc) if not set */ - if (prefs.toolbar_icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR || - prefs.toolbar_icon_size == GTK_ICON_SIZE_LARGE_TOOLBAR) + if (toolbar_prefs.icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR || + toolbar_prefs.icon_size == GTK_ICON_SIZE_LARGE_TOOLBAR) { - gtk_toolbar_set_icon_size(GTK_TOOLBAR(app->toolbar), prefs.toolbar_icon_size); + gtk_toolbar_set_icon_size(GTK_TOOLBAR(app->toolbar), toolbar_prefs.icon_size); } - ui_update_toolbar_icons(prefs.toolbar_icon_size); + ui_update_toolbar_icons(toolbar_prefs.icon_size); /* line number and markers margin are by default enabled */ if (! editor_prefs.show_markers_margin) @@ -244,7 +244,7 @@ static void apply_settings(void) } /* hide statusbar if desired */ - if (! prefs.statusbar_visible) + if (! interface_prefs.statusbar_visible) { gtk_widget_hide(app->statusbar); } @@ -262,14 +262,14 @@ static void apply_settings(void) lookup_widget(app->window, "menutoolbutton1")), ui_widgets.new_file_menu); /* set the tab placements of the notebooks */ - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->notebook), prefs.tab_pos_editor); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow.notebook), prefs.tab_pos_msgwin); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->treeview_notebook), prefs.tab_pos_sidebar); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->notebook), interface_prefs.tab_pos_editor); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow.notebook), interface_prefs.tab_pos_msgwin); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->treeview_notebook), interface_prefs.tab_pos_sidebar); ui_update_toolbar_items(); /* whether to show notebook tabs or not */ - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), prefs.show_notebook_tabs); + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), interface_prefs.show_notebook_tabs); } @@ -285,7 +285,7 @@ static void main_init(void) ui_widgets.prefs_dialog = NULL; tv.default_tag_tree = NULL; main_status.main_window_realized= FALSE; - prefs.tab_order_ltr = FALSE; + file_prefs.tab_order_ltr = FALSE; main_status.quitting = FALSE; app->ignore_callback = FALSE; app->tm_workspace = tm_get_workspace(); @@ -758,6 +758,13 @@ gint main(gint argc, gchar **argv) app = g_new0(GeanyApp, 1); memset(&main_status, 0, sizeof(GeanyStatus)); memset(&prefs, 0, sizeof(GeanyPrefs)); + memset(&interface_prefs, 0, sizeof(GeanyInterfacePrefs)); + memset(&toolbar_prefs, 0, sizeof(GeanyToolbarPrefs)); + memset(&editor_prefs, 0, sizeof(GeanyEditorPrefs)); + memset(&file_prefs, 0, sizeof(GeanyFilePrefs)); + memset(&search_prefs, 0, sizeof(GeanySearchPrefs)); + memset(&tool_prefs, 0, sizeof(GeanyToolPrefs)); + memset(&template_prefs, 0, sizeof(GeanyTemplatePrefs)); memset(&ui_prefs, 0, sizeof(UIPrefs)); memset(&ui_widgets, 0, sizeof(UIWidgets)); @@ -957,20 +964,20 @@ void main_quit() g_free(app->docdir); g_free(prefs.default_open_path); g_free(ui_prefs.custom_date_format); - g_free(prefs.editor_font); - g_free(prefs.tagbar_font); - g_free(prefs.msgwin_font); + g_free(interface_prefs.editor_font); + g_free(interface_prefs.tagbar_font); + g_free(interface_prefs.msgwin_font); g_free(editor_prefs.long_line_color); - g_free(prefs.context_action_cmd); - g_free(prefs.template_developer); - g_free(prefs.template_company); - g_free(prefs.template_mail); - g_free(prefs.template_initial); - g_free(prefs.template_version); - g_free(prefs.tools_make_cmd); - g_free(prefs.tools_term_cmd); - g_free(prefs.tools_browser_cmd); - g_free(prefs.tools_grep_cmd); + g_free(tool_prefs.context_action_cmd); + g_free(template_prefs.developer); + g_free(template_prefs.company); + g_free(template_prefs.mail); + g_free(template_prefs.initials); + g_free(template_prefs.version); + g_free(tool_prefs.make_cmd); + g_free(tool_prefs.term_cmd); + g_free(tool_prefs.browser_cmd); + g_free(tool_prefs.grep_cmd); g_free(printing_prefs.external_print_cmd); g_free(printing_prefs.page_header_datefmt); g_strfreev(ui_prefs.custom_commands); diff --git a/src/msgwindow.c b/src/msgwindow.c index c273acf2..fecffe38 100644 --- a/src/msgwindow.c +++ b/src/msgwindow.c @@ -117,7 +117,7 @@ static void prepare_status_tree_view(void) gtk_tree_view_set_enable_search(GTK_TREE_VIEW(msgwindow.tree_status), FALSE); - pfd = pango_font_description_from_string(prefs.msgwin_font); + pfd = pango_font_description_from_string(interface_prefs.msgwin_font); gtk_widget_modify_font(msgwindow.tree_status, pfd); pango_font_description_free(pfd); @@ -147,7 +147,7 @@ static void prepare_msg_tree_view(void) gtk_tree_view_set_enable_search(GTK_TREE_VIEW(msgwindow.tree_msg), FALSE); - pfd = pango_font_description_from_string(prefs.msgwin_font); + pfd = pango_font_description_from_string(interface_prefs.msgwin_font); gtk_widget_modify_font(msgwindow.tree_msg, pfd); pango_font_description_free(pfd); @@ -180,7 +180,7 @@ static void prepare_compiler_tree_view(void) gtk_tree_view_set_enable_search(GTK_TREE_VIEW(msgwindow.tree_compiler), FALSE); - pfd = pango_font_description_from_string(prefs.msgwin_font); + pfd = pango_font_description_from_string(interface_prefs.msgwin_font); gtk_widget_modify_font(msgwindow.tree_compiler, pfd); pango_font_description_free(pfd); @@ -353,7 +353,7 @@ void msgwin_status_add(const gchar *format, ...) GtkTreePath *path = gtk_tree_model_get_path(gtk_tree_view_get_model(GTK_TREE_VIEW(msgwindow.tree_status)), &iter); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(msgwindow.tree_status), path, NULL, FALSE, 0.0, 0.0); - if (prefs.switch_msgwin_pages) gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_STATUS); + if (prefs.switch_to_status) gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_STATUS); gtk_tree_path_free(path); } } diff --git a/src/notebook.c b/src/notebook.c index 3d86cf4e..790ed4cd 100644 --- a/src/notebook.c +++ b/src/notebook.c @@ -27,7 +27,6 @@ #include "geany.h" #include "notebook.h" -#include "prefs.h" #include "document.h" #include "ui_utils.h" #include "treeviews.h" @@ -339,7 +338,7 @@ gint notebook_new_tab(gint doc_idx) gtk_container_add(GTK_CONTAINER(ebox), this->tab_label); gtk_box_pack_start(GTK_BOX(hbox), ebox, FALSE, FALSE, 0); - if (prefs.show_tab_cross) + if (file_prefs.show_tab_cross) { GtkWidget *image, *btn, *align; GtkRcStyle *rcstyle; @@ -376,7 +375,7 @@ gint notebook_new_tab(gint doc_idx) this->tabmenu_label = gtk_label_new(title); gtk_misc_set_alignment(GTK_MISC(this->tabmenu_label), 0.0, 0); - if (prefs.tab_order_ltr) + if (file_prefs.tab_order_ltr) tabnum = gtk_notebook_append_page_menu(GTK_NOTEBOOK(app->notebook), page, hbox, this->tabmenu_label); else @@ -412,7 +411,7 @@ void notebook_remove_page(gint page_num) gint curpage = gtk_notebook_get_current_page(GTK_NOTEBOOK(app->notebook)); /* Focus the next page, not the previous */ - if (curpage == page_num && prefs.tab_order_ltr) + if (curpage == page_num && file_prefs.tab_order_ltr) { gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), curpage + 1); } diff --git a/src/plugindata.h b/src/plugindata.h index b1f49de8..7b3422a2 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -35,12 +35,12 @@ /* The API version should be incremented whenever any plugin data types below are * modified or appended to. */ -static const gint api_version = 58; +static const gint api_version = 59; /* The ABI version should be incremented whenever existing fields in the plugin * data types below have to be changed or reordered. It should stay the same if fields * are only appended, as this doesn't affect existing fields. */ -static const gint abi_version = 28; +static const gint abi_version = 29; /** Check the plugin can be loaded by Geany. * This performs runtime checks that try to ensure: @@ -153,13 +153,19 @@ PluginFields; * Variables and functions will be appended when needed by plugin authors. */ typedef struct GeanyData { - GeanyApp *app; /**< Geany application data fields */ - GtkWidget *tools_menu; /**< Most plugins should add menu items to the Tools menu only */ - GArray *doc_array; /**< Dynamic array of document structs */ - GPtrArray *filetypes_array; /**< Dynamic array of filetype pointers */ - struct GeanyPrefs *prefs; /* Note: this will be split up in future versions */ - struct EditorPrefs *editor_prefs; /**< Editor settings */ - struct BuildInfo *build_info; /**< Current build information */ + GeanyApp *app; /**< Geany application data fields */ + GtkWidget *tools_menu; /**< Most plugins should add menu items to the Tools menu only */ + GArray *doc_array; /**< Dynamic array of document structs */ + GPtrArray *filetypes_array; /**< Dynamic array of filetype pointers */ + struct GeanyPrefs *prefs; /**< General settings */ + struct GeanyInterfacePrefs *interface_prefs; /**< Interface settings */ + struct GeanyToolbarPrefs *toolbar_prefs; /**< Toolbar settings */ + struct GeanyEditorPrefs *editor_prefs; /**< Editor settings */ + struct GeanyFilePrefs *file_prefs; /**< File-related settings */ + struct GeanySearchPrefs *search_prefs; /**< Search-related settings */ + struct GeanyToolPrefs *tool_prefs; /**< Tool settings */ + struct GeanyTemplatePrefs *template_prefs; /**< Template settings */ + struct BuildInfo *build_info; /**< Current build information */ struct DocumentFuncs *documents; /**< See document.h */ struct ScintillaFuncs *sci; /**< See sciwrappers.h */ diff --git a/src/plugins.c b/src/plugins.c index b035552c..75c12731 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -252,6 +252,12 @@ static GeanyData geany_data = { NULL, NULL, NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, &doc_funcs, &sci_funcs, @@ -280,7 +286,13 @@ geany_data_init(void) geany_data.doc_array = doc_array; geany_data.filetypes_array = filetypes_array; geany_data.prefs = &prefs; + geany_data.interface_prefs = &interface_prefs; + geany_data.toolbar_prefs = &toolbar_prefs; geany_data.editor_prefs = &editor_prefs; + geany_data.file_prefs = &file_prefs; + geany_data.search_prefs = &search_prefs; + geany_data.tool_prefs = &tool_prefs; + geany_data.template_prefs = &template_prefs; geany_data.build_info = &build_info; } diff --git a/src/prefs.c b/src/prefs.c index 543f1607..e2525e71 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -49,6 +49,8 @@ #include "treeviews.h" #include "printing.h" #include "geanywraplabel.h" +#include "templates.h" +#include "search.h" #ifdef HAVE_VTE # include "vte.h" @@ -60,8 +62,8 @@ GeanyPrefs prefs; +GeanyToolPrefs tool_prefs; -GeanyFilePrefs file_prefs; static gchar *dialog_key_name; static GtkTreeIter g_iter; @@ -186,7 +188,7 @@ void prefs_init_dialog(void) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.beep_on_errors); widget = lookup_widget(ui_widgets.prefs_dialog, "check_switch_pages"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.switch_msgwin_pages); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.switch_to_status); widget = lookup_widget(ui_widgets.prefs_dialog, "check_suppress_status_msgs"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.suppress_status_messages); @@ -195,13 +197,13 @@ void prefs_init_dialog(void) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.auto_focus); widget = lookup_widget(ui_widgets.prefs_dialog, "check_ask_suppress_search_dialogs"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.suppress_search_dialogs); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), search_prefs.suppress_dialogs); widget = lookup_widget(ui_widgets.prefs_dialog, "check_search_use_current_word"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.search_use_current_word); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), search_prefs.use_current_word); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"); - gtk_entry_set_text(GTK_ENTRY(widget), prefs.context_action_cmd); + gtk_entry_set_text(GTK_ENTRY(widget), tool_prefs.context_action_cmd); widget = lookup_widget(ui_widgets.prefs_dialog, "startup_path_entry"); gtk_entry_set_text(GTK_ENTRY(widget), prefs.default_open_path); @@ -211,23 +213,23 @@ void prefs_init_dialog(void) /* Interface settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "check_list_symbol"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.sidebar_symbol_visible); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), interface_prefs.sidebar_symbol_visible); widget = lookup_widget(ui_widgets.prefs_dialog, "check_list_openfiles"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.sidebar_openfiles_visible); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), interface_prefs.sidebar_openfiles_visible); on_openfiles_visible_toggled(GTK_TOGGLE_BUTTON(widget), NULL); widget = lookup_widget(ui_widgets.prefs_dialog, "check_list_openfiles_fullpath"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.sidebar_openfiles_fullpath); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), interface_prefs.sidebar_openfiles_fullpath); widget = lookup_widget(ui_widgets.prefs_dialog, "tagbar_font"); - gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), prefs.tagbar_font); + gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), interface_prefs.tagbar_font); widget = lookup_widget(ui_widgets.prefs_dialog, "msgwin_font"); - gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), prefs.msgwin_font); + gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), interface_prefs.msgwin_font); widget = lookup_widget(ui_widgets.prefs_dialog, "editor_font"); - gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), prefs.editor_font); + gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), interface_prefs.editor_font); widget = lookup_widget(ui_widgets.prefs_dialog, "spin_long_line"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), editor_prefs.long_line_column); @@ -247,63 +249,63 @@ void prefs_init_dialog(void) g_free(color); widget = lookup_widget(ui_widgets.prefs_dialog, "check_show_notebook_tabs"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.show_notebook_tabs); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), interface_prefs.show_notebook_tabs); /* disable following setting if notebook tabs are hidden */ on_show_notebook_tabs_toggled(GTK_TOGGLE_BUTTON( lookup_widget(ui_widgets.prefs_dialog, "check_show_notebook_tabs")), NULL); widget = lookup_widget(ui_widgets.prefs_dialog, "check_show_tab_cross"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.show_tab_cross); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.show_tab_cross); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_tab_editor"); - gtk_combo_box_set_active(GTK_COMBO_BOX(widget), prefs.tab_pos_editor); + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), interface_prefs.tab_pos_editor); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_tab_msgwin"); - gtk_combo_box_set_active(GTK_COMBO_BOX(widget), prefs.tab_pos_msgwin); + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), interface_prefs.tab_pos_msgwin); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_tab_sidebar"); - gtk_combo_box_set_active(GTK_COMBO_BOX(widget), prefs.tab_pos_sidebar); + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), interface_prefs.tab_pos_sidebar); widget = lookup_widget(ui_widgets.prefs_dialog, "check_statusbar_visible"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.statusbar_visible); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), interface_prefs.statusbar_visible); /* Toolbar settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_show"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_visible); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.visible); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_search"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_search); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_search); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_goto"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_goto); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_goto); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_compile"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_compile); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_compile); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_zoom"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_zoom); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_zoom); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_indent"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_indent); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_indent); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_undo"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_undo); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_undo); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_navigation"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_navigation); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_navigation); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_colour"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_colour); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_colour); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_fileops"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_fileops); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_fileops); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_quit"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.toolbar_show_quit); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), toolbar_prefs.show_quit); - switch (prefs.toolbar_icon_style) + switch (toolbar_prefs.icon_style) { case 0: widget = lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_image"); break; case 1: widget = lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_text"); break; @@ -312,7 +314,7 @@ void prefs_init_dialog(void) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); - switch (prefs.toolbar_icon_size) + switch (toolbar_prefs.icon_size) { case GTK_ICON_SIZE_LARGE_TOOLBAR: widget = lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_large"); break; @@ -325,14 +327,14 @@ void prefs_init_dialog(void) /* Files settings */ - if (prefs.tab_order_ltr) + if (file_prefs.tab_order_ltr) widget = lookup_widget(ui_widgets.prefs_dialog, "radio_tab_right"); else widget = lookup_widget(ui_widgets.prefs_dialog, "radio_tab_left"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); widget = lookup_widget(ui_widgets.prefs_dialog, "spin_mru"); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), prefs.mru_length); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), file_prefs.mru_length); widget = lookup_widget(ui_widgets.prefs_dialog, "spin_disk_check"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), file_prefs.disk_check_timeout); @@ -340,41 +342,41 @@ void prefs_init_dialog(void) widget = lookup_widget(ui_widgets.prefs_dialog, "combo_new_encoding"); /* luckily the index of the combo box items match the index of the encodings array */ - gtk_combo_box_set_active(GTK_COMBO_BOX(widget), prefs.default_new_encoding); + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), file_prefs.default_new_encoding); widget = lookup_widget(ui_widgets.prefs_dialog, "check_open_encoding"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), - (prefs.default_open_encoding >= 0) ? TRUE : FALSE); + (file_prefs.default_open_encoding >= 0) ? TRUE : FALSE); on_open_encoding_toggled(GTK_TOGGLE_BUTTON(widget), NULL); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_open_encoding"); - if (prefs.default_open_encoding >= 0) + if (file_prefs.default_open_encoding >= 0) { - gtk_combo_box_set_active(GTK_COMBO_BOX(widget), prefs.default_open_encoding); + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), file_prefs.default_open_encoding); } else gtk_combo_box_set_active(GTK_COMBO_BOX(widget), GEANY_ENCODING_UTF_8); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_eol"); - if (prefs.default_eol_character >= 0 && prefs.default_eol_character < 3) + if (file_prefs.default_eol_character >= 0 && file_prefs.default_eol_character < 3) { - gtk_combo_box_set_active(GTK_COMBO_BOX(widget), prefs.default_eol_character); + gtk_combo_box_set_active(GTK_COMBO_BOX(widget), file_prefs.default_eol_character); } else gtk_combo_box_set_active(GTK_COMBO_BOX(widget), GEANY_DEFAULT_EOL_CHARACTER); widget = lookup_widget(ui_widgets.prefs_dialog, "check_trailing_spaces"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.strip_trailing_spaces); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.strip_trailing_spaces); widget = lookup_widget(ui_widgets.prefs_dialog, "check_new_line"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.final_new_line); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.final_new_line); /* Editor settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "spin_tab_width"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), editor_prefs.tab_width); widget = lookup_widget(ui_widgets.prefs_dialog, "check_replace_tabs"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.replace_tabs); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.replace_tabs); widget = lookup_widget(ui_widgets.prefs_dialog, "check_indent"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.show_indent_guide); @@ -443,34 +445,34 @@ void prefs_init_dialog(void) /* Tools Settings */ - if (prefs.tools_make_cmd) - gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_com_make")), prefs.tools_make_cmd); + if (tool_prefs.make_cmd) + gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_com_make")), tool_prefs.make_cmd); - if (prefs.tools_term_cmd) - gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_com_term")), prefs.tools_term_cmd); + if (tool_prefs.term_cmd) + gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_com_term")), tool_prefs.term_cmd); - if (prefs.tools_browser_cmd) - gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_browser")), prefs.tools_browser_cmd); + if (tool_prefs.browser_cmd) + gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_browser")), tool_prefs.browser_cmd); - if (prefs.tools_grep_cmd) - gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_grep")), prefs.tools_grep_cmd); + if (tool_prefs.grep_cmd) + gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_grep")), tool_prefs.grep_cmd); /* Template settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_developer"); - gtk_entry_set_text(GTK_ENTRY(widget), prefs.template_developer); + gtk_entry_set_text(GTK_ENTRY(widget), template_prefs.developer); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_company"); - gtk_entry_set_text(GTK_ENTRY(widget), prefs.template_company); + gtk_entry_set_text(GTK_ENTRY(widget), template_prefs.company); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_mail"); - gtk_entry_set_text(GTK_ENTRY(widget), prefs.template_mail); + gtk_entry_set_text(GTK_ENTRY(widget), template_prefs.mail); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_initial"); - gtk_entry_set_text(GTK_ENTRY(widget), prefs.template_initial); + gtk_entry_set_text(GTK_ENTRY(widget), template_prefs.initials); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_version"); - gtk_entry_set_text(GTK_ENTRY(widget), prefs.template_version); + gtk_entry_set_text(GTK_ENTRY(widget), template_prefs.version); /* Keybindings */ @@ -608,23 +610,23 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data) prefs.beep_on_errors = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_ask_suppress_search_dialogs"); - prefs.suppress_search_dialogs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + search_prefs.suppress_dialogs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_switch_pages"); - prefs.switch_msgwin_pages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + prefs.switch_to_status = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_suppress_status_msgs"); prefs.suppress_status_messages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_search_use_current_word"); - prefs.search_use_current_word = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + search_prefs.use_current_word = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_auto_focus"); prefs.auto_focus = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"); - g_free(prefs.context_action_cmd); - prefs.context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(tool_prefs.context_action_cmd); + tool_prefs.context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "startup_path_entry"); g_free(prefs.default_open_path); @@ -635,13 +637,13 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data) /* Interface settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "check_list_symbol"); - prefs.sidebar_symbol_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + interface_prefs.sidebar_symbol_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_list_openfiles"); - prefs.sidebar_openfiles_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + interface_prefs.sidebar_openfiles_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_list_openfiles_fullpath"); - prefs.sidebar_openfiles_fullpath = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + interface_prefs.sidebar_openfiles_fullpath = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "radio_long_line_line"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) editor_prefs.long_line_type = 0; @@ -657,111 +659,111 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data) if (editor_prefs.long_line_column == 0) editor_prefs.long_line_type = 2; widget = lookup_widget(ui_widgets.prefs_dialog, "check_show_notebook_tabs"); - prefs.show_notebook_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + interface_prefs.show_notebook_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_show_tab_cross"); - prefs.show_tab_cross = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + file_prefs.show_tab_cross = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_tab_editor"); - prefs.tab_pos_editor = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + interface_prefs.tab_pos_editor = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_tab_msgwin"); - prefs.tab_pos_msgwin = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + interface_prefs.tab_pos_msgwin = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_tab_sidebar"); - prefs.tab_pos_sidebar = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + interface_prefs.tab_pos_sidebar = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_statusbar_visible"); - prefs.statusbar_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + interface_prefs.statusbar_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); /* Toolbar settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_show"); - prefs.toolbar_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_search"); - prefs.toolbar_show_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_goto"); - prefs.toolbar_show_goto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_goto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_zoom"); - prefs.toolbar_show_zoom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_zoom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_indent"); - prefs.toolbar_show_indent = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_indent = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_undo"); - prefs.toolbar_show_undo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_undo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_navigation"); - prefs.toolbar_show_navigation = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_navigation = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_compile"); - prefs.toolbar_show_compile = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_compile = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_colour"); - prefs.toolbar_show_colour = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_colour = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_fileops"); - prefs.toolbar_show_fileops = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_fileops = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_quit"); - prefs.toolbar_show_quit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + toolbar_prefs.show_quit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_imagetext"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) prefs.toolbar_icon_style = 2; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) toolbar_prefs.icon_style = 2; else { widget = lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_image"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) - prefs.toolbar_icon_style = 0; + toolbar_prefs.icon_style = 0; else /* now only the text only radio remains, so set text only */ - prefs.toolbar_icon_style = 1; + toolbar_prefs.icon_style = 1; } widget = lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_large"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) - prefs.toolbar_icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR; + toolbar_prefs.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR; else - prefs.toolbar_icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR; + toolbar_prefs.icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR; /* Files settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "radio_tab_right"); - prefs.tab_order_ltr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + file_prefs.tab_order_ltr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "spin_mru"); - prefs.mru_length = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); + file_prefs.mru_length = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "spin_disk_check"); file_prefs.disk_check_timeout = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "combo_new_encoding"); - prefs.default_new_encoding = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + file_prefs.default_new_encoding = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_open_encoding"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { widget = lookup_widget(ui_widgets.prefs_dialog, "combo_open_encoding"); - prefs.default_open_encoding = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + file_prefs.default_open_encoding = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); } else - prefs.default_open_encoding = -1; + file_prefs.default_open_encoding = -1; widget = lookup_widget(ui_widgets.prefs_dialog, "combo_eol"); - prefs.default_eol_character = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + file_prefs.default_eol_character = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_trailing_spaces"); - prefs.strip_trailing_spaces = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + file_prefs.strip_trailing_spaces = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_new_line"); - prefs.final_new_line = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + file_prefs.final_new_line = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(ui_widgets.prefs_dialog, "check_replace_tabs"); - prefs.replace_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + file_prefs.replace_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); /* Editor settings */ @@ -848,42 +850,42 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data) /* Tools Settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "entry_com_make"); - g_free(prefs.tools_make_cmd); - prefs.tools_make_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(tool_prefs.make_cmd); + tool_prefs.make_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_com_term"); - g_free(prefs.tools_term_cmd); - prefs.tools_term_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(tool_prefs.term_cmd); + tool_prefs.term_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_browser"); - g_free(prefs.tools_browser_cmd); - prefs.tools_browser_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(tool_prefs.browser_cmd); + tool_prefs.browser_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_grep"); - g_free(prefs.tools_grep_cmd); - prefs.tools_grep_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(tool_prefs.grep_cmd); + tool_prefs.grep_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); /* Template settings */ widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_developer"); - g_free(prefs.template_developer); - prefs.template_developer = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(template_prefs.developer); + template_prefs.developer = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_company"); - g_free(prefs.template_company); - prefs.template_company = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(template_prefs.company); + template_prefs.company = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_mail"); - g_free(prefs.template_mail); - prefs.template_mail = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(template_prefs.mail); + template_prefs.mail = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_initial"); - g_free(prefs.template_initial); - prefs.template_initial = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(template_prefs.initials); + template_prefs.initials = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); widget = lookup_widget(ui_widgets.prefs_dialog, "entry_template_version"); - g_free(prefs.template_version); - prefs.template_version = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + g_free(template_prefs.version); + template_prefs.version = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); /* Keybindings */ @@ -959,17 +961,17 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data) #endif /* apply the changes made */ - ui_statusbar_showhide(prefs.statusbar_visible); + ui_statusbar_showhide(interface_prefs.statusbar_visible); treeviews_openfiles_update_all(); /* to update if full path setting has changed */ ui_update_toolbar_items(); - ui_update_toolbar_icons(prefs.toolbar_icon_size); - gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), prefs.toolbar_icon_style); + ui_update_toolbar_icons(toolbar_prefs.icon_size); + gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), toolbar_prefs.icon_style); ui_sidebar_show_hide(); - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), prefs.show_notebook_tabs); + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), interface_prefs.show_notebook_tabs); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->notebook), prefs.tab_pos_editor); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow.notebook), prefs.tab_pos_msgwin); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->treeview_notebook), prefs.tab_pos_sidebar); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->notebook), interface_prefs.tab_pos_editor); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow.notebook), interface_prefs.tab_pos_msgwin); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->treeview_notebook), interface_prefs.tab_pos_sidebar); /* re-colourise all open documents, if tab width or long line settings have changed */ for (i = 0; i < doc_array->len; i++) @@ -1036,29 +1038,29 @@ void on_prefs_font_choosed(GtkFontButton *widget, gpointer user_data) { case 1: { - if (strcmp(fontbtn, prefs.tagbar_font) == 0) break; - g_free(prefs.tagbar_font); - prefs.tagbar_font = g_strdup(fontbtn); + if (strcmp(fontbtn, interface_prefs.tagbar_font) == 0) break; + g_free(interface_prefs.tagbar_font); + interface_prefs.tagbar_font = g_strdup(fontbtn); for (i = 0; i < doc_array->len; i++) { if (doc_list[i].is_valid && GTK_IS_WIDGET(doc_list[i].tag_tree)) ui_widget_modify_font_from_string(doc_list[i].tag_tree, - prefs.tagbar_font); + interface_prefs.tagbar_font); } if (GTK_IS_WIDGET(tv.default_tag_tree)) - ui_widget_modify_font_from_string(tv.default_tag_tree, prefs.tagbar_font); + ui_widget_modify_font_from_string(tv.default_tag_tree, interface_prefs.tagbar_font); ui_widget_modify_font_from_string(lookup_widget(app->window, "entry1"), - prefs.tagbar_font); + interface_prefs.tagbar_font); break; } case 2: { - if (strcmp(fontbtn, prefs.msgwin_font) == 0) break; - g_free(prefs.msgwin_font); - prefs.msgwin_font = g_strdup(fontbtn); - ui_widget_modify_font_from_string(msgwindow.tree_compiler, prefs.msgwin_font); - ui_widget_modify_font_from_string(msgwindow.tree_msg, prefs.msgwin_font); - ui_widget_modify_font_from_string(msgwindow.tree_status, prefs.msgwin_font); + if (strcmp(fontbtn, interface_prefs.msgwin_font) == 0) break; + g_free(interface_prefs.msgwin_font); + interface_prefs.msgwin_font = g_strdup(fontbtn); + ui_widget_modify_font_from_string(msgwindow.tree_compiler, interface_prefs.msgwin_font); + ui_widget_modify_font_from_string(msgwindow.tree_msg, interface_prefs.msgwin_font); + ui_widget_modify_font_from_string(msgwindow.tree_status, interface_prefs.msgwin_font); break; } case 3: diff --git a/src/prefs.h b/src/prefs.h index 27a9982d..55017196 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -24,90 +24,36 @@ #ifndef GEANY_PREFS_H #define GEANY_PREFS_H 1 -/* Preferences dialog settings. - * (See also EditorPrefs in editor.h and PrintingPrefs in printing.h). - * Remember to increment abi_version in plugindata.h when changing items. */ +/* General Preferences dialog settings. + * Remember to increment abi_version in plugindata.h if you have to change an item. */ typedef struct GeanyPrefs { - /* general */ gboolean load_session; gboolean load_plugins; gboolean save_winpos; gboolean confirm_exit; gboolean beep_on_errors; - gboolean suppress_search_dialogs; - gboolean search_use_current_word; gboolean suppress_status_messages; - gboolean switch_msgwin_pages; + gboolean switch_to_status; gboolean auto_focus; gchar *default_open_path; - - /* interface */ - gboolean sidebar_symbol_visible; - gboolean sidebar_openfiles_visible; - gboolean sidebar_openfiles_fullpath; - gchar *editor_font; - gchar *tagbar_font; - gchar *msgwin_font; - gboolean show_notebook_tabs; - gint tab_pos_editor; - gint tab_pos_msgwin; - gint tab_pos_sidebar; - gboolean statusbar_visible; - gboolean show_symbol_list_expanders; - - /* toolbar */ - gboolean toolbar_visible; - gboolean toolbar_show_search; - gboolean toolbar_show_goto; - gboolean toolbar_show_undo; - gboolean toolbar_show_navigation; - gboolean toolbar_show_compile; - gboolean toolbar_show_zoom; - gboolean toolbar_show_indent; - gboolean toolbar_show_colour; - gboolean toolbar_show_fileops; - gboolean toolbar_show_quit; - GtkIconSize toolbar_icon_size; - gint toolbar_icon_style; - - /* files */ - gint default_new_encoding; - gint default_open_encoding; - gboolean final_new_line; - gboolean strip_trailing_spaces; - gboolean replace_tabs; - gboolean tab_order_ltr; - gboolean show_tab_cross; - guint mru_length; - gint default_eol_character; - - /* tools */ - gchar *tools_browser_cmd; - gchar *tools_make_cmd; - gchar *tools_term_cmd; - gchar *tools_grep_cmd; - gchar *context_action_cmd; - - /* templates */ - gchar *template_developer; - gchar *template_company; - gchar *template_mail; - gchar *template_initial; - gchar *template_version; } GeanyPrefs; extern GeanyPrefs prefs; -typedef struct GeanyFilePrefs +typedef struct GeanyToolPrefs { - gint disk_check_timeout; + gchar *browser_cmd; + gchar *make_cmd; + gchar *term_cmd; + gchar *grep_cmd; + gchar *context_action_cmd; } -GeanyFilePrefs; +GeanyToolPrefs; -extern GeanyFilePrefs file_prefs; +extern GeanyToolPrefs tool_prefs; void prefs_init_dialog(void); diff --git a/src/printing.c b/src/printing.c index d835f7ca..e86fd4e9 100644 --- a/src/printing.c +++ b/src/printing.c @@ -33,7 +33,6 @@ #include "geany.h" #include "printing.h" -#include "prefs.h" #include "document.h" #include "sciwrappers.h" #include "editor.h" @@ -415,7 +414,7 @@ static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, if (dinfo == NULL) return; - desc = pango_font_description_from_string(prefs.editor_font); + desc = pango_font_description_from_string(interface_prefs.editor_font); /* init dinfo fields */ dinfo->lines = sci_get_line_count(doc_list[dinfo->idx].sci); diff --git a/src/search.c b/src/search.c index ae6dfc78..ed48a341 100644 --- a/src/search.c +++ b/src/search.c @@ -64,7 +64,8 @@ enum { GeanySearchData search_data; -SearchPrefs search_prefs = {NULL}; +GeanySearchPrefs search_prefs; + static struct { @@ -290,7 +291,7 @@ void search_show_find_dialog(void) g_return_if_fail(DOC_IDX_VALID(idx)); - sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL); + sel = editor_get_default_selection(idx, search_prefs.use_current_word, NULL); if (widgets.find_dialog == NULL) { @@ -411,7 +412,7 @@ void search_show_replace_dialog(void) if (idx == -1 || ! doc_list[idx].is_valid) return; - sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL); + sel = editor_get_default_selection(idx, search_prefs.use_current_word, NULL); if (widgets.replace_dialog == NULL) { @@ -710,13 +711,13 @@ void search_show_find_in_files_dialog(const gchar *dir) G_CALLBACK(gtk_widget_hide_on_delete), NULL); gtk_widget_show_all(widgets.find_in_files_dialog); - sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL); + sel = editor_get_default_selection(idx, search_prefs.use_current_word, NULL); } entry = GTK_BIN(combo)->child; /* only set selection if the dialog is not already visible, or has just been created */ if (! sel && ! GTK_WIDGET_VISIBLE(widgets.find_in_files_dialog)) - sel = editor_get_default_selection(idx, prefs.search_use_current_word, NULL); + sel = editor_get_default_selection(idx, search_prefs.use_current_word, NULL); if (sel) gtk_entry_set_text(GTK_ENTRY(entry), sel); g_free(sel); @@ -882,7 +883,7 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) document_find_text(idx, search_data.text, search_data.flags, (response == GEANY_RESPONSE_FIND_PREVIOUS), TRUE, GTK_WIDGET(widgets.find_dialog)); check_close = FALSE; - if (prefs.suppress_search_dialogs) + if (search_prefs.suppress_dialogs) check_close = TRUE; break; @@ -1165,11 +1166,11 @@ search_find_in_files(const gchar *search_text, const gchar *dir, const gchar *op if (! search_text || ! *search_text || ! dir) return TRUE; - command_grep = g_find_program_in_path(prefs.tools_grep_cmd); + command_grep = g_find_program_in_path(tool_prefs.grep_cmd); if (command_grep == NULL) { ui_set_statusbar(TRUE, _("Cannot execute grep tool '%s';" - " check the path setting in Preferences."), prefs.tools_grep_cmd); + " check the path setting in Preferences."), tool_prefs.grep_cmd); return FALSE; } @@ -1186,7 +1187,7 @@ search_find_in_files(const gchar *search_text, const gchar *dir, const gchar *op } g_strfreev(opts_argv); - i++; /* correct for prefs.tools_grep_cmd */ + i++; /* correct for tool_prefs.grep_cmd */ argv_prefix[i++] = g_strdup("--"); argv_prefix[i++] = g_strdup(search_text); @@ -1234,7 +1235,7 @@ search_find_in_files(const gchar *search_text, const gchar *dir, const gchar *op g_child_watch_add(child_pid, search_close_pid, NULL); str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"), - prefs.tools_grep_cmd, opts, search_text, dir); + tool_prefs.grep_cmd, opts, search_text, dir); utf8_str = utils_get_utf8_from_locale(str); msgwin_msg_add(COLOR_BLUE, -1, -1, utf8_str); utils_free_pointers(str, utf8_str, NULL); diff --git a/src/search.h b/src/search.h index 69e5b897..c1343707 100644 --- a/src/search.h +++ b/src/search.h @@ -26,7 +26,7 @@ #define GEANY_SEARCH_H 1 /* the flags given in the search dialog for "find next", also used by the search bar */ -typedef struct +typedef struct GeanySearchData { gchar *text; gint flags; @@ -34,17 +34,21 @@ typedef struct /* set to TRUE when text was set by a search bar callback to keep track of * search bar background colour */ gboolean search_bar; -} GeanySearchData; +} +GeanySearchData; extern GeanySearchData search_data; -typedef struct +typedef struct GeanySearchPrefs { gchar *fif_extra_options; -} SearchPrefs; + gboolean suppress_dialogs; + gboolean use_current_word; +} +GeanySearchPrefs; -extern SearchPrefs search_prefs; +extern GeanySearchPrefs search_prefs; void search_init(void); diff --git a/src/templates.c b/src/templates.c index c6d350fd..34d3d680 100644 --- a/src/templates.c +++ b/src/templates.c @@ -32,7 +32,6 @@ #include "geany.h" #include "templates.h" -#include "prefs.h" #include "support.h" #include "utils.h" #include "document.h" @@ -44,6 +43,8 @@ #define TEMPLATE_DATETIME_FORMAT "%d.%m.%Y %H:%M:%S %Z" +GeanyTemplatePrefs template_prefs; + static GtkWidget *new_with_template_menu = NULL; /* File menu submenu */ @@ -763,11 +764,11 @@ static gchar *templates_replace_all(gchar *text, const gchar *year, const gchar { text = utils_str_replace(text, "{year}", year); text = utils_str_replace(text, "{date}", date); - text = utils_str_replace(text, "{version}", prefs.template_version); - text = utils_str_replace(text, "{initial}", prefs.template_initial); - text = utils_str_replace(text, "{developer}", prefs.template_developer); - text = utils_str_replace(text, "{mail}", prefs.template_mail); - text = utils_str_replace(text, "{company}", prefs.template_company); + text = utils_str_replace(text, "{version}", template_prefs.version); + text = utils_str_replace(text, "{initial}", template_prefs.initials); + text = utils_str_replace(text, "{developer}", template_prefs.developer); + text = utils_str_replace(text, "{mail}", template_prefs.mail); + text = utils_str_replace(text, "{company}", template_prefs.company); text = utils_str_replace(text, "{untitled}", GEANY_STRING_UNTITLED); text = utils_str_replace(text, "{geanyversion}", "Geany " VERSION); diff --git a/src/templates.h b/src/templates.h index 03a87104..344d96e3 100644 --- a/src/templates.h +++ b/src/templates.h @@ -34,6 +34,20 @@ enum GEANY_MAX_TEMPLATES }; + +typedef struct GeanyTemplatePrefs +{ + gchar *developer; + gchar *company; + gchar *mail; + gchar *initials; + gchar *version; +} +GeanyTemplatePrefs; + +extern GeanyTemplatePrefs template_prefs; + + struct filetype; void templates_init(void); diff --git a/src/treeviews.c b/src/treeviews.c index 92b5d802..e87d1d9e 100644 --- a/src/treeviews.c +++ b/src/treeviews.c @@ -28,7 +28,6 @@ #include #include "geany.h" -#include "prefs.h" #include "support.h" #include "callbacks.h" #include "treeviews.h" @@ -113,7 +112,7 @@ static void prepare_taglist(GtkWidget *tree, GtkTreeStore *store) gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); - pfd = pango_font_description_from_string(prefs.tagbar_font); + pfd = pango_font_description_from_string(interface_prefs.tagbar_font); gtk_widget_modify_font(tree, pfd); pango_font_description_free(pfd); @@ -126,8 +125,8 @@ static void prepare_taglist(GtkWidget *tree, GtkTreeStore *store) gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE); #if GTK_CHECK_VERSION(2, 12, 0) - gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(tree), prefs.show_symbol_list_expanders); - if (! prefs.show_symbol_list_expanders) + gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(tree), interface_prefs.show_symbol_list_expanders); + if (! interface_prefs.show_symbol_list_expanders) gtk_tree_view_set_level_indentation(GTK_TREE_VIEW(tree), 10); #endif @@ -274,7 +273,7 @@ static void prepare_openfiles(void) sortable = GTK_TREE_SORTABLE(GTK_TREE_MODEL(store_openfiles)); gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING); - pfd = pango_font_description_from_string(prefs.tagbar_font); + pfd = pango_font_description_from_string(interface_prefs.tagbar_font); gtk_widget_modify_font(tv.tree_openfiles, pfd); pango_font_description_free(pfd); @@ -311,7 +310,7 @@ void treeviews_openfiles_update(gint idx) gchar *basename; GdkColor *color = document_get_status_color(idx); - if (prefs.sidebar_openfiles_fullpath) + if (interface_prefs.sidebar_openfiles_fullpath) basename = DOC_FILENAME(idx); else basename = g_path_get_basename(DOC_FILENAME(idx)); @@ -321,7 +320,7 @@ void treeviews_openfiles_update(gint idx) #else 0, basename, 1, idx, 2, color, -1); #endif - if (! prefs.sidebar_openfiles_fullpath) + if (! interface_prefs.sidebar_openfiles_fullpath) g_free(basename); } @@ -409,21 +408,21 @@ static void create_taglist_popup_menu(void) static void on_openfiles_fullpath_activate(GtkCheckMenuItem *item, gpointer user_data) { - prefs.sidebar_openfiles_fullpath = gtk_check_menu_item_get_active(item); + interface_prefs.sidebar_openfiles_fullpath = gtk_check_menu_item_get_active(item); treeviews_openfiles_update_all(); } static void on_list_document_activate(GtkCheckMenuItem *item, gpointer user_data) { - prefs.sidebar_openfiles_visible = gtk_check_menu_item_get_active(item); + interface_prefs.sidebar_openfiles_visible = gtk_check_menu_item_get_active(item); ui_sidebar_show_hide(); } static void on_list_symbol_activate(GtkCheckMenuItem *item, gpointer user_data) { - prefs.sidebar_symbol_visible = gtk_check_menu_item_get_active(item); + interface_prefs.sidebar_symbol_visible = gtk_check_menu_item_get_active(item); ui_sidebar_show_hide(); } @@ -619,7 +618,7 @@ static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_d } case SYMBOL_ACTION_HIDE: { - prefs.sidebar_symbol_visible = FALSE; + interface_prefs.sidebar_symbol_visible = FALSE; ui_sidebar_show_hide(); break; } @@ -708,20 +707,20 @@ static gboolean on_treeviews_button_press_event(GtkWidget *widget, GdkEventButto if (GPOINTER_TO_INT(user_data) == TREEVIEW_OPENFILES) { gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi.documents_show_documents), - prefs.sidebar_openfiles_visible); + interface_prefs.sidebar_openfiles_visible); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi.documents_show_symbols), - prefs.sidebar_symbol_visible); + interface_prefs.sidebar_symbol_visible); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi.documents_fullpath), - prefs.sidebar_openfiles_fullpath); + interface_prefs.sidebar_openfiles_fullpath); gtk_menu_popup(GTK_MENU(tv.popup_openfiles), NULL, NULL, NULL, NULL, event->button, event->time); } else if (GPOINTER_TO_INT(user_data) == TREEVIEW_SYMBOL) { gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi.symbols_show_documents), - prefs.sidebar_openfiles_visible); + interface_prefs.sidebar_openfiles_visible); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi.symbols_show_symbols), - prefs.sidebar_symbol_visible); + interface_prefs.sidebar_symbol_visible); gtk_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL, NULL, NULL, event->button, event->time); return TRUE; /* prevent selection changed signal for symbol tags */ diff --git a/src/ui_utils.c b/src/ui_utils.c index aad4fdc6..fe44a6fc 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -47,6 +47,8 @@ #include "plugins.h" +GeanyInterfacePrefs interface_prefs; +GeanyToolbarPrefs toolbar_prefs; UIPrefs ui_prefs; UIWidgets ui_widgets; @@ -73,7 +75,7 @@ static void set_statusbar(const gchar *text, gboolean allow_override) GTimeVal timeval; const gint GEANY_STATUS_TIMEOUT = 1; - if (! prefs.statusbar_visible) + if (! interface_prefs.statusbar_visible) return; /* just do nothing if statusbar is not visible */ g_get_current_time(&timeval); @@ -115,7 +117,7 @@ void ui_set_statusbar(gboolean log, const gchar *format, ...) /* updates the status bar document statistics */ void ui_update_statusbar(gint idx, gint pos) { - if (! prefs.statusbar_visible) + if (! interface_prefs.statusbar_visible) return; /* just do nothing if statusbar is not visible */ if (idx == -1) idx = document_get_cur_idx(); @@ -244,13 +246,13 @@ void ui_set_editor_font(const gchar *font_name) g_return_if_fail(font_name != NULL); /* do nothing if font has not changed */ - if (prefs.editor_font != NULL) - if (strcmp(font_name, prefs.editor_font) == 0) return; + if (interface_prefs.editor_font != NULL) + if (strcmp(font_name, interface_prefs.editor_font) == 0) return; - g_free(prefs.editor_font); - prefs.editor_font = g_strdup(font_name); + g_free(interface_prefs.editor_font); + interface_prefs.editor_font = g_strdup(font_name); - font_desc = pango_font_description_from_string(prefs.editor_font); + font_desc = pango_font_description_from_string(interface_prefs.editor_font); fname = g_strdup_printf("!%s", pango_font_description_get_family(font_desc)); size = pango_font_description_get_size(font_desc) / PANGO_SCALE; @@ -265,7 +267,7 @@ void ui_set_editor_font(const gchar *font_name) } pango_font_description_free(font_desc); - ui_set_statusbar(TRUE, _("Font updated (%s)."), prefs.editor_font); + ui_set_statusbar(TRUE, _("Font updated (%s)."), interface_prefs.editor_font); g_free(fname); } @@ -638,7 +640,7 @@ void ui_sidebar_show_hide(void) /* check that there are no other notebook pages before hiding the sidebar completely * other pages could be e.g. the file browser plugin */ - if (! prefs.sidebar_openfiles_visible && ! prefs.sidebar_symbol_visible && + if (! interface_prefs.sidebar_openfiles_visible && ! interface_prefs.sidebar_symbol_visible && gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->treeview_notebook)) <= 2) { ui_prefs.sidebar_visible = FALSE; @@ -655,9 +657,9 @@ void ui_sidebar_show_hide(void) ui_widget_show_hide(app->treeview_notebook, ui_prefs.sidebar_visible); ui_widget_show_hide(gtk_notebook_get_nth_page( - GTK_NOTEBOOK(app->treeview_notebook), 0), prefs.sidebar_symbol_visible); + GTK_NOTEBOOK(app->treeview_notebook), 0), interface_prefs.sidebar_symbol_visible); ui_widget_show_hide(gtk_notebook_get_nth_page( - GTK_NOTEBOOK(app->treeview_notebook), 1), prefs.sidebar_openfiles_visible); + GTK_NOTEBOOK(app->treeview_notebook), 1), interface_prefs.sidebar_openfiles_visible); } @@ -739,60 +741,60 @@ void ui_update_toolbar_items(void) { /* show toolbar */ GtkWidget *widget = lookup_widget(app->window, "menu_show_toolbar1"); - if (prefs.toolbar_visible && ! gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) + if (toolbar_prefs.visible && ! gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) { /* will be changed by the toggled callback */ - prefs.toolbar_visible = ! prefs.toolbar_visible; + toolbar_prefs.visible = ! toolbar_prefs.visible; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), TRUE); } - else if (! prefs.toolbar_visible && gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) + else if (! toolbar_prefs.visible && gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) { /* will be changed by the toggled callback */ - prefs.toolbar_visible = ! prefs.toolbar_visible; + toolbar_prefs.visible = ! toolbar_prefs.visible; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), FALSE); } /* fileops */ - ui_widget_show_hide(lookup_widget(app->window, "menutoolbutton1"), prefs.toolbar_show_fileops); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton9"), prefs.toolbar_show_fileops); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton10"), prefs.toolbar_show_fileops); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton22"), prefs.toolbar_show_fileops); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton23"), prefs.toolbar_show_fileops); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton15"), prefs.toolbar_show_fileops); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem7"), prefs.toolbar_show_fileops); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem2"), prefs.toolbar_show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "menutoolbutton1"), toolbar_prefs.show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton9"), toolbar_prefs.show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton10"), toolbar_prefs.show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton22"), toolbar_prefs.show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton23"), toolbar_prefs.show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton15"), toolbar_prefs.show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem7"), toolbar_prefs.show_fileops); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem2"), toolbar_prefs.show_fileops); /* search */ - ui_widget_show_hide(lookup_widget(app->window, "entry1"), prefs.toolbar_show_search); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton18"), prefs.toolbar_show_search); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem5"), prefs.toolbar_show_search); + ui_widget_show_hide(lookup_widget(app->window, "entry1"), toolbar_prefs.show_search); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton18"), toolbar_prefs.show_search); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem5"), toolbar_prefs.show_search); /* goto line */ - ui_widget_show_hide(lookup_widget(app->window, "entry_goto_line"), prefs.toolbar_show_goto); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton25"), prefs.toolbar_show_goto); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem8"), prefs.toolbar_show_goto); + ui_widget_show_hide(lookup_widget(app->window, "entry_goto_line"), toolbar_prefs.show_goto); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton25"), toolbar_prefs.show_goto); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem8"), toolbar_prefs.show_goto); /* compile */ - ui_widget_show_hide(lookup_widget(app->window, "toolbutton13"), prefs.toolbar_show_compile); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton26"), prefs.toolbar_show_compile); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem6"), prefs.toolbar_show_compile); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton13"), toolbar_prefs.show_compile); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton26"), toolbar_prefs.show_compile); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem6"), toolbar_prefs.show_compile); /* colour */ - ui_widget_show_hide(lookup_widget(app->window, "toolbutton24"), prefs.toolbar_show_colour); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem3"), prefs.toolbar_show_colour); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton24"), toolbar_prefs.show_colour); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem3"), toolbar_prefs.show_colour); /* zoom */ - ui_widget_show_hide(lookup_widget(app->window, "toolbutton20"), prefs.toolbar_show_zoom); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton21"), prefs.toolbar_show_zoom); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem4"), prefs.toolbar_show_zoom); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton20"), toolbar_prefs.show_zoom); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton21"), toolbar_prefs.show_zoom); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem4"), toolbar_prefs.show_zoom); /* indent */ - ui_widget_show_hide(lookup_widget(app->window, "toolbutton_indent_dec"), prefs.toolbar_show_indent); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton_indent_inc"), prefs.toolbar_show_indent); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem11"), prefs.toolbar_show_indent); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton_indent_dec"), toolbar_prefs.show_indent); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton_indent_inc"), toolbar_prefs.show_indent); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem11"), toolbar_prefs.show_indent); /* undo */ - ui_widget_show_hide(lookup_widget(app->window, "toolbutton_undo"), prefs.toolbar_show_undo); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton_redo"), prefs.toolbar_show_undo); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem9"), prefs.toolbar_show_undo); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton_undo"), toolbar_prefs.show_undo); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton_redo"), toolbar_prefs.show_undo); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem9"), toolbar_prefs.show_undo); /* navigation */ - ui_widget_show_hide(lookup_widget(app->window, "toolbutton_back"), prefs.toolbar_show_navigation); - ui_widget_show_hide(lookup_widget(app->window, "toolbutton_forward"), prefs.toolbar_show_navigation); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem10"), prefs.toolbar_show_navigation); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton_back"), toolbar_prefs.show_navigation); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton_forward"), toolbar_prefs.show_navigation); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem10"), toolbar_prefs.show_navigation); /* quit */ - ui_widget_show_hide(lookup_widget(app->window, "toolbutton19"), prefs.toolbar_show_quit); - ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem8"), prefs.toolbar_show_quit); + ui_widget_show_hide(lookup_widget(app->window, "toolbutton19"), toolbar_prefs.show_quit); + ui_widget_show_hide(lookup_widget(app->window, "separatortoolitem8"), toolbar_prefs.show_quit); } @@ -805,7 +807,7 @@ GdkPixbuf *ui_new_pixbuf_from_inline(gint img, gboolean small_img) case GEANY_IMAGE_LOGO: return gdk_pixbuf_new_from_inline(-1, aladin_inline, FALSE, NULL); break; case GEANY_IMAGE_SAVE_ALL: { - if ((prefs.toolbar_icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR) || small_img) + if ((toolbar_prefs.icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR) || small_img) { return gdk_pixbuf_scale_simple(gdk_pixbuf_new_from_inline(-1, save_all_inline, FALSE, NULL), 16, 16, GDK_INTERP_HYPER); @@ -818,7 +820,7 @@ GdkPixbuf *ui_new_pixbuf_from_inline(gint img, gboolean small_img) } case GEANY_IMAGE_NEW_ARROW: { - if ((prefs.toolbar_icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR) || small_img) + if ((toolbar_prefs.icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR) || small_img) { return gdk_pixbuf_scale_simple(gdk_pixbuf_new_from_inline(-1, newfile_inline, FALSE, NULL), 16, 16, GDK_INTERP_HYPER); @@ -860,7 +862,7 @@ void ui_create_recent_menu(void) lookup_widget(app->window, "toolbutton9")), ui_widgets.recent_files_toolbar); } - for (i = 0; i < MIN(prefs.mru_length, g_queue_get_length(ui_prefs.recent_queue)); i++) + for (i = 0; i < MIN(file_prefs.mru_length, g_queue_get_length(ui_prefs.recent_queue)); i++) { filename = g_queue_peek_nth(ui_prefs.recent_queue, i); /* create menu item for the recent files menu in the menu bar */ @@ -908,7 +910,7 @@ void ui_add_recent_file(const gchar *utf8_filename) } #endif g_queue_push_head(ui_prefs.recent_queue, g_strdup(utf8_filename)); - if (g_queue_get_length(ui_prefs.recent_queue) > prefs.mru_length) + if (g_queue_get_length(ui_prefs.recent_queue) > file_prefs.mru_length) { g_free(g_queue_pop_tail(ui_prefs.recent_queue)); } @@ -1006,9 +1008,9 @@ static void update_recent_menu(void) /* clean the MRU list before adding an item (menubar) */ children = gtk_container_get_children(GTK_CONTAINER(ui_widgets.recent_files_menubar)); - if (g_list_length(children) > prefs.mru_length - 1) + if (g_list_length(children) > file_prefs.mru_length - 1) { - item = g_list_nth(children, prefs.mru_length - 1); + item = g_list_nth(children, file_prefs.mru_length - 1); while (item != NULL) { if (GTK_IS_MENU_ITEM(item->data)) gtk_widget_destroy(GTK_WIDGET(item->data)); @@ -1018,9 +1020,9 @@ static void update_recent_menu(void) /* clean the MRU list before adding an item (toolbar) */ children = gtk_container_get_children(GTK_CONTAINER(ui_widgets.recent_files_toolbar)); - if (g_list_length(children) > prefs.mru_length - 1) + if (g_list_length(children) > file_prefs.mru_length - 1) { - item = g_list_nth(children, prefs.mru_length - 1); + item = g_list_nth(children, file_prefs.mru_length - 1); while (item != NULL) { if (GTK_IS_MENU_ITEM(item->data)) gtk_widget_destroy(GTK_WIDGET(item->data)); diff --git a/src/ui_utils.h b/src/ui_utils.h index 2bdb71d1..777ba48e 100644 --- a/src/ui_utils.h +++ b/src/ui_utils.h @@ -24,6 +24,47 @@ #ifndef GEANY_UI_UTILS_H #define GEANY_UI_UTILS_H 1 +typedef struct GeanyInterfacePrefs +{ + gboolean sidebar_symbol_visible; + gboolean sidebar_openfiles_visible; + gboolean sidebar_openfiles_fullpath; + gchar *editor_font; + gchar *tagbar_font; + gchar *msgwin_font; + gboolean show_notebook_tabs; + gint tab_pos_editor; + gint tab_pos_msgwin; + gint tab_pos_sidebar; + gboolean statusbar_visible; + gboolean show_symbol_list_expanders; +} +GeanyInterfacePrefs; + +extern GeanyInterfacePrefs interface_prefs; + + +typedef struct GeanyToolbarPrefs +{ + gboolean visible; + gboolean show_search; + gboolean show_goto; + gboolean show_undo; + gboolean show_navigation; + gboolean show_compile; + gboolean show_zoom; + gboolean show_indent; + gboolean show_colour; + gboolean show_fileops; + gboolean show_quit; + GtkIconSize icon_size; + gint icon_style; +} +GeanyToolbarPrefs; + +extern GeanyToolbarPrefs toolbar_prefs; + + /* User Interface settings not shown in the Prefs dialog. */ typedef struct UIPrefs { diff --git a/src/utils.c b/src/utils.c index e05d67f6..9b1430ca 100644 --- a/src/utils.c +++ b/src/utils.c @@ -64,7 +64,7 @@ void utils_start_browser(const gchar *uri) #else const gchar *argv[3]; - argv[0] = prefs.tools_browser_cmd; + argv[0] = tool_prefs.browser_cmd; argv[1] = uri; argv[2] = NULL;