mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Introduce /reload command
This command reloads the configuration file. Fix https://github.com/profanity-im/profanity/issues/627
This commit is contained in:
parent
523681a642
commit
5c77b97c35
@ -2408,6 +2408,19 @@ static struct cmd_t command_defs[] =
|
||||
CMD_NOARGS
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
|
||||
{ "/reload",
|
||||
parse_args, 0, 0, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_reload)
|
||||
CMD_NOTAGS
|
||||
CMD_SYN(
|
||||
"/reload")
|
||||
CMD_DESC(
|
||||
"Reload preferences from configuration file.")
|
||||
CMD_NOARGS
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
};
|
||||
|
||||
static GHashTable *search_index;
|
||||
|
@ -8551,3 +8551,12 @@ cmd_save(ProfWin *window, const char *const command, gchar **args)
|
||||
prefs_save();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_reload(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
log_info("Reloading preferences");
|
||||
cons_show("Reloading preferences.");
|
||||
prefs_reload();
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -227,4 +227,5 @@ gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **ar
|
||||
gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_save(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args);
|
||||
#endif
|
||||
|
@ -78,25 +78,9 @@ static const char* _get_key(preference_t pref);
|
||||
static gboolean _get_default_boolean(preference_t pref);
|
||||
static char* _get_default_string(preference_t pref);
|
||||
|
||||
void
|
||||
prefs_load(char *config_file)
|
||||
void _prefs_load(void)
|
||||
{
|
||||
GError *err;
|
||||
|
||||
if (config_file == NULL) {
|
||||
prefs_loc = files_get_config_path(FILE_PROFRC);
|
||||
} else {
|
||||
prefs_loc = config_file;
|
||||
}
|
||||
|
||||
if (g_file_test(prefs_loc, G_FILE_TEST_EXISTS)) {
|
||||
g_chmod(prefs_loc, S_IRUSR | S_IWUSR);
|
||||
}
|
||||
|
||||
prefs = g_key_file_new();
|
||||
g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
||||
|
||||
err = NULL;
|
||||
GError *err = NULL;
|
||||
log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err);
|
||||
if (err) {
|
||||
log_maxsize = 0;
|
||||
@ -180,6 +164,38 @@ prefs_load(char *config_file)
|
||||
g_strfreev(triggers);
|
||||
}
|
||||
|
||||
void
|
||||
prefs_reload(void)
|
||||
{
|
||||
g_key_file_free(prefs);
|
||||
prefs = NULL;
|
||||
|
||||
prefs = g_key_file_new();
|
||||
g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
||||
|
||||
_prefs_load();
|
||||
}
|
||||
|
||||
void
|
||||
prefs_load(char *config_file)
|
||||
{
|
||||
|
||||
if (config_file == NULL) {
|
||||
prefs_loc = files_get_config_path(FILE_PROFRC);
|
||||
} else {
|
||||
prefs_loc = config_file;
|
||||
}
|
||||
|
||||
if (g_file_test(prefs_loc, G_FILE_TEST_EXISTS)) {
|
||||
g_chmod(prefs_loc, S_IRUSR | S_IWUSR);
|
||||
}
|
||||
|
||||
prefs = g_key_file_new();
|
||||
g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
||||
|
||||
_prefs_load();
|
||||
}
|
||||
|
||||
void
|
||||
prefs_save(void)
|
||||
{
|
||||
|
@ -169,6 +169,7 @@ typedef struct prof_winplacement_t {
|
||||
void prefs_load(char *config_file);
|
||||
void prefs_save(void);
|
||||
void prefs_close(void);
|
||||
void prefs_reload(void);
|
||||
|
||||
char* prefs_find_login(char *prefix);
|
||||
void prefs_reset_login_search(void);
|
||||
|
Loading…
Reference in New Issue
Block a user