2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* keyfile.c - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2006-05-17 18:29:29 +00:00
|
|
|
* Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
|
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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-05-17 18:29:29 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
2005-11-25 01:19:04 +00:00
|
|
|
* $Id$
|
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"
|
|
|
|
|
|
|
|
#include "support.h"
|
|
|
|
#include "keyfile.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "document.h"
|
2005-12-29 20:01:18 +00:00
|
|
|
#include "sciwrappers.h"
|
2006-07-25 09:12:51 +00:00
|
|
|
#include "encodings.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
static gchar *scribble_text = NULL;
|
2005-12-12 02:23:51 +00:00
|
|
|
static gchar *session_files[GEANY_SESSION_FILES];
|
2005-11-22 12:26:26 +00:00
|
|
|
static gint hpan_position;
|
2005-11-25 01:19:04 +00:00
|
|
|
static gint vpan_position;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
2006-08-01 21:07:46 +00:00
|
|
|
static void generate_filetype_extensions(const gchar *output_dir);
|
|
|
|
|
|
|
|
|
|
|
|
void configuration_save()
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gint i = 0, j = 0, idx, max;
|
|
|
|
gboolean config_exists;
|
|
|
|
GKeyFile *config = g_key_file_new();
|
|
|
|
gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
|
2006-02-25 22:27:41 +00:00
|
|
|
gchar *data;
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *entry = g_malloc(14);
|
|
|
|
gchar *fname = g_malloc0(256);
|
2006-04-29 18:15:37 +00:00
|
|
|
gchar **recent_files = g_new0(gchar*, app->mru_length + 1);
|
2005-11-22 12:26:26 +00:00
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkTextIter start, end;
|
|
|
|
|
|
|
|
config_exists = g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
|
|
|
|
|
|
|
if (!config_exists)
|
|
|
|
{
|
2006-06-28 15:18:23 +00:00
|
|
|
gchar *start_comm = g_strdup_printf(_("%s configuration file, edit as you need"), PACKAGE);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_comment(config, NULL, NULL, start_comm, NULL);
|
|
|
|
g_free(start_comm);
|
|
|
|
}
|
|
|
|
|
|
|
|
// gets the text from the scribble textview
|
|
|
|
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble")));
|
|
|
|
gtk_text_buffer_get_bounds(buffer, &start, &end);
|
|
|
|
scribble_text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
|
|
|
|
|
|
|
|
// store basic settings
|
2005-11-25 01:19:04 +00:00
|
|
|
if (app->pref_main_save_winpos)
|
|
|
|
{
|
|
|
|
g_key_file_set_integer(config, PACKAGE, "treeview_position",
|
2005-11-22 12:26:26 +00:00
|
|
|
gtk_paned_get_position(GTK_PANED(lookup_widget(app->window, "hpaned1"))));
|
2005-11-25 01:19:04 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "msgwindow_position",
|
|
|
|
gtk_paned_get_position(GTK_PANED(lookup_widget(app->window, "vpaned1"))));
|
|
|
|
}
|
|
|
|
|
2005-12-12 02:23:51 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "mru_length", app->mru_length);
|
2006-07-01 00:25:34 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "long_line_type", app->long_line_type);
|
2006-07-02 16:21:35 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "tab_pos_editor", app->tab_pos_editor);
|
|
|
|
g_key_file_set_integer(config, PACKAGE, "tab_pos_msgwin", app->tab_pos_msgwin);
|
|
|
|
g_key_file_set_integer(config, PACKAGE, "tab_pos_sidebar", app->tab_pos_sidebar);
|
2005-11-25 01:19:04 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "long_line_column", app->long_line_column);
|
2005-12-11 02:16:02 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "long_line_color", app->long_line_color);
|
2006-01-03 12:39:25 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "beep_on_errors", app->beep_on_errors);
|
2006-07-07 14:34:43 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "sidebar_symbol_visible", app->sidebar_symbol_visible);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_visible", app->sidebar_openfiles_visible);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "sidebar_visible", app->sidebar_visible);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", app->msgwindow_visible);
|
2006-02-26 18:19:28 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "use_folding", app->pref_editor_folding);
|
2006-02-14 22:07:55 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "use_auto_indention", app->pref_editor_use_auto_indention);
|
2006-06-13 19:37:21 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "use_indicators", app->pref_editor_use_indicators);
|
2006-02-14 22:07:55 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", app->pref_editor_show_indent_guide);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_white_space", app->pref_editor_show_white_space);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_markers_margin", app->show_markers_margin);
|
2006-02-14 22:07:55 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_linenumber_margin", app->show_linenumber_margin);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "line_breaking", app->pref_editor_line_breaking);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "show_line_endings", app->pref_editor_show_line_endings);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "fullscreen", app->fullscreen);
|
2006-04-27 17:57:28 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "tab_order_ltr", app->tab_order_ltr);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "brace_match_ltgt", app->brace_match_ltgt);
|
2005-11-24 22:28:45 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", app->switch_msgwin_pages);
|
2006-02-14 22:07:55 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "auto_close_xml_tags", app->pref_editor_auto_close_xml_tags);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "auto_complete_constructs", app->pref_editor_auto_complete_constructs);
|
2005-12-16 23:23:18 +00:00
|
|
|
#ifdef HAVE_VTE
|
2006-05-22 00:25:19 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "load_vte", app->load_vte);
|
2005-12-12 02:23:51 +00:00
|
|
|
g_key_file_set_comment(config, PACKAGE, "terminal_settings",
|
2006-07-02 18:34:03 +00:00
|
|
|
_(" VTE settings: FONT;FOREGROUND;BACKGROUND;scrollback;type;scroll on keystroke;scroll on output;follow path of file"), NULL);
|
2005-11-24 22:28:45 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "terminal_settings", app->terminal_settings);
|
2005-12-16 23:23:18 +00:00
|
|
|
#endif
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "editor_font", app->editor_font);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "tagbar_font", app->tagbar_font);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "msgwin_font", app->msgwin_font);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "scribble_text", scribble_text);
|
2006-07-08 17:37:41 +00:00
|
|
|
if (app->pref_main_save_winpos && ! app->fullscreen)
|
2006-01-11 18:41:32 +00:00
|
|
|
{
|
|
|
|
gtk_window_get_position(GTK_WINDOW(app->window), &app->geometry[0], &app->geometry[1]);
|
|
|
|
gtk_window_get_size(GTK_WINDOW(app->window), &app->geometry[2], &app->geometry[3]);
|
|
|
|
g_key_file_set_integer_list(config, PACKAGE, "geometry", app->geometry, 4);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "pref_editor_tab_width", app->pref_editor_tab_width);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", app->pref_main_confirm_exit);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", app->pref_main_load_session);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", app->pref_main_save_winpos);
|
2006-07-11 14:15:56 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", app->toolbar_visible);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_search", app->pref_toolbar_show_search);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_goto", app->pref_toolbar_show_goto);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_zoom", app->pref_toolbar_show_zoom);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_undo", app->pref_toolbar_show_undo);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_compile", app->pref_toolbar_show_compile);
|
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_colour", app->pref_toolbar_show_colour);
|
2006-07-15 18:15:30 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_fileops", app->pref_toolbar_show_fileops);
|
2006-07-11 14:15:56 +00:00
|
|
|
g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_style", app->toolbar_icon_style);
|
|
|
|
g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_size", app->toolbar_icon_size);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_editor_new_line", app->pref_editor_new_line);
|
2006-06-21 18:54:07 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", app->pref_editor_replace_tabs);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", app->pref_editor_trail_space);
|
2006-07-25 09:12:51 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_editor_default_encoding", encodings[app->pref_editor_default_encoding].charset);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_developer", app->pref_template_developer);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_company", app->pref_template_company);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_mail", app->pref_template_mail);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_initial", app->pref_template_initial);
|
|
|
|
g_key_file_set_string(config, PACKAGE, "pref_template_version", app->pref_template_version);
|
|
|
|
|
2006-06-29 14:00:09 +00:00
|
|
|
// store tools settings
|
|
|
|
g_key_file_set_string(config, "tools", "make_cmd", app->tools_make_cmd ? app->tools_make_cmd : "");
|
2006-07-08 16:59:08 +00:00
|
|
|
g_key_file_set_string(config, "tools", "term_cmd", app->tools_term_cmd ? app->tools_term_cmd : "");
|
2006-06-29 14:00:09 +00:00
|
|
|
g_key_file_set_string(config, "tools", "browser_cmd", app->tools_browser_cmd ? app->tools_browser_cmd : "");
|
2006-06-29 17:14:52 +00:00
|
|
|
g_key_file_set_string(config, "tools", "print_cmd", app->tools_print_cmd ? app->tools_print_cmd : "");
|
2006-07-13 14:30:44 +00:00
|
|
|
g_key_file_set_string(config, "tools", "grep_cmd", app->tools_grep_cmd? app->tools_grep_cmd: "");
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2005-12-12 02:23:51 +00:00
|
|
|
for (i = 0; i < app->mru_length; i++)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
if (! g_queue_is_empty(app->recent_queue))
|
|
|
|
{
|
2006-06-28 15:18:23 +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
|
|
|
|
recent_files[i] = g_strdup(g_queue_peek_nth(app->recent_queue, i));
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2005-12-12 02:23:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
recent_files[i] = NULL;
|
2006-06-28 15:18:23 +00:00
|
|
|
break;
|
2005-12-12 02:23:51 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2006-04-29 18:15:37 +00:00
|
|
|
// There is a bug in GTK2.6 g_key_file_set_string_list, we must NULL terminate.
|
|
|
|
recent_files[app->mru_length] = NULL;
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_string_list(config, "files", "recent_files",
|
2005-12-12 02:23:51 +00:00
|
|
|
(const gchar**)recent_files, app->mru_length);
|
2006-06-27 15:24:39 +00:00
|
|
|
g_strfreev(recent_files);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2005-12-12 02:23:51 +00:00
|
|
|
// store the last 15(or what ever GEANY_SESSION_FILES is set to) filenames, to reopen the next time
|
2005-11-22 12:26:26 +00:00
|
|
|
max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
|
2005-12-12 02:23:51 +00:00
|
|
|
for(i = 0; (i < max) && (j < GEANY_SESSION_FILES); i++)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
idx = document_get_n_idx(i);
|
|
|
|
if (idx >= 0 && doc_list[idx].file_name)
|
|
|
|
{
|
|
|
|
g_snprintf(entry, 13, "FILE_NAME_%d", j);
|
2006-02-25 22:27:41 +00:00
|
|
|
g_snprintf(fname, 255, "%d:%d:%s", sci_get_current_position(doc_list[idx].sci), doc_list[idx].file_type->id, doc_list[idx].file_name);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_key_file_set_string(config, "files", entry, fname);
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2006-05-31 21:17:30 +00:00
|
|
|
// if open filenames less than GEANY_SESSION_FILES, delete existing saved entries in the list
|
|
|
|
for(i = j; i < GEANY_SESSION_FILES; i++)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-05-31 21:17:30 +00:00
|
|
|
g_snprintf(entry, 13, "FILE_NAME_%d", i);
|
|
|
|
g_key_file_set_string(config, "files", entry, "");
|
2005-11-22 12:26:26 +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);
|
|
|
|
g_free(entry);
|
|
|
|
g_free(fname);
|
|
|
|
g_free(scribble_text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-01 18:49:44 +00:00
|
|
|
#define GEANY_GET_SETTING(propertyname, value, default_value) \
|
|
|
|
if (g_object_class_find_property( \
|
|
|
|
G_OBJECT_GET_CLASS(G_OBJECT(gtk_settings_get_default())), propertyname)) \
|
|
|
|
g_object_get(G_OBJECT(gtk_settings_get_default()), propertyname, &value, \
|
|
|
|
NULL); \
|
|
|
|
else \
|
|
|
|
value = default_value;
|
|
|
|
|
2006-08-01 21:07:46 +00:00
|
|
|
gboolean configuration_load()
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gboolean config_exists;
|
|
|
|
guint i, geo_len;
|
|
|
|
gint *geo = g_malloc(sizeof(gint) * 4);
|
2005-12-12 02:23:51 +00:00
|
|
|
gsize len = 0;
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
|
|
|
|
gchar *entry = g_malloc(14);
|
|
|
|
gchar *tmp_string, *tmp_string2;
|
|
|
|
GKeyFile *config = g_key_file_new();
|
|
|
|
GError *error = NULL;
|
2006-06-27 15:24:39 +00:00
|
|
|
gchar **recent_files;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
config_exists = g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
|
|
|
|
2006-07-11 14:15:56 +00:00
|
|
|
app->toolbar_visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE);
|
2006-07-01 18:49:44 +00:00
|
|
|
{
|
|
|
|
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);
|
2006-07-11 14:15:56 +00:00
|
|
|
app->toolbar_icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", tb_style);
|
|
|
|
app->toolbar_icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", tb_iconsize);
|
2006-07-01 18:49:44 +00:00
|
|
|
}
|
2006-01-03 12:39:25 +00:00
|
|
|
app->beep_on_errors = utils_get_setting_boolean(config, PACKAGE, "beep_on_errors", TRUE);
|
2006-07-01 15:04:41 +00:00
|
|
|
app->mru_length = utils_get_setting_integer(config, PACKAGE, "mru_length", GEANY_DEFAULT_MRU_LENGHTH);
|
2006-07-01 00:25:34 +00:00
|
|
|
app->long_line_type = utils_get_setting_integer(config, PACKAGE, "long_line_type", 0);
|
2005-12-11 02:16:02 +00:00
|
|
|
app->long_line_color = utils_get_setting_string(config, PACKAGE, "long_line_color", "#C2EBC2");
|
2005-11-22 12:26:26 +00:00
|
|
|
app->long_line_column = utils_get_setting_integer(config, PACKAGE, "long_line_column", 72);
|
2006-07-02 16:21:35 +00:00
|
|
|
app->tab_pos_editor = utils_get_setting_integer(config, PACKAGE, "tab_pos_editor", GTK_POS_TOP);
|
|
|
|
app->tab_pos_msgwin = utils_get_setting_integer(config, PACKAGE, "tab_pos_msgwin",GTK_POS_LEFT);
|
|
|
|
app->tab_pos_sidebar = utils_get_setting_integer(config, PACKAGE, "tab_pos_sidebar", GTK_POS_TOP);
|
2006-07-07 14:34:43 +00:00
|
|
|
app->sidebar_symbol_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_symbol_visible", TRUE);
|
|
|
|
app->sidebar_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_visible", TRUE);
|
|
|
|
app->sidebar_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_visible", TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
app->msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
|
2006-08-01 10:06:28 +00:00
|
|
|
app->pref_editor_line_breaking = utils_get_setting_boolean(config, PACKAGE, "line_breaking", FALSE); //default is off for better performance
|
2006-02-14 22:07:55 +00:00
|
|
|
app->pref_editor_use_auto_indention = utils_get_setting_boolean(config, PACKAGE, "use_auto_indention", TRUE);
|
2006-08-01 10:06:28 +00:00
|
|
|
app->pref_editor_use_indicators = utils_get_setting_boolean(config, PACKAGE, "use_indicators", TRUE);
|
2006-02-14 22:07:55 +00:00
|
|
|
app->pref_editor_show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);
|
|
|
|
app->pref_editor_show_white_space = utils_get_setting_boolean(config, PACKAGE, "show_white_space", FALSE);
|
2006-08-01 10:06:28 +00:00
|
|
|
app->pref_editor_show_line_endings = utils_get_setting_boolean(config, PACKAGE, "show_line_endings", FALSE);
|
|
|
|
app->pref_editor_auto_close_xml_tags = utils_get_setting_boolean(config, PACKAGE, "auto_close_xml_tags", TRUE);
|
|
|
|
app->pref_editor_auto_complete_constructs = utils_get_setting_boolean(config, PACKAGE, "auto_complete_constructs", TRUE);
|
|
|
|
app->pref_editor_folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
app->show_markers_margin = utils_get_setting_boolean(config, PACKAGE, "show_markers_margin", TRUE);
|
2006-02-14 22:07:55 +00:00
|
|
|
app->show_linenumber_margin = utils_get_setting_boolean(config, PACKAGE, "show_linenumber_margin", TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
app->fullscreen = utils_get_setting_boolean(config, PACKAGE, "fullscreen", FALSE);
|
2006-04-27 17:57:28 +00:00
|
|
|
app->tab_order_ltr = utils_get_setting_boolean(config, PACKAGE, "tab_order_ltr", FALSE);
|
|
|
|
app->brace_match_ltgt = utils_get_setting_boolean(config, PACKAGE, "brace_match_ltgt", FALSE);
|
2006-06-21 18:54:07 +00:00
|
|
|
app->switch_msgwin_pages = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE);
|
2006-07-01 15:04:41 +00:00
|
|
|
app->editor_font = utils_get_setting_string(config, PACKAGE, "editor_font", GEANY_DEFAULT_FONT_EDITOR);
|
|
|
|
app->tagbar_font = utils_get_setting_string(config, PACKAGE, "tagbar_font", GEANY_DEFAULT_FONT_SYMBOL_LIST);
|
|
|
|
app->msgwin_font = utils_get_setting_string(config, PACKAGE, "msgwin_font", GEANY_DEFAULT_FONT_MSG_WINDOW);
|
2005-11-24 22:28:45 +00:00
|
|
|
scribble_text = utils_get_setting_string(config, PACKAGE, "scribble_text",
|
|
|
|
_("Type here what you want, use it as a notice/scratch board"));
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
geo = g_key_file_get_integer_list(config, PACKAGE, "geometry", &geo_len, &error);
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
app->geometry[0] = -1;
|
|
|
|
g_error_free(error);
|
|
|
|
error = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
app->geometry[0] = geo[0];
|
|
|
|
app->geometry[1] = geo[1];
|
|
|
|
app->geometry[2] = geo[2];
|
|
|
|
app->geometry[3] = geo[3];
|
|
|
|
}
|
2006-03-15 23:19:45 +00:00
|
|
|
hpan_position = utils_get_setting_integer(config, PACKAGE, "treeview_position", 156);
|
2006-05-17 18:29:29 +00:00
|
|
|
vpan_position = utils_get_setting_integer(config, PACKAGE, "msgwindow_position", (geo) ?
|
|
|
|
(GEANY_MSGWIN_HEIGHT + geo[3] - 440) :
|
2006-03-15 23:19:45 +00:00
|
|
|
(GEANY_MSGWIN_HEIGHT + GEANY_WINDOW_DEFAULT_HEIGHT - 440));
|
2005-11-25 01:19:04 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
app->pref_editor_tab_width = utils_get_setting_integer(config, PACKAGE, "pref_editor_tab_width", 4);
|
2006-07-25 09:12:51 +00:00
|
|
|
tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_encoding",
|
|
|
|
encodings[GEANY_ENCODING_UTF_8].charset);
|
|
|
|
if (tmp_string)
|
|
|
|
{
|
|
|
|
const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
|
|
|
|
if (enc != NULL)
|
|
|
|
app->pref_editor_default_encoding = enc->idx;
|
|
|
|
else
|
|
|
|
app->pref_editor_default_encoding = GEANY_ENCODING_UTF_8;
|
|
|
|
|
|
|
|
g_free(tmp_string);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
app->pref_main_confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", TRUE);
|
|
|
|
app->pref_main_load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
|
|
|
|
app->pref_main_save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
|
2006-07-11 14:15:56 +00:00
|
|
|
app->pref_toolbar_show_search = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_search", TRUE);
|
|
|
|
app->pref_toolbar_show_goto = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_goto", TRUE);
|
|
|
|
app->pref_toolbar_show_zoom = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_zoom", FALSE);
|
|
|
|
app->pref_toolbar_show_compile = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_compile", TRUE);
|
|
|
|
app->pref_toolbar_show_undo = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_undo", FALSE);
|
|
|
|
app->pref_toolbar_show_colour = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_colour", TRUE);
|
2006-07-15 18:15:30 +00:00
|
|
|
app->pref_toolbar_show_fileops = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_fileops", TRUE);
|
2005-12-16 23:23:18 +00:00
|
|
|
#ifdef HAVE_VTE
|
2006-05-22 00:25:19 +00:00
|
|
|
app->load_vte = utils_get_setting_boolean(config, PACKAGE, "load_vte", TRUE);
|
2005-12-12 02:23:51 +00:00
|
|
|
app->terminal_settings = utils_get_setting_string(config, PACKAGE, "terminal_settings", "");
|
2005-12-16 23:23:18 +00:00
|
|
|
#endif
|
2006-05-22 00:25:19 +00:00
|
|
|
app->pref_template_developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name());
|
|
|
|
app->pref_template_company = utils_get_setting_string(config, PACKAGE, "pref_template_company", "");
|
2005-11-22 12:26:26 +00:00
|
|
|
tmp_string = utils_get_initials(app->pref_template_developer);
|
|
|
|
app->pref_template_initial = utils_get_setting_string(config, PACKAGE, "pref_template_initial", tmp_string);
|
|
|
|
g_free(tmp_string);
|
|
|
|
|
|
|
|
app->pref_template_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);
|
|
|
|
app->pref_template_mail = utils_get_setting_string(config, PACKAGE, "pref_template_mail", tmp_string);
|
|
|
|
g_free(tmp_string);
|
|
|
|
g_free(tmp_string2);
|
|
|
|
|
2006-06-21 18:54:07 +00:00
|
|
|
app->pref_editor_replace_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_replace_tabs", FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
app->pref_editor_new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE);
|
2006-08-01 10:30:56 +00:00
|
|
|
app->pref_editor_trail_space = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-07-01 15:04:41 +00:00
|
|
|
tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_MAKE);
|
2006-06-29 17:14:52 +00:00
|
|
|
app->tools_make_cmd = utils_get_setting_string(config, "tools", "make_cmd", tmp_string);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(tmp_string);
|
|
|
|
|
2006-07-01 15:04:41 +00:00
|
|
|
tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_TERMINAL);
|
2006-06-29 17:14:52 +00:00
|
|
|
app->tools_term_cmd = utils_get_setting_string(config, "tools", "term_cmd", tmp_string);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(tmp_string);
|
|
|
|
|
2006-07-01 15:04:41 +00:00
|
|
|
tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_BROWSER);
|
2006-06-29 17:14:52 +00:00
|
|
|
app->tools_browser_cmd = utils_get_setting_string(config, "tools", "browser_cmd", tmp_string);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(tmp_string);
|
|
|
|
|
2006-07-01 15:04:41 +00:00
|
|
|
tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD);
|
2006-06-29 17:14:52 +00:00
|
|
|
tmp_string = g_strconcat(tmp_string2, " %f", NULL);
|
|
|
|
app->tools_print_cmd = utils_get_setting_string(config, "tools", "print_cmd", tmp_string);
|
|
|
|
g_free(tmp_string);
|
|
|
|
g_free(tmp_string2);
|
|
|
|
|
2006-07-13 14:30:44 +00:00
|
|
|
tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_GREP);
|
|
|
|
app->tools_grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", tmp_string);
|
|
|
|
g_free(tmp_string);
|
|
|
|
|
2006-06-27 15:24:39 +00:00
|
|
|
recent_files = g_key_file_get_string_list(config, "files", "recent_files", &len, NULL);
|
|
|
|
if (recent_files != NULL)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2005-12-12 02:23:51 +00:00
|
|
|
for (i = 0; (i < len) && (i < app->mru_length); i++)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-06-27 15:24:39 +00:00
|
|
|
gchar *filename = g_strdup(recent_files[i]);
|
|
|
|
g_queue_push_tail(app->recent_queue, filename);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-27 15:24:39 +00:00
|
|
|
g_strfreev(recent_files);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2005-12-12 02:23:51 +00:00
|
|
|
for(i = 0; i < GEANY_SESSION_FILES; i++)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
g_snprintf(entry, 13, "FILE_NAME_%d", i);
|
|
|
|
session_files[i] = g_key_file_get_string(config, "files", entry, &error);
|
|
|
|
if (! session_files[i] || error)
|
|
|
|
{
|
|
|
|
g_error_free(error);
|
|
|
|
error = NULL;
|
|
|
|
session_files[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_key_file_free(config);
|
|
|
|
g_free(configfile);
|
|
|
|
g_free(entry);
|
|
|
|
g_free(geo);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 21:07:46 +00:00
|
|
|
gboolean configuration_open_files()
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gint i;
|
2006-04-27 17:57:28 +00:00
|
|
|
guint x, pos, ft_id, y, len;
|
|
|
|
gchar *file, *locale_filename, **array;
|
2005-11-22 12:26:26 +00:00
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
2006-04-29 18:15:37 +00:00
|
|
|
i = app->tab_order_ltr ? 0 : GEANY_SESSION_FILES - 1;
|
|
|
|
while(TRUE)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
if (session_files[i] && strlen(session_files[i]))
|
|
|
|
{
|
|
|
|
x = 0;
|
2006-02-25 22:27:41 +00:00
|
|
|
y = 0;
|
2006-02-26 12:50:48 +00:00
|
|
|
ft_id = GEANY_MAX_FILE_TYPES;
|
2006-05-17 18:29:29 +00:00
|
|
|
|
2006-04-27 17:57:28 +00:00
|
|
|
// yes it is :, it should be a ;, but now it is too late to change it
|
|
|
|
array = g_strsplit(session_files[i], ":", 3);
|
|
|
|
len = g_strv_length(array);
|
2006-05-17 18:29:29 +00:00
|
|
|
|
2006-02-25 22:27:41 +00:00
|
|
|
// read position
|
2006-04-27 17:57:28 +00:00
|
|
|
if (len > 0 && array[0]) pos = atoi(array[0]);
|
|
|
|
else pos = 0;
|
2006-02-26 12:50:48 +00:00
|
|
|
|
2006-04-27 17:57:28 +00:00
|
|
|
// read filetype (only if there are more than two fields, otherwise we have the old format)
|
|
|
|
if (len > 2 && array[1])
|
2006-02-25 22:27:41 +00:00
|
|
|
{
|
2006-04-27 17:57:28 +00:00
|
|
|
ft_id = atoi(array[1]);
|
|
|
|
file = array[2];
|
2006-02-25 22:27:41 +00:00
|
|
|
}
|
2006-04-27 17:57:28 +00:00
|
|
|
else file = array[1];
|
2006-05-17 18:29:29 +00:00
|
|
|
|
2006-04-27 17:57:28 +00:00
|
|
|
// try to get the locale equivalent for the filename, fallback to filename if error
|
|
|
|
locale_filename = g_locale_from_utf8(file, -1, NULL, NULL, NULL);
|
|
|
|
if (locale_filename == NULL) locale_filename = g_strdup(file);
|
|
|
|
|
2006-01-23 17:05:29 +00:00
|
|
|
if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR || G_FILE_TEST_IS_SYMLINK))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-02-26 12:50:48 +00:00
|
|
|
document_open_file(-1, locale_filename, pos, FALSE,
|
2006-07-22 01:29:10 +00:00
|
|
|
(ft_id == GEANY_MAX_FILE_TYPES) ? NULL : filetypes[ft_id], NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
2006-01-23 17:05:29 +00:00
|
|
|
g_free(locale_filename);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
g_free(session_files[i]);
|
2006-04-29 18:15:37 +00:00
|
|
|
|
|
|
|
if (app->tab_order_ltr)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
if (i >= GEANY_SESSION_FILES) break;
|
|
|
|
}
|
2006-05-17 18:29:29 +00:00
|
|
|
else
|
2006-04-29 18:15:37 +00:00
|
|
|
{
|
|
|
|
i--;
|
|
|
|
if (i < 0) break;
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2005-12-18 22:20:22 +00:00
|
|
|
|
2006-04-27 17:57:28 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set some settings which are already read from the config file, but need other things, like the
|
|
|
|
* realisation of the main window */
|
2006-08-01 21:07:46 +00:00
|
|
|
void configuration_apply_settings()
|
2006-04-27 17:57:28 +00:00
|
|
|
{
|
2005-11-22 12:26:26 +00:00
|
|
|
if (scribble_text)
|
|
|
|
{ // update the scribble widget, because now it's realized
|
|
|
|
gtk_text_buffer_set_text(
|
|
|
|
gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble"))),
|
|
|
|
scribble_text, -1);
|
|
|
|
}
|
|
|
|
g_free(scribble_text);
|
|
|
|
|
2006-04-27 17:57:28 +00:00
|
|
|
// set the position of the hpaned and vpaned
|
2005-11-22 12:26:26 +00:00
|
|
|
if (app->pref_main_save_winpos)
|
2005-11-25 01:19:04 +00:00
|
|
|
{
|
2005-11-22 12:26:26 +00:00
|
|
|
gtk_paned_set_position(GTK_PANED(lookup_widget(app->window, "hpaned1")), hpan_position);
|
2005-11-25 01:19:04 +00:00
|
|
|
gtk_paned_set_position(GTK_PANED(lookup_widget(app->window, "vpaned1")), vpan_position);
|
|
|
|
}
|
2006-05-30 18:03:19 +00:00
|
|
|
|
|
|
|
// now the scintilla widget pages may need scrolling in view
|
|
|
|
if (app->pref_main_load_session)
|
|
|
|
{
|
|
|
|
gint idx;
|
|
|
|
guint tabnum = 0;
|
|
|
|
|
|
|
|
while (tabnum < gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)))
|
|
|
|
{
|
|
|
|
idx = document_get_n_idx(tabnum);
|
|
|
|
if (idx < 0) break;
|
|
|
|
sci_scroll_caret(doc_list[idx].sci);
|
|
|
|
tabnum++;
|
|
|
|
}
|
|
|
|
}
|
2006-07-08 17:37:41 +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
|
|
|
|
if (app->fullscreen)
|
|
|
|
{
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_fullscreen1")), TRUE);
|
|
|
|
app->fullscreen = TRUE;
|
|
|
|
utils_set_fullscreen();
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
2006-02-14 22:07:55 +00:00
|
|
|
|
2006-08-01 21:07:46 +00:00
|
|
|
/* Generate the config files in "data/" from defaults */
|
|
|
|
void configuration_generate_data_files()
|
|
|
|
{
|
|
|
|
gchar *cur_dir, *gen_dir;
|
|
|
|
|
|
|
|
cur_dir = g_get_current_dir();
|
|
|
|
gen_dir = g_strconcat(cur_dir, G_DIR_SEPARATOR_S, "data", NULL);
|
|
|
|
g_free(cur_dir);
|
|
|
|
|
|
|
|
if (! g_file_test(gen_dir, G_FILE_TEST_IS_DIR))
|
|
|
|
{
|
|
|
|
g_print("%s does not exist!\n", gen_dir);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_print("Generating system files in %s:\n", gen_dir);
|
|
|
|
generate_filetype_extensions(gen_dir);
|
|
|
|
g_free(gen_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 16:12:45 +00:00
|
|
|
/* This will write the default settings for the system filetype_extensions.conf */
|
|
|
|
static void generate_filetype_extensions(const gchar *output_dir)
|
2006-02-14 22:07:55 +00:00
|
|
|
{
|
2006-02-25 22:27:41 +00:00
|
|
|
guint i;
|
2006-08-01 16:12:45 +00:00
|
|
|
gchar *configfile = g_strconcat(output_dir, G_DIR_SEPARATOR_S, "filetype_extensions.conf", NULL);
|
2006-08-01 21:07:46 +00:00
|
|
|
gchar *data, *basename;
|
|
|
|
GKeyFile *config;
|
2006-02-25 22:27:41 +00:00
|
|
|
|
2006-08-01 16:12:45 +00:00
|
|
|
config = g_key_file_new();
|
2006-08-01 21:07:46 +00:00
|
|
|
// add filetype keys
|
2006-02-25 22:27:41 +00:00
|
|
|
for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
|
|
|
|
{
|
2006-08-01 21:07:46 +00:00
|
|
|
g_key_file_set_string_list(config, "Extensions", filetypes[i]->name,
|
|
|
|
(const gchar**) filetypes[i]->pattern, g_strv_length(filetypes[i]->pattern));
|
2006-02-25 22:27:41 +00:00
|
|
|
}
|
2006-08-01 21:07:46 +00:00
|
|
|
// add comment
|
|
|
|
g_key_file_set_comment(config, "Extensions", NULL,
|
|
|
|
"Filetype extension configuration file for Geany\n"
|
|
|
|
"Insert as many items as you want, seperate them with a \";\".\n"
|
|
|
|
"See Geany's main documentation for details.", NULL);
|
2006-02-25 22:27:41 +00:00
|
|
|
|
2006-08-01 16:12:45 +00:00
|
|
|
// write the file
|
2006-08-01 21:07:46 +00:00
|
|
|
g_print("%s: ", __func__);
|
2006-08-01 16:12:45 +00:00
|
|
|
data = g_key_file_to_data(config, NULL, NULL);
|
2006-08-01 21:07:46 +00:00
|
|
|
basename = g_path_get_basename(configfile);
|
|
|
|
|
|
|
|
if (utils_write_file(configfile, data) == 0)
|
|
|
|
g_print("wrote file %s.\n", basename);
|
|
|
|
else
|
|
|
|
g_print("*** ERROR: error writing file %s\n", basename);
|
|
|
|
g_free(basename);
|
|
|
|
|
2006-08-01 16:12:45 +00:00
|
|
|
g_free(data);
|
|
|
|
g_key_file_free(config);
|
|
|
|
}
|
2006-02-25 22:27:41 +00:00
|
|
|
|
2006-08-01 16:12:45 +00:00
|
|
|
|
2006-08-01 21:07:46 +00:00
|
|
|
void configuration_read_filetype_extensions()
|
2006-08-01 16:12:45 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
gsize len = 0;
|
|
|
|
gchar *sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S,
|
|
|
|
"filetype_extensions.conf", NULL);
|
|
|
|
gchar *userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
|
|
|
|
"filetype_extensions.conf", NULL);
|
|
|
|
gchar **list;
|
|
|
|
GKeyFile *sysconfig = g_key_file_new();
|
|
|
|
GKeyFile *userconfig = g_key_file_new();
|
|
|
|
|
|
|
|
g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE, NULL);
|
|
|
|
g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE, NULL);
|
|
|
|
|
|
|
|
// read the keys
|
2006-02-25 22:27:41 +00:00
|
|
|
for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
|
|
|
|
{
|
2006-08-01 16:12:45 +00:00
|
|
|
gboolean userset =
|
|
|
|
g_key_file_has_key(userconfig, "Extensions", filetypes[i]->name, NULL);
|
|
|
|
list = g_key_file_get_string_list(
|
|
|
|
(userset) ? userconfig : sysconfig, "Extensions", filetypes[i]->name, &len, NULL);
|
2006-02-25 22:27:41 +00:00
|
|
|
if (list && len > 0)
|
|
|
|
{
|
|
|
|
g_strfreev(filetypes[i]->pattern);
|
|
|
|
filetypes[i]->pattern = list;
|
|
|
|
}
|
2006-08-01 16:12:45 +00:00
|
|
|
else g_strfreev(list);
|
2006-02-25 22:27:41 +00:00
|
|
|
}
|
|
|
|
|
2006-08-01 16:12:45 +00:00
|
|
|
g_key_file_free(sysconfig);
|
|
|
|
g_key_file_free(userconfig);
|
2006-02-14 22:07:55 +00:00
|
|
|
}
|