geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

keyfile.c
Go to the documentation of this file.
1/*
2 * keyfile.c - this file is part of Geany, a fast and lightweight IDE
3 *
4 * Copyright 2005 The Geany contributors
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21/*
22 * geany.conf preferences file loading and saving.
23 */
24
25/*
26 * Session file format:
27 * filename_xx=pos;filetype UID;read only;Eencoding;use_tabs;auto_indent;line_wrapping;filename
28 */
29
30#ifdef HAVE_CONFIG_H
31# include "config.h"
32#endif
33
34#include "keyfile.h"
35
36#include "app.h"
37#include "build.h"
38#include "document.h"
39#include "encodings.h"
40#include "encodingsprivate.h"
41#include "filetypes.h"
42#include "geanyobject.h"
43#include "main.h"
44#include "msgwindow.h"
45#include "prefs.h"
46#include "printing.h"
47#include "project.h"
48#include "sciwrappers.h"
49#include "socket.h"
50#include "stash.h"
51#include "support.h"
52#include "symbols.h"
53#include "templates.h"
54#include "toolbar.h"
55#include "ui_utils.h"
56#include "utils.h"
57#include "vte.h"
58
59#include <stdlib.h>
60#include <string.h>
61#include <ctype.h>
62
63#ifdef HAVE_VTE
64#include <pwd.h>
65#include <sys/types.h>
66#include <unistd.h>
67#endif
68
69
70/* some default settings which are used at the very first start of Geany to fill
71 * the configuration file */
72#define GEANY_MAX_SYMBOLLIST_HEIGHT 10
73#define GEANY_MIN_SYMBOLLIST_CHARS 4
74#define GEANY_MSGWIN_HEIGHT 208
75#define GEANY_DISK_CHECK_TIMEOUT 30
76#define GEANY_DEFAULT_TOOLS_MAKE "make"
77#ifdef G_OS_WIN32
78#define GEANY_DEFAULT_TOOLS_TERMINAL "cmd.exe /Q /C %c"
79#elif defined(__APPLE__)
80#define GEANY_DEFAULT_TOOLS_TERMINAL "open -a terminal %c"
81#else
82#define GEANY_DEFAULT_TOOLS_TERMINAL "xterm -e \"/bin/sh %c\""
83#endif
84#ifdef __APPLE__
85#define GEANY_DEFAULT_TOOLS_BROWSER "open -a safari"
86#define GEANY_DEFAULT_FONT_SYMBOL_LIST "Helvetica Medium 12"
87#define GEANY_DEFAULT_FONT_MSG_WINDOW "Menlo Medium 12"
88#define GEANY_DEFAULT_FONT_EDITOR "Menlo Medium 12"
89#else
90#define GEANY_DEFAULT_TOOLS_BROWSER "firefox"
91#define GEANY_DEFAULT_FONT_SYMBOL_LIST "Sans 9"
92#define GEANY_DEFAULT_FONT_MSG_WINDOW "Monospace 9"
93#define GEANY_DEFAULT_FONT_EDITOR "Monospace 10"
94#endif
95#define GEANY_DEFAULT_TOOLS_PRINTCMD "lpr"
96#define GEANY_DEFAULT_TOOLS_GREP "grep"
97#define GEANY_DEFAULT_MRU_LENGTH 10
98#define GEANY_TOGGLE_MARK "~ "
99#define GEANY_MAX_AUTOCOMPLETE_WORDS 30
100#define GEANY_MAX_SYMBOLS_UPDATE_FREQ 250
101#define GEANY_DEFAULT_FILETYPE_REGEX "-\\*-\\s*([^\\s]+)\\s*-\\*-"
102
103
104static gchar *scribble_text = NULL;
105static gint scribble_pos = -1;
106static GPtrArray *session_files = NULL;
108static gint hpan_position;
109static gint vpan_position;
111static const gchar atomic_file_saving_key[] = "use_atomic_file_saving";
112
113static GPtrArray *keyfile_groups = NULL;
114
115GPtrArray *pref_groups = NULL;
116
117static struct
118{
122}
124
125
126/* The group will be free'd on quitting.
127 * @param for_prefs_dialog is whether the group also has Prefs dialog items. */
128void configuration_add_pref_group(struct StashGroup *group, gboolean for_prefs_dialog)
129{
130 g_ptr_array_add(keyfile_groups, group);
131
132 if (for_prefs_dialog)
133 g_ptr_array_add(pref_groups, group);
134}
135
136
137/* The group will be free'd on quitting.
138 * prefix can be NULL to use group name */
140 const gchar *prefix)
141{
143 stash_group_set_various(group, TRUE, prefix);
144}
145
146
147static void init_pref_groups(void)
148{
150
151 group = stash_group_new(PACKAGE);
154 "default_open_path", "", "startup_path_entry");
155
157 "cmdline_new_files", TRUE, "check_cmdline_new_files");
158
160 "notebook_double_click_hides_widgets", FALSE, "check_double_click_hides_widgets");
162 "tab_close_switch_to_mru", FALSE, "check_tab_close_switch_to_mru");
163 stash_group_add_integer(group, &interface_prefs.tab_pos_sidebar, "tab_pos_sidebar", GTK_POS_TOP);
165 "sidebar_pos", GTK_POS_LEFT,
166 "radio_sidebar_left", GTK_POS_LEFT,
167 "radio_sidebar_right", GTK_POS_RIGHT,
168 NULL);
170 "symbols_sort_mode", SYMBOLS_SORT_BY_NAME,
171 "radio_symbols_sort_by_name", SYMBOLS_SORT_BY_NAME,
172 "radio_symbols_sort_by_appearance", SYMBOLS_SORT_BY_APPEARANCE,
173 NULL);
175 "msgwin_orientation", GTK_ORIENTATION_VERTICAL,
176 "radio_msgwin_vertical", GTK_ORIENTATION_VERTICAL,
177 "radio_msgwin_horizontal", GTK_ORIENTATION_HORIZONTAL,
178 NULL);
179
180 /* editor display */
182 "highlighting_invert_all", FALSE, "check_highlighting_invert");
183
185 "pref_main_search_use_current_word", TRUE, "check_search_use_current_word");
186
187 /* editor */
189 "check_detect_indent", FALSE, "check_detect_indent_type");
191 "detect_indent_width", FALSE, "check_detect_indent_width");
193 "use_tab_to_indent", TRUE, "check_tab_key_indents");
195 "pref_editor_tab_width", 4, "spin_indent_width");
197 "indent_mode", GEANY_AUTOINDENT_CURRENTCHARS, "combo_auto_indent_mode");
199 "indent_type", GEANY_INDENT_TYPE_TABS,
200 "radio_indent_spaces", GEANY_INDENT_TYPE_SPACES,
201 "radio_indent_tabs", GEANY_INDENT_TYPE_TABS,
202 "radio_indent_both", GEANY_INDENT_TYPE_BOTH,
203 NULL);
205 "virtualspace", GEANY_VIRTUAL_SPACE_SELECTION,
206 "radio_virtualspace_disabled", GEANY_VIRTUAL_SPACE_DISABLED,
207 "radio_virtualspace_selection", GEANY_VIRTUAL_SPACE_SELECTION,
208 "radio_virtualspace_always", GEANY_VIRTUAL_SPACE_ALWAYS,
209 NULL);
211 "autocomplete_doc_words", FALSE, "check_autocomplete_doc_words");
213 "completion_drops_rest_of_word", FALSE, "check_completion_drops_rest_of_word");
215 "autocompletion_max_entries", GEANY_MAX_AUTOCOMPLETE_WORDS,
216 "spin_autocompletion_max_entries");
218 "autocompletion_update_freq", GEANY_MAX_SYMBOLS_UPDATE_FREQ, "spin_symbol_update_freq");
220 "color_scheme", NULL);
222 "scroll_lines_around_cursor", 0, "spin_scroll_lines_around_cursor");
223
224 /* files */
226 "mru_length", GEANY_DEFAULT_MRU_LENGTH, "spin_mru");
228 "disk_check_timeout", GEANY_DISK_CHECK_TIMEOUT, "spin_disk_check");
229
230 /* various geany prefs */
231 group = stash_group_new(PACKAGE);
233
235 "show_editor_scrollbars", TRUE);
237 "brace_match_ltgt", FALSE);
239 "use_gtk_word_boundaries", TRUE);
241 "complete_snippets_whilst_editing", FALSE);
242 /* for backwards-compatibility */
244 "indent_hard_tab_width", 8);
246 "editor_ime_interaction", SC_IME_WINDOWED);
247
248 group = stash_group_new(PACKAGE);
250
254 "gio_unsafe_save_backup", FALSE);
256 "use_gio_unsafe_file_saving", TRUE);
258 "keep_edit_history_on_reload", TRUE);
260 "show_keep_edit_history_on_reload_msg", TRUE);
262 "reload_clean_doc_on_file_change", FALSE);
264 "save_config_on_file_change", TRUE);
266 "extract_filetype_regex", GEANY_DEFAULT_FILETYPE_REGEX);
267 stash_group_add_boolean(group, &ui_prefs.allow_always_save,
268 "allow_always_save", FALSE);
269
270 group = stash_group_new(PACKAGE);
272
274 "find_selection_type", GEANY_FIND_SEL_CURRENT_WORD);
276 "replace_and_find_by_default", TRUE);
277
278 group = stash_group_new(PACKAGE);
280
281#ifdef G_OS_WIN32
282 stash_group_add_integer(group, (gint*)&prefs.socket_remote_cmd_port,
283 "socket_remote_cmd_port", SOCKET_WINDOWS_REMOTE_CMD_PORT);
284#endif
285
286 /* Note: Interface-related various prefs are in ui_init_prefs() */
287
288 /* various build-menu prefs */
289 // Warning: don't move PACKAGE group name items here
290 group = stash_group_new("build-menu");
292
293 stash_group_add_integer(group, &build_menu_prefs.number_ft_menu_items,
294 "number_ft_menu_items", 0);
295 stash_group_add_integer(group, &build_menu_prefs.number_non_ft_menu_items,
296 "number_non_ft_menu_items", 0);
297 stash_group_add_integer(group, &build_menu_prefs.number_exec_menu_items,
298 "number_exec_menu_items", 0);
299}
300
301
302typedef enum SettingAction
303{
308
309static void settings_action(GKeyFile *config, SettingAction action)
310{
311 guint i;
313
315 {
316 switch (action)
317 {
318 case SETTING_READ:
320 case SETTING_WRITE:
321 stash_group_save_to_key_file(group, config); break;
322 }
323 }
324}
325
326
327static void save_recent_files(GKeyFile *config, GQueue *queue, gchar const *key)
328{
329 gchar **recent_files = g_new0(gchar*, file_prefs.mru_length + 1);
330 guint i;
331
332 for (i = 0; i < file_prefs.mru_length; i++)
333 {
334 if (! g_queue_is_empty(queue))
335 {
336 /* copy the values, this is necessary when this function is called from the
337 * preferences dialog or when quitting is canceled to keep the queue intact */
338 recent_files[i] = g_strdup(g_queue_peek_nth(queue, i));
339 }
340 else
341 {
342 recent_files[i] = NULL;
343 break;
344 }
345 }
346 /* There is a bug in GTK 2.6 g_key_file_set_string_list, we must NULL terminate. */
347 recent_files[file_prefs.mru_length] = NULL;
348 g_key_file_set_string_list(config, "files", key,
349 (const gchar**)recent_files, file_prefs.mru_length);
350 g_strfreev(recent_files);
351}
352
353
355{
356 gchar *fname;
357 gchar *locale_filename;
358 gchar *escaped_filename;
359 GeanyFiletype *ft = doc->file_type;
360
361 if (ft == NULL) /* can happen when saving a new file when quitting */
363
364 locale_filename = utils_get_locale_from_utf8(doc->file_name);
365 escaped_filename = g_uri_escape_string(locale_filename, NULL, TRUE);
366
367 fname = g_strdup_printf("%d;%s;%d;E%s;%d;%d;%d;%s;%d;%d",
369 ft->name,
370 doc->readonly,
371 doc->encoding,
372 doc->editor->indent_type,
373 doc->editor->auto_indent,
374 doc->editor->line_wrapping,
375 escaped_filename,
376 doc->editor->line_breaking,
377 doc->editor->indent_width);
378 g_free(escaped_filename);
379 g_free(locale_filename);
380 return fname;
381}
382
383
384static void remove_session_files(GKeyFile *config)
385{
386 gchar **ptr;
387 gchar **keys = g_key_file_get_keys(config, "files", NULL, NULL);
388
389 foreach_strv(ptr, keys)
390 {
391 if (g_str_has_prefix(*ptr, "FILE_NAME_"))
392 g_key_file_remove_key(config, "files", *ptr, NULL);
393 }
394 g_strfreev(keys);
395}
396
397
399{
400 gint npage;
401 gchar entry[16];
402 guint i = 0, j = 0, max;
403
404 npage = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
405 g_key_file_set_integer(config, "files", "current_page", npage);
406
407 // clear existing entries first as they might not all be overwritten
408 remove_session_files(config);
409
410 /* store the filenames in the notebook tab order to reopen them the next time */
411 max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
412 for (i = 0; i < max; i++)
413 {
415
416 if (doc != NULL && doc->real_path != NULL)
417 {
418 gchar *fname;
419
420 g_snprintf(entry, sizeof(entry), "FILE_NAME_%d", j);
421 fname = get_session_file_string(doc);
422 g_key_file_set_string(config, "files", entry, fname);
423 g_free(fname);
424 j++;
425 }
426 }
427
428#ifdef HAVE_VTE
429 if (vte_info.have_vte)
430 {
431 vte_get_working_directory(); /* refresh vte_info.dir */
432 g_key_file_set_string(config, "VTE", "last_dir", vte_info.dir);
433 }
434#endif
435}
436
437
438static void save_dialog_prefs(GKeyFile *config)
439{
440 /* new settings should be added in init_pref_groups() */
442
443 /* Some of the key names are not consistent, but this is for backwards compatibility */
444
445 /* general */
446 g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", prefs.load_session);
447 g_key_file_set_boolean(config, PACKAGE, "pref_main_project_session", project_prefs.project_session);
448 g_key_file_set_boolean(config, PACKAGE, "pref_main_project_file_in_basedir", project_prefs.project_file_in_basedir);
449 g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos);
450 g_key_file_set_boolean(config, PACKAGE, "pref_main_save_wingeom", prefs.save_wingeom);
451 g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", prefs.confirm_exit);
452 g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_status_messages", prefs.suppress_status_messages);
453 g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_to_status);
454 g_key_file_set_boolean(config, PACKAGE, "beep_on_errors", prefs.beep_on_errors);
455 g_key_file_set_boolean(config, PACKAGE, "auto_focus", prefs.auto_focus);
456
457 /* interface */
458 g_key_file_set_boolean(config, PACKAGE, "sidebar_symbol_visible", interface_prefs.sidebar_symbol_visible);
459 g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_visible", interface_prefs.sidebar_openfiles_visible);
460 g_key_file_set_string(config, PACKAGE, "editor_font", interface_prefs.editor_font);
461 g_key_file_set_string(config, PACKAGE, "tagbar_font", interface_prefs.tagbar_font);
462 g_key_file_set_string(config, PACKAGE, "msgwin_font", interface_prefs.msgwin_font);
463 g_key_file_set_boolean(config, PACKAGE, "show_notebook_tabs", interface_prefs.show_notebook_tabs);
464 g_key_file_set_boolean(config, PACKAGE, "show_tab_cross", file_prefs.show_tab_cross);
465 g_key_file_set_boolean(config, PACKAGE, "tab_order_ltr", file_prefs.tab_order_ltr);
466 g_key_file_set_boolean(config, PACKAGE, "tab_order_beside", file_prefs.tab_order_beside);
467 g_key_file_set_integer(config, PACKAGE, "tab_pos_editor", interface_prefs.tab_pos_editor);
468 g_key_file_set_integer(config, PACKAGE, "tab_pos_msgwin", interface_prefs.tab_pos_msgwin);
469 g_key_file_set_boolean(config, PACKAGE, "use_native_windows_dialogs", interface_prefs.use_native_windows_dialogs);
470
471 /* display */
472 g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", editor_prefs.show_indent_guide);
473 g_key_file_set_boolean(config, PACKAGE, "show_white_space", editor_prefs.show_white_space);
474 g_key_file_set_boolean(config, PACKAGE, "show_line_endings", editor_prefs.show_line_endings);
475 g_key_file_set_boolean(config, PACKAGE, "show_markers_margin", editor_prefs.show_markers_margin);
476 g_key_file_set_boolean(config, PACKAGE, "show_linenumber_margin", editor_prefs.show_linenumber_margin);
477 g_key_file_set_boolean(config, PACKAGE, "long_line_enabled", editor_prefs.long_line_enabled);
478 g_key_file_set_integer(config, PACKAGE, "long_line_type", editor_prefs.long_line_type);
479 g_key_file_set_integer(config, PACKAGE, "long_line_column", editor_prefs.long_line_column);
480 g_key_file_set_string(config, PACKAGE, "long_line_color", editor_prefs.long_line_color);
481
482 /* editor */
483 g_key_file_set_integer(config, PACKAGE, "symbolcompletion_max_height", editor_prefs.symbolcompletion_max_height);
484 g_key_file_set_integer(config, PACKAGE, "symbolcompletion_min_chars", editor_prefs.symbolcompletion_min_chars);
485 g_key_file_set_boolean(config, PACKAGE, "use_folding", editor_prefs.folding);
486 g_key_file_set_boolean(config, PACKAGE, "unfold_all_children", editor_prefs.unfold_all_children);
487 g_key_file_set_boolean(config, PACKAGE, "use_indicators", editor_prefs.use_indicators);
488 g_key_file_set_boolean(config, PACKAGE, "line_wrapping", editor_prefs.line_wrapping);
489 g_key_file_set_boolean(config, PACKAGE, "auto_close_xml_tags", editor_prefs.auto_close_xml_tags);
490 g_key_file_set_boolean(config, PACKAGE, "complete_snippets", editor_prefs.complete_snippets);
491 g_key_file_set_boolean(config, PACKAGE, "auto_complete_symbols", editor_prefs.auto_complete_symbols);
492 g_key_file_set_boolean(config, PACKAGE, "pref_editor_disable_dnd", editor_prefs.disable_dnd);
493 g_key_file_set_boolean(config, PACKAGE, "pref_editor_smart_home_key", editor_prefs.smart_home_key);
494 g_key_file_set_boolean(config, PACKAGE, "pref_editor_newline_strip", editor_prefs.newline_strip);
495 g_key_file_set_integer(config, PACKAGE, "line_break_column", editor_prefs.line_break_column);
496 g_key_file_set_boolean(config, PACKAGE, "auto_continue_multiline", editor_prefs.auto_continue_multiline);
497 g_key_file_set_string(config, PACKAGE, "comment_toggle_mark", editor_prefs.comment_toggle_mark);
498 g_key_file_set_boolean(config, PACKAGE, "scroll_stop_at_last_line", editor_prefs.scroll_stop_at_last_line);
499 g_key_file_set_integer(config, PACKAGE, "autoclose_chars", editor_prefs.autoclose_chars);
500
501 /* files */
502 g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[file_prefs.default_new_encoding].charset);
504 g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", "none");
505 else
506 g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", encodings[file_prefs.default_open_encoding].charset);
507 g_key_file_set_integer(config, PACKAGE, "default_eol_character", file_prefs.default_eol_character);
508 g_key_file_set_boolean(config, PACKAGE, "pref_editor_new_line", file_prefs.final_new_line);
509 g_key_file_set_boolean(config, PACKAGE, "pref_editor_ensure_convert_line_endings", file_prefs.ensure_convert_new_lines);
510 g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", file_prefs.replace_tabs);
511 g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", file_prefs.strip_trailing_spaces);
512
513 /* toolbar */
514 g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", toolbar_prefs.visible);
515 g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_append_to_menu", toolbar_prefs.append_to_menu);
516 g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_style", toolbar_prefs.use_gtk_default_style);
517 g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_icon", toolbar_prefs.use_gtk_default_icon);
518 g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_style", toolbar_prefs.icon_style);
519 g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_size", toolbar_prefs.icon_size);
520
521 /* templates */
522 g_key_file_set_string(config, PACKAGE, "pref_template_developer", template_prefs.developer);
523 g_key_file_set_string(config, PACKAGE, "pref_template_company", template_prefs.company);
524 g_key_file_set_string(config, PACKAGE, "pref_template_mail", template_prefs.mail);
525 g_key_file_set_string(config, PACKAGE, "pref_template_initial", template_prefs.initials);
526 g_key_file_set_string(config, PACKAGE, "pref_template_version", template_prefs.version);
527 g_key_file_set_string(config, PACKAGE, "pref_template_year", template_prefs.year_format);
528 g_key_file_set_string(config, PACKAGE, "pref_template_date", template_prefs.date_format);
529 g_key_file_set_string(config, PACKAGE, "pref_template_datetime", template_prefs.datetime_format);
530
531 /* tools settings */
532 g_key_file_set_string(config, "tools", "terminal_cmd", tool_prefs.term_cmd ? tool_prefs.term_cmd : "");
533 g_key_file_set_string(config, "tools", "browser_cmd", tool_prefs.browser_cmd ? tool_prefs.browser_cmd : "");
534 g_key_file_set_string(config, "tools", "grep_cmd", tool_prefs.grep_cmd ? tool_prefs.grep_cmd : "");
535 g_key_file_set_string(config, PACKAGE, "context_action_cmd", tool_prefs.context_action_cmd);
536
537 /* build menu */
539
540 /* printing */
541 g_key_file_set_string(config, "printing", "print_cmd", printing_prefs.external_print_cmd ? printing_prefs.external_print_cmd : "");
542 g_key_file_set_boolean(config, "printing", "use_gtk_printing", printing_prefs.use_gtk_printing);
543 g_key_file_set_boolean(config, "printing", "print_line_numbers", printing_prefs.print_line_numbers);
544 g_key_file_set_boolean(config, "printing", "print_page_numbers", printing_prefs.print_page_numbers);
545 g_key_file_set_boolean(config, "printing", "print_page_header", printing_prefs.print_page_header);
546 g_key_file_set_boolean(config, "printing", "page_header_basename", printing_prefs.page_header_basename);
547 g_key_file_set_string(config, "printing", "page_header_datefmt", printing_prefs.page_header_datefmt);
548
549 /* VTE */
550#ifdef HAVE_VTE
551 g_key_file_set_boolean(config, "VTE", "load_vte", vte_info.load_vte);
552 if (vte_info.have_vte)
553 {
554 gchar *tmp_string;
555
556 g_key_file_set_string(config, "VTE", "font", vc->font);
557 g_key_file_set_boolean(config, "VTE", "scroll_on_key", vc->scroll_on_key);
558 g_key_file_set_boolean(config, "VTE", "scroll_on_out", vc->scroll_on_out);
559 g_key_file_set_boolean(config, "VTE", "enable_bash_keys", vc->enable_bash_keys);
560 g_key_file_set_boolean(config, "VTE", "ignore_menu_bar_accel", vc->ignore_menu_bar_accel);
561 g_key_file_set_boolean(config, "VTE", "follow_path", vc->follow_path);
562 g_key_file_set_boolean(config, "VTE", "run_in_vte", vc->run_in_vte);
563 g_key_file_set_boolean(config, "VTE", "skip_run_script", vc->skip_run_script);
564 g_key_file_set_boolean(config, "VTE", "cursor_blinks", vc->cursor_blinks);
565 g_key_file_set_integer(config, "VTE", "scrollback_lines", vc->scrollback_lines);
566 g_key_file_set_string(config, "VTE", "font", vc->font);
567 g_key_file_set_string(config, "VTE", "shell", vc->shell);
568 tmp_string = utils_get_hex_from_color(&vc->colour_fore);
569 g_key_file_set_string(config, "VTE", "colour_fore", tmp_string);
570 g_free(tmp_string);
571 tmp_string = utils_get_hex_from_color(&vc->colour_back);
572 g_key_file_set_string(config, "VTE", "colour_back", tmp_string);
573 g_free(tmp_string);
574 }
575#endif
576}
577
578
579static void save_ui_prefs(GKeyFile *config)
580{
581 g_key_file_set_boolean(config, PACKAGE, "sidebar_visible", ui_prefs.sidebar_visible);
582 g_key_file_set_boolean(config, PACKAGE, "statusbar_visible", interface_prefs.statusbar_visible);
583 g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", ui_prefs.msgwindow_visible);
584 g_key_file_set_boolean(config, PACKAGE, "fullscreen", ui_prefs.fullscreen);
585 g_key_file_set_string(config, PACKAGE, "color_picker_palette", ui_prefs.color_picker_palette);
586
587 /* get the text from the scribble textview */
588 {
589 GtkTextBuffer *buffer;
590 GtkTextIter start, end, iter;
591 GtkTextMark *mark;
592
593 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(msgwindow.scribble));
594 gtk_text_buffer_get_bounds(buffer, &start, &end);
595 scribble_text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
596 g_key_file_set_string(config, PACKAGE, "scribble_text", scribble_text);
597 g_free(scribble_text);
598
599 mark = gtk_text_buffer_get_insert(buffer);
600 gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
601 scribble_pos = gtk_text_iter_get_offset(&iter);
602 g_key_file_set_integer(config, PACKAGE, "scribble_pos", scribble_pos);
603 }
604
606 {
607 GdkWindowState wstate;
608
609 g_key_file_set_integer(config, PACKAGE, "treeview_position",
610 gtk_paned_get_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "hpaned1"))));
611 g_key_file_set_integer(config, PACKAGE, "msgwindow_position",
612 gtk_paned_get_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "vpaned1"))));
613
614 gtk_window_get_position(GTK_WINDOW(main_widgets.window), &ui_prefs.geometry[0], &ui_prefs.geometry[1]);
615 gtk_window_get_size(GTK_WINDOW(main_widgets.window), &ui_prefs.geometry[2], &ui_prefs.geometry[3]);
616 wstate = gdk_window_get_state(gtk_widget_get_window(main_widgets.window));
617 ui_prefs.geometry[4] = (wstate & GDK_WINDOW_STATE_MAXIMIZED) ? 1 : 0;
618 g_key_file_set_integer_list(config, PACKAGE, "geometry", ui_prefs.geometry, 5);
619 }
620
621 g_key_file_set_string(config, PACKAGE, "custom_date_format", ui_prefs.custom_date_format);
622 if (ui_prefs.custom_commands != NULL)
623 {
624 g_key_file_set_string_list(config, PACKAGE, "custom_commands",
625 (const gchar**) ui_prefs.custom_commands, g_strv_length(ui_prefs.custom_commands));
626 g_key_file_set_string_list(config, PACKAGE, "custom_commands_labels",
627 (const gchar**) ui_prefs.custom_commands_labels, g_strv_length(ui_prefs.custom_commands_labels));
628 }
629}
630
631
633{
634 GKeyFile *config = g_key_file_new();
635 gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
636 gchar *data;
637
638 g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
639
640 /* this signal can be used e.g. to prepare any settings before Stash code reads them below */
641 g_signal_emit_by_name(geany_object, "save-settings", config);
642
643 save_dialog_prefs(config);
644 save_ui_prefs(config);
645 project_save_prefs(config); /* save project filename, etc. */
646 save_recent_files(config, ui_prefs.recent_queue, "recent_files");
647 save_recent_files(config, ui_prefs.recent_projects_queue, "recent_projects");
648
649 if (cl_options.load_session)
651#ifdef HAVE_VTE
652 else if (vte_info.have_vte)
653 {
654 vte_get_working_directory(); /* refresh vte_info.dir */
655 g_key_file_set_string(config, "VTE", "last_dir", vte_info.dir);
656 }
657#endif
658
659 /* write the file */
660 data = g_key_file_to_data(config, NULL, NULL);
661 utils_write_file(configfile, data);
662 g_free(data);
663
664 g_key_file_free(config);
665 g_free(configfile);
666}
667
668
669static void load_recent_files(GKeyFile *config, GQueue *queue, const gchar *key)
670{
671 gchar **recent_files;
672 gsize i, len = 0;
673
674 recent_files = g_key_file_get_string_list(config, "files", key, &len, NULL);
675 if (recent_files != NULL)
676 {
677 for (i = 0; (i < len) && (i < file_prefs.mru_length); i++)
678 {
679 gchar *filename = g_strdup(recent_files[i]);
680 g_queue_push_tail(queue, filename);
681 }
682 g_strfreev(recent_files);
683 }
684}
685
686
687/*
688 * Load session list from the given keyfile, and store it in the global
689 * session_files variable for later file loading
690 * */
691void configuration_load_session_files(GKeyFile *config, gboolean read_recent_files)
692{
693 guint i;
694 gboolean have_session_files;
695 gchar entry[16];
696 gchar **tmp_array;
697 GError *error = NULL;
698
699 session_notebook_page = utils_get_setting_integer(config, "files", "current_page", -1);
700
701 if (read_recent_files)
702 {
703 load_recent_files(config, ui_prefs.recent_queue, "recent_files");
704 load_recent_files(config, ui_prefs.recent_projects_queue, "recent_projects");
705 }
706
707 /* the project may load another list than the main setting */
708 if (session_files != NULL)
709 {
710 foreach_ptr_array(tmp_array, i, session_files)
711 g_strfreev(tmp_array);
712 g_ptr_array_free(session_files, TRUE);
713 }
714
715 session_files = g_ptr_array_new();
716 have_session_files = TRUE;
717 i = 0;
718 while (have_session_files)
719 {
720 g_snprintf(entry, sizeof(entry), "FILE_NAME_%d", i);
721 tmp_array = g_key_file_get_string_list(config, "files", entry, NULL, &error);
722 if (! tmp_array || error)
723 {
724 g_error_free(error);
725 error = NULL;
726 have_session_files = FALSE;
727 }
728 g_ptr_array_add(session_files, tmp_array);
729 i++;
730 }
731
732#ifdef HAVE_VTE
733 /* BUG: after loading project at startup, closing project doesn't restore old VTE path */
734 if (vte_info.have_vte)
735 {
736 gchar *tmp_string = utils_get_setting_string(config, "VTE", "last_dir", NULL);
737 vte_cwd(tmp_string,TRUE);
738 g_free(tmp_string);
739 }
740#endif
741}
742
743
744#ifdef HAVE_VTE
745static void get_setting_color(GKeyFile *config, const gchar *section, const gchar *key,
746 GdkColor *color, const gchar *default_color)
747{
748 gchar *str = utils_get_setting_string(config, section, key, NULL);
749 if (str == NULL || ! utils_parse_color(str, color))
750 utils_parse_color(default_color, color);
751 g_free(str);
752}
753#endif
754
755
756/* note: new settings should be added in init_pref_groups() */
757static void load_dialog_prefs(GKeyFile *config)
758{
759 gchar *tmp_string, *tmp_string2;
760 const gchar *default_charset = NULL;
761 gchar *cmd;
762
763 /* compatibility with Geany 0.20 */
764 if (!g_key_file_has_key(config, PACKAGE, atomic_file_saving_key, NULL))
765 {
766 g_key_file_set_boolean(config, PACKAGE, atomic_file_saving_key,
767 utils_get_setting_boolean(config, PACKAGE, "use_safe_file_saving", FALSE));
768 }
769
770 /* compatibility with Geany 0.21 */
771 {
772 gboolean suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE);
773
774 if (!g_key_file_has_key(config, "search", "pref_search_always_wrap", NULL))
775 g_key_file_set_boolean(config, "search", "pref_search_always_wrap", suppress_search_dialogs);
776
777 if (!g_key_file_has_key(config, "search", "pref_search_hide_find_dialog", NULL))
778 g_key_file_set_boolean(config, "search", "pref_search_hide_find_dialog", suppress_search_dialogs);
779 }
780
781 /* general */
782 prefs.confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", FALSE);
783 prefs.suppress_status_messages = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_status_messages", FALSE);
784 prefs.load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
785 project_prefs.project_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_session", TRUE);
786 project_prefs.project_file_in_basedir = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_file_in_basedir", FALSE);
787 prefs.save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
788 prefs.save_wingeom = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_wingeom", prefs.save_winpos);
789 prefs.beep_on_errors = utils_get_setting_boolean(config, PACKAGE, "beep_on_errors", TRUE);
790 prefs.switch_to_status = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE);
791 prefs.auto_focus = utils_get_setting_boolean(config, PACKAGE, "auto_focus", FALSE);
792
793 /* interface */
794 interface_prefs.tab_pos_editor = utils_get_setting_integer(config, PACKAGE, "tab_pos_editor", GTK_POS_TOP);
795 interface_prefs.tab_pos_msgwin = utils_get_setting_integer(config, PACKAGE, "tab_pos_msgwin",GTK_POS_LEFT);
796 interface_prefs.sidebar_symbol_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_symbol_visible", TRUE);
797 interface_prefs.sidebar_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_visible", TRUE);
798 interface_prefs.statusbar_visible = utils_get_setting_boolean(config, PACKAGE, "statusbar_visible", TRUE);
799 file_prefs.tab_order_ltr = utils_get_setting_boolean(config, PACKAGE, "tab_order_ltr", TRUE);
800 file_prefs.tab_order_beside = utils_get_setting_boolean(config, PACKAGE, "tab_order_beside", FALSE);
801 interface_prefs.show_notebook_tabs = utils_get_setting_boolean(config, PACKAGE, "show_notebook_tabs", TRUE);
802 file_prefs.show_tab_cross = utils_get_setting_boolean(config, PACKAGE, "show_tab_cross", TRUE);
806 interface_prefs.use_native_windows_dialogs = utils_get_setting_boolean(config, PACKAGE, "use_native_windows_dialogs", FALSE);
807
808 /* display, editor */
809 editor_prefs.long_line_enabled = utils_get_setting_boolean(config, PACKAGE, "long_line_enabled", TRUE);
810 editor_prefs.long_line_type = utils_get_setting_integer(config, PACKAGE, "long_line_type", 0);
811 if (editor_prefs.long_line_type == 2) /* backward compatibility */
812 {
815 }
816 editor_prefs.long_line_color = utils_get_setting_string(config, PACKAGE, "long_line_color", "#C2EBC2");
817 editor_prefs.long_line_column = utils_get_setting_integer(config, PACKAGE, "long_line_column", 72);
820 editor_prefs.line_wrapping = utils_get_setting_boolean(config, PACKAGE, "line_wrapping", FALSE); /* default is off for better performance */
821 editor_prefs.use_indicators = utils_get_setting_boolean(config, PACKAGE, "use_indicators", TRUE);
822 editor_prefs.show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);
823 editor_prefs.show_white_space = utils_get_setting_boolean(config, PACKAGE, "show_white_space", FALSE);
824 editor_prefs.show_line_endings = utils_get_setting_boolean(config, PACKAGE, "show_line_endings", FALSE);
825 editor_prefs.scroll_stop_at_last_line = utils_get_setting_boolean(config, PACKAGE, "scroll_stop_at_last_line", TRUE);
826 editor_prefs.auto_close_xml_tags = utils_get_setting_boolean(config, PACKAGE, "auto_close_xml_tags", TRUE);
827 editor_prefs.complete_snippets = utils_get_setting_boolean(config, PACKAGE, "complete_snippets", TRUE);
828 editor_prefs.auto_complete_symbols = utils_get_setting_boolean(config, PACKAGE, "auto_complete_symbols", TRUE);
829 editor_prefs.folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE);
830 editor_prefs.unfold_all_children = utils_get_setting_boolean(config, PACKAGE, "unfold_all_children", FALSE);
831 editor_prefs.show_markers_margin = utils_get_setting_boolean(config, PACKAGE, "show_markers_margin", TRUE);
832 editor_prefs.show_linenumber_margin = utils_get_setting_boolean(config, PACKAGE, "show_linenumber_margin", TRUE);
833 editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE);
834 editor_prefs.smart_home_key = utils_get_setting_boolean(config, PACKAGE, "pref_editor_smart_home_key", TRUE);
835 editor_prefs.newline_strip = utils_get_setting_boolean(config, PACKAGE, "pref_editor_newline_strip", FALSE);
836 editor_prefs.line_break_column = utils_get_setting_integer(config, PACKAGE, "line_break_column", 72);
837 editor_prefs.auto_continue_multiline = utils_get_setting_boolean(config, PACKAGE, "auto_continue_multiline", TRUE);
838 editor_prefs.comment_toggle_mark = utils_get_setting_string(config, PACKAGE, "comment_toggle_mark", GEANY_TOGGLE_MARK);
839 editor_prefs.autoclose_chars = utils_get_setting_integer(config, PACKAGE, "autoclose_chars", 0);
840
841 /* Files
842 * use current locale encoding as default for new files (should be UTF-8 in most cases) */
843 g_get_charset(&default_charset);
844 tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_new_encoding",
845 default_charset);
846 if (tmp_string)
847 {
848 const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
849 if (enc != NULL)
851 else
853
854 g_free(tmp_string);
855 }
856 tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_open_encoding",
857 "none");
858 if (tmp_string)
859 {
860 const GeanyEncoding *enc = NULL;
861 if (strcmp(tmp_string, "none") != 0)
862 enc = encodings_get_from_charset(tmp_string);
863 if (enc != NULL)
865 else
867
868 g_free(tmp_string);
869 }
870 file_prefs.default_eol_character = utils_get_setting_integer(config, PACKAGE, "default_eol_character", GEANY_DEFAULT_EOL_CHARACTER);
871 file_prefs.replace_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_replace_tabs", FALSE);
872 file_prefs.ensure_convert_new_lines = utils_get_setting_boolean(config, PACKAGE, "pref_editor_ensure_convert_line_endings", FALSE);
873 file_prefs.final_new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE);
874 file_prefs.strip_trailing_spaces = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE);
875
876 /* toolbar */
877 toolbar_prefs.visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE);
878 toolbar_prefs.append_to_menu = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_append_to_menu", FALSE);
879 {
880 toolbar_prefs.use_gtk_default_style = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_style", TRUE);
882 toolbar_prefs.icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", GTK_TOOLBAR_ICONS);
883
884 toolbar_prefs.use_gtk_default_icon = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_icon", TRUE);
886 toolbar_prefs.icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", GTK_ICON_SIZE_LARGE_TOOLBAR);
887 }
888
889 /* VTE */
890#ifdef HAVE_VTE
891 vte_info.load_vte = utils_get_setting_boolean(config, "VTE", "load_vte", TRUE);
892 if (vte_info.load_vte && vte_info.load_vte_cmdline /* not disabled on the cmdline */)
893 {
895 struct passwd *pw = getpwuid(getuid());
896 const gchar *shell = (pw != NULL) ? pw->pw_shell : "/bin/sh";
897
898#ifdef __APPLE__
899 /* Geany is started using launchd on OS X and we don't get any environment variables
900 * so PS1 isn't defined. Start as a login shell to read the corresponding config files. */
901 if (strcmp(shell, "/bin/bash") == 0)
902 shell = "/bin/bash -l";
903#endif
904
905 vc = g_new0(VteConfig, 1);
906 vte_info.dir = utils_get_setting_string(config, "VTE", "last_dir", NULL);
907 if ((vte_info.dir == NULL || utils_str_equal(vte_info.dir, "")) && pw != NULL)
908 /* last dir is not set, fallback to user's home directory */
909 SETPTR(vte_info.dir, g_strdup(pw->pw_dir));
910 else if (vte_info.dir == NULL && pw == NULL)
911 /* fallback to root */
912 vte_info.dir = g_strdup("/");
913
914 vc->shell = utils_get_setting_string(config, "VTE", "shell", shell);
915 vc->font = utils_get_setting_string(config, "VTE", "font", GEANY_DEFAULT_FONT_EDITOR);
916 vc->scroll_on_key = utils_get_setting_boolean(config, "VTE", "scroll_on_key", TRUE);
917 vc->scroll_on_out = utils_get_setting_boolean(config, "VTE", "scroll_on_out", TRUE);
918 vc->enable_bash_keys = utils_get_setting_boolean(config, "VTE", "enable_bash_keys", TRUE);
919 vc->ignore_menu_bar_accel = utils_get_setting_boolean(config, "VTE", "ignore_menu_bar_accel", FALSE);
920 vc->follow_path = utils_get_setting_boolean(config, "VTE", "follow_path", FALSE);
921 vc->run_in_vte = utils_get_setting_boolean(config, "VTE", "run_in_vte", FALSE);
922 vc->skip_run_script = utils_get_setting_boolean(config, "VTE", "skip_run_script", FALSE);
923 vc->cursor_blinks = utils_get_setting_boolean(config, "VTE", "cursor_blinks", FALSE);
924 vc->scrollback_lines = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500);
925 get_setting_color(config, "VTE", "colour_fore", &vc->colour_fore, "#ffffff");
926 get_setting_color(config, "VTE", "colour_back", &vc->colour_back, "#000000");
927
928 /* various VTE prefs.
929 * this can't be done in init_pref_groups() because we need to know the value of
930 * vte_info.load_vte, and `vc` to be initialized */
931 group = stash_group_new("VTE");
933
934 stash_group_add_string(group, &vc->send_cmd_prefix, "send_cmd_prefix", "");
935 stash_group_add_boolean(group, &vc->send_selection_unsafe, "send_selection_unsafe", FALSE);
936 }
937#endif
938 /* templates */
939 template_prefs.developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name());
940 template_prefs.company = utils_get_setting_string(config, PACKAGE, "pref_template_company", "");
942 template_prefs.initials = utils_get_setting_string(config, PACKAGE, "pref_template_initial", tmp_string);
943 g_free(tmp_string);
944
945 template_prefs.version = utils_get_setting_string(config, PACKAGE, "pref_template_version", "1.0");
946
947 tmp_string = g_strdup_printf("%s@%s", g_get_user_name(), g_get_host_name());
948 template_prefs.mail = utils_get_setting_string(config, PACKAGE, "pref_template_mail", tmp_string);
949 g_free(tmp_string);
950 template_prefs.year_format = utils_get_setting_string(config, PACKAGE, "pref_template_year", GEANY_TEMPLATES_FORMAT_YEAR);
951 template_prefs.date_format = utils_get_setting_string(config, PACKAGE, "pref_template_date", GEANY_TEMPLATES_FORMAT_DATE);
952 template_prefs.datetime_format = utils_get_setting_string(config, PACKAGE, "pref_template_datetime", GEANY_TEMPLATES_FORMAT_DATETIME);
953
954 /* tools */
955 cmd = utils_get_setting_string(config, "tools", "terminal_cmd", "");
956 if (EMPTY(cmd))
957 {
958 SETPTR(cmd, utils_get_setting_string(config, "tools", "term_cmd", ""));
959 if (!EMPTY(cmd))
960 {
961 tmp_string = cmd;
962#ifdef G_OS_WIN32
963 if (strstr(cmd, "cmd.exe"))
964 cmd = g_strconcat(cmd, " /Q /C %c", NULL);
965 else
966 cmd = g_strconcat(cmd, " %c", NULL);
967#else
968 cmd = g_strconcat(cmd, " -e \"/bin/sh %c\"", NULL);
969#endif
970 g_free(tmp_string);
971 }
972 else
973 SETPTR(cmd, g_strdup(GEANY_DEFAULT_TOOLS_TERMINAL));
974 }
975 tool_prefs.term_cmd = cmd;
978
979 tool_prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
980
981 /* printing */
982 tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD);
983
984 if (!EMPTY(tmp_string2))
985 {
986 #ifdef G_OS_WIN32
987 tmp_string = g_strconcat(GEANY_DEFAULT_TOOLS_PRINTCMD, " \"%f\"", NULL);
988 #else
989 tmp_string = g_strconcat(GEANY_DEFAULT_TOOLS_PRINTCMD, " '%f'", NULL);
990 #endif
991 }
992 else
993 {
994 tmp_string = g_strdup("");
995 }
996
997 printing_prefs.external_print_cmd = utils_get_setting_string(config, "printing", "print_cmd", tmp_string);
998 g_free(tmp_string);
999 g_free(tmp_string2);
1000
1001 printing_prefs.use_gtk_printing = utils_get_setting_boolean(config, "printing", "use_gtk_printing", TRUE);
1002 printing_prefs.print_line_numbers = utils_get_setting_boolean(config, "printing", "print_line_numbers", TRUE);
1003 printing_prefs.print_page_numbers = utils_get_setting_boolean(config, "printing", "print_page_numbers", TRUE);
1004 printing_prefs.print_page_header = utils_get_setting_boolean(config, "printing", "print_page_header", TRUE);
1005 printing_prefs.page_header_basename = utils_get_setting_boolean(config, "printing", "page_header_basename", FALSE);
1006 printing_prefs.page_header_datefmt = utils_get_setting_string(config, "printing", "page_header_datefmt", "%c");
1007
1008 /* read stash prefs */
1010
1011 /* build menu
1012 * after stash prefs as it uses some of them */
1014 build_set_group_count(GEANY_GBG_NON_FT, build_menu_prefs.number_non_ft_menu_items);
1015 build_set_group_count(GEANY_GBG_EXEC, build_menu_prefs.number_exec_menu_items);
1017}
1018
1019
1020static void load_ui_prefs(GKeyFile *config)
1021{
1022 gint *geo;
1023 gsize geo_len;
1024
1025 ui_prefs.sidebar_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_visible", TRUE);
1026 ui_prefs.msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
1027 ui_prefs.fullscreen = utils_get_setting_boolean(config, PACKAGE, "fullscreen", FALSE);
1028 ui_prefs.custom_date_format = utils_get_setting_string(config, PACKAGE, "custom_date_format", "");
1029 ui_prefs.custom_commands = g_key_file_get_string_list(config, PACKAGE, "custom_commands", NULL, NULL);
1030 ui_prefs.custom_commands_labels = g_key_file_get_string_list(config, PACKAGE, "custom_commands_labels", NULL, NULL);
1031 ui_prefs.color_picker_palette = utils_get_setting_string(config, PACKAGE, "color_picker_palette", "");
1032
1033 /* Load the saved color picker palette */
1034 if (!EMPTY(ui_prefs.color_picker_palette))
1035 {
1036 GtkSettings *settings;
1037 settings = gtk_settings_get_for_screen(gtk_window_get_screen(GTK_WINDOW(main_widgets.window)));
1038 g_object_set(G_OBJECT(settings), "gtk-color-palette", ui_prefs.color_picker_palette, NULL);
1039 }
1040
1041 /* sanitize custom commands labels */
1042 if (ui_prefs.custom_commands || ui_prefs.custom_commands_labels)
1043 {
1044 guint i;
1045 guint cc_len = ui_prefs.custom_commands ? g_strv_length(ui_prefs.custom_commands) : 0;
1046 guint cc_labels_len = ui_prefs.custom_commands_labels ? g_strv_length(ui_prefs.custom_commands_labels) : 0;
1047
1048 /* not enough items, resize and fill */
1049 if (cc_labels_len < cc_len)
1050 {
1051 ui_prefs.custom_commands_labels = g_realloc(ui_prefs.custom_commands_labels,
1052 (cc_len + 1) * sizeof *ui_prefs.custom_commands_labels);
1053 for (i = cc_labels_len; i < cc_len; i++)
1054 ui_prefs.custom_commands_labels[i] = g_strdup("");
1055 ui_prefs.custom_commands_labels[cc_len] = NULL;
1056 }
1057 /* too many items, cut off */
1058 else if (cc_labels_len > cc_len)
1059 {
1060 for (i = cc_len; i < cc_labels_len; i++)
1061 {
1062 g_free(ui_prefs.custom_commands_labels[i]);
1063 ui_prefs.custom_commands_labels[i] = NULL;
1064 }
1065 }
1066 }
1067
1068 scribble_text = utils_get_setting_string(config, PACKAGE, "scribble_text",
1069 _("Type here what you want, use it as a notice/scratch board"));
1070 scribble_pos = utils_get_setting_integer(config, PACKAGE, "scribble_pos", -1);
1071
1072 geo = g_key_file_get_integer_list(config, PACKAGE, "geometry", &geo_len, NULL);
1073 if (! geo || geo_len < 5)
1074 {
1075 ui_prefs.geometry[0] = -1;
1076 ui_prefs.geometry[1] = -1;
1077 ui_prefs.geometry[2] = -1;
1078 ui_prefs.geometry[3] = -1;
1079 ui_prefs.geometry[4] = 0;
1080 }
1081 else
1082 {
1083 /* don't use insane values but when main windows was maximized last time, pos might be
1084 * negative (due to differences in root window and window decorations) */
1085 /* quitting when minimized can make pos -32000, -32000 on Windows! */
1086 ui_prefs.geometry[0] = MAX(-1, geo[0]);
1087 ui_prefs.geometry[1] = MAX(-1, geo[1]);
1088 ui_prefs.geometry[2] = MAX(-1, geo[2]);
1089 ui_prefs.geometry[3] = MAX(-1, geo[3]);
1090 ui_prefs.geometry[4] = geo[4] != 0;
1091 }
1092 hpan_position = utils_get_setting_integer(config, PACKAGE, "treeview_position", 156);
1093 vpan_position = utils_get_setting_integer(config, PACKAGE, "msgwindow_position", (geo) ?
1094 (GEANY_MSGWIN_HEIGHT + geo[3] - 440) :
1096
1097 g_free(geo);
1098}
1099
1100
1101/*
1102 * Save current session in default configuration file
1103 */
1105{
1106 gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
1107 gchar *data;
1108 GKeyFile *config = g_key_file_new();
1109
1110 g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
1111
1112 if (cl_options.load_session)
1114
1115 /* write the file */
1116 data = g_key_file_to_data(config, NULL, NULL);
1117 utils_write_file(configfile, data);
1118 g_free(data);
1119
1120 g_key_file_free(config);
1121 g_free(configfile);
1122}
1123
1124
1126{
1127 gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
1128 gchar *data;
1129 GKeyFile *config = g_key_file_new();
1130
1131 g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
1132
1133 if (cl_options.load_session)
1134 remove_session_files(config);
1135
1136 /* write the file */
1137 data = g_key_file_to_data(config, NULL, NULL);
1138 utils_write_file(configfile, data);
1139 g_free(data);
1140
1141 g_key_file_free(config);
1142 g_free(configfile);
1143}
1144
1145
1146/*
1147 * Only reload the session part of the default configuration
1148 */
1150{
1151 gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
1152 GKeyFile *config = g_key_file_new();
1153
1154 g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
1155 g_free(configfile);
1156
1157 configuration_load_session_files(config, FALSE);
1158
1159 g_key_file_free(config);
1160}
1161
1162
1164{
1165 gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
1166 GKeyFile *config = g_key_file_new();
1167
1168 if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR))
1169 { /* config file does not (yet) exist, so try to load a global config file which may be */
1170 /* created by distributors */
1171 geany_debug("No user config file found, trying to use global configuration.");
1172 SETPTR(configfile, g_build_filename(app->datadir, "geany.conf", NULL));
1173 }
1174 g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
1175 g_free(configfile);
1176
1177 load_dialog_prefs(config);
1178 load_ui_prefs(config);
1179 project_load_prefs(config);
1181
1182 /* this signal can be used e.g. to delay building UI elements until settings have been read */
1183 g_signal_emit_by_name(geany_object, "load-settings", config);
1184
1185 g_key_file_free(config);
1186 return TRUE;
1187}
1188
1189
1190static gboolean open_session_file(gchar **tmp, guint len)
1191{
1192 guint pos;
1193 const gchar *ft_name;
1194 gchar *locale_filename;
1195 gchar *unescaped_filename;
1196 const gchar *encoding;
1197 gint indent_type;
1198 gboolean ro, auto_indent, line_wrapping;
1199 /** TODO when we have a global pref for line breaking, use its value */
1200 gboolean line_breaking = FALSE;
1201 gboolean ret = FALSE;
1202
1203 pos = atoi(tmp[0]);
1204 ft_name = tmp[1];
1205 ro = atoi(tmp[2]);
1206 if (isdigit(tmp[3][0]))
1207 {
1208 encoding = encodings_get_charset_from_index(atoi(tmp[3]));
1209 }
1210 else
1211 {
1212 encoding = &(tmp[3][1]);
1213 }
1214 indent_type = atoi(tmp[4]);
1215 auto_indent = atoi(tmp[5]);
1216 line_wrapping = atoi(tmp[6]);
1217 /* try to get the locale equivalent for the filename */
1218 unescaped_filename = g_uri_unescape_string(tmp[7], NULL);
1219 locale_filename = utils_get_locale_from_utf8(unescaped_filename);
1220
1221 if (len > 8)
1222 line_breaking = atoi(tmp[8]);
1223
1224 if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR))
1225 {
1228 NULL, locale_filename, pos, ro, ft, encoding);
1229
1230 if (doc)
1231 {
1232 gint indent_width = doc->editor->indent_width;
1233
1234 if (len > 9)
1235 indent_width = atoi(tmp[9]);
1236 editor_set_indent(doc->editor, indent_type, indent_width);
1237 editor_set_line_wrapping(doc->editor, line_wrapping);
1238 doc->editor->line_breaking = line_breaking;
1239 doc->editor->auto_indent = auto_indent;
1240 ret = TRUE;
1241 }
1242 }
1243 else
1244 {
1245 geany_debug("Could not find file '%s'.", unescaped_filename);
1246 }
1247
1248 g_free(locale_filename);
1249 g_free(unescaped_filename);
1250 return ret;
1251}
1252
1253
1254/* Open session files
1255 * Note: notebook page switch handler and adding to recent files list is always disabled
1256 * for all files opened within this function */
1258{
1259 gint i;
1260 gboolean failure = FALSE;
1261
1262 /* necessary to set it to TRUE for project session support */
1263 main_status.opening_session_files = TRUE;
1264
1265 i = file_prefs.tab_order_ltr ? 0 : (session_files->len - 1);
1266 while (TRUE)
1267 {
1268 gchar **tmp = g_ptr_array_index(session_files, i);
1269 guint len;
1270
1271 if (tmp != NULL && (len = g_strv_length(tmp)) >= 8)
1272 {
1273 if (! open_session_file(tmp, len))
1274 failure = TRUE;
1275 }
1276 g_strfreev(tmp);
1277
1279 {
1280 i++;
1281 if (i >= (gint)session_files->len)
1282 break;
1283 }
1284 else
1285 {
1286 i--;
1287 if (i < 0)
1288 break;
1289 }
1290 }
1291
1292 g_ptr_array_free(session_files, TRUE);
1294
1295 if (failure)
1296 ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
1297 else
1298 {
1299 /* explicitly trigger a notebook page switch after unsetting main_status.opening_session_files
1300 * for callbacks to run (and update window title, encoding settings, and so on) */
1301 gint n_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
1302 gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
1303 gint target_page = session_notebook_page >= 0 ? session_notebook_page : cur_page;
1304
1305 /* if target page is current page, switch to another page first to really trigger an event */
1306 if (target_page == cur_page && n_pages > 0)
1307 gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), (cur_page + 1) % n_pages);
1308
1309 main_status.opening_session_files = FALSE;
1310 gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), target_page);
1311 }
1312 main_status.opening_session_files = FALSE;
1313}
1314
1315
1316/* set some settings which are already read from the config file, but need other things, like the
1317 * realisation of the main window */
1319{
1320 if (scribble_text)
1321 { /* update the scribble widget, because now it's realized */
1322 GtkTextIter iter;
1323 GtkTextBuffer *buffer =
1324 gtk_text_view_get_buffer(GTK_TEXT_VIEW(msgwindow.scribble));
1325
1326 gtk_text_buffer_set_text(buffer, scribble_text, -1);
1327 gtk_text_buffer_get_iter_at_offset(buffer, &iter, scribble_pos);
1328 gtk_text_buffer_place_cursor(buffer, &iter);
1329 }
1330 g_free(scribble_text);
1331
1332 /* set the position of the hpaned and vpaned */
1333 if (prefs.save_winpos)
1334 {
1335 gtk_paned_set_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "hpaned1")), hpan_position);
1336 gtk_paned_set_position(GTK_PANED(ui_lookup_widget(main_widgets.window, "vpaned1")), vpan_position);
1337 }
1338
1339 /* set fullscreen after initial draw so that returning to normal view is the right size.
1340 * fullscreen mode is disabled by default, so act only if it is true */
1341 if (ui_prefs.fullscreen)
1342 {
1343 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_fullscreen1")), TRUE);
1344 ui_prefs.fullscreen = TRUE;
1346 }
1347
1349}
1350
1351
1352static gboolean save_configuration_cb(gpointer data)
1353{
1355 if (app->project != NULL)
1356 {
1358 }
1360 return G_SOURCE_REMOVE;
1361}
1362
1363
1364static void document_list_changed_cb(GObject *obj, GeanyDocument *doc, gpointer data)
1365{
1366 g_return_if_fail(doc != NULL && doc->is_valid);
1367
1368 /* save configuration, especially session file list, but only if we are not just starting
1369 * and not about to quit */
1371 main_status.main_window_realized &&
1372 !main_status.opening_session_files &&
1373 !main_status.quitting)
1374 {
1376 {
1378 }
1379 }
1380}
1381
1382
1384{
1385 keyfile_groups = g_ptr_array_new();
1386 pref_groups = g_ptr_array_new();
1388
1389 g_signal_connect(geany_object, "document-open", G_CALLBACK(document_list_changed_cb), NULL);
1390 g_signal_connect(geany_object, "document-save", G_CALLBACK(document_list_changed_cb), NULL);
1391 g_signal_connect(geany_object, "document-close", G_CALLBACK(document_list_changed_cb), NULL);
1392}
1393
1394
1396{
1397 guint i;
1399
1400 g_signal_handlers_disconnect_by_func(geany_object, G_CALLBACK(document_list_changed_cb), NULL);
1401
1404
1405 g_ptr_array_free(keyfile_groups, TRUE);
1406 g_ptr_array_free(pref_groups, TRUE);
1407}
#define SC_IME_WINDOWED
Definition: Scintilla.h:107
Contains the GeanyApp.
void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
Definition: build.c:2576
void build_load_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
Definition: build.c:2356
GeanyBuildCommand ** ptr
Definition: build.c:2679
void build_set_group_count(GeanyBuildGroup grp, gint count)
Definition: build.c:2636
Interface to the Build menu functionality.
@ GEANY_GBG_NON_FT
non filetype items.
Definition: build.h:37
@ GEANY_GBG_FT
filetype items
Definition: build.h:36
@ GEANY_GBG_EXEC
execute items
Definition: build.h:38
@ GEANY_BCS_PREF
Preferences file ~/.config/geany/geany.conf.
Definition: build.h:48
GeanyDocument * document_open_file_full(GeanyDocument *doc, const gchar *filename, gint pos, gboolean readonly, GeanyFiletype *ft, const gchar *forced_enc)
Definition: document.c:1285
GeanyDocument * document_get_from_page(guint page_num)
Finds the document for the given notebook page page_num.
Definition: document.c:352
GeanyFilePrefs file_prefs
Definition: document.c:86
GdkColor color
Definition: document.c:3220
Document related actions: new, save, open, etc.
void editor_set_indent(GeanyEditor *editor, GeanyIndentType type, gint width)
Definition: editor.c:4668
void editor_set_line_wrapping(GeanyEditor *editor, gboolean wrap)
Definition: editor.c:4633
gint pos
Definition: editor.c:87
GeanyEditorPrefs editor_prefs
Definition: editor.c:77
@ GEANY_AUTOINDENT_CURRENTCHARS
Definition: editor.h:58
@ GEANY_INDENT_TYPE_BOTH
Both.
Definition: editor.h:48
@ GEANY_INDENT_TYPE_TABS
Tabs.
Definition: editor.h:47
@ GEANY_INDENT_TYPE_SPACES
Spaces.
Definition: editor.h:46
GeanyEncoding encodings[GEANY_ENCODINGS_MAX]
Definition: encodings.c:59
const gchar * encodings_get_charset_from_index(gint idx)
Gets the character set name of the specified index e.g.
Definition: encodings.c:267
const GeanyEncoding * encodings_get_from_charset(const gchar *charset)
Definition: encodings.c:215
Encoding conversion and Byte Order Mark (BOM) handling.
@ GEANY_ENCODING_UTF_8
Definition: encodings.h:68
void error(const errorSelection selection, const char *const format,...)
Definition: error.c:53
Filetype detection, file extensions and filetype menu items.
@ GEANY_FILETYPES_NONE
Definition: filetypes.h:46
#define filetypes
Wraps GeanyData::filetypes_array so it can be used with C array syntax.
Definition: filetypes.h:178
#define GEANY_WINDOW_DEFAULT_HEIGHT
Definition: geany.h:52
unsigned int max
GObject * geany_object
Definition: geanyobject.c:41
static struct @96 build_menu_prefs
gint number_non_ft_menu_items
Definition: keyfile.c:120
void configuration_save(void)
Definition: keyfile.c:632
void configuration_apply_settings(void)
Definition: keyfile.c:1318
static gint session_notebook_page
Definition: keyfile.c:107
#define GEANY_MIN_SYMBOLLIST_CHARS
Definition: keyfile.c:73
#define GEANY_DEFAULT_TOOLS_TERMINAL
Definition: keyfile.c:82
#define GEANY_DEFAULT_TOOLS_BROWSER
Definition: keyfile.c:90
void configuration_add_pref_group(struct StashGroup *group, gboolean for_prefs_dialog)
Definition: keyfile.c:128
static guint document_list_update_idle_func_id
Definition: keyfile.c:110
static gint hpan_position
Definition: keyfile.c:108
void configuration_reload_default_session(void)
Definition: keyfile.c:1149
static void load_ui_prefs(GKeyFile *config)
Definition: keyfile.c:1020
static void load_dialog_prefs(GKeyFile *config)
Definition: keyfile.c:757
static gboolean save_configuration_cb(gpointer data)
Definition: keyfile.c:1352
static gint scribble_pos
Definition: keyfile.c:105
void configuration_init(void)
Definition: keyfile.c:1383
static const gchar atomic_file_saving_key[]
Definition: keyfile.c:111
static gint vpan_position
Definition: keyfile.c:109
static void load_recent_files(GKeyFile *config, GQueue *queue, const gchar *key)
Definition: keyfile.c:669
static void init_pref_groups(void)
Definition: keyfile.c:147
static gboolean open_session_file(gchar **tmp, guint len)
Definition: keyfile.c:1190
gboolean configuration_load(void)
Definition: keyfile.c:1163
void configuration_open_files(void)
Definition: keyfile.c:1257
static void save_dialog_prefs(GKeyFile *config)
Definition: keyfile.c:438
#define GEANY_DEFAULT_FONT_MSG_WINDOW
Definition: keyfile.c:92
#define GEANY_DEFAULT_FILETYPE_REGEX
Definition: keyfile.c:101
static GPtrArray * keyfile_groups
Definition: keyfile.c:113
void configuration_clear_default_session(void)
Definition: keyfile.c:1125
#define GEANY_MAX_AUTOCOMPLETE_WORDS
Definition: keyfile.c:99
static void remove_session_files(GKeyFile *config)
Definition: keyfile.c:384
GPtrArray * pref_groups
Definition: keyfile.c:115
static void save_recent_files(GKeyFile *config, GQueue *queue, gchar const *key)
Definition: keyfile.c:327
#define GEANY_DISK_CHECK_TIMEOUT
Definition: keyfile.c:75
static gchar * get_session_file_string(GeanyDocument *doc)
Definition: keyfile.c:354
static GPtrArray * session_files
Definition: keyfile.c:106
#define GEANY_DEFAULT_FONT_SYMBOL_LIST
Definition: keyfile.c:91
static void document_list_changed_cb(GObject *obj, GeanyDocument *doc, gpointer data)
Definition: keyfile.c:1364
#define GEANY_MAX_SYMBOLS_UPDATE_FREQ
Definition: keyfile.c:100
static gchar * scribble_text
Definition: keyfile.c:104
void configuration_save_default_session(void)
Definition: keyfile.c:1104
static void save_ui_prefs(GKeyFile *config)
Definition: keyfile.c:579
static void settings_action(GKeyFile *config, SettingAction action)
Definition: keyfile.c:309
gint number_ft_menu_items
Definition: keyfile.c:119
void configuration_load_session_files(GKeyFile *config, gboolean read_recent_files)
Definition: keyfile.c:691
#define GEANY_DEFAULT_FONT_EDITOR
Definition: keyfile.c:93
void configuration_save_session_files(GKeyFile *config)
Definition: keyfile.c:398
SettingAction
Definition: keyfile.c:303
@ SETTING_WRITE
Definition: keyfile.c:305
@ SETTING_READ
Definition: keyfile.c:304
void configuration_finalize(void)
Definition: keyfile.c:1395
#define GEANY_DEFAULT_TOOLS_GREP
Definition: keyfile.c:96
gint number_exec_menu_items
Definition: keyfile.c:121
void configuration_add_various_pref_group(struct StashGroup *group, const gchar *prefix)
Definition: keyfile.c:139
#define GEANY_DEFAULT_MRU_LENGTH
Definition: keyfile.c:97
#define GEANY_MAX_SYMBOLLIST_HEIGHT
Definition: keyfile.c:72
#define GEANY_TOGGLE_MARK
Definition: keyfile.c:98
#define GEANY_MSGWIN_HEIGHT
Definition: keyfile.c:74
#define GEANY_DEFAULT_TOOLS_PRINTCMD
Definition: keyfile.c:95
CommandLineOptions cl_options
Definition: libmain.c:90
GeanyApp * app
Definition: libmain.c:86
GeanyStatus main_status
Definition: libmain.c:89
void geany_debug(gchar const *format,...)
Definition: log.c:67
Main program-related commands.
#define MAX(a, b)
Definition: mio.c:93
void msgwin_show_hide_tabs(void)
Definition: msgwindow.c:99
MessageWindow msgwindow
Definition: msgwindow.c:66
Message window functions (status, compiler, messages windows).
GeanyToolPrefs tool_prefs
Definition: prefs.c:67
GeanyPrefs prefs
Definition: prefs.c:66
PrintingPrefs printing_prefs
Definition: printing.c:50
static GtkPrintSettings * settings
Definition: printing.c:82
void project_write_config(void)
Forces the project file rewrite and emission of the project-save signal.
Definition: project.c:1159
void project_load_prefs(GKeyFile *config)
Definition: project.c:1212
ProjectPrefs project_prefs
Definition: project.c:53
void project_save_prefs(GKeyFile *config)
Definition: project.c:1197
Project Management.
#define NULL
Definition: rbtree.h:150
char * strstr(const char *str, const char *substr)
Definition: routines.c:304
gint sci_get_current_position(ScintillaObject *sci)
Gets the cursor position.
Definition: sciwrappers.c:507
Wrapper functions for the Scintilla editor widget SCI_* messages.
GtkWidget * entry
Definition: search.c:118
GeanySearchPrefs search_prefs
Definition: search.c:78
@ GEANY_FIND_SEL_CURRENT_WORD
Definition: search.h:49
#define SOCKET_WINDOWS_REMOTE_CMD_PORT
Definition: socket.h:32
GeanyFiletype * filetypes_lookup_by_name(const gchar *name)
Finds a filetype pointer from its name field.
Definition: filetypes.c:1242
StashGroup * group
Definition: stash-example.c:1
stash_group_add_boolean(group, &china_enabled, "china", TRUE)
stash_group_add_string(group, &potter_name, "potter_name", "Miss Clay")
const gchar filename[]
Definition: stash-example.c:4
if(!stash_group_load_from_file(group, filename)) g_warning(_("Could not load keyfile %s!")
stash_group_add_toggle_button(group, &want_handle, "handle", TRUE, "check_handle")
void stash_group_add_spin_button_integer(StashGroup *group, gint *setting, const gchar *key_name, gint default_value, StashWidgetID widget_id)
Adds a GtkSpinButton widget pref.
Definition: stash.c:896
void stash_group_add_radio_buttons(StashGroup *group, gint *setting, const gchar *key_name, gint default_value, StashWidgetID widget_id, gint enum_id,...)
Adds a GtkRadioButton widget group pref.
Definition: stash.c:845
void stash_group_save_to_key_file(StashGroup *group, GKeyFile *keyfile)
Writes group settings into key values in keyfile.
Definition: stash.c:286
void stash_group_add_integer(StashGroup *group, gint *setting, const gchar *key_name, gint default_value)
Adds integer setting.
Definition: stash.c:485
void stash_group_load_from_key_file(StashGroup *group, GKeyFile *keyfile)
Reads key values from keyfile into the group settings.
Definition: stash.c:275
void stash_group_add_combo_box(StashGroup *group, gint *setting, const gchar *key_name, gint default_value, StashWidgetID widget_id)
Adds a GtkComboBox widget pref.
Definition: stash.c:912
StashGroup * stash_group_new(const gchar *name)
Creates a new group.
Definition: stash.c:360
void stash_group_free(StashGroup *group)
Frees a group.
Definition: stash.c:407
void stash_group_set_various(StashGroup *group, gboolean various, const gchar *prefix)
Definition: stash.c:429
void stash_group_add_entry(StashGroup *group, gchar **setting, const gchar *key_name, const gchar *default_value, StashWidgetID widget_id)
Adds a GtkEntry widget pref.
Definition: stash.c:944
Lightweight library for reading/writing GKeyFile settings and synchronizing widgets with C variables.
struct GeanyProject * project
Currently active project or NULL if none is open.
Definition: app.h:49
gchar * configdir
User configuration directory, usually ~/.config/geany.
Definition: app.h:45
gchar * datadir
Definition: app.h:46
Structure for representing an open tab with all its properties.
Definition: document.h:81
gchar * file_name
The UTF-8 encoded file name.
Definition: document.h:92
GeanyFiletype * file_type
The filetype for this document, it's only a reference to one of the elements of the global filetypes ...
Definition: document.h:101
gchar * real_path
The link-dereferenced, locale-encoded file name.
Definition: document.h:115
gchar * encoding
The encoding of the document, must be a valid string representation of an encoding,...
Definition: document.h:95
gboolean readonly
Whether this document is read-only.
Definition: document.h:105
gboolean is_valid
Flag used to check if this document is valid when iterating GeanyData::documents_array.
Definition: document.h:83
GeanyEditor * editor
The editor associated with the document.
Definition: document.h:98
gboolean unfold_all_children
Definition: editor.h:115
gint symbolcompletion_min_chars
Definition: editor.h:123
gboolean line_wrapping
Definition: editor.h:112
gboolean show_scrollbars
Definition: editor.h:110
gboolean scroll_stop_at_last_line
Definition: editor.h:111
gboolean newline_strip
Definition: editor.h:119
gboolean disable_dnd
Definition: editor.h:116
gboolean brace_match_ltgt
Definition: editor.h:125
gint autocompletion_update_freq
Definition: editor.h:138
GeanyIndentPrefs * indentation
Definition: editor.h:100
gboolean show_markers_margin
Definition: editor.h:108
gboolean auto_continue_multiline
Definition: editor.h:129
gboolean complete_snippets_whilst_editing
Definition: editor.h:127
gint line_break_column
Definition: editor.h:128
gint ime_interaction
Definition: editor.h:140
gboolean long_line_enabled
Definition: editor.h:137
gboolean use_tab_to_indent
Definition: editor.h:117
gboolean show_indent_guide
Definition: editor.h:102
gboolean show_linenumber_margin
Definition: editor.h:109
gint long_line_column
Definition: editor.h:106
guint autocompletion_max_entries
Definition: editor.h:131
gchar * color_scheme
Definition: editor.h:135
gint show_virtual_space
Definition: editor.h:136
guint autoclose_chars
Definition: editor.h:132
gchar * comment_toggle_mark
Definition: editor.h:130
gboolean autocomplete_doc_words
Definition: editor.h:133
gboolean auto_close_xml_tags
Definition: editor.h:121
gboolean auto_complete_symbols
Definition: editor.h:120
gboolean use_indicators
Definition: editor.h:113
gboolean complete_snippets
Definition: editor.h:122
gint symbolcompletion_max_height
Definition: editor.h:124
gint long_line_type
Definition: editor.h:105
gboolean use_gtk_word_boundaries
Definition: editor.h:126
gint scroll_lines_around_cursor
Definition: editor.h:139
gboolean smart_home_key
Definition: editor.h:118
gboolean show_line_endings
Definition: editor.h:103
gboolean folding
Definition: editor.h:114
gchar * long_line_color
Definition: editor.h:107
gboolean completion_drops_rest_of_word
Definition: editor.h:134
gboolean show_white_space
Definition: editor.h:101
GeanyIndentType indent_type
Definition: editor.h:157
gboolean line_breaking
Whether to split long lines as you type.
Definition: editor.h:158
gboolean auto_indent
TRUE if auto-indentation is enabled.
Definition: editor.h:154
ScintillaObject * sci
The Scintilla editor GtkWidget.
Definition: editor.h:152
gboolean line_wrapping
TRUE if line wrapping is enabled.
Definition: editor.h:153
gint indent_width
Definition: editor.h:159
GeanyEncodingIndex idx
const gchar * charset
gboolean reload_clean_doc_on_file_change
Definition: document.h:68
gboolean use_safe_file_saving
Definition: document.h:60
gboolean keep_edit_history_on_reload
Definition: document.h:66
gint default_new_encoding
Definition: document.h:48
guint mru_length
Definition: document.h:56
gboolean show_keep_edit_history_on_reload_msg
Definition: document.h:67
gboolean tab_order_beside
Definition: document.h:54
gint disk_check_timeout
Definition: document.h:58
gint default_open_encoding
Definition: document.h:49
gboolean gio_unsafe_save_backup
Definition: document.h:62
gboolean use_gio_unsafe_file_saving
Definition: document.h:63
gboolean strip_trailing_spaces
Definition: document.h:51
gboolean cmdline_new_files
Definition: document.h:59
gchar * extract_filetype_regex
Definition: document.h:64
gboolean final_new_line
Definition: document.h:50
gint default_eol_character
Definition: document.h:57
gboolean show_tab_cross
Definition: document.h:55
gboolean ensure_convert_new_lines
Definition: document.h:61
gboolean save_config_on_file_change
Definition: document.h:69
gboolean tab_close_switch_to_mru
Definition: document.h:65
gboolean replace_tabs
Definition: document.h:52
gboolean tab_order_ltr
Definition: document.h:53
Represents a filetype.
Definition: filetypes.h:144
gchar * name
Untranslated short name, such as "C", "None".
Definition: filetypes.h:152
gboolean detect_type
Definition: editor.h:90
GeanyIndentType type
Whether to use tabs, spaces or both to indent.
Definition: editor.h:85
gboolean detect_width
Definition: editor.h:91
gint hard_tab_width
Width of a tab, but only when using GEANY_INDENT_TYPE_BOTH.
Definition: editor.h:88
GeanyAutoIndent auto_indent_mode
Definition: editor.h:89
gint width
Indent width.
Definition: editor.h:84
gint tab_pos_editor
positions of editor's tabs
Definition: ui_utils.h:53
gint symbols_sort_mode
symbol list sorting mode
Definition: ui_utils.h:71
gboolean statusbar_visible
whether the status bar is visible
Definition: ui_utils.h:56
gint sidebar_pos
position of the sidebar (left or right)
Definition: ui_utils.h:61
gboolean use_native_windows_dialogs
whether to use native Windows' dialogs (only used on Windows)
Definition: ui_utils.h:67
gboolean sidebar_symbol_visible
whether the symbol sidebar is visible
Definition: ui_utils.h:47
gint tab_pos_sidebar
positions of sidebar's tabs
Definition: ui_utils.h:55
gchar * editor_font
editor font
Definition: ui_utils.h:49
gboolean highlighting_invert_all
whether highlighting colors are inverted
Definition: ui_utils.h:60
gboolean sidebar_openfiles_visible
whether the open file list is visible
Definition: ui_utils.h:48
gchar * msgwin_font
message window font
Definition: ui_utils.h:51
gboolean show_notebook_tabs
whether editor tabs are visible
Definition: ui_utils.h:52
gint tab_pos_msgwin
positions of message window's tabs
Definition: ui_utils.h:54
gint msgwin_orientation
orientation of the message window
Definition: ui_utils.h:70
gboolean notebook_double_click_hides_widgets
whether a double click on notebook tabs hides all other windows
Definition: ui_utils.h:59
gchar * tagbar_font
symbol sidebar font
Definition: ui_utils.h:50
GtkWidget * window
Main window.
Definition: ui_utils.h:80
GtkWidget * notebook
Document notebook.
Definition: ui_utils.h:83
gboolean confirm_exit
Definition: prefs.h:34
gboolean save_winpos
Definition: prefs.h:33
gboolean save_wingeom
Definition: prefs.h:41
gboolean auto_focus
Definition: prefs.h:38
gboolean suppress_status_messages
Definition: prefs.h:36
gboolean load_session
Definition: prefs.h:31
gboolean beep_on_errors
Definition: prefs.h:35
gboolean switch_to_status
Definition: prefs.h:37
gchar * default_open_path
Default path to look for files when no other path is appropriate.
Definition: prefs.h:39
gboolean replace_and_find_by_default
Definition: search.h:62
gboolean use_current_word
Use current word for default search text.
Definition: search.h:59
GeanyFindSelOptions find_selection_type
Definition: search.h:63
gchar * initials
Initials.
Definition: templates.h:43
gchar * mail
Email.
Definition: templates.h:42
gchar * year_format
Definition: templates.h:45
gchar * company
Company.
Definition: templates.h:41
gchar * version
Initial version.
Definition: templates.h:44
gchar * datetime_format
Definition: templates.h:47
gchar * date_format
Definition: templates.h:46
gchar * developer
Name.
Definition: templates.h:40
gchar * grep_cmd
grep command
Definition: prefs.h:53
gchar * context_action_cmd
context action command
Definition: prefs.h:54
gchar * term_cmd
terminal emulator command
Definition: prefs.h:52
gchar * browser_cmd
web browser command
Definition: prefs.h:51
GtkToolbarStyle icon_style
Icon style.
Definition: toolbar.h:33
gboolean visible
Definition: toolbar.h:31
gboolean use_gtk_default_icon
Definition: toolbar.h:35
gboolean use_gtk_default_style
Definition: toolbar.h:34
gboolean append_to_menu
Definition: toolbar.h:36
GtkIconSize icon_size
Definition: toolbar.h:32
gchar * external_print_cmd
Definition: printing.h:40
gboolean use_gtk_printing
Definition: printing.h:34
gboolean print_page_header
Definition: printing.h:37
gboolean page_header_basename
Definition: printing.h:38
gchar * page_header_datefmt
Definition: printing.h:39
gboolean print_page_numbers
Definition: printing.h:36
gboolean print_line_numbers
Definition: printing.h:35
Defines internationalization macros.
#define _(String)
Definition: support.h:42
Tag-related functions.
GeanyTemplatePrefs template_prefs
Definition: templates.c:50
Templates (prefs).
GeanyToolbarPrefs toolbar_prefs
Definition: toolbar.c:48
Toolbar (prefs).
void ui_set_fullscreen(void)
Definition: ui_utils.c:440
GeanyMainWidgets main_widgets
Definition: ui_utils.c:72
void ui_set_statusbar(gboolean log, const gchar *format,...)
Displays text on the statusbar.
Definition: ui_utils.c:168
UIPrefs ui_prefs
Definition: ui_utils.c:74
GtkWidget * ui_lookup_widget(GtkWidget *widget, const gchar *widget_name)
Returns a widget from a name in a component, usually created by Glade.
Definition: ui_utils.c:2743
GeanyInterfacePrefs interface_prefs
Definition: ui_utils.c:71
User Interface general utility functions.
gboolean utils_parse_color(const gchar *spec, GdkColor *color)
Definition: utils.c:976
gint utils_write_file(const gchar *filename, const gchar *text)
Writes text into a file named filename.
Definition: utils.c:209
gint utils_get_setting_integer(GKeyFile *config, const gchar *section, const gchar *key, const gint default_value)
Wraps g_key_file_get_integer() to add a default value argument.
Definition: utils.c:805
gboolean utils_get_setting_boolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean default_value)
Wraps g_key_file_get_boolean() to add a default value argument.
Definition: utils.c:836
gchar * utils_get_initials(const gchar *name)
Definition: utils.c:774
gboolean utils_str_equal(const gchar *a, const gchar *b)
NULL-safe string comparison.
Definition: utils.c:599
gchar * utils_get_setting_string(GKeyFile *config, const gchar *section, const gchar *key, const gchar *default_value)
Wraps g_key_file_get_string() to add a default value argument.
Definition: utils.c:867
gchar * utils_get_hex_from_color(GdkColor *color)
Definition: utils.c:883
gchar * utils_get_locale_from_utf8(const gchar *utf8_text)
Converts the given UTF-8 encoded string into locale encoding.
Definition: utils.c:1243
General utility functions, non-GTK related.
#define foreach_strv(str_ptr, strv)
Iterates a null-terminated string vector.
Definition: utils.h:152
#define foreach_ptr_array(item, idx, ptr_array)
Iterates all the pointers in ptr_array.
Definition: utils.h:108
#define SETPTR(ptr, result)
Assigns result to ptr, then frees the old value.
Definition: utils.h:50
#define EMPTY(ptr)
Returns TRUE if ptr is NULL or *ptr is FALSE.
Definition: utils.h:38