Move utils_reload_configuration() to main.c.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2803 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-07-23 11:46:02 +00:00
parent 5c2e1a1a4d
commit 4faeb8f46f
9 changed files with 68 additions and 47 deletions

View File

@ -1,3 +1,10 @@
2008-07-23 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/utils.c, src/utils.h, src/plugindata.h, src/callbacks.c,
src/plugins.c, src/main.c, src/main.h, plugins/pluginmacros.h:
Move utils_reload_configuration() to main.c.
2008-07-22 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* scintilla/LexHTML.cxx:

View File

@ -49,6 +49,7 @@
#define p_filetypes geany_functions->p_filetypes /**< See filetypes.h */
#define p_highlighting geany_functions->p_highlighting /**< See highlighting.h */
#define p_keybindings geany_functions->p_keybindings /**< See keybindings.h */
#define p_main geany_functions->p_main /**< See main.h */
#define p_msgwindow geany_functions->p_msgwindow /**< See msgwindow.h */
#define p_navqueue geany_functions->p_navqueue /**< See navqueue.h */
#define p_sci geany_functions->p_sci /**< See sciwrappers.h */

View File

@ -2222,6 +2222,6 @@ void
on_menu_reload_configuration1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
utils_reload_configuration();
main_reload_configuration();
}

View File

@ -1021,3 +1021,42 @@ void *rpl_malloc(size_t n)
n = 1;
return malloc(n);
}
/**
* Reloads most of Geany's configuration files without restarting. Currently the following
* files are reloaded: all template files, also new file templates and the 'New (with template)'
* menus will be updated, Snippets (snippets.conf), filetype extensions (filetype_extensions.conf),
* and 'settings' and 'build_settings' sections of the filetype definition files.
*
* Plugins may call this function if they changed any of these files (e.g. a configuration file
* editor plugin).
*
**/
void main_reload_configuration(void)
{
guint i;
/* reload templates */
templates_free_templates();
templates_init();
/* reload snippets */
editor_snippets_free();
editor_snippets_init();
/* reload filetype extensions */
configuration_read_filetype_extensions();
/* save possibly changed commands before re-reading them */
filetypes_save_commands();
/* reload filetype configs */
for (i = 0; i < filetypes_array->len; i++)
{
/* filetypes_load_config() will skip not loaded filetypes */
filetypes_load_config(i, TRUE);
}
ui_set_statusbar(TRUE, _("Configuration files reloaded."));
}

View File

@ -55,4 +55,6 @@ void main_quit(void);
gboolean main_handle_filename(gchar *locale_filename);
void main_reload_configuration(void);
#endif

View File

@ -36,12 +36,12 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
static const gint api_version = 79;
static const gint api_version = 80;
/* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields
* are only appended, as this doesn't affect existing fields. */
static const gint abi_version = 42;
static const gint abi_version = 43;
/** Check the plugin can be loaded by Geany.
* This performs runtime checks that try to ensure:
@ -190,6 +190,7 @@ typedef struct GeanyFunctions
struct FiletypeFuncs *p_filetypes; /**< See filetypes.h */
struct NavQueueFuncs *p_navqueue; /**< See navqueue.h */
struct EditorFuncs *p_editor; /**< See editor.h */
struct MainFuncs *p_main; /**< See main.h */
}
GeanyFunctions;
@ -300,11 +301,18 @@ typedef struct UtilsFuncs
gboolean (*spawn_async) (const gchar *dir, gchar **argv, gchar **env, GSpawnFlags flags,
GSpawnChildSetupFunc child_setup, gpointer user_data, GPid *child_pid,
GError **error);
void (*reload_configuration) (void);
}
UtilsFuncs;
/* See main.h */
typedef struct MainFuncs
{
void (*reload_configuration) (void);
}
MainFuncs;
/* See ui_utils.h */
typedef struct UIUtilsFuncs
{

View File

@ -55,6 +55,7 @@
#include "highlighting.h"
#include "keybindings.h"
#include "navqueue.h"
#include "main.h"
#ifdef G_OS_WIN32
@ -171,7 +172,6 @@ static UtilsFuncs utils_funcs = {
&utils_get_setting_string,
&utils_spawn_sync,
&utils_spawn_async,
&utils_reload_configuration
};
static UIUtilsFuncs uiutils_funcs = {
@ -239,6 +239,10 @@ static NavQueueFuncs navqueue_funcs = {
&navqueue_goto_line
};
static MainFuncs main_funcs = {
&main_reload_configuration
};
static GeanyFunctions geany_functions = {
&doc_funcs,
&sci_funcs,
@ -255,7 +259,8 @@ static GeanyFunctions geany_functions = {
&highlighting_funcs,
&filetype_funcs,
&navqueue_funcs,
&editor_funcs
&editor_funcs,
&main_funcs
};
static GeanyData geany_data;

View File

@ -1523,42 +1523,3 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
#endif
return result;
}
/**
* Reloads most of Geany's configuration files without restarting. Currently the following
* files are reloaded: all template files, also new file templates and the 'New (with template)'
* menus will be updated, Snippets (snippets.conf), filetype extensions (filetype_extensions.conf),
* and 'settings' and 'build_settings' sections of the filetype definition files.
*
* Plugins may call this function if they changed any of these files (e.g. a configuration file
* editor plugin).
*
**/
void utils_reload_configuration(void)
{
guint i;
/* reload templates */
templates_free_templates();
templates_init();
/* reload snippets */
editor_snippets_free();
editor_snippets_init();
/* reload filetype extensions */
configuration_read_filetype_extensions();
/* save possibly changed commands before re-reading them */
filetypes_save_commands();
/* reload filetype configs */
for (i = 0; i < filetypes_array->len; i++)
{
/* filetypes_load_config() will skip not loaded filetypes */
filetypes_load_config(i, TRUE);
}
ui_set_statusbar(TRUE, _("Configuration files reloaded."));
}

View File

@ -141,6 +141,4 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
GSpawnChildSetupFunc child_setup, gpointer user_data, GPid *child_pid,
GError **error);
void utils_reload_configuration(void);
#endif