2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* keyfile.c - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2012-06-18 01:13:05 +02:00
|
|
|
* Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2012-08-24 19:25:57 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
|
|
|
|
2007-02-24 11:41:56 +00:00
|
|
|
/*
|
|
|
|
* geany.conf preferences file loading and saving.
|
|
|
|
*/
|
|
|
|
|
2007-12-07 14:13:05 +00:00
|
|
|
/*
|
|
|
|
* Session file format:
|
|
|
|
* filename_xx=pos;filetype UID;read only;encoding idx;use_tabs;auto_indent;line_wrapping;filename
|
|
|
|
*/
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
#include <stdlib.h>
|
2005-12-29 20:01:18 +00:00
|
|
|
#include <string.h>
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
#include "geany.h"
|
|
|
|
|
2006-08-22 19:03:38 +00:00
|
|
|
#ifdef HAVE_VTE
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "support.h"
|
|
|
|
#include "keyfile.h"
|
2007-08-23 11:34:06 +00:00
|
|
|
#include "prefs.h"
|
2006-09-05 14:24:47 +00:00
|
|
|
#include "ui_utils.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "utils.h"
|
|
|
|
#include "document.h"
|
2007-08-15 15:37:21 +00:00
|
|
|
#include "filetypes.h"
|
2005-12-29 20:01:18 +00:00
|
|
|
#include "sciwrappers.h"
|
2006-07-25 09:12:51 +00:00
|
|
|
#include "encodings.h"
|
2006-08-19 15:07:11 +00:00
|
|
|
#include "vte.h"
|
2006-09-04 11:16:07 +00:00
|
|
|
#include "main.h"
|
2006-11-09 15:52:31 +00:00
|
|
|
#include "msgwindow.h"
|
2007-04-15 15:59:57 +00:00
|
|
|
#include "search.h"
|
2007-04-21 12:25:17 +00:00
|
|
|
#include "project.h"
|
2007-05-29 16:30:54 +00:00
|
|
|
#include "editor.h"
|
2007-11-17 14:04:27 +00:00
|
|
|
#include "printing.h"
|
2008-05-16 12:08:39 +00:00
|
|
|
#include "templates.h"
|
2008-12-06 11:10:06 +00:00
|
|
|
#include "toolbar.h"
|
2008-11-28 12:52:19 +00:00
|
|
|
#include "stash.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
2008-04-23 16:47:42 +00:00
|
|
|
/* some default settings which are used at the very first start of Geany to fill
|
|
|
|
* the configuration file */
|
|
|
|
#define GEANY_MAX_SYMBOLLIST_HEIGHT 10
|
|
|
|
#define GEANY_MIN_SYMBOLLIST_CHARS 4
|
|
|
|
#define GEANY_MSGWIN_HEIGHT 208
|
|
|
|
#define GEANY_DISK_CHECK_TIMEOUT 30
|
|
|
|
#define GEANY_DEFAULT_TOOLS_MAKE "make"
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#define GEANY_DEFAULT_TOOLS_TERMINAL "cmd.exe"
|
|
|
|
#else
|
|
|
|
#define GEANY_DEFAULT_TOOLS_TERMINAL "xterm"
|
|
|
|
#endif
|
|
|
|
#define GEANY_DEFAULT_TOOLS_BROWSER "firefox"
|
|
|
|
#define GEANY_DEFAULT_TOOLS_PRINTCMD "lpr"
|
|
|
|
#define GEANY_DEFAULT_TOOLS_GREP "grep"
|
|
|
|
#define GEANY_DEFAULT_MRU_LENGTH 10
|
|
|
|
#define GEANY_DEFAULT_FONT_SYMBOL_LIST "Sans 9"
|
|
|
|
#define GEANY_DEFAULT_FONT_MSG_WINDOW "Sans 9"
|
|
|
|
#define GEANY_DEFAULT_FONT_EDITOR "Monospace 10"
|
2008-08-29 17:00:02 +00:00
|
|
|
#define GEANY_TOGGLE_MARK "~ "
|
|
|
|
#define GEANY_MAX_AUTOCOMPLETE_WORDS 30
|
2011-03-05 22:46:32 +00:00
|
|
|
#define GEANY_MAX_SYMBOLS_UPDATE_FREQ 250
|
2011-10-22 22:55:57 +11:00
|
|
|
#define GEANY_DEFAULT_FILETYPE_REGEX "-\\*-\\s*([^\\s]+)\\s*-\\*-"
|
2008-04-23 16:47:42 +00:00
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
static gchar *scribble_text = NULL;
|
2009-05-13 15:21:54 +00:00
|
|
|
static gint scribble_pos = -1;
|
2006-10-11 16:35:21 +00:00
|
|
|
static GPtrArray *session_files = NULL;
|
2007-09-18 16:04:22 +00:00
|
|
|
static gint session_notebook_page;
|
2005-11-22 12:26:26 +00:00
|
|
|
static gint hpan_position;
|
2005-11-25 01:19:04 +00:00
|
|
|
static gint vpan_position;
|
2011-09-20 14:29:46 +00:00
|
|
|
static const gchar atomic_file_saving_key[] = "use_atomic_file_saving";
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-12-16 13:01:47 +00:00
|
|
|
static GPtrArray *keyfile_groups = NULL;
|
2011-09-20 14:29:46 +00:00
|
|
|
|
2008-12-11 12:49:26 +00:00
|
|
|
GPtrArray *pref_groups = NULL;
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2011-09-22 15:55:10 +00:00
|
|
|
static struct
|
|
|
|
{
|
2011-12-17 23:10:03 +01:00
|
|
|
gint number_ft_menu_items;
|
|
|
|
gint number_non_ft_menu_items;
|
|
|
|
gint number_exec_menu_items;
|
2011-09-22 15:55:10 +00:00
|
|
|
}
|
|
|
|
build_menu_prefs;
|
|
|
|
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2008-12-16 13:01:47 +00:00
|
|
|
/* The group will be free'd on quitting.
|
|
|
|
* @param for_prefs_dialog is whether the group also has Prefs dialog items. */
|
2010-03-18 17:04:17 +00:00
|
|
|
void configuration_add_pref_group(struct StashGroup *group, gboolean for_prefs_dialog)
|
2008-12-09 13:16:52 +00:00
|
|
|
{
|
2008-12-16 13:01:47 +00:00
|
|
|
g_ptr_array_add(keyfile_groups, group);
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2008-12-16 13:01:47 +00:00
|
|
|
if (for_prefs_dialog)
|
|
|
|
g_ptr_array_add(pref_groups, group);
|
2008-12-09 13:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-22 11:52:58 +00:00
|
|
|
/* The group will be free'd on quitting. */
|
|
|
|
void configuration_add_various_pref_group(struct StashGroup *group)
|
|
|
|
{
|
|
|
|
configuration_add_pref_group(group, TRUE);
|
|
|
|
stash_group_set_various(group, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-09 13:16:52 +00:00
|
|
|
static void init_pref_groups(void)
|
|
|
|
{
|
2010-03-18 17:04:17 +00:00
|
|
|
StashGroup *group;
|
2008-12-09 13:16:52 +00:00
|
|
|
|
|
|
|
group = stash_group_new(PACKAGE);
|
2008-12-16 13:01:47 +00:00
|
|
|
configuration_add_pref_group(group, TRUE);
|
2008-12-22 17:13:37 +00:00
|
|
|
stash_group_add_entry(group, &prefs.default_open_path,
|
|
|
|
"default_open_path", "", "startup_path_entry");
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2008-12-11 12:49:26 +00:00
|
|
|
stash_group_add_toggle_button(group, &file_prefs.cmdline_new_files,
|
|
|
|
"cmdline_new_files", TRUE, "check_cmdline_new_files");
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2008-12-11 16:29:54 +00:00
|
|
|
stash_group_add_toggle_button(group, &interface_prefs.notebook_double_click_hides_widgets,
|
|
|
|
"notebook_double_click_hides_widgets", FALSE, "check_double_click_hides_widgets");
|
2011-12-16 19:16:20 +01:00
|
|
|
stash_group_add_toggle_button(group, &file_prefs.tab_close_switch_to_mru,
|
|
|
|
"tab_close_switch_to_mru", FALSE, "check_tab_close_switch_to_mru");
|
2009-07-16 15:50:13 +00:00
|
|
|
stash_group_add_integer(group, &interface_prefs.tab_pos_sidebar, "tab_pos_sidebar", GTK_POS_TOP);
|
2009-10-23 16:18:05 +00:00
|
|
|
stash_group_add_radio_buttons(group, &interface_prefs.sidebar_pos,
|
|
|
|
"sidebar_pos", GTK_POS_LEFT,
|
|
|
|
"radio_sidebar_left", GTK_POS_LEFT,
|
|
|
|
"radio_sidebar_right", GTK_POS_RIGHT,
|
|
|
|
NULL);
|
2008-12-11 16:29:54 +00:00
|
|
|
|
2009-10-23 16:18:05 +00:00
|
|
|
/* editor display */
|
2009-01-14 19:19:08 +00:00
|
|
|
stash_group_add_toggle_button(group, &interface_prefs.highlighting_invert_all,
|
|
|
|
"highlighting_invert_all", FALSE, "check_highlighting_invert");
|
|
|
|
|
2008-12-11 12:49:26 +00:00
|
|
|
stash_group_add_toggle_button(group, &search_prefs.use_current_word,
|
|
|
|
"pref_main_search_use_current_word", TRUE, "check_search_use_current_word");
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2009-01-08 17:14:18 +00:00
|
|
|
/* editor */
|
2008-12-11 12:49:26 +00:00
|
|
|
stash_group_add_toggle_button(group, &editor_prefs.indentation->detect_type,
|
2011-03-26 17:25:24 +00:00
|
|
|
"check_detect_indent", FALSE, "check_detect_indent_type");
|
|
|
|
stash_group_add_toggle_button(group, &editor_prefs.indentation->detect_width,
|
|
|
|
"detect_indent_width", FALSE, "check_detect_indent_width");
|
2008-12-11 12:49:26 +00:00
|
|
|
stash_group_add_toggle_button(group, &editor_prefs.use_tab_to_indent,
|
|
|
|
"use_tab_to_indent", TRUE, "check_tab_key_indents");
|
2008-12-22 16:03:16 +00:00
|
|
|
stash_group_add_spin_button_integer(group, &editor_prefs.indentation->width,
|
|
|
|
"pref_editor_tab_width", 4, "spin_indent_width");
|
2009-01-16 20:34:34 +00:00
|
|
|
stash_group_add_combo_box(group, (gint*)(void*)&editor_prefs.indentation->auto_indent_mode,
|
2008-12-22 16:03:16 +00:00
|
|
|
"indent_mode", GEANY_AUTOINDENT_CURRENTCHARS, "combo_auto_indent_mode");
|
2009-01-16 20:34:34 +00:00
|
|
|
stash_group_add_radio_buttons(group, (gint*)(void*)&editor_prefs.indentation->type,
|
2008-12-15 13:02:29 +00:00
|
|
|
"indent_type", GEANY_INDENT_TYPE_TABS,
|
|
|
|
"radio_indent_spaces", GEANY_INDENT_TYPE_SPACES,
|
|
|
|
"radio_indent_tabs", GEANY_INDENT_TYPE_TABS,
|
|
|
|
"radio_indent_both", GEANY_INDENT_TYPE_BOTH,
|
|
|
|
NULL);
|
2010-03-07 10:36:27 +00:00
|
|
|
stash_group_add_radio_buttons(group, (gint*)(void*)&editor_prefs.show_virtual_space,
|
|
|
|
"virtualspace", GEANY_VIRTUAL_SPACE_SELECTION,
|
|
|
|
"radio_virtualspace_disabled", GEANY_VIRTUAL_SPACE_DISABLED,
|
|
|
|
"radio_virtualspace_selection", GEANY_VIRTUAL_SPACE_SELECTION,
|
|
|
|
"radio_virtualspace_always", GEANY_VIRTUAL_SPACE_ALWAYS,
|
|
|
|
NULL);
|
2009-07-08 12:29:20 +00:00
|
|
|
stash_group_add_toggle_button(group, &editor_prefs.autocomplete_doc_words,
|
|
|
|
"autocomplete_doc_words", FALSE, "check_autocomplete_doc_words");
|
2009-07-09 11:18:45 +00:00
|
|
|
stash_group_add_toggle_button(group, &editor_prefs.completion_drops_rest_of_word,
|
|
|
|
"completion_drops_rest_of_word", FALSE, "check_completion_drops_rest_of_word");
|
2008-12-22 16:03:16 +00:00
|
|
|
stash_group_add_spin_button_integer(group, (gint*)&editor_prefs.autocompletion_max_entries,
|
|
|
|
"autocompletion_max_entries", GEANY_MAX_AUTOCOMPLETE_WORDS,
|
|
|
|
"spin_autocompletion_max_entries");
|
2011-03-05 22:46:32 +00:00
|
|
|
stash_group_add_spin_button_integer(group, (gint*)&editor_prefs.autocompletion_update_freq,
|
|
|
|
"autocompletion_update_freq", GEANY_MAX_SYMBOLS_UPDATE_FREQ, "spin_symbol_update_freq");
|
2009-11-04 12:36:56 +00:00
|
|
|
stash_group_add_string(group, &editor_prefs.color_scheme,
|
|
|
|
"color_scheme", NULL);
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2009-01-08 17:14:18 +00:00
|
|
|
/* files */
|
|
|
|
stash_group_add_spin_button_integer(group, (gint*)&file_prefs.mru_length,
|
|
|
|
"mru_length", GEANY_DEFAULT_MRU_LENGTH, "spin_mru");
|
|
|
|
stash_group_add_spin_button_integer(group, &file_prefs.disk_check_timeout,
|
|
|
|
"disk_check_timeout", GEANY_DISK_CHECK_TIMEOUT, "spin_disk_check");
|
|
|
|
|
2011-07-28 17:59:22 +00:00
|
|
|
/* various geany prefs */
|
2008-12-09 13:16:52 +00:00
|
|
|
group = stash_group_new(PACKAGE);
|
2011-09-22 11:52:58 +00:00
|
|
|
configuration_add_various_pref_group(group);
|
2010-04-28 13:08:15 +00:00
|
|
|
|
2008-12-11 13:14:33 +00:00
|
|
|
stash_group_add_boolean(group, &editor_prefs.show_scrollbars,
|
|
|
|
"show_editor_scrollbars", TRUE);
|
|
|
|
stash_group_add_boolean(group, &editor_prefs.brace_match_ltgt,
|
|
|
|
"brace_match_ltgt", FALSE);
|
|
|
|
stash_group_add_boolean(group, &editor_prefs.use_gtk_word_boundaries,
|
|
|
|
"use_gtk_word_boundaries", TRUE);
|
|
|
|
stash_group_add_boolean(group, &editor_prefs.complete_snippets_whilst_editing,
|
|
|
|
"complete_snippets_whilst_editing", FALSE);
|
2009-04-21 20:54:04 +00:00
|
|
|
stash_group_add_boolean(group, &file_prefs.use_safe_file_saving,
|
2011-09-20 14:29:46 +00:00
|
|
|
atomic_file_saving_key, FALSE);
|
2010-11-23 16:23:22 +00:00
|
|
|
stash_group_add_boolean(group, &file_prefs.gio_unsafe_save_backup,
|
|
|
|
"gio_unsafe_save_backup", FALSE);
|
2011-06-20 16:11:18 +00:00
|
|
|
stash_group_add_boolean(group, &file_prefs.use_gio_unsafe_file_saving,
|
|
|
|
"use_gio_unsafe_file_saving", TRUE);
|
2010-04-28 13:08:15 +00:00
|
|
|
/* for backwards-compatibility */
|
|
|
|
stash_group_add_integer(group, &editor_prefs.indentation->hard_tab_width,
|
|
|
|
"indent_hard_tab_width", 8);
|
2010-09-23 12:22:44 +00:00
|
|
|
stash_group_add_integer(group, (gint*)&search_prefs.find_selection_type,
|
|
|
|
"find_selection_type", GEANY_FIND_SEL_CURRENT_WORD);
|
2011-10-22 22:55:57 +11:00
|
|
|
stash_group_add_string(group, &file_prefs.extract_filetype_regex,
|
|
|
|
"extract_filetype_regex", GEANY_DEFAULT_FILETYPE_REGEX);
|
2010-09-23 12:22:44 +00:00
|
|
|
|
2011-07-28 17:59:22 +00:00
|
|
|
/* Note: Interface-related various prefs are in ui_init_prefs() */
|
|
|
|
|
|
|
|
/* various build-menu prefs */
|
|
|
|
group = stash_group_new("build-menu");
|
2011-09-22 11:52:58 +00:00
|
|
|
configuration_add_various_pref_group(group);
|
2011-07-28 17:59:22 +00:00
|
|
|
|
|
|
|
stash_group_add_integer(group, &build_menu_prefs.number_ft_menu_items,
|
|
|
|
"number_ft_menu_items", 0);
|
|
|
|
stash_group_add_integer(group, &build_menu_prefs.number_non_ft_menu_items,
|
|
|
|
"number_non_ft_menu_items", 0);
|
|
|
|
stash_group_add_integer(group, &build_menu_prefs.number_exec_menu_items,
|
|
|
|
"number_exec_menu_items", 0);
|
2008-12-09 13:16:52 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-11-28 12:52:19 +00:00
|
|
|
typedef enum SettingAction
|
2008-07-29 17:49:29 +00:00
|
|
|
{
|
|
|
|
SETTING_READ,
|
|
|
|
SETTING_WRITE
|
|
|
|
}
|
2008-11-28 12:52:19 +00:00
|
|
|
SettingAction;
|
2008-07-29 17:49:29 +00:00
|
|
|
|
2008-11-28 12:52:19 +00:00
|
|
|
static void settings_action(GKeyFile *config, SettingAction action)
|
2008-07-29 17:49:29 +00:00
|
|
|
{
|
2009-07-20 12:25:24 +00:00
|
|
|
guint i;
|
2010-03-18 17:04:17 +00:00
|
|
|
StashGroup *group;
|
2008-07-29 17:49:29 +00:00
|
|
|
|
2009-07-20 12:25:24 +00:00
|
|
|
foreach_ptr_array(group, i, keyfile_groups)
|
2008-07-29 17:49:29 +00:00
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case SETTING_READ:
|
2008-12-22 12:50:19 +00:00
|
|
|
stash_group_load_from_key_file(group, config); break;
|
2008-07-29 17:49:29 +00:00
|
|
|
case SETTING_WRITE:
|
2008-12-22 12:50:19 +00:00
|
|
|
stash_group_save_to_key_file(group, config); break;
|
2008-07-29 17:49:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 14:14:29 +00:00
|
|
|
static void save_recent_files(GKeyFile *config, GQueue *queue, gchar const *key)
|
2007-04-20 16:31:19 +00:00
|
|
|
{
|
2008-05-16 12:08:39 +00:00
|
|
|
gchar **recent_files = g_new0(gchar*, file_prefs.mru_length + 1);
|
2007-04-20 16:31:19 +00:00
|
|
|
guint i;
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
for (i = 0; i < file_prefs.mru_length; i++)
|
2007-04-20 16:31:19 +00:00
|
|
|
{
|
2009-04-05 14:14:29 +00:00
|
|
|
if (! g_queue_is_empty(queue))
|
2007-04-20 16:31:19 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* copy the values, this is necessary when this function is called from the
|
|
|
|
* preferences dialog or when quitting is canceled to keep the queue intact */
|
2009-04-05 14:14:29 +00:00
|
|
|
recent_files[i] = g_strdup(g_queue_peek_nth(queue, i));
|
2007-04-20 16:31:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
recent_files[i] = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-02-27 13:17:29 +00:00
|
|
|
/* There is a bug in GTK 2.6 g_key_file_set_string_list, we must NULL terminate. */
|
2008-05-16 12:08:39 +00:00
|
|
|
recent_files[file_prefs.mru_length] = NULL;
|
2009-04-05 14:14:29 +00:00
|
|
|
g_key_file_set_string_list(config, "files", key,
|
2008-05-16 12:08:39 +00:00
|
|
|
(const gchar**)recent_files, file_prefs.mru_length);
|
2007-04-20 16:31:19 +00:00
|
|
|
g_strfreev(recent_files);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
static gchar *get_session_file_string(GeanyDocument *doc)
|
2008-04-29 12:00:13 +00:00
|
|
|
{
|
|
|
|
gchar *fname;
|
2009-03-25 19:00:34 +00:00
|
|
|
gchar *locale_filename;
|
2011-10-23 13:41:10 +11:00
|
|
|
gchar *escaped_filename;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyFiletype *ft = doc->file_type;
|
2008-04-29 12:00:13 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (ft == NULL) /* can happen when saving a new file when quitting */
|
2008-05-07 13:54:21 +00:00
|
|
|
ft = filetypes[GEANY_FILETYPES_NONE];
|
2008-04-29 12:00:13 +00:00
|
|
|
|
2009-03-25 19:00:34 +00:00
|
|
|
locale_filename = utils_get_locale_from_utf8(doc->file_name);
|
2011-10-23 13:41:10 +11:00
|
|
|
escaped_filename = g_uri_escape_string(locale_filename, NULL, TRUE);
|
2008-11-23 18:43:09 +00:00
|
|
|
|
2010-09-15 14:59:41 +00:00
|
|
|
fname = g_strdup_printf("%d;%s;%d;%d;%d;%d;%d;%s;%d;%d",
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_get_current_position(doc->editor->sci),
|
2008-05-01 12:10:46 +00:00
|
|
|
ft->name,
|
2008-06-15 13:35:48 +00:00
|
|
|
doc->readonly,
|
|
|
|
encodings_get_idx_from_charset(doc->encoding),
|
2008-08-04 14:07:49 +00:00
|
|
|
doc->editor->indent_type,
|
2008-07-08 16:30:37 +00:00
|
|
|
doc->editor->auto_indent,
|
|
|
|
doc->editor->line_wrapping,
|
2011-10-23 13:41:10 +11:00
|
|
|
escaped_filename,
|
2010-09-15 14:59:41 +00:00
|
|
|
doc->editor->line_breaking,
|
|
|
|
doc->editor->indent_width);
|
2011-10-23 13:41:10 +11:00
|
|
|
g_free(escaped_filename);
|
2009-03-25 19:00:34 +00:00
|
|
|
g_free(locale_filename);
|
2008-04-29 12:00:13 +00:00
|
|
|
return fname;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-11 19:06:41 +00:00
|
|
|
void configuration_save_session_files(GKeyFile *config)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
gint npage;
|
2007-04-20 16:31:19 +00:00
|
|
|
gchar *tmp;
|
2008-07-03 12:51:14 +00:00
|
|
|
gchar entry[16];
|
2007-04-20 16:31:19 +00:00
|
|
|
guint i = 0, j = 0, max;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc;
|
2007-04-20 16:31:19 +00:00
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
npage = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
|
2007-09-18 16:04:22 +00:00
|
|
|
g_key_file_set_integer(config, "files", "current_page", npage);
|
|
|
|
|
2011-11-02 00:04:35 +01:00
|
|
|
/* store the filenames in the notebook tab order to reopen them the next time */
|
2008-05-22 14:41:28 +00:00
|
|
|
max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
|
2007-09-18 16:04:22 +00:00
|
|
|
for (i = 0; i < max; i++)
|
2007-04-20 16:31:19 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
doc = document_get_from_page(i);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc != NULL && doc->real_path != NULL)
|
2007-04-20 16:31:19 +00:00
|
|
|
{
|
2007-09-18 16:04:22 +00:00
|
|
|
gchar *fname;
|
|
|
|
|
2008-07-03 12:51:14 +00:00
|
|
|
g_snprintf(entry, sizeof(entry), "FILE_NAME_%d", j);
|
2008-06-15 13:35:48 +00:00
|
|
|
fname = get_session_file_string(doc);
|
2007-09-18 16:04:22 +00:00
|
|
|
g_key_file_set_string(config, "files", entry, fname);
|
|
|
|
g_free(fname);
|
|
|
|
j++;
|
2007-04-20 16:31:19 +00:00
|
|
|
}
|
2007-09-18 16:04:22 +00:00
|
|
|
}
|
2008-02-27 13:17:29 +00:00
|
|
|
/* if open filenames less than saved session files, delete existing entries in the list */
|
2007-09-18 16:04:22 +00:00
|
|
|
i = j;
|
|
|
|
while (TRUE)
|
|
|
|
{
|
2008-07-03 12:51:14 +00:00
|
|
|
g_snprintf(entry, sizeof(entry), "FILE_NAME_%d", i);
|
2007-09-18 16:04:22 +00:00
|
|
|
tmp = g_key_file_get_string(config, "files", entry, NULL);
|
2009-04-05 21:07:40 +00:00
|
|
|
if (G_UNLIKELY(tmp == NULL))
|
2007-04-20 16:31:19 +00:00
|
|
|
{
|
2007-09-18 16:04:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_key_file_remove_key(config, "files", entry, NULL);
|
|
|
|
g_free(tmp);
|
|
|
|
i++;
|
2007-04-20 16:31:19 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-11 12:40:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_VTE
|
|
|
|
if (vte_info.have_vte)
|
|
|
|
{
|
|
|
|
vte_get_working_directory(); /* refresh vte_info.dir */
|
|
|
|
g_key_file_set_string(config, "VTE", "last_dir", vte_info.dir);
|
|
|
|
}
|
|
|
|
#endif
|
2007-04-20 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-24 15:44:07 +00:00
|
|
|
static void save_dialog_prefs(GKeyFile *config)
|
2007-04-20 16:31:19 +00:00
|
|
|
{
|
2008-12-09 13:18:55 +00:00
|
|
|
/* new settings should be added in init_pref_groups() */
|
2008-07-29 17:49:29 +00:00
|
|
|
settings_action(config, SETTING_WRITE);
|
2008-06-25 11:56:58 +00:00
|
|
|
|
2007-08-27 16:39:49 +00:00
|
|
|
/* Some of the key names are not consistent, but this is for backwards compatibility */
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* general */
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", prefs.load_session);
|
2008-01-16 16:30:34 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_main_project_session", project_prefs.project_session);
|
2008-10-02 15:09:33 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_main_project_file_in_basedir", project_prefs.project_file_in_basedir);
|
2007-08-24 15:44:07 +00:00
|
|
|
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_status_messages", prefs.suppress_status_messages);
|
2008-05-16 12:08:39 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_to_status);
|
2007-08-24 15:44:07 +00:00
|
|
|
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);
|
2005-11-25 01:19:04 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* interface */
|
2008-05-16 12:08:39 +00:00
|
|
|
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_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);
|
2010-05-16 17:45:39 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "tab_order_beside", file_prefs.tab_order_beside);
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2010-05-16 18:22:24 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "use_native_windows_dialogs", interface_prefs.use_native_windows_dialogs);
|
2007-08-24 15:44:07 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* display */
|
2007-08-27 16:39:49 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", editor_prefs.show_indent_guide);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_white_space", editor_prefs.show_white_space);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_line_endings", editor_prefs.show_line_endings);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_markers_margin", editor_prefs.show_markers_margin);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_linenumber_margin", editor_prefs.show_linenumber_margin);
|
2010-11-23 17:36:29 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "long_line_enabled", editor_prefs.long_line_enabled);
|
|
|
|
g_key_file_set_integer(config, PACKAGE, "long_line_type", editor_prefs.long_line_type);
|
|
|
|
g_key_file_set_integer(config, PACKAGE, "long_line_column", editor_prefs.long_line_column);
|
2007-08-23 11:34:06 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "long_line_color", editor_prefs.long_line_color);
|
2007-08-27 16:39:49 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* editor */
|
2007-11-12 09:27:43 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "symbolcompletion_max_height", editor_prefs.symbolcompletion_max_height);
|
2007-12-01 17:53:36 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "symbolcompletion_min_chars", editor_prefs.symbolcompletion_min_chars);
|
2007-05-29 16:30:54 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "use_folding", editor_prefs.folding);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "unfold_all_children", editor_prefs.unfold_all_children);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "use_indicators", editor_prefs.use_indicators);
|
2008-05-09 14:17:25 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "line_wrapping", editor_prefs.line_wrapping);
|
2007-05-29 16:30:54 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "auto_close_xml_tags", editor_prefs.auto_close_xml_tags);
|
2007-11-12 09:27:43 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "complete_snippets", editor_prefs.complete_snippets);
|
2007-05-29 16:30:54 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "auto_complete_symbols", editor_prefs.auto_complete_symbols);
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_editor_disable_dnd", editor_prefs.disable_dnd);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_editor_smart_home_key", editor_prefs.smart_home_key);
|
2007-10-18 11:52:47 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_editor_newline_strip", editor_prefs.newline_strip);
|
2008-05-09 12:13:29 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "line_break_column", editor_prefs.line_break_column);
|
2008-05-14 15:36:27 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "auto_continue_multiline", editor_prefs.auto_continue_multiline);
|
2008-07-27 18:41:07 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "comment_toggle_mark", editor_prefs.comment_toggle_mark);
|
2008-09-01 11:18:06 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "scroll_stop_at_last_line", editor_prefs.scroll_stop_at_last_line);
|
2008-12-04 20:19:20 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "autoclose_chars", editor_prefs.autoclose_chars);
|
2007-08-27 16:39:49 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* files */
|
2008-05-16 12:08:39 +00:00
|
|
|
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)
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", "none");
|
|
|
|
else
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2010-10-25 16:24:55 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_editor_ensure_convert_line_endings", file_prefs.ensure_convert_new_lines);
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2007-08-24 15:44:07 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* toolbar */
|
2008-05-16 12:08:39 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", toolbar_prefs.visible);
|
2009-03-29 16:15:35 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_append_to_menu", toolbar_prefs.append_to_menu);
|
2010-04-11 21:56:08 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_style", toolbar_prefs.use_gtk_default_style);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_icon", toolbar_prefs.use_gtk_default_icon);
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2007-08-24 15:44:07 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* templates */
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2008-07-13 11:51:00 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_year", template_prefs.year_format);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_date", template_prefs.date_format);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_datetime", template_prefs.datetime_format);
|
2007-08-24 15:44:07 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* tools settings */
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2007-08-24 15:44:07 +00:00
|
|
|
|
2009-07-09 06:49:42 +00:00
|
|
|
/* build menu */
|
2009-09-16 14:13:38 +00:00
|
|
|
build_save_menu(config, NULL, GEANY_BCS_PREF);
|
2009-08-27 16:31:53 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* printing */
|
2007-11-17 14:04:27 +00:00
|
|
|
g_key_file_set_string(config, "printing", "print_cmd", printing_prefs.external_print_cmd ? printing_prefs.external_print_cmd : "");
|
|
|
|
g_key_file_set_boolean(config, "printing", "use_gtk_printing", printing_prefs.use_gtk_printing);
|
|
|
|
g_key_file_set_boolean(config, "printing", "print_line_numbers", printing_prefs.print_line_numbers);
|
|
|
|
g_key_file_set_boolean(config, "printing", "print_page_numbers", printing_prefs.print_page_numbers);
|
|
|
|
g_key_file_set_boolean(config, "printing", "print_page_header", printing_prefs.print_page_header);
|
|
|
|
g_key_file_set_boolean(config, "printing", "page_header_basename", printing_prefs.page_header_basename);
|
|
|
|
g_key_file_set_string(config, "printing", "page_header_datefmt", printing_prefs.page_header_datefmt);
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* VTE */
|
2005-12-16 23:23:18 +00:00
|
|
|
#ifdef HAVE_VTE
|
2006-08-22 19:03:38 +00:00
|
|
|
g_key_file_set_boolean(config, "VTE", "load_vte", vte_info.load_vte);
|
2010-12-07 13:16:57 +00:00
|
|
|
if (vte_info.have_vte)
|
2006-08-22 19:03:38 +00:00
|
|
|
{
|
|
|
|
gchar *tmp_string;
|
|
|
|
|
2008-12-01 14:39:26 +00:00
|
|
|
if (!g_key_file_has_key(config, "VTE", "emulation", NULL)) /* hidden */
|
|
|
|
g_key_file_set_string(config, "VTE", "emulation", vc->emulation);
|
2009-11-29 20:59:31 +00:00
|
|
|
if (!g_key_file_has_key(config, "VTE", "send_selection_unsafe", NULL)) /* hidden */
|
|
|
|
g_key_file_set_boolean(config, "VTE", "send_selection_unsafe",
|
|
|
|
vc->send_selection_unsafe);
|
2011-11-17 03:36:11 +01:00
|
|
|
if (!g_key_file_has_key(config, "VTE", "send_cmd_prefix", NULL)) /* hidden */
|
|
|
|
g_key_file_set_string(config, "VTE", "send_cmd_prefix", vc->send_cmd_prefix);
|
2006-08-22 19:03:38 +00:00
|
|
|
g_key_file_set_string(config, "VTE", "font", vc->font);
|
|
|
|
g_key_file_set_boolean(config, "VTE", "scroll_on_key", vc->scroll_on_key);
|
|
|
|
g_key_file_set_boolean(config, "VTE", "scroll_on_out", vc->scroll_on_out);
|
2008-01-10 17:11:19 +00:00
|
|
|
g_key_file_set_boolean(config, "VTE", "enable_bash_keys", vc->enable_bash_keys);
|
2006-08-22 19:03:38 +00:00
|
|
|
g_key_file_set_boolean(config, "VTE", "ignore_menu_bar_accel", vc->ignore_menu_bar_accel);
|
|
|
|
g_key_file_set_boolean(config, "VTE", "follow_path", vc->follow_path);
|
2006-12-10 21:29:04 +00:00
|
|
|
g_key_file_set_boolean(config, "VTE", "run_in_vte", vc->run_in_vte);
|
2007-12-17 16:58:26 +00:00
|
|
|
g_key_file_set_boolean(config, "VTE", "skip_run_script", vc->skip_run_script);
|
2008-12-07 19:11:36 +00:00
|
|
|
g_key_file_set_boolean(config, "VTE", "cursor_blinks", vc->cursor_blinks);
|
2006-08-22 19:03:38 +00:00
|
|
|
g_key_file_set_integer(config, "VTE", "scrollback_lines", vc->scrollback_lines);
|
|
|
|
g_key_file_set_string(config, "VTE", "font", vc->font);
|
|
|
|
g_key_file_set_string(config, "VTE", "shell", vc->shell);
|
|
|
|
tmp_string = utils_get_hex_from_color(vc->colour_fore);
|
|
|
|
g_key_file_set_string(config, "VTE", "colour_fore", tmp_string);
|
|
|
|
g_free(tmp_string);
|
|
|
|
tmp_string = utils_get_hex_from_color(vc->colour_back);
|
|
|
|
g_key_file_set_string(config, "VTE", "colour_back", tmp_string);
|
|
|
|
g_free(tmp_string);
|
|
|
|
}
|
2005-12-16 23:23:18 +00:00
|
|
|
#endif
|
2007-08-24 15:44:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void save_ui_prefs(GKeyFile *config)
|
|
|
|
{
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "sidebar_visible", ui_prefs.sidebar_visible);
|
2008-05-16 12:08:39 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "statusbar_visible", interface_prefs.statusbar_visible);
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", ui_prefs.msgwindow_visible);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "fullscreen", ui_prefs.fullscreen);
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* get the text from the scribble textview */
|
2007-02-25 14:26:55 +00:00
|
|
|
{
|
2007-08-24 15:44:07 +00:00
|
|
|
GtkTextBuffer *buffer;
|
2009-05-13 15:21:54 +00:00
|
|
|
GtkTextIter start, end, iter;
|
|
|
|
GtkTextMark *mark;
|
2007-08-24 15:44:07 +00:00
|
|
|
|
2009-12-20 20:07:04 +00:00
|
|
|
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(msgwindow.scribble));
|
2007-08-24 15:44:07 +00:00
|
|
|
gtk_text_buffer_get_bounds(buffer, &start, &end);
|
|
|
|
scribble_text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "scribble_text", scribble_text);
|
|
|
|
g_free(scribble_text);
|
2009-05-13 15:21:54 +00:00
|
|
|
|
|
|
|
mark = gtk_text_buffer_get_insert(buffer);
|
|
|
|
gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
|
|
|
|
scribble_pos = gtk_text_iter_get_offset(&iter);
|
|
|
|
g_key_file_set_integer(config, PACKAGE, "scribble_pos", scribble_pos);
|
2007-08-24 15:44:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (prefs.save_winpos)
|
|
|
|
{
|
2011-12-08 16:31:21 +00:00
|
|
|
GdkWindowState wstate;
|
|
|
|
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "treeview_position",
|
2008-12-18 21:21:53 +00:00
|
|
|
gtk_paned_get_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "hpaned1"))));
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "msgwindow_position",
|
2008-12-18 21:21:53 +00:00
|
|
|
gtk_paned_get_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "vpaned1"))));
|
2007-02-25 14:26:55 +00:00
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_window_get_position(GTK_WINDOW(main_widgets.window), &ui_prefs.geometry[0], &ui_prefs.geometry[1]);
|
|
|
|
gtk_window_get_size(GTK_WINDOW(main_widgets.window), &ui_prefs.geometry[2], &ui_prefs.geometry[3]);
|
2011-12-08 16:31:21 +00:00
|
|
|
wstate = gdk_window_get_state(gtk_widget_get_window(main_widgets.window));
|
|
|
|
ui_prefs.geometry[4] = (wstate & GDK_WINDOW_STATE_MAXIMIZED) ? 1 : 0;
|
2007-08-23 11:34:06 +00:00
|
|
|
g_key_file_set_integer_list(config, PACKAGE, "geometry", ui_prefs.geometry, 5);
|
2006-01-11 18:41:32 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "custom_date_format", ui_prefs.custom_date_format);
|
|
|
|
if (ui_prefs.custom_commands != NULL)
|
|
|
|
{
|
|
|
|
g_key_file_set_string_list(config, PACKAGE, "custom_commands",
|
|
|
|
(const gchar**) ui_prefs.custom_commands, g_strv_length(ui_prefs.custom_commands));
|
2012-05-14 22:22:29 +02:00
|
|
|
g_key_file_set_string_list(config, PACKAGE, "custom_commands_labels",
|
|
|
|
(const gchar**) ui_prefs.custom_commands_labels, g_strv_length(ui_prefs.custom_commands_labels));
|
2007-08-24 15:44:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void configuration_save(void)
|
2007-08-24 15:44:07 +00:00
|
|
|
{
|
|
|
|
GKeyFile *config = g_key_file_new();
|
2012-08-09 18:15:47 -07:00
|
|
|
gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
|
2007-08-24 15:44:07 +00:00
|
|
|
gchar *data;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-08-24 15:44:07 +00:00
|
|
|
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
|
2007-08-16 15:20:38 +00:00
|
|
|
|
2008-12-28 13:21:35 +00:00
|
|
|
/* this signal can be used e.g. to prepare any settings before Stash code reads them below */
|
|
|
|
g_signal_emit_by_name(geany_object, "save-settings", config);
|
|
|
|
|
2007-08-24 15:44:07 +00:00
|
|
|
save_dialog_prefs(config);
|
|
|
|
save_ui_prefs(config);
|
2008-02-27 13:17:29 +00:00
|
|
|
project_save_prefs(config); /* save project filename, etc. */
|
2009-04-05 14:14:29 +00:00
|
|
|
save_recent_files(config, ui_prefs.recent_queue, "recent_files");
|
|
|
|
save_recent_files(config, ui_prefs.recent_projects_queue, "recent_projects");
|
2009-04-15 22:46:13 +00:00
|
|
|
|
2008-01-31 16:31:19 +00:00
|
|
|
if (cl_options.load_session)
|
|
|
|
configuration_save_session_files(config);
|
2011-04-11 12:40:34 +00:00
|
|
|
#ifdef HAVE_VTE
|
|
|
|
else if (vte_info.have_vte)
|
|
|
|
{
|
|
|
|
vte_get_working_directory(); /* refresh vte_info.dir */
|
|
|
|
g_key_file_set_string(config, "VTE", "last_dir", vte_info.dir);
|
|
|
|
}
|
|
|
|
#endif
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* write the file */
|
2006-02-25 22:27:41 +00:00
|
|
|
data = g_key_file_to_data(config, NULL, NULL);
|
|
|
|
utils_write_file(configfile, data);
|
|
|
|
g_free(data);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
g_key_file_free(config);
|
|
|
|
g_free(configfile);
|
|
|
|
}
|
|
|
|
|
2009-04-05 14:14:29 +00:00
|
|
|
|
|
|
|
static void load_recent_files(GKeyFile *config, GQueue *queue, const gchar *key)
|
|
|
|
{
|
|
|
|
gchar **recent_files;
|
|
|
|
gsize i, len = 0;
|
|
|
|
|
|
|
|
recent_files = g_key_file_get_string_list(config, "files", key, &len, NULL);
|
|
|
|
if (recent_files != NULL)
|
|
|
|
{
|
|
|
|
for (i = 0; (i < len) && (i < file_prefs.mru_length); i++)
|
|
|
|
{
|
|
|
|
gchar *filename = g_strdup(recent_files[i]);
|
|
|
|
g_queue_push_tail(queue, filename);
|
|
|
|
}
|
2009-04-15 22:46:13 +00:00
|
|
|
g_strfreev(recent_files);
|
2009-04-05 14:14:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-11 19:06:41 +00:00
|
|
|
/*
|
|
|
|
* Load session list from the given keyfile, and store it in the global
|
|
|
|
* session_files variable for later file loading
|
|
|
|
* */
|
2009-04-15 22:46:13 +00:00
|
|
|
void configuration_load_session_files(GKeyFile *config, gboolean read_recent_files)
|
2007-04-20 16:43:11 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
gboolean have_session_files;
|
2008-07-03 12:51:14 +00:00
|
|
|
gchar entry[16];
|
2007-12-07 14:13:05 +00:00
|
|
|
gchar **tmp_array;
|
2007-04-20 16:43:11 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
|
2007-09-18 16:04:22 +00:00
|
|
|
session_notebook_page = utils_get_setting_integer(config, "files", "current_page", -1);
|
|
|
|
|
2009-04-15 22:46:13 +00:00
|
|
|
if (read_recent_files)
|
|
|
|
{
|
|
|
|
load_recent_files(config, ui_prefs.recent_queue, "recent_files");
|
|
|
|
load_recent_files(config, ui_prefs.recent_projects_queue, "recent_projects");
|
|
|
|
}
|
2007-04-20 16:43:11 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* the project may load another list than the main setting */
|
2007-11-11 19:06:41 +00:00
|
|
|
if (session_files != NULL)
|
|
|
|
g_ptr_array_free(session_files, TRUE);
|
|
|
|
|
2007-04-20 16:43:11 +00:00
|
|
|
session_files = g_ptr_array_new();
|
|
|
|
have_session_files = TRUE;
|
|
|
|
i = 0;
|
2009-04-15 22:47:33 +00:00
|
|
|
while (have_session_files)
|
2007-04-20 16:43:11 +00:00
|
|
|
{
|
2008-07-03 12:51:14 +00:00
|
|
|
g_snprintf(entry, sizeof(entry), "FILE_NAME_%d", i);
|
2007-12-07 14:13:05 +00:00
|
|
|
tmp_array = g_key_file_get_string_list(config, "files", entry, NULL, &error);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! tmp_array || error)
|
2007-04-20 16:43:11 +00:00
|
|
|
{
|
|
|
|
g_error_free(error);
|
|
|
|
error = NULL;
|
|
|
|
have_session_files = FALSE;
|
|
|
|
}
|
2007-12-07 14:13:05 +00:00
|
|
|
g_ptr_array_add(session_files, tmp_array);
|
2007-04-20 16:43:11 +00:00
|
|
|
i++;
|
|
|
|
}
|
2011-04-11 12:40:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_VTE
|
|
|
|
/* BUG: after loading project at startup, closing project doesn't restore old VTE path */
|
|
|
|
if (vte_info.have_vte)
|
|
|
|
{
|
|
|
|
gchar *tmp_string = utils_get_setting_string(config, "VTE", "last_dir", NULL);
|
|
|
|
vte_cwd(tmp_string,TRUE);
|
|
|
|
g_free(tmp_string);
|
|
|
|
}
|
|
|
|
#endif
|
2007-04-20 16:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-20 14:29:46 +00:00
|
|
|
/* note: new settings should be added in init_pref_groups() */
|
2007-08-27 16:54:15 +00:00
|
|
|
static void load_dialog_prefs(GKeyFile *config)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gchar *tmp_string, *tmp_string2;
|
2007-05-26 15:09:06 +00:00
|
|
|
const gchar *default_charset = NULL;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2011-09-20 14:29:46 +00:00
|
|
|
/* compatibility with Geany 0.20 */
|
|
|
|
if (!g_key_file_has_key(config, PACKAGE, atomic_file_saving_key, NULL))
|
|
|
|
{
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, atomic_file_saving_key,
|
|
|
|
utils_get_setting_boolean(config, PACKAGE, "use_safe_file_saving", FALSE));
|
|
|
|
}
|
2011-10-11 21:52:58 -07:00
|
|
|
|
2011-12-05 21:24:33 +02:00
|
|
|
/* compatibility with Geany 0.21 */
|
|
|
|
{
|
|
|
|
gboolean suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE);
|
|
|
|
|
|
|
|
if (!g_key_file_has_key(config, "search", "pref_search_always_wrap", NULL))
|
|
|
|
g_key_file_set_boolean(config, "search", "pref_search_always_wrap", suppress_search_dialogs);
|
|
|
|
|
|
|
|
if (!g_key_file_has_key(config, "search", "pref_search_hide_find_dialog", NULL))
|
|
|
|
g_key_file_set_boolean(config, "search", "pref_search_hide_find_dialog", suppress_search_dialogs);
|
|
|
|
}
|
|
|
|
|
2011-09-20 14:29:46 +00:00
|
|
|
/* read stash prefs */
|
2008-07-29 17:49:29 +00:00
|
|
|
settings_action(config, SETTING_READ);
|
2008-06-25 11:56:58 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* general */
|
2007-08-28 15:10:13 +00:00
|
|
|
prefs.confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", FALSE);
|
|
|
|
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);
|
2008-01-16 16:30:34 +00:00
|
|
|
project_prefs.project_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_session", TRUE);
|
2008-10-02 15:09:33 +00:00
|
|
|
project_prefs.project_file_in_basedir = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_file_in_basedir", FALSE);
|
2007-08-28 15:10:13 +00:00
|
|
|
prefs.save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
|
2007-08-23 11:34:06 +00:00
|
|
|
prefs.beep_on_errors = utils_get_setting_boolean(config, PACKAGE, "beep_on_errors", TRUE);
|
2008-05-16 12:08:39 +00:00
|
|
|
prefs.switch_to_status = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE);
|
2007-08-28 15:10:13 +00:00
|
|
|
prefs.auto_focus = utils_get_setting_boolean(config, PACKAGE, "auto_focus", FALSE);
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* interface */
|
2008-05-16 12:08:39 +00:00
|
|
|
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.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.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);
|
2010-05-16 17:45:39 +00:00
|
|
|
file_prefs.tab_order_beside = utils_get_setting_boolean(config, PACKAGE, "tab_order_beside", FALSE);
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2010-05-16 18:22:24 +00:00
|
|
|
interface_prefs.use_native_windows_dialogs = utils_get_setting_boolean(config, PACKAGE, "use_native_windows_dialogs", FALSE);
|
2007-08-28 15:10:13 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* display, editor */
|
2010-11-23 17:36:29 +00:00
|
|
|
editor_prefs.long_line_enabled = utils_get_setting_boolean(config, PACKAGE, "long_line_enabled", TRUE);
|
|
|
|
editor_prefs.long_line_type = utils_get_setting_integer(config, PACKAGE, "long_line_type", 0);
|
|
|
|
if (editor_prefs.long_line_type == 2) /* backward compatibility */
|
2010-03-10 16:20:34 +00:00
|
|
|
{
|
2010-11-23 17:36:29 +00:00
|
|
|
editor_prefs.long_line_type = 0;
|
|
|
|
editor_prefs.long_line_enabled = FALSE;
|
2010-03-10 16:20:34 +00:00
|
|
|
}
|
2007-08-28 15:10:13 +00:00
|
|
|
editor_prefs.long_line_color = utils_get_setting_string(config, PACKAGE, "long_line_color", "#C2EBC2");
|
2010-11-23 17:36:29 +00:00
|
|
|
editor_prefs.long_line_column = utils_get_setting_integer(config, PACKAGE, "long_line_column", 72);
|
2007-12-01 17:53:36 +00:00
|
|
|
editor_prefs.symbolcompletion_min_chars = utils_get_setting_integer(config, PACKAGE, "symbolcompletion_min_chars", GEANY_MIN_SYMBOLLIST_CHARS);
|
2007-11-12 09:27:43 +00:00
|
|
|
editor_prefs.symbolcompletion_max_height = utils_get_setting_integer(config, PACKAGE, "symbolcompletion_max_height", GEANY_MAX_SYMBOLLIST_HEIGHT);
|
2008-05-09 14:17:25 +00:00
|
|
|
editor_prefs.line_wrapping = utils_get_setting_boolean(config, PACKAGE, "line_wrapping", FALSE); /* default is off for better performance */
|
2007-05-29 16:30:54 +00:00
|
|
|
editor_prefs.use_indicators = utils_get_setting_boolean(config, PACKAGE, "use_indicators", TRUE);
|
|
|
|
editor_prefs.show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);
|
|
|
|
editor_prefs.show_white_space = utils_get_setting_boolean(config, PACKAGE, "show_white_space", FALSE);
|
|
|
|
editor_prefs.show_line_endings = utils_get_setting_boolean(config, PACKAGE, "show_line_endings", FALSE);
|
2008-09-01 11:18:06 +00:00
|
|
|
editor_prefs.scroll_stop_at_last_line = utils_get_setting_boolean(config, PACKAGE, "scroll_stop_at_last_line", TRUE);
|
2007-05-29 16:30:54 +00:00
|
|
|
editor_prefs.auto_close_xml_tags = utils_get_setting_boolean(config, PACKAGE, "auto_close_xml_tags", TRUE);
|
2007-11-12 09:27:43 +00:00
|
|
|
editor_prefs.complete_snippets = utils_get_setting_boolean(config, PACKAGE, "complete_snippets", TRUE);
|
2007-05-29 16:30:54 +00:00
|
|
|
editor_prefs.auto_complete_symbols = utils_get_setting_boolean(config, PACKAGE, "auto_complete_symbols", TRUE);
|
|
|
|
editor_prefs.folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE);
|
|
|
|
editor_prefs.unfold_all_children = utils_get_setting_boolean(config, PACKAGE, "unfold_all_children", FALSE);
|
2007-08-23 11:34:06 +00:00
|
|
|
editor_prefs.show_markers_margin = utils_get_setting_boolean(config, PACKAGE, "show_markers_margin", TRUE);
|
|
|
|
editor_prefs.show_linenumber_margin = utils_get_setting_boolean(config, PACKAGE, "show_linenumber_margin", TRUE);
|
2007-08-28 15:10:13 +00:00
|
|
|
editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE);
|
|
|
|
editor_prefs.smart_home_key = utils_get_setting_boolean(config, PACKAGE, "pref_editor_smart_home_key", TRUE);
|
2007-10-18 11:52:47 +00:00
|
|
|
editor_prefs.newline_strip = utils_get_setting_boolean(config, PACKAGE, "pref_editor_newline_strip", FALSE);
|
2008-05-09 12:13:29 +00:00
|
|
|
editor_prefs.line_break_column = utils_get_setting_integer(config, PACKAGE, "line_break_column", 72);
|
2008-05-14 15:36:27 +00:00
|
|
|
editor_prefs.auto_continue_multiline = utils_get_setting_boolean(config, PACKAGE, "auto_continue_multiline", TRUE);
|
2008-07-27 18:41:07 +00:00
|
|
|
editor_prefs.comment_toggle_mark = utils_get_setting_string(config, PACKAGE, "comment_toggle_mark", GEANY_TOGGLE_MARK);
|
2008-12-04 20:19:20 +00:00
|
|
|
editor_prefs.autoclose_chars = utils_get_setting_integer(config, PACKAGE, "autoclose_chars", 0);
|
2007-08-28 15:10:13 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* Files
|
|
|
|
* use current locale encoding as default for new files (should be UTF-8 in most cases) */
|
2007-05-26 15:09:06 +00:00
|
|
|
g_get_charset(&default_charset);
|
2007-06-26 15:41:27 +00:00
|
|
|
tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_new_encoding",
|
2007-08-28 15:10:13 +00:00
|
|
|
default_charset);
|
2006-07-25 09:12:51 +00:00
|
|
|
if (tmp_string)
|
|
|
|
{
|
|
|
|
const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
|
|
|
|
if (enc != NULL)
|
2008-05-16 12:08:39 +00:00
|
|
|
file_prefs.default_new_encoding = enc->idx;
|
2007-06-26 15:41:27 +00:00
|
|
|
else
|
2008-05-16 12:08:39 +00:00
|
|
|
file_prefs.default_new_encoding = GEANY_ENCODING_UTF_8;
|
2007-06-26 15:41:27 +00:00
|
|
|
|
|
|
|
g_free(tmp_string);
|
|
|
|
}
|
2007-08-28 15:10:13 +00:00
|
|
|
tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_open_encoding",
|
|
|
|
"none");
|
2007-06-26 15:41:27 +00:00
|
|
|
if (tmp_string)
|
|
|
|
{
|
|
|
|
const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (enc != NULL)
|
2008-05-16 12:08:39 +00:00
|
|
|
file_prefs.default_open_encoding = enc->idx;
|
2006-07-25 09:12:51 +00:00
|
|
|
else
|
2008-05-16 12:08:39 +00:00
|
|
|
file_prefs.default_open_encoding = -1;
|
2006-07-25 09:12:51 +00:00
|
|
|
|
|
|
|
g_free(tmp_string);
|
|
|
|
}
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2010-10-25 16:24:55 +00:00
|
|
|
file_prefs.ensure_convert_new_lines = utils_get_setting_boolean(config, PACKAGE, "pref_editor_ensure_convert_line_endings", FALSE);
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2007-08-28 15:10:13 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* toolbar */
|
2008-05-16 12:08:39 +00:00
|
|
|
toolbar_prefs.visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE);
|
2009-03-29 16:15:35 +00:00
|
|
|
toolbar_prefs.append_to_menu = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_append_to_menu", FALSE);
|
2007-08-28 15:10:13 +00:00
|
|
|
{
|
2010-04-11 21:56:08 +00:00
|
|
|
toolbar_prefs.use_gtk_default_style = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_style", TRUE);
|
|
|
|
if (! toolbar_prefs.use_gtk_default_style)
|
|
|
|
toolbar_prefs.icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", GTK_TOOLBAR_ICONS);
|
|
|
|
|
|
|
|
toolbar_prefs.use_gtk_default_icon = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_icon", TRUE);
|
|
|
|
if (! toolbar_prefs.use_gtk_default_icon)
|
|
|
|
toolbar_prefs.icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", GTK_ICON_SIZE_LARGE_TOOLBAR);
|
2007-08-28 15:10:13 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* VTE */
|
2005-12-16 23:23:18 +00:00
|
|
|
#ifdef HAVE_VTE
|
2006-08-22 19:03:38 +00:00
|
|
|
vte_info.load_vte = utils_get_setting_boolean(config, "VTE", "load_vte", TRUE);
|
|
|
|
if (vte_info.load_vte)
|
|
|
|
{
|
|
|
|
struct passwd *pw = getpwuid(getuid());
|
2010-04-25 17:43:39 +00:00
|
|
|
const gchar *shell = (pw != NULL) ? pw->pw_shell : "/bin/sh";
|
2006-08-22 19:03:38 +00:00
|
|
|
|
|
|
|
vc = g_new0(VteConfig, 1);
|
|
|
|
vte_info.dir = utils_get_setting_string(config, "VTE", "last_dir", NULL);
|
2006-12-07 16:09:45 +00:00
|
|
|
if ((vte_info.dir == NULL || utils_str_equal(vte_info.dir, "")) && pw != NULL)
|
2008-02-27 13:17:29 +00:00
|
|
|
/* last dir is not set, fallback to user's home directory */
|
2006-08-22 19:03:38 +00:00
|
|
|
vte_info.dir = g_strdup(pw->pw_dir);
|
|
|
|
else if (vte_info.dir == NULL && pw == NULL)
|
2008-02-27 13:17:29 +00:00
|
|
|
/* fallback to root */
|
2006-08-22 19:03:38 +00:00
|
|
|
vte_info.dir = g_strdup("/");
|
|
|
|
|
|
|
|
vc->emulation = utils_get_setting_string(config, "VTE", "emulation", "xterm");
|
2009-11-29 20:59:31 +00:00
|
|
|
vc->send_selection_unsafe = utils_get_setting_boolean(config, "VTE",
|
|
|
|
"send_selection_unsafe", FALSE);
|
2006-08-22 19:03:38 +00:00
|
|
|
vc->shell = utils_get_setting_string(config, "VTE", "shell", shell);
|
|
|
|
vc->font = utils_get_setting_string(config, "VTE", "font", "Monospace 10");
|
|
|
|
vc->scroll_on_key = utils_get_setting_boolean(config, "VTE", "scroll_on_key", TRUE);
|
|
|
|
vc->scroll_on_out = utils_get_setting_boolean(config, "VTE", "scroll_on_out", TRUE);
|
2010-10-26 15:20:53 +00:00
|
|
|
vc->enable_bash_keys = utils_get_setting_boolean(config, "VTE", "enable_bash_keys", TRUE);
|
2006-08-22 19:03:38 +00:00
|
|
|
vc->ignore_menu_bar_accel = utils_get_setting_boolean(config, "VTE", "ignore_menu_bar_accel", FALSE);
|
|
|
|
vc->follow_path = utils_get_setting_boolean(config, "VTE", "follow_path", FALSE);
|
2011-11-17 03:36:11 +01:00
|
|
|
vc->send_cmd_prefix = utils_get_setting_string(config, "VTE", "send_cmd_prefix", "");
|
2006-12-10 21:29:04 +00:00
|
|
|
vc->run_in_vte = utils_get_setting_boolean(config, "VTE", "run_in_vte", FALSE);
|
2007-12-17 16:58:26 +00:00
|
|
|
vc->skip_run_script = utils_get_setting_boolean(config, "VTE", "skip_run_script", FALSE);
|
2008-12-07 19:11:36 +00:00
|
|
|
vc->cursor_blinks = utils_get_setting_boolean(config, "VTE", "cursor_blinks", FALSE);
|
2006-08-22 19:03:38 +00:00
|
|
|
vc->scrollback_lines = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500);
|
|
|
|
vc->colour_fore = g_new0(GdkColor, 1);
|
|
|
|
vc->colour_back = g_new0(GdkColor, 1);
|
|
|
|
tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff");
|
|
|
|
gdk_color_parse(tmp_string, vc->colour_fore);
|
|
|
|
g_free(tmp_string);
|
|
|
|
tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000");
|
|
|
|
gdk_color_parse(tmp_string, vc->colour_back);
|
|
|
|
g_free(tmp_string);
|
|
|
|
}
|
2005-12-16 23:23:18 +00:00
|
|
|
#endif
|
2008-02-27 13:17:29 +00:00
|
|
|
/* templates */
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(tmp_string);
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
template_prefs.version = utils_get_setting_string(config, PACKAGE, "pref_template_version", "1.0");
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
tmp_string2 = utils_get_hostname();
|
|
|
|
tmp_string = g_strdup_printf("%s@%s", g_get_user_name(), tmp_string2);
|
2008-05-16 12:08:39 +00:00
|
|
|
template_prefs.mail = utils_get_setting_string(config, PACKAGE, "pref_template_mail", tmp_string);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(tmp_string);
|
|
|
|
g_free(tmp_string2);
|
2008-07-13 11:51:00 +00:00
|
|
|
template_prefs.year_format = utils_get_setting_string(config, PACKAGE, "pref_template_year", "%Y");
|
|
|
|
template_prefs.date_format = utils_get_setting_string(config, PACKAGE, "pref_template_date", "%Y-%m-%d");
|
|
|
|
template_prefs.datetime_format = utils_get_setting_string(config, PACKAGE, "pref_template_datetime", "%d.%m.%Y %H:%M:%S %Z");
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* tools */
|
2008-05-16 12:08:39 +00:00
|
|
|
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);
|
2007-11-17 14:04:27 +00:00
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
tool_prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
|
2007-11-17 14:04:27 +00:00
|
|
|
|
2009-07-09 06:49:42 +00:00
|
|
|
/* build menu */
|
2011-07-28 17:59:22 +00:00
|
|
|
build_set_group_count(GEANY_GBG_FT, build_menu_prefs.number_ft_menu_items);
|
|
|
|
build_set_group_count(GEANY_GBG_NON_FT, build_menu_prefs.number_non_ft_menu_items);
|
|
|
|
build_set_group_count(GEANY_GBG_EXEC, build_menu_prefs.number_exec_menu_items);
|
2009-09-16 14:13:38 +00:00
|
|
|
build_load_menu(config, GEANY_BCS_PREF, NULL);
|
2009-07-09 06:49:42 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* printing */
|
2006-07-01 15:04:41 +00:00
|
|
|
tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD);
|
2007-04-15 19:25:22 +00:00
|
|
|
#ifdef G_OS_WIN32
|
2008-02-27 13:17:29 +00:00
|
|
|
/* single quote paths on Win32 for g_spawn_command_line_async */
|
2007-04-15 19:25:22 +00:00
|
|
|
tmp_string = g_strconcat("'", tmp_string2, "' '%f'", NULL);
|
|
|
|
#else
|
2006-06-29 17:14:52 +00:00
|
|
|
tmp_string = g_strconcat(tmp_string2, " %f", NULL);
|
2007-04-15 19:25:22 +00:00
|
|
|
#endif
|
2007-11-17 14:04:27 +00:00
|
|
|
printing_prefs.external_print_cmd = utils_get_setting_string(config, "printing", "print_cmd", tmp_string);
|
2006-06-29 17:14:52 +00:00
|
|
|
g_free(tmp_string);
|
|
|
|
g_free(tmp_string2);
|
|
|
|
|
2007-11-17 14:04:27 +00:00
|
|
|
printing_prefs.use_gtk_printing = utils_get_setting_boolean(config, "printing", "use_gtk_printing", TRUE);
|
|
|
|
printing_prefs.print_line_numbers = utils_get_setting_boolean(config, "printing", "print_line_numbers", TRUE);
|
|
|
|
printing_prefs.print_page_numbers = utils_get_setting_boolean(config, "printing", "print_page_numbers", TRUE);
|
|
|
|
printing_prefs.print_page_header = utils_get_setting_boolean(config, "printing", "print_page_header", TRUE);
|
|
|
|
printing_prefs.page_header_basename = utils_get_setting_boolean(config, "printing", "page_header_basename", FALSE);
|
|
|
|
printing_prefs.page_header_datefmt = utils_get_setting_string(config, "printing", "page_header_datefmt", "%c");
|
2007-08-27 16:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void load_ui_prefs(GKeyFile *config)
|
|
|
|
{
|
|
|
|
gint *geo;
|
2011-12-11 23:13:24 +01:00
|
|
|
gsize geo_len;
|
2007-08-27 16:54:15 +00:00
|
|
|
|
|
|
|
ui_prefs.sidebar_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_visible", TRUE);
|
|
|
|
ui_prefs.msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
|
|
|
|
ui_prefs.fullscreen = utils_get_setting_boolean(config, PACKAGE, "fullscreen", FALSE);
|
|
|
|
ui_prefs.custom_date_format = utils_get_setting_string(config, PACKAGE, "custom_date_format", "");
|
|
|
|
ui_prefs.custom_commands = g_key_file_get_string_list(config, PACKAGE, "custom_commands", NULL, NULL);
|
2012-05-14 22:22:29 +02:00
|
|
|
ui_prefs.custom_commands_labels = g_key_file_get_string_list(config, PACKAGE, "custom_commands_labels", NULL, NULL);
|
|
|
|
|
|
|
|
/* sanitize custom commands labels */
|
|
|
|
if (ui_prefs.custom_commands || ui_prefs.custom_commands_labels)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
guint cc_len = ui_prefs.custom_commands ? g_strv_length(ui_prefs.custom_commands) : 0;
|
|
|
|
guint cc_labels_len = ui_prefs.custom_commands_labels ? g_strv_length(ui_prefs.custom_commands_labels) : 0;
|
|
|
|
|
|
|
|
/* not enough items, resize and fill */
|
|
|
|
if (cc_labels_len < cc_len)
|
|
|
|
{
|
|
|
|
ui_prefs.custom_commands_labels = g_realloc(ui_prefs.custom_commands_labels,
|
|
|
|
(cc_len + 1) * sizeof *ui_prefs.custom_commands_labels);
|
|
|
|
for (i = cc_labels_len; i < cc_len; i++)
|
|
|
|
ui_prefs.custom_commands_labels[i] = g_strdup("");
|
|
|
|
ui_prefs.custom_commands_labels[cc_len] = NULL;
|
|
|
|
}
|
|
|
|
/* too many items, cut off */
|
|
|
|
else if (cc_labels_len > cc_len)
|
|
|
|
{
|
|
|
|
for (i = cc_len; i < cc_labels_len; i++)
|
|
|
|
{
|
|
|
|
g_free(ui_prefs.custom_commands_labels[i]);
|
|
|
|
ui_prefs.custom_commands_labels[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-27 16:54:15 +00:00
|
|
|
|
|
|
|
scribble_text = utils_get_setting_string(config, PACKAGE, "scribble_text",
|
|
|
|
_("Type here what you want, use it as a notice/scratch board"));
|
2009-05-13 15:21:54 +00:00
|
|
|
scribble_pos = utils_get_setting_integer(config, PACKAGE, "scribble_pos", -1);
|
2007-08-27 16:54:15 +00:00
|
|
|
|
2011-12-11 23:13:24 +01:00
|
|
|
geo = g_key_file_get_integer_list(config, PACKAGE, "geometry", &geo_len, NULL);
|
|
|
|
if (! geo || geo_len < 5)
|
2007-08-27 16:54:15 +00:00
|
|
|
{
|
|
|
|
ui_prefs.geometry[0] = -1;
|
2011-12-11 13:10:05 -08:00
|
|
|
ui_prefs.geometry[1] = -1;
|
|
|
|
ui_prefs.geometry[2] = -1;
|
|
|
|
ui_prefs.geometry[3] = -1;
|
|
|
|
ui_prefs.geometry[4] = 0;
|
2007-08-27 16:54:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* don't use insane values but when main windows was maximized last time, pos might be
|
2009-03-27 16:25:57 +00:00
|
|
|
* negative (due to differences in root window and window decorations) */
|
2011-12-08 16:31:21 +00:00
|
|
|
/* quitting when minimized can make pos -32000, -32000 on Windows! */
|
2011-12-11 23:13:24 +01:00
|
|
|
ui_prefs.geometry[0] = MAX(-1, geo[0]);
|
|
|
|
ui_prefs.geometry[1] = MAX(-1, geo[1]);
|
|
|
|
ui_prefs.geometry[2] = MAX(-1, geo[2]);
|
|
|
|
ui_prefs.geometry[3] = MAX(-1, geo[3]);
|
|
|
|
ui_prefs.geometry[4] = geo[4] != 0;
|
2007-08-27 16:54:15 +00:00
|
|
|
}
|
|
|
|
hpan_position = utils_get_setting_integer(config, PACKAGE, "treeview_position", 156);
|
|
|
|
vpan_position = utils_get_setting_integer(config, PACKAGE, "msgwindow_position", (geo) ?
|
|
|
|
(GEANY_MSGWIN_HEIGHT + geo[3] - 440) :
|
|
|
|
(GEANY_MSGWIN_HEIGHT + GEANY_WINDOW_DEFAULT_HEIGHT - 440));
|
|
|
|
|
|
|
|
g_free(geo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-18 18:24:23 +00:00
|
|
|
/*
|
|
|
|
* Save current session in default configuration file
|
|
|
|
*/
|
2008-02-20 11:24:23 +00:00
|
|
|
void configuration_save_default_session(void)
|
2007-11-18 18:24:23 +00:00
|
|
|
{
|
2012-08-09 18:15:47 -07:00
|
|
|
gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
|
2007-11-18 18:24:23 +00:00
|
|
|
gchar *data;
|
|
|
|
GKeyFile *config = g_key_file_new();
|
|
|
|
|
|
|
|
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
|
|
|
|
|
2008-01-31 16:31:19 +00:00
|
|
|
if (cl_options.load_session)
|
|
|
|
configuration_save_session_files(config);
|
2007-11-18 18:24:23 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* write the file */
|
2007-11-18 18:24:23 +00:00
|
|
|
data = g_key_file_to_data(config, NULL, NULL);
|
|
|
|
utils_write_file(configfile, data);
|
|
|
|
g_free(data);
|
|
|
|
|
|
|
|
g_key_file_free(config);
|
|
|
|
g_free(configfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only reload the session part of the default configuration
|
|
|
|
*/
|
2008-02-20 11:24:23 +00:00
|
|
|
void configuration_reload_default_session(void)
|
2007-11-18 18:24:23 +00:00
|
|
|
{
|
2012-03-08 18:53:23 +02:00
|
|
|
gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
|
2007-11-18 18:24:23 +00:00
|
|
|
GKeyFile *config = g_key_file_new();
|
|
|
|
|
|
|
|
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
|
2012-03-08 18:53:23 +02:00
|
|
|
g_free(configfile);
|
2007-11-18 18:24:23 +00:00
|
|
|
|
2009-04-15 22:46:13 +00:00
|
|
|
configuration_load_session_files(config, FALSE);
|
2007-11-18 18:24:23 +00:00
|
|
|
|
|
|
|
g_key_file_free(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
gboolean configuration_load(void)
|
2007-08-27 16:54:15 +00:00
|
|
|
{
|
2012-02-06 16:41:18 +00:00
|
|
|
gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
|
2007-08-27 16:54:15 +00:00
|
|
|
GKeyFile *config = g_key_file_new();
|
|
|
|
|
2010-07-05 12:03:27 +00:00
|
|
|
if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR))
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* config file does not (yet) exist, so try to load a global config file which may be */
|
|
|
|
/* created by distributors */
|
2010-06-29 11:53:41 +00:00
|
|
|
geany_debug("No user config file found, trying to use global configuration.");
|
2012-02-06 16:41:18 +00:00
|
|
|
SETPTR(configfile, g_build_filename(app->datadir, "geany.conf", NULL));
|
2007-08-27 16:54:15 +00:00
|
|
|
}
|
|
|
|
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
|
2011-04-13 12:59:20 +00:00
|
|
|
g_free(configfile);
|
2007-08-27 16:54:15 +00:00
|
|
|
|
|
|
|
load_dialog_prefs(config);
|
|
|
|
load_ui_prefs(config);
|
2007-04-21 12:25:17 +00:00
|
|
|
project_load_prefs(config);
|
2009-04-15 22:46:13 +00:00
|
|
|
configuration_load_session_files(config, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2009-07-16 15:04:21 +00:00
|
|
|
/* this signal can be used e.g. to delay building UI elements until settings have been read */
|
|
|
|
g_signal_emit_by_name(geany_object, "load-settings", config);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_free(config);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-23 18:43:09 +00:00
|
|
|
static gboolean open_session_file(gchar **tmp, guint len)
|
2008-04-29 11:30:19 +00:00
|
|
|
{
|
|
|
|
guint pos;
|
2008-05-01 12:10:46 +00:00
|
|
|
const gchar *ft_name;
|
2008-04-29 11:30:19 +00:00
|
|
|
gchar *locale_filename;
|
2011-10-23 13:41:10 +11:00
|
|
|
gchar *unescaped_filename;
|
2008-08-04 14:07:49 +00:00
|
|
|
gint enc_idx, indent_type;
|
|
|
|
gboolean ro, auto_indent, line_wrapping;
|
2008-11-23 18:43:09 +00:00
|
|
|
/** TODO when we have a global pref for line breaking, use its value */
|
|
|
|
gboolean line_breaking = FALSE;
|
2008-04-29 11:30:19 +00:00
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
pos = atoi(tmp[0]);
|
2008-05-01 12:10:46 +00:00
|
|
|
ft_name = tmp[1];
|
2008-04-29 11:30:19 +00:00
|
|
|
ro = atoi(tmp[2]);
|
|
|
|
enc_idx = atoi(tmp[3]);
|
2008-08-04 14:07:49 +00:00
|
|
|
indent_type = atoi(tmp[4]);
|
2008-04-29 11:30:19 +00:00
|
|
|
auto_indent = atoi(tmp[5]);
|
|
|
|
line_wrapping = atoi(tmp[6]);
|
|
|
|
/* try to get the locale equivalent for the filename */
|
2011-10-23 13:41:10 +11:00
|
|
|
unescaped_filename = g_uri_unescape_string(tmp[7], NULL);
|
|
|
|
locale_filename = utils_get_locale_from_utf8(unescaped_filename);
|
2009-03-25 19:00:34 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (len > 8)
|
2008-11-23 18:43:09 +00:00
|
|
|
line_breaking = atoi(tmp[8]);
|
2008-04-29 11:30:19 +00:00
|
|
|
|
2010-07-05 12:03:27 +00:00
|
|
|
if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR))
|
2008-04-29 11:30:19 +00:00
|
|
|
{
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *ft = filetypes_lookup_by_name(ft_name);
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_open_file_full(
|
|
|
|
NULL, locale_filename, pos, ro, ft,
|
2008-04-29 11:30:19 +00:00
|
|
|
(enc_idx >= 0 && enc_idx < GEANY_ENCODINGS_MAX) ?
|
|
|
|
encodings[enc_idx].charset : NULL);
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc)
|
2008-04-29 11:30:19 +00:00
|
|
|
{
|
2010-09-15 14:59:41 +00:00
|
|
|
gint indent_width = doc->editor->indent_width;
|
|
|
|
|
|
|
|
if (len > 9)
|
|
|
|
indent_width = atoi(tmp[9]);
|
|
|
|
editor_set_indent(doc->editor, indent_type, indent_width);
|
2008-07-08 13:53:08 +00:00
|
|
|
editor_set_line_wrapping(doc->editor, line_wrapping);
|
2008-11-23 18:43:09 +00:00
|
|
|
doc->editor->line_breaking = line_breaking;
|
2008-07-08 16:30:37 +00:00
|
|
|
doc->editor->auto_indent = auto_indent;
|
2008-04-29 11:30:19 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geany_debug("Could not find file '%s'.", tmp[7]);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free(locale_filename);
|
2011-10-23 13:41:10 +11:00
|
|
|
g_free(unescaped_filename);
|
2008-04-29 11:30:19 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-13 17:50:04 +00:00
|
|
|
/* Open session files
|
|
|
|
* Note: notebook page switch handler and adding to recent files list is always disabled
|
|
|
|
* for all files opened within this function */
|
2008-04-29 11:30:19 +00:00
|
|
|
void configuration_open_files(void)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gint i;
|
2008-04-29 11:30:19 +00:00
|
|
|
gboolean failure = FALSE;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* necessary to set it to TRUE for project session support */
|
2008-01-13 17:50:04 +00:00
|
|
|
main_status.opening_session_files = TRUE;
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
i = file_prefs.tab_order_ltr ? 0 : (session_files->len - 1);
|
2006-10-11 16:35:21 +00:00
|
|
|
while (TRUE)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2007-12-07 14:13:05 +00:00
|
|
|
gchar **tmp = g_ptr_array_index(session_files, i);
|
2008-11-23 18:43:09 +00:00
|
|
|
guint len;
|
2006-12-20 10:42:12 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (tmp != NULL && (len = g_strv_length(tmp)) >= 8)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-11-23 18:43:09 +00:00
|
|
|
if (! open_session_file(tmp, len))
|
2006-11-09 15:52:31 +00:00
|
|
|
failure = TRUE;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2007-12-07 14:13:05 +00:00
|
|
|
g_strfreev(tmp);
|
2006-04-29 18:15:37 +00:00
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
if (file_prefs.tab_order_ltr)
|
2006-04-29 18:15:37 +00:00
|
|
|
{
|
|
|
|
i++;
|
2009-04-15 22:47:33 +00:00
|
|
|
if (i >= (gint)session_files->len)
|
2009-04-05 21:07:40 +00:00
|
|
|
break;
|
2006-04-29 18:15:37 +00:00
|
|
|
}
|
2006-05-17 18:29:29 +00:00
|
|
|
else
|
2006-04-29 18:15:37 +00:00
|
|
|
{
|
|
|
|
i--;
|
2009-04-15 22:47:33 +00:00
|
|
|
if (i < 0)
|
2009-04-05 21:07:40 +00:00
|
|
|
break;
|
2006-04-29 18:15:37 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2005-12-18 22:20:22 +00:00
|
|
|
|
2006-10-11 16:35:21 +00:00
|
|
|
g_ptr_array_free(session_files, TRUE);
|
2007-11-11 19:06:41 +00:00
|
|
|
session_files = NULL;
|
2007-09-18 16:04:22 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (failure)
|
2007-10-24 10:52:48 +00:00
|
|
|
ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
|
2007-09-18 16:04:22 +00:00
|
|
|
else if (session_notebook_page >= 0)
|
2007-10-20 14:57:37 +00:00
|
|
|
{
|
2008-04-29 11:30:19 +00:00
|
|
|
/* explicitly allow notebook switch page callback to be called for window title,
|
2008-02-27 13:17:29 +00:00
|
|
|
* encoding settings and so other things */
|
2007-10-20 14:57:37 +00:00
|
|
|
main_status.opening_session_files = FALSE;
|
2008-02-27 13:17:29 +00:00
|
|
|
/** TODO if session_notebook_page is equal to the current notebook tab(the last opened)
|
|
|
|
** the notebook switch page callback isn't triggered and e.g. menu items are not updated */
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), session_notebook_page);
|
2007-10-20 14:57:37 +00:00
|
|
|
}
|
2008-01-13 17:50:04 +00:00
|
|
|
main_status.opening_session_files = FALSE;
|
2006-04-27 17:57:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set some settings which are already read from the config file, but need other things, like the
|
|
|
|
* realisation of the main window */
|
2008-02-20 11:24:23 +00:00
|
|
|
void configuration_apply_settings(void)
|
2006-04-27 17:57:28 +00:00
|
|
|
{
|
2009-04-15 22:47:33 +00:00
|
|
|
if (scribble_text)
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* update the scribble widget, because now it's realized */
|
2009-05-13 15:21:54 +00:00
|
|
|
GtkTextIter iter;
|
|
|
|
GtkTextBuffer *buffer =
|
2009-12-20 20:07:04 +00:00
|
|
|
gtk_text_view_get_buffer(GTK_TEXT_VIEW(msgwindow.scribble));
|
2009-05-13 15:21:54 +00:00
|
|
|
|
|
|
|
gtk_text_buffer_set_text(buffer, scribble_text, -1);
|
|
|
|
gtk_text_buffer_get_iter_at_offset(buffer, &iter, scribble_pos);
|
|
|
|
gtk_text_buffer_place_cursor(buffer, &iter);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
g_free(scribble_text);
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* set the position of the hpaned and vpaned */
|
2007-08-23 11:34:06 +00:00
|
|
|
if (prefs.save_winpos)
|
2005-11-25 01:19:04 +00:00
|
|
|
{
|
2008-12-18 21:21:53 +00:00
|
|
|
gtk_paned_set_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "hpaned1")), hpan_position);
|
|
|
|
gtk_paned_set_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "vpaned1")), vpan_position);
|
2005-11-25 01:19:04 +00:00
|
|
|
}
|
2006-05-30 18:03:19 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* set fullscreen after initial draw so that returning to normal view is the right size.
|
|
|
|
* fullscreen mode is disabled by default, so act only if it is true */
|
2007-08-23 11:34:06 +00:00
|
|
|
if (ui_prefs.fullscreen)
|
2006-07-08 17:37:41 +00:00
|
|
|
{
|
2008-12-18 21:21:53 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_fullscreen1")), TRUE);
|
2007-08-23 11:34:06 +00:00
|
|
|
ui_prefs.fullscreen = TRUE;
|
2006-09-05 14:24:47 +00:00
|
|
|
ui_set_fullscreen();
|
2006-07-08 17:37:41 +00:00
|
|
|
}
|
2009-12-20 20:07:52 +00:00
|
|
|
|
|
|
|
msgwin_show_hide_tabs();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
2006-02-14 22:07:55 +00:00
|
|
|
|
2008-12-09 13:16:52 +00:00
|
|
|
void configuration_init(void)
|
|
|
|
{
|
2008-12-16 13:01:47 +00:00
|
|
|
keyfile_groups = g_ptr_array_new();
|
|
|
|
pref_groups = g_ptr_array_new();
|
2008-12-09 13:16:52 +00:00
|
|
|
init_pref_groups();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void configuration_finalize(void)
|
|
|
|
{
|
2009-07-20 12:25:24 +00:00
|
|
|
guint i;
|
2010-03-18 17:04:17 +00:00
|
|
|
StashGroup *group;
|
2008-12-09 13:16:52 +00:00
|
|
|
|
2009-07-20 12:25:24 +00:00
|
|
|
foreach_ptr_array(group, i, keyfile_groups)
|
2008-12-09 13:16:52 +00:00
|
|
|
stash_group_free(group);
|
|
|
|
|
2008-12-16 13:01:47 +00:00
|
|
|
g_ptr_array_free(keyfile_groups, TRUE);
|
2008-12-09 13:16:52 +00:00
|
|
|
g_ptr_array_free(pref_groups, TRUE);
|
|
|
|
}
|