From aaa9ae1ada5b51adf5bff690fb275ab9dac7a70f Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 11 Dec 2016 20:19:42 +0100 Subject: [PATCH] Bug 698278 - Preferences|Reset ignores /etc/gimp/2.0/gimprc Make gimp_rc_load() public as gimp_rc_load_system() and gimp_rc_load_user() and call gimp_rc_load_system() from the preferences dialog's reset code. --- app/config/gimprc.c | 88 +++++++++++++++++--------------- app/config/gimprc.h | 10 +++- app/dialogs/preferences-dialog.c | 1 + 3 files changed, 57 insertions(+), 42 deletions(-) diff --git a/app/config/gimprc.c b/app/config/gimprc.c index e68816bb9c..998f784b74 100644 --- a/app/config/gimprc.c +++ b/app/config/gimprc.c @@ -62,7 +62,6 @@ static void gimp_rc_get_property (GObject *object, GParamSpec *pspec); static GimpConfig * gimp_rc_duplicate (GimpConfig *object); -static void gimp_rc_load (GimpRc *rc); static gboolean gimp_rc_idle_save (GimpRc *rc); static void gimp_rc_notify (GimpRc *rc, GParamSpec *param, @@ -251,44 +250,6 @@ gimp_rc_duplicate (GimpConfig *config) return dup; } -static void -gimp_rc_load (GimpRc *rc) -{ - GError *error = NULL; - - g_return_if_fail (GIMP_IS_RC (rc)); - - if (rc->verbose) - g_print ("Parsing '%s'\n", - gimp_file_get_utf8_name (rc->system_gimprc)); - - if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc), - rc->system_gimprc, NULL, &error)) - { - if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) - g_message ("%s", error->message); - - g_clear_error (&error); - } - - if (rc->verbose) - g_print ("Parsing '%s'\n", - gimp_file_get_utf8_name (rc->user_gimprc)); - - if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc), - rc->user_gimprc, NULL, &error)) - { - if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) - { - g_message ("%s", error->message); - - gimp_config_file_backup_on_error (rc->user_gimprc, "gimprc", NULL); - } - - g_clear_error (&error); - } -} - static gboolean gimp_rc_idle_save (GimpRc *rc) { @@ -346,11 +307,58 @@ gimp_rc_new (GObject *gimp, "user-gimprc", user_gimprc, NULL); - gimp_rc_load (rc); + gimp_rc_load_system (rc); + gimp_rc_load_user (rc); return rc; } +void +gimp_rc_load_system (GimpRc *rc) +{ + GError *error = NULL; + + g_return_if_fail (GIMP_IS_RC (rc)); + + if (rc->verbose) + g_print ("Parsing '%s'\n", + gimp_file_get_utf8_name (rc->system_gimprc)); + + if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc), + rc->system_gimprc, NULL, &error)) + { + if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) + g_message ("%s", error->message); + + g_clear_error (&error); + } +} + +void +gimp_rc_load_user (GimpRc *rc) +{ + GError *error = NULL; + + g_return_if_fail (GIMP_IS_RC (rc)); + + if (rc->verbose) + g_print ("Parsing '%s'\n", + gimp_file_get_utf8_name (rc->user_gimprc)); + + if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc), + rc->user_gimprc, NULL, &error)) + { + if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) + { + g_message ("%s", error->message); + + gimp_config_file_backup_on_error (rc->user_gimprc, "gimprc", NULL); + } + + g_clear_error (&error); + } +} + void gimp_rc_set_autosave (GimpRc *rc, gboolean autosave) diff --git a/app/config/gimprc.h b/app/config/gimprc.h index 5cbb557d8b..53391f5154 100644 --- a/app/config/gimprc.h +++ b/app/config/gimprc.h @@ -51,16 +51,22 @@ struct _GimpRcClass GType gimp_rc_get_type (void) G_GNUC_CONST; + GimpRc * gimp_rc_new (GObject *gimp, GFile *system_gimprc, GFile *user_gimprc, gboolean verbose); -void gimp_rc_set_autosave (GimpRc *gimprc, +void gimp_rc_load_system (GimpRc *rc); +void gimp_rc_load_user (GimpRc *rc); + +void gimp_rc_set_autosave (GimpRc *rc, gboolean autosave); -void gimp_rc_save (GimpRc *gimprc); +void gimp_rc_save (GimpRc *rc); + gchar * gimp_rc_query (GimpRc *rc, const gchar *key); + void gimp_rc_set_unknown_token (GimpRc *rc, const gchar *token, const gchar *value); diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 04ad6bc986..36fe715cff 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -294,6 +294,7 @@ prefs_response (GtkWidget *widget, config_copy = g_object_get_data (G_OBJECT (dialog), "config-copy"); gimp_config_reset (config_copy); + gimp_rc_load_system (GIMP_RC (config_copy)); /* don't use the default value if there is no help browser */ if (! gimp_help_browser_is_installed (gimp))