Improve making-a-release a little
[geany-mirror.git] / src / libmain.c
blobce6bb8cf06a37d1217cd2a422ef96b16d848312e
1 /*
2 * libmain.c - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 /**
23 * @file: main.h
24 * Main program-related commands.
25 * Handles program initialization and cleanup.
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include "main.h"
34 #include "app.h"
35 #include "build.h"
36 #include "callbacks.h"
37 #include "dialogs.h"
38 #include "document.h"
39 #include "encodingsprivate.h"
40 #include "filetypes.h"
41 #include "geanyobject.h"
42 #include "highlighting.h"
43 #include "keybindings.h"
44 #include "keyfile.h"
45 #include "log.h"
46 #include "msgwindow.h"
47 #include "navqueue.h"
48 #include "notebook.h"
49 #include "plugins.h"
50 #include "prefs.h"
51 #include "printing.h"
52 #include "sidebar.h"
53 #ifdef HAVE_SOCKET
54 # include "socket.h"
55 #endif
56 #include "support.h"
57 #include "symbols.h"
58 #include "templates.h"
59 #include "toolbar.h"
60 #include "tools.h"
61 #include "ui_utils.h"
62 #include "utils.h"
63 #include "vte.h"
64 #include "win32.h"
65 #include "osx.h"
67 #include "gtkcompat.h"
69 #include <signal.h>
70 #include <time.h>
71 #include <sys/types.h>
72 #include <sys/stat.h>
73 #include <errno.h>
74 #include <string.h>
75 #include <stdlib.h>
77 #include <glib/gstdio.h>
79 #ifdef HAVE_LOCALE_H
80 # include <locale.h>
81 #endif
84 GeanyApp *app;
85 gboolean ignore_callback; /* hack workaround for GTK+ toggle button callback problem */
87 GeanyStatus main_status;
88 CommandLineOptions cl_options; /* fields initialised in parse_command_line_options */
90 static gchar *original_cwd = NULL;
92 static const gchar geany_lib_versions[] = "GTK %u.%u.%u, GLib %u.%u.%u";
94 static gboolean want_plugins;
96 /* command-line options */
97 static gboolean verbose_mode = FALSE;
98 static gboolean ignore_global_tags = FALSE;
99 static gboolean no_msgwin = FALSE;
100 static gboolean show_version = FALSE;
101 static gchar *alternate_config = NULL;
102 #ifdef HAVE_VTE
103 static gboolean no_vte = FALSE;
104 static gchar *lib_vte = NULL;
105 #endif
106 static gboolean generate_tags = FALSE;
107 static gboolean no_preprocessing = FALSE;
108 static gboolean ft_names = FALSE;
109 static gboolean print_prefix = FALSE;
110 #ifdef HAVE_PLUGINS
111 static gboolean no_plugins = FALSE;
112 #endif
113 static gboolean dummy = FALSE;
115 /* in alphabetical order of short options */
116 static GOptionEntry entries[] =
118 { "column", 0, 0, G_OPTION_ARG_INT, &cl_options.goto_column, N_("Set initial column number for the first opened file (useful in conjunction with --line)"), NULL },
119 { "config", 'c', 0, G_OPTION_ARG_FILENAME, &alternate_config, N_("Use an alternate configuration directory"), NULL },
120 { "ft-names", 0, 0, G_OPTION_ARG_NONE, &ft_names, N_("Print internal filetype names"), NULL },
121 { "generate-tags", 'g', 0, G_OPTION_ARG_NONE, &generate_tags, N_("Generate global tags file (see documentation)"), NULL },
122 { "no-preprocessing", 'P', 0, G_OPTION_ARG_NONE, &no_preprocessing, N_("Don't preprocess C/C++ files when generating tags file"), NULL },
123 #ifdef HAVE_SOCKET
124 { "new-instance", 'i', 0, G_OPTION_ARG_NONE, &cl_options.new_instance, N_("Don't open files in a running instance, force opening a new instance"), NULL },
125 { "socket-file", 0, 0, G_OPTION_ARG_FILENAME, &cl_options.socket_filename, N_("Use this socket filename for communication with a running Geany instance"), NULL },
126 { "list-documents", 0, 0, G_OPTION_ARG_NONE, &cl_options.list_documents, N_("Return a list of open documents in a running Geany instance"), NULL },
127 #endif
128 { "line", 'l', 0, G_OPTION_ARG_INT, &cl_options.goto_line, N_("Set initial line number for the first opened file"), NULL },
129 { "no-msgwin", 'm', 0, G_OPTION_ARG_NONE, &no_msgwin, N_("Don't show message window at startup"), NULL },
130 { "no-ctags", 'n', 0, G_OPTION_ARG_NONE, &ignore_global_tags, N_("Don't load auto completion data (see documentation)"), NULL },
131 #ifdef HAVE_PLUGINS
132 { "no-plugins", 'p', 0, G_OPTION_ARG_NONE, &no_plugins, N_("Don't load plugins"), NULL },
133 #endif
134 { "print-prefix", 0, 0, G_OPTION_ARG_NONE, &print_prefix, N_("Print Geany's installation prefix"), NULL },
135 { "read-only", 'r', 0, G_OPTION_ARG_NONE, &cl_options.readonly, N_("Open all FILES in read-only mode (see documentation)"), NULL },
136 { "no-session", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &cl_options.load_session, N_("Don't load the previous session's files"), NULL },
137 #ifdef HAVE_VTE
138 { "no-terminal", 't', 0, G_OPTION_ARG_NONE, &no_vte, N_("Don't load terminal support"), NULL },
139 { "vte-lib", 0, 0, G_OPTION_ARG_FILENAME, &lib_vte, N_("Filename of libvte.so"), NULL },
140 #endif
141 { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_mode, N_("Be verbose"), NULL },
142 { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version and exit"), NULL },
143 { "dummy", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &dummy, NULL, NULL }, /* for +NNN line number arguments */
144 { NULL, 0, 0, 0, NULL, NULL, NULL }
148 static void setup_window_position(void)
150 /* interprets the saved window geometry */
151 if (!prefs.save_winpos)
152 return;
154 if (ui_prefs.geometry[0] != -1 && ui_prefs.geometry[1] != -1)
155 gtk_window_move(GTK_WINDOW(main_widgets.window),
156 ui_prefs.geometry[0], ui_prefs.geometry[1]);
158 if (ui_prefs.geometry[2] != -1 && ui_prefs.geometry[3] != -1)
159 gtk_window_set_default_size(GTK_WINDOW(main_widgets.window),
160 ui_prefs.geometry[2], ui_prefs.geometry[3]);
162 if (ui_prefs.geometry[4] == 1)
163 gtk_window_maximize(GTK_WINDOW(main_widgets.window));
167 /* special things for the initial setup of the checkboxes and related stuff
168 * an action on a setting is only performed if the setting is not equal to the program default
169 * (all the following code is not perfect but it works for the moment) */
170 static void apply_settings(void)
172 ui_update_fold_items();
174 /* toolbar, message window and sidebar are by default visible, so don't change it if it is true */
175 toolbar_show_hide();
176 if (! ui_prefs.msgwindow_visible)
178 ignore_callback = TRUE;
179 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_show_messages_window1")), FALSE);
180 gtk_widget_hide(main_widgets.message_window_notebook);
181 ignore_callback = FALSE;
183 if (! ui_prefs.sidebar_visible)
185 ignore_callback = TRUE;
186 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_show_sidebar1")), FALSE);
187 ignore_callback = FALSE;
190 toolbar_apply_settings();
191 toolbar_update_ui();
193 ui_update_view_editor_menu_items();
195 /* hide statusbar if desired */
196 if (! interface_prefs.statusbar_visible)
198 gtk_widget_hide(ui_widgets.statusbar);
201 /* set the tab placements of the notebooks */
202 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(main_widgets.notebook), interface_prefs.tab_pos_editor);
203 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow.notebook), interface_prefs.tab_pos_msgwin);
204 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(main_widgets.sidebar_notebook), interface_prefs.tab_pos_sidebar);
206 /* whether to show notebook tabs or not */
207 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets.notebook), interface_prefs.show_notebook_tabs);
209 #ifdef HAVE_VTE
210 if (! vte_info.have_vte)
211 #endif
213 gtk_widget_set_sensitive(
214 ui_lookup_widget(main_widgets.window, "send_selection_to_vte1"), FALSE);
217 if (interface_prefs.sidebar_pos != GTK_POS_LEFT)
218 ui_swap_sidebar_pos();
220 gtk_orientable_set_orientation(GTK_ORIENTABLE(ui_lookup_widget(main_widgets.window, "vpaned1")),
221 interface_prefs.msgwin_orientation);
225 static void on_window_active_changed(GtkWindow *window, GParamSpec *pspec, gpointer data)
227 GeanyDocument *doc = document_get_current();
229 if (doc && gtk_window_is_active(window))
230 document_check_disk_status(doc, TRUE);
234 static void main_init(void)
236 /* add our icon path in case we aren't installed in the system prefix */
237 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), utils_resource_dir(RESOURCE_DIR_ICON));
239 /* inits */
240 ui_init_stock_items();
242 ui_init_builder();
244 main_widgets.window = NULL;
245 app->project = NULL;
246 ui_widgets.open_fontsel = NULL;
247 ui_widgets.open_colorsel = NULL;
248 ui_widgets.prefs_dialog = NULL;
249 main_status.main_window_realized = FALSE;
250 file_prefs.tab_order_ltr = FALSE;
251 file_prefs.tab_order_beside = FALSE;
252 main_status.quitting = FALSE;
253 ignore_callback = FALSE;
254 ui_prefs.recent_queue = g_queue_new();
255 ui_prefs.recent_projects_queue = g_queue_new();
256 main_status.opening_session_files = FALSE;
258 main_widgets.window = create_window1();
259 g_signal_connect(main_widgets.window, "notify::is-active", G_CALLBACK(on_window_active_changed), NULL);
261 /* add recent projects to the Project menu */
262 ui_widgets.recent_projects_menuitem = ui_lookup_widget(main_widgets.window, "recent_projects1");
263 ui_widgets.recent_projects_menu_menubar = gtk_menu_new();
264 gtk_menu_item_set_submenu(GTK_MENU_ITEM(ui_widgets.recent_projects_menuitem),
265 ui_widgets.recent_projects_menu_menubar);
267 /* store important pointers for later reference */
268 main_widgets.toolbar = toolbar_init();
269 main_widgets.sidebar_notebook = ui_lookup_widget(main_widgets.window, "notebook3");
270 main_widgets.notebook = ui_lookup_widget(main_widgets.window, "notebook1");
271 main_widgets.editor_menu = create_edit_menu1();
272 main_widgets.tools_menu = ui_lookup_widget(main_widgets.window, "tools1_menu");
273 main_widgets.message_window_notebook = ui_lookup_widget(main_widgets.window, "notebook_info");
274 main_widgets.project_menu = ui_lookup_widget(main_widgets.window, "menu_project1_menu");
276 ui_widgets.toolbar_menu = create_toolbar_popup_menu1();
277 ui_init();
278 #ifdef MAC_INTEGRATION
279 osx_ui_init();
280 #endif
282 /* set widget names for matching with .gtkrc-2.0 */
283 gtk_widget_set_name(main_widgets.window, "GeanyMainWindow");
284 gtk_widget_set_name(ui_widgets.toolbar_menu, "GeanyToolbarMenu");
285 gtk_widget_set_name(main_widgets.editor_menu, "GeanyEditMenu");
286 gtk_widget_set_name(ui_lookup_widget(main_widgets.window, "menubar1"), "GeanyMenubar");
287 gtk_widget_set_name(main_widgets.toolbar, "GeanyToolbar");
289 gtk_window_set_default_size(GTK_WINDOW(main_widgets.window),
290 GEANY_WINDOW_DEFAULT_WIDTH, GEANY_WINDOW_DEFAULT_HEIGHT);
294 const gchar *main_get_version_string(void)
296 static gchar full[] = VERSION " (git >= " REVISION ")";
298 if (utils_str_equal(REVISION, "-1"))
299 return VERSION;
300 else
301 return full;
305 /* get the full file path of a command-line argument
306 * N.B. the result should be freed and may contain '/../' or '/./ ' */
307 gchar *main_get_argv_filename(const gchar *filename)
309 gchar *result;
311 if (g_path_is_absolute(filename) || utils_is_uri(filename))
312 result = g_strdup(filename);
313 else
315 /* use current dir */
316 gchar *cur_dir = NULL;
317 if (original_cwd == NULL)
318 cur_dir = g_get_current_dir();
319 else
320 cur_dir = g_strdup(original_cwd);
322 result = g_strjoin(
323 G_DIR_SEPARATOR_S, cur_dir, filename, NULL);
324 g_free(cur_dir);
326 return result;
330 /* get a :line:column specifier from the end of a filename (if present),
331 * return the line/column values, and remove the specifier from the string
332 * (Note that *line and *column must both be set to -1 initially) */
333 static void get_line_and_column_from_filename(gchar *filename, gint *line, gint *column)
335 gsize i;
336 gint colon_count = 0;
337 gboolean have_number = FALSE;
338 gsize len;
340 g_assert(*line == -1 && *column == -1);
342 if (G_UNLIKELY(EMPTY(filename)))
343 return;
345 /* allow to open files like "test:0" */
346 if (g_file_test(filename, G_FILE_TEST_EXISTS))
347 return;
349 len = strlen(filename);
350 for (i = len - 1; i >= 1; i--)
352 gboolean is_colon = filename[i] == ':';
353 gboolean is_digit = g_ascii_isdigit(filename[i]);
355 if (! is_colon && ! is_digit)
356 break;
358 if (is_colon)
360 if (++colon_count > 1)
361 break; /* bail on 2+ colons in a row */
363 else
364 colon_count = 0;
366 if (is_digit)
367 have_number = TRUE;
369 if (is_colon && have_number)
371 gint number = atoi(&filename[i + 1]);
373 filename[i] = '\0';
374 have_number = FALSE;
376 *column = *line;
377 *line = number;
380 if (*column >= 0)
381 break; /* line and column are set, so we're done */
386 #ifdef G_OS_WIN32
387 static void change_working_directory_on_windows(void)
389 gchar *install_dir = win32_get_installation_dir();
391 /* remember original working directory for use with opening files from the command line */
392 original_cwd = g_get_current_dir();
394 /* On Windows, change the working directory to the Geany installation path to not lock
395 * the directory of a file passed as command line argument (see bug #2626124).
396 * This also helps if plugins or other code uses relative paths to load
397 * any additional resources (e.g. share/geany-plugins/...). */
398 win32_set_working_directory(install_dir);
400 g_free(install_dir);
402 #endif
405 static void setup_paths(void)
407 /* convert path names to locale encoding */
408 app->datadir = utils_get_locale_from_utf8(utils_resource_dir(RESOURCE_DIR_DATA));
409 app->docdir = utils_get_locale_from_utf8(utils_resource_dir(RESOURCE_DIR_DOC));
414 * Checks whether the main window has been realized.
415 * This is an easy indicator whether Geany is right now starting up (main window is not
416 * yet realized) or whether it has finished the startup process (main window is realized).
417 * This is because the main window is realized (i.e. actually drawn on the screen) at the
418 * end of the startup process.
420 * @note Maybe you want to use the @link pluginsignals.c @c "geany-startup-complete" signal @endlink
421 * to get notified about the completed startup process.
423 * @return @c TRUE if the Geany main window has been realized or @c FALSE otherwise.
425 * @since 0.19
427 GEANY_API_SYMBOL
428 gboolean main_is_realized(void)
430 return main_status.main_window_realized;
435 * Initialises the gettext translation system.
436 * This is a convenience function to set up gettext for internationalisation support
437 * in external plugins. You should call this function early in @ref plugin_init().
438 * If the macro HAVE_LOCALE_H is defined, @c setlocale(LC_ALL, "") is called.
439 * The codeset for the message translations is set to UTF-8.
441 * Note that this function only setups the gettext textdomain for you. You still have
442 * to adjust the build system of your plugin to get internationalisation support
443 * working properly.
445 * If you have already used @ref PLUGIN_SET_TRANSLATABLE_INFO() you
446 * don't need to call main_locale_init() again as it has already been done.
448 * @param locale_dir The location where the translation files should be searched. This is
449 * usually the @c LOCALEDIR macro, defined by the build system.
450 * E.g. @c $prefix/share/locale.
451 * Only used on non-Windows systems. On Windows, the directory is determined
452 * by @c g_win32_get_package_installation_directory().
453 * @param package The package name, usually this is the @c GETTEXT_PACKAGE macro,
454 * defined by the build system.
456 * @since 0.16
458 GEANY_API_SYMBOL
459 void main_locale_init(const gchar *locale_dir, const gchar *package)
461 #ifdef HAVE_LOCALE_H
462 setlocale(LC_ALL, "");
463 #endif
465 #ifdef G_OS_WIN32
466 locale_dir = utils_resource_dir(RESOURCE_DIR_LOCALE);
467 #endif
468 (void) bindtextdomain(package, locale_dir);
469 (void) bind_textdomain_codeset(package, "UTF-8");
473 static void print_filetypes(void)
475 const GSList *list, *node;
477 filetypes_init_types();
478 printf("Geany's filetype names:\n");
480 list = filetypes_get_sorted_by_name();
481 foreach_slist(node, list)
483 GeanyFiletype *ft = node->data;
485 printf("%s\n", ft->name);
487 filetypes_free_types();
491 static void wait_for_input_on_windows(void)
493 #ifdef G_OS_WIN32
494 if (verbose_mode)
496 geany_debug("Press any key to continue");
497 getchar();
499 #endif
503 static void parse_command_line_options(gint *argc, gchar ***argv)
505 GError *error = NULL;
506 GOptionContext *context;
507 gint i;
508 CommandLineOptions def_clo = {FALSE, NULL, TRUE, -1, -1, FALSE, FALSE, FALSE};
510 /* first initialise cl_options fields with default values */
511 cl_options = def_clo;
513 /* the GLib option parser can't handle the +NNN (line number) option,
514 * so we grab that here and replace it with a no-op */
515 for (i = 1; i < (*argc); i++)
517 if ((*argv)[i][0] != '+')
518 continue;
520 cl_options.goto_line = atoi((*argv)[i] + 1);
521 (*argv)[i] = (gchar *) "--dummy";
524 context = g_option_context_new(_("[FILES...]"));
526 g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
527 g_option_group_set_translation_domain(g_option_context_get_main_group(context), GETTEXT_PACKAGE);
528 g_option_context_add_group(context, gtk_get_option_group(FALSE));
529 g_option_context_parse(context, argc, argv, &error);
530 g_option_context_free(context);
532 if (error != NULL)
534 g_printerr("Geany: %s\n", error->message);
535 g_error_free(error);
536 exit(1);
539 app->debug_mode = verbose_mode;
540 if (app->debug_mode)
542 /* Since GLib 2.32 messages logged with levels INFO and DEBUG aren't output by the
543 * default log handler unless the G_MESSAGES_DEBUG environment variable contains the
544 * domain of the message or is set to the special value "all" */
545 g_setenv("G_MESSAGES_DEBUG", "all", FALSE);
548 #ifdef G_OS_WIN32
549 win32_init_debug_code();
550 #endif
552 if (show_version)
554 gchar *build_date = utils_parse_and_format_build_date(__DATE__);
556 printf(PACKAGE " %s (", main_get_version_string());
557 /* note for translators: library versions are printed after this */
558 printf(_("built on %s with "), build_date);
559 printf(geany_lib_versions,
560 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
561 GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
562 printf(")\n");
563 g_free(build_date);
564 wait_for_input_on_windows();
565 exit(0);
568 if (print_prefix)
570 printf("%s\n", GEANY_PREFIX);
571 printf("%s\n", GEANY_DATADIR);
572 printf("%s\n", GEANY_LIBDIR);
573 printf("%s\n", GEANY_LOCALEDIR);
574 wait_for_input_on_windows();
575 exit(0);
578 if (alternate_config)
580 geany_debug("Using alternate configuration directory");
581 app->configdir = alternate_config;
583 else
585 app->configdir = utils_get_user_config_dir();
588 if (generate_tags)
590 gboolean ret;
592 filetypes_init_types();
593 ret = symbols_generate_global_tags(*argc, *argv, ! no_preprocessing);
594 filetypes_free_types();
595 wait_for_input_on_windows();
596 exit(ret);
599 if (ft_names)
601 print_filetypes();
602 wait_for_input_on_windows();
603 exit(0);
606 #ifdef HAVE_SOCKET
607 socket_info.ignore_socket = cl_options.new_instance;
608 if (cl_options.socket_filename)
610 socket_info.file_name = cl_options.socket_filename;
612 #endif
614 #ifdef HAVE_VTE
615 vte_info.lib_vte = lib_vte;
616 #endif
617 cl_options.ignore_global_tags = ignore_global_tags;
619 if (! gtk_init_check(NULL, NULL))
620 { /* check whether we have a valid X display and exit if not */
621 g_printerr("Geany: cannot open display\n");
622 exit(1);
625 #ifdef MAC_INTEGRATION
626 /* Create GtkosxApplication singleton - should be created shortly after gtk_init() */
627 gtkosx_application_get();
628 #endif
632 static gint create_config_dir(void)
634 gint saved_errno = 0;
635 gchar *conf_file = NULL;
636 gchar *filedefs_dir = NULL;
637 gchar *templates_dir = NULL;
639 if (! g_file_test(app->configdir, G_FILE_TEST_EXISTS))
641 #ifndef G_OS_WIN32
642 /* if we are *not* using an alternate config directory, we check whether the old one
643 * in ~/.geany still exists and try to move it */
644 if (alternate_config == NULL)
646 gchar *old_dir = g_build_filename(g_get_home_dir(), ".geany", NULL);
647 /* move the old config dir if it exists */
648 if (g_file_test(old_dir, G_FILE_TEST_EXISTS))
650 if (! dialogs_show_question_full(main_widgets.window,
651 GTK_STOCK_YES, GTK_STOCK_QUIT, _("Move it now?"),
652 "%s",
653 _("Geany needs to move your old configuration directory before starting.")))
654 exit(0);
656 if (! g_file_test(app->configdir, G_FILE_TEST_IS_DIR))
657 utils_mkdir(app->configdir, TRUE);
659 if (g_rename(old_dir, app->configdir) == 0)
661 dialogs_show_msgbox(GTK_MESSAGE_INFO,
662 _("Your configuration directory has been successfully moved from \"%s\" to \"%s\"."),
663 old_dir, app->configdir);
664 g_free(old_dir);
665 return 0;
667 else
669 dialogs_show_msgbox(GTK_MESSAGE_WARNING,
670 /* for translators: the third %s in brackets is the error message which
671 * describes why moving the dir didn't work */
672 _("Your old configuration directory \"%s\" could not be moved to \"%s\" (%s). "
673 "Please move manually the directory to the new location."),
674 old_dir, app->configdir, g_strerror(errno));
677 g_free(old_dir);
679 #endif
680 geany_debug("Creating configuration directory");
681 saved_errno = utils_mkdir(app->configdir, TRUE);
684 conf_file = g_build_filename(app->configdir, "geany.conf", NULL);
685 filedefs_dir = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL);
686 templates_dir = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR, NULL);
688 if (saved_errno == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS))
689 { /* check whether geany.conf can be written */
690 saved_errno = utils_is_file_writable(app->configdir);
693 /* make subdir for filetype definitions */
694 if (saved_errno == 0)
696 gchar *filedefs_readme = g_build_filename(app->configdir,
697 GEANY_FILEDEFS_SUBDIR, "filetypes.README", NULL);
699 if (! g_file_test(filedefs_dir, G_FILE_TEST_EXISTS))
701 saved_errno = utils_mkdir(filedefs_dir, FALSE);
703 if (saved_errno == 0 && ! g_file_test(filedefs_readme, G_FILE_TEST_EXISTS))
705 gchar *text = g_strconcat(
706 "Copy files from ", app->datadir, "/filedefs to this directory to overwrite "
707 "them. To use the defaults, just delete the file in this directory.\nFor more information read "
708 "the documentation (in ", app->docdir, G_DIR_SEPARATOR_S "index.html or visit " GEANY_HOMEPAGE ").", NULL);
709 utils_write_file(filedefs_readme, text);
710 g_free(text);
712 g_free(filedefs_readme);
715 /* make subdir for template files */
716 if (saved_errno == 0)
718 gchar *templates_readme = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR,
719 "templates.README", NULL);
721 if (! g_file_test(templates_dir, G_FILE_TEST_EXISTS))
723 saved_errno = utils_mkdir(templates_dir, FALSE);
725 if (saved_errno == 0 && ! g_file_test(templates_readme, G_FILE_TEST_EXISTS))
727 gchar *text = g_strconcat(
728 "There are several template files in this directory. For these templates you can use wildcards.\n\
729 For more information read the documentation (in ", app->docdir, G_DIR_SEPARATOR_S "index.html or visit " GEANY_HOMEPAGE ").",
730 NULL);
731 utils_write_file(templates_readme, text);
732 g_free(text);
734 g_free(templates_readme);
737 g_free(filedefs_dir);
738 g_free(templates_dir);
739 g_free(conf_file);
741 return saved_errno;
745 /* Returns 0 if config dir is OK. */
746 static gint setup_config_dir(void)
748 gint mkdir_result = 0;
750 mkdir_result = create_config_dir();
751 if (mkdir_result != 0)
753 if (! dialogs_show_question(
754 _("Configuration directory could not be created (%s).\nThere could be some problems "
755 "using Geany without a configuration directory.\nStart Geany anyway?"),
756 g_strerror(mkdir_result)))
758 exit(0);
761 /* make configdir a real path */
762 if (g_file_test(app->configdir, G_FILE_TEST_EXISTS))
763 SETPTR(app->configdir, tm_get_real_path(app->configdir));
765 return mkdir_result;
768 /* Signal handling removed since main_quit() uses functions that are
769 * illegal in signal handlers
770 static void signal_cb(gint sig)
772 if (sig == SIGTERM)
774 main_quit();
779 /* Used for command-line arguments at startup or from socket.
780 * this will strip any :line:col filename suffix from locale_filename */
781 gboolean main_handle_filename(const gchar *locale_filename)
783 GeanyDocument *doc;
784 gint line = -1, column = -1;
785 gchar *filename;
787 g_return_val_if_fail(locale_filename, FALSE);
789 /* check whether the passed filename is an URI */
790 filename = utils_get_path_from_uri(locale_filename);
791 if (filename == NULL)
792 return FALSE;
794 get_line_and_column_from_filename(filename, &line, &column);
795 if (line >= 0)
796 cl_options.goto_line = line;
797 if (column >= 0)
798 cl_options.goto_column = column;
800 if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
802 doc = document_open_file(filename, cl_options.readonly, NULL, NULL);
803 /* add recent file manually if opening_session_files is set */
804 if (doc != NULL && main_status.opening_session_files)
805 ui_add_recent_document(doc);
806 g_free(filename);
807 return TRUE;
809 else if (file_prefs.cmdline_new_files)
810 { /* create new file with the given filename */
811 gchar *utf8_filename = utils_get_utf8_from_locale(filename);
813 doc = document_find_by_filename(utf8_filename);
814 if (doc)
815 document_show_tab(doc);
816 else
817 doc = document_new_file(utf8_filename, NULL, NULL);
818 if (doc != NULL)
819 ui_add_recent_document(doc);
820 g_free(utf8_filename);
821 g_free(filename);
822 return TRUE;
824 g_free(filename);
825 return FALSE;
829 /* open files from command line */
830 static void open_cl_files(gint argc, gchar **argv)
832 gint i;
834 for (i = 1; i < argc; i++)
836 gchar *filename = main_get_argv_filename(argv[i]);
838 if (g_file_test(filename, G_FILE_TEST_IS_DIR))
840 g_free(filename);
841 continue;
844 #ifdef G_OS_WIN32
845 /* It seems argv elements are encoded in CP1252 on a German Windows */
846 SETPTR(filename, g_locale_to_utf8(filename, -1, NULL, NULL, NULL));
847 #endif
848 if (filename && ! main_handle_filename(filename))
850 const gchar *msg = _("Could not find file '%s'.");
852 g_printerr(msg, filename); /* also print to the terminal */
853 g_printerr("\n");
854 ui_set_statusbar(TRUE, msg, filename);
856 g_free(filename);
861 static void load_session_project_file(void)
863 gchar *locale_filename;
865 g_return_if_fail(project_prefs.session_file != NULL);
867 locale_filename = utils_get_locale_from_utf8(project_prefs.session_file);
869 if (G_LIKELY(!EMPTY(locale_filename)))
870 project_load_file(locale_filename);
872 g_free(locale_filename);
873 g_free(project_prefs.session_file); /* no longer needed */
877 static void load_settings(void)
879 configuration_load();
880 /* let cmdline options overwrite configuration settings */
881 #ifdef HAVE_VTE
882 vte_info.have_vte = (no_vte) ? FALSE : vte_info.load_vte;
883 #endif
884 if (no_msgwin)
885 ui_prefs.msgwindow_visible = FALSE;
887 #ifdef HAVE_PLUGINS
888 want_plugins = prefs.load_plugins && !no_plugins;
889 #endif
893 void main_load_project_from_command_line(const gchar *locale_filename, gboolean use_session)
895 gchar *pfile;
897 pfile = utils_get_path_from_uri(locale_filename);
898 if (pfile != NULL)
900 if (use_session)
901 project_load_file_with_session(pfile);
902 else
903 project_load_file(pfile);
905 g_free(pfile);
909 static void load_startup_files(gint argc, gchar **argv)
911 gboolean load_session = FALSE;
913 if (argc > 1 && g_str_has_suffix(argv[1], ".geany"))
915 gchar *filename = main_get_argv_filename(argv[1]);
917 /* project file specified: load it, but decide the session later */
918 main_load_project_from_command_line(filename, FALSE);
919 argc--, argv++;
920 /* force session load if using project-based session files */
921 load_session = project_prefs.project_session;
922 g_free(filename);
925 /* Load the default session if:
926 * 1. "Load files from the last session" is active.
927 * 2. --no-session is not specified.
928 * 3. We are a primary instance.
929 * Has no effect if a CL project is loaded and using project-based session files. */
930 if (prefs.load_session && cl_options.load_session && !cl_options.new_instance)
932 if (app->project == NULL)
933 load_session_project_file();
934 load_session = TRUE;
937 if (load_session)
939 /* load session files into tabs, as they are found in the session_files variable */
940 configuration_open_files();
942 if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0)
944 ui_update_popup_copy_items(NULL);
945 ui_update_popup_reundo_items(NULL);
949 open_cl_files(argc, argv);
953 static gboolean send_startup_complete(gpointer data)
955 g_signal_emit_by_name(geany_object, "geany-startup-complete");
956 return FALSE;
960 static const gchar *get_locale(void)
962 const gchar *locale = "unknown";
963 #ifdef HAVE_LOCALE_H
964 locale = setlocale(LC_CTYPE, NULL);
965 #endif
966 return locale;
970 #if ! GTK_CHECK_VERSION(3, 0, 0)
971 /* This prepends our own gtkrc file to the list of RC files to be loaded by GTK at startup.
972 * This function *has* to be called before gtk_init().
974 * We have a custom RC file defining various styles we need, and we want the user to be
975 * able to override them (e.g. if they want -- or need -- other colors). Fair enough, one
976 * would simply call gtk_rc_parse() with the appropriate filename. However, the styling
977 * rules applies in the order they are loaded, then if we load our styles after GTK has
978 * loaded the user's ones we'd override them.
980 * There are 2 solutions to fix this:
981 * 1) set our styles' priority to something with lower than "user" (actually "theme"
982 * priority because rules precedence are first calculated depending on the priority
983 * no matter of how precise the rules is, so we need to override the theme).
984 * 2) prepend our custom style to GTK's list while keeping priority to user (which is the
985 * default), so it gets loaded before real user's ones and so gets overridden by them.
987 * One would normally go for 1 because it's ways simpler and requires less code: you just
988 * have to add the priorities to your styles, which is a matter of adding a few ":theme" in
989 * the RC file. However, KDE being a bitch it doesn't set the gtk-theme-name but rather
990 * directly includes the style to use in a user gtkrc file, which makes the theme have
991 * "user" priority, hence overriding our styles. So, we cannot set priorities in the RC
992 * file if we want to support running under KDE, which pretty much leave us with no choice
993 * but to go with solution 2, which unfortunately requires writing ugly code since GTK
994 * don't have a gtk_rc_prepend_default_file() function. Thank you very much KDE.
996 * Though, as a side benefit it also makes the code work with people using gtk-chtheme,
997 * which also found it funny to include the theme in the user RC file. */
998 static void setup_gtk2_styles(void)
1000 gchar **gtk_files = gtk_rc_get_default_files();
1001 gchar **new_files = g_malloc(sizeof *new_files * (g_strv_length(gtk_files) + 2));
1002 guint i = 0;
1004 new_files[i++] = g_build_filename(app->datadir, "geany.gtkrc", NULL);
1005 for (; *gtk_files; gtk_files++)
1006 new_files[i++] = g_strdup(*gtk_files);
1007 new_files[i] = NULL;
1009 gtk_rc_set_default_files(new_files);
1011 g_strfreev(new_files);
1013 #endif
1016 GEANY_EXPORT_SYMBOL
1017 gint main_lib(gint argc, gchar **argv)
1019 GeanyDocument *doc;
1020 gint config_dir_result;
1021 const gchar *locale;
1022 gchar *utf8_configdir;
1024 #if ! GLIB_CHECK_VERSION(2, 36, 0)
1025 g_type_init();
1026 #endif
1028 log_handlers_init();
1030 app = g_new0(GeanyApp, 1);
1031 memset(&main_status, 0, sizeof(GeanyStatus));
1032 memset(&prefs, 0, sizeof(GeanyPrefs));
1033 memset(&interface_prefs, 0, sizeof(GeanyInterfacePrefs));
1034 memset(&toolbar_prefs, 0, sizeof(GeanyToolbarPrefs));
1035 memset(&file_prefs, 0, sizeof(GeanyFilePrefs));
1036 memset(&search_prefs, 0, sizeof(GeanySearchPrefs));
1037 memset(&tool_prefs, 0, sizeof(GeanyToolPrefs));
1038 memset(&template_prefs, 0, sizeof(GeanyTemplatePrefs));
1039 memset(&ui_prefs, 0, sizeof(UIPrefs));
1040 memset(&ui_widgets, 0, sizeof(UIWidgets));
1042 setup_paths();
1043 #if ! GTK_CHECK_VERSION(3, 0, 0)
1044 setup_gtk2_styles();
1045 #endif
1046 #ifdef ENABLE_NLS
1047 main_locale_init(utils_resource_dir(RESOURCE_DIR_LOCALE), GETTEXT_PACKAGE);
1048 #endif
1049 /* initialize TM before parsing command-line - needed for tag file generation */
1050 app->tm_workspace = tm_get_workspace();
1051 parse_command_line_options(&argc, &argv);
1053 #if ! GLIB_CHECK_VERSION(2, 32, 0)
1054 /* Initialize GLib's thread system in case any plugins want to use it or their
1055 * dependencies (e.g. WebKit, Soup, ...). Deprecated since GLIB 2.32. */
1056 if (!g_thread_supported())
1057 g_thread_init(NULL);
1058 #endif
1060 /* removed as signal handling was wrong, see signal_cb()
1061 signal(SIGTERM, signal_cb); */
1063 #ifdef G_OS_UNIX
1064 /* ignore SIGPIPE signal for preventing sudden death of program */
1065 signal(SIGPIPE, SIG_IGN);
1066 #endif
1068 config_dir_result = setup_config_dir();
1069 #ifdef HAVE_SOCKET
1070 /* check and create (unix domain) socket for remote operation */
1071 if (! socket_info.ignore_socket)
1073 socket_info.lock_socket = -1;
1074 socket_info.lock_socket_tag = 0;
1075 socket_info.lock_socket = socket_init(argc, argv);
1076 /* Quit if filenames were sent to first instance or the list of open
1077 * documents has been printed */
1078 if ((socket_info.lock_socket == -2 /* socket exists */ && argc > 1) ||
1079 cl_options.list_documents)
1081 socket_finalize();
1082 gdk_notify_startup_complete();
1083 g_free(app->configdir);
1084 g_free(app->datadir);
1085 g_free(app->docdir);
1086 g_free(app);
1087 return 0;
1089 /* Start a new instance if no command line strings were passed,
1090 * even if the socket already exists */
1091 else if (socket_info.lock_socket == -2 /* socket already exists */)
1093 socket_info.ignore_socket = TRUE;
1094 cl_options.new_instance = TRUE;
1097 #endif
1099 #ifdef G_OS_WIN32
1100 /* after we initialized the socket code and handled command line args,
1101 * let's change the working directory on Windows to not lock it */
1102 change_working_directory_on_windows();
1103 #endif
1105 locale = get_locale();
1106 geany_debug("Geany %s, %s",
1107 main_get_version_string(),
1108 locale);
1109 geany_debug(geany_lib_versions,
1110 gtk_major_version, gtk_minor_version, gtk_micro_version,
1111 glib_major_version, glib_minor_version, glib_micro_version);
1112 geany_debug("System data dir: %s", app->datadir);
1113 utf8_configdir = utils_get_utf8_from_locale(app->configdir);
1114 geany_debug("User config dir: %s", utf8_configdir);
1115 g_free(utf8_configdir);
1117 /* create the object so Geany signals can be connected in init() functions */
1118 geany_object = geany_object_new();
1120 /* inits */
1121 main_init();
1123 encodings_init();
1124 editor_init();
1126 /* init stash groups before loading keyfile */
1127 configuration_init();
1128 ui_init_prefs();
1129 search_init();
1130 project_init();
1131 #ifdef HAVE_PLUGINS
1132 plugins_init();
1133 #endif
1134 sidebar_init();
1135 load_settings(); /* load keyfile */
1137 msgwin_init();
1138 build_init();
1139 ui_create_insert_menu_items();
1140 ui_create_insert_date_menu_items();
1141 keybindings_init();
1142 notebook_init();
1143 filetypes_init();
1144 templates_init();
1145 navqueue_init();
1146 document_init_doclist();
1147 symbols_init();
1148 editor_snippets_init();
1150 #ifdef HAVE_VTE
1151 vte_init();
1152 #endif
1153 ui_create_recent_menus();
1155 ui_set_statusbar(TRUE, _("This is Geany %s."), main_get_version_string());
1156 if (config_dir_result != 0)
1157 ui_set_statusbar(TRUE, _("Configuration directory could not be created (%s)."),
1158 g_strerror(config_dir_result));
1160 /* apply all configuration options */
1161 apply_settings();
1163 #ifdef HAVE_PLUGINS
1164 /* load any enabled plugins before we open any documents */
1165 if (want_plugins)
1166 plugins_load_active();
1167 #endif
1169 ui_sidebar_show_hide();
1171 /* set the active sidebar page after plugins have been loaded */
1172 gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.sidebar_notebook), ui_prefs.sidebar_page);
1174 /* load keybinding settings after plugins have added their groups */
1175 keybindings_load_keyfile();
1177 /* create the custom command menu after the keybindings have been loaded to have the proper
1178 * accelerator shown for the menu items */
1179 tools_create_insert_custom_command_menu_items();
1181 /* load any command line files or session files */
1182 main_status.opening_session_files = TRUE;
1183 load_startup_files(argc, argv);
1184 main_status.opening_session_files = FALSE;
1186 /* open a new file if no other file was opened */
1187 document_new_file_if_non_open();
1189 ui_document_buttons_update();
1190 ui_save_buttons_toggle(FALSE);
1192 doc = document_get_current();
1193 sidebar_select_openfiles_item(doc);
1194 build_menu_update(doc);
1195 sidebar_update_tag_list(doc, FALSE);
1197 #ifdef G_OS_WIN32
1198 /* Manually realise the main window to be able to set the position but don't show it.
1199 * We don't set the position after showing the window to avoid flickering. */
1200 gtk_widget_realize(main_widgets.window);
1201 #endif
1202 setup_window_position();
1204 /* finally show the window */
1205 document_grab_focus(doc);
1206 gtk_widget_show(main_widgets.window);
1207 main_status.main_window_realized = TRUE;
1209 configuration_apply_settings();
1211 #ifdef HAVE_SOCKET
1212 /* register the callback of socket input */
1213 if (! socket_info.ignore_socket && socket_info.lock_socket > 0)
1215 socket_info.read_ioc = g_io_channel_unix_new(socket_info.lock_socket);
1216 socket_info.lock_socket_tag = g_io_add_watch(socket_info.read_ioc,
1217 G_IO_IN | G_IO_PRI | G_IO_ERR, socket_lock_input_cb, main_widgets.window);
1219 #endif
1221 /* when we are really done with setting everything up and the main event loop is running,
1222 * tell other components, mainly plugins, that startup is complete */
1223 g_idle_add_full(G_PRIORITY_LOW, send_startup_complete, NULL, NULL);
1225 #ifdef MAC_INTEGRATION
1226 /* OS X application ready - has to be called before entering main loop */
1227 gtkosx_application_ready(gtkosx_application_get());
1228 #endif
1230 gtk_main();
1231 return 0;
1235 static void queue_free(GQueue *queue)
1237 while (! g_queue_is_empty(queue))
1239 g_free(g_queue_pop_tail(queue));
1241 g_queue_free(queue);
1245 static void do_main_quit(void)
1247 geany_debug("Quitting...");
1249 configuration_save();
1251 if (app->project != NULL)
1252 project_close(FALSE); /* save project session files */
1254 document_close_all();
1256 main_status.quitting = TRUE;
1258 #ifdef HAVE_SOCKET
1259 socket_finalize();
1260 #endif
1262 #ifdef HAVE_PLUGINS
1263 plugins_finalize();
1264 #endif
1266 navqueue_free();
1267 keybindings_free();
1268 notebook_free();
1269 highlighting_free_styles();
1270 templates_free_templates();
1271 msgwin_finalize();
1272 search_finalize();
1273 build_finalize();
1274 document_finalize();
1275 symbols_finalize();
1276 project_finalize();
1277 editor_finalize();
1278 editor_snippets_free();
1279 encodings_finalize();
1280 toolbar_finalize();
1281 sidebar_finalize();
1282 configuration_finalize();
1283 filetypes_free_types();
1284 log_finalize();
1286 tm_workspace_free();
1287 g_free(app->configdir);
1288 g_free(app->datadir);
1289 g_free(app->docdir);
1290 g_free(prefs.default_open_path);
1291 g_free(prefs.custom_plugin_path);
1292 g_free(ui_prefs.custom_date_format);
1293 g_free(interface_prefs.editor_font);
1294 g_free(interface_prefs.tagbar_font);
1295 g_free(interface_prefs.msgwin_font);
1296 g_free(editor_prefs.long_line_color);
1297 g_free(editor_prefs.comment_toggle_mark);
1298 g_free(editor_prefs.color_scheme);
1299 g_free(tool_prefs.context_action_cmd);
1300 g_free(template_prefs.developer);
1301 g_free(template_prefs.company);
1302 g_free(template_prefs.mail);
1303 g_free(template_prefs.initials);
1304 g_free(template_prefs.version);
1305 g_free(tool_prefs.term_cmd);
1306 g_free(tool_prefs.browser_cmd);
1307 g_free(tool_prefs.grep_cmd);
1308 g_free(printing_prefs.external_print_cmd);
1309 g_free(printing_prefs.page_header_datefmt);
1310 g_strfreev(ui_prefs.custom_commands);
1311 g_strfreev(ui_prefs.custom_commands_labels);
1313 queue_free(ui_prefs.recent_queue);
1314 queue_free(ui_prefs.recent_projects_queue);
1316 if (ui_widgets.prefs_dialog && GTK_IS_WIDGET(ui_widgets.prefs_dialog)) gtk_widget_destroy(ui_widgets.prefs_dialog);
1317 if (ui_widgets.open_fontsel && GTK_IS_WIDGET(ui_widgets.open_fontsel)) gtk_widget_destroy(ui_widgets.open_fontsel);
1318 if (ui_widgets.open_colorsel && GTK_IS_WIDGET(ui_widgets.open_colorsel)) gtk_widget_destroy(ui_widgets.open_colorsel);
1319 #ifdef HAVE_VTE
1320 if (vte_info.have_vte) vte_close();
1321 g_free(vte_info.lib_vte);
1322 g_free(vte_info.dir);
1323 #endif
1324 gtk_widget_destroy(main_widgets.window);
1326 /* destroy popup menus */
1327 if (main_widgets.editor_menu && GTK_IS_WIDGET(main_widgets.editor_menu))
1328 gtk_widget_destroy(main_widgets.editor_menu);
1329 if (ui_widgets.toolbar_menu && GTK_IS_WIDGET(ui_widgets.toolbar_menu))
1330 gtk_widget_destroy(ui_widgets.toolbar_menu);
1331 if (msgwindow.popup_status_menu && GTK_IS_WIDGET(msgwindow.popup_status_menu))
1332 gtk_widget_destroy(msgwindow.popup_status_menu);
1333 if (msgwindow.popup_msg_menu && GTK_IS_WIDGET(msgwindow.popup_msg_menu))
1334 gtk_widget_destroy(msgwindow.popup_msg_menu);
1335 if (msgwindow.popup_compiler_menu && GTK_IS_WIDGET(msgwindow.popup_compiler_menu))
1336 gtk_widget_destroy(msgwindow.popup_compiler_menu);
1338 g_object_unref(geany_object);
1339 geany_object = NULL;
1341 g_free(original_cwd);
1342 g_free(app);
1344 ui_finalize_builder();
1346 gtk_main_quit();
1350 static gboolean check_no_unsaved(void)
1352 guint i;
1354 for (i = 0; i < documents_array->len; i++)
1356 if (documents[i]->is_valid && documents[i]->changed)
1358 return FALSE;
1361 return TRUE; /* no unsaved edits */
1365 /* Returns false when quitting is aborted due to user cancellation */
1366 gboolean main_quit(void)
1368 main_status.quitting = TRUE;
1370 if (! check_no_unsaved())
1372 if (document_account_for_unsaved())
1374 do_main_quit();
1375 return TRUE;
1378 else
1379 if (! prefs.confirm_exit ||
1380 dialogs_show_question_full(NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL,
1381 _("Do you really want to quit?")))
1383 do_main_quit();
1384 return TRUE;
1387 main_status.quitting = FALSE;
1388 return FALSE;
1392 * Reloads most of Geany's configuration files without restarting. Currently the following
1393 * files are reloaded: all template files, also new file templates and the 'New (with template)'
1394 * menus will be updated, Snippets (snippets.conf), filetype extensions (filetype_extensions.conf),
1395 * and 'settings' and 'build_settings' sections of the filetype definition files.
1397 * Plugins may call this function if they changed any of these files (e.g. a configuration file
1398 * editor plugin).
1400 * @since 0.15
1402 GEANY_API_SYMBOL
1403 void main_reload_configuration(void)
1405 /* reload templates */
1406 templates_free_templates();
1407 templates_init();
1409 /* reload snippets */
1410 editor_snippets_free();
1411 editor_snippets_init();
1413 filetypes_reload_extensions();
1414 filetypes_reload();
1416 /* C tag names to ignore */
1417 symbols_reload_config_files();
1419 ui_set_statusbar(TRUE, _("Configuration files reloaded."));