mirror of https://github.com/GNOME/gimp.git
app: change gimp_config_file_backup_on_error() to take a GFile
This commit is contained in:
parent
98e7ec090b
commit
3665352ad6
app
|
@ -211,20 +211,22 @@ gimp_config_file_copy (const gchar *source,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gimp_config_file_backup_on_error (const gchar *filename,
|
||||
gimp_config_file_backup_on_error (GFile *file,
|
||||
const gchar *name,
|
||||
GError **error)
|
||||
{
|
||||
gchar *path;
|
||||
gchar *backup;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
g_return_val_if_fail (G_IS_FILE (file), FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
backup = g_strconcat (filename, "~", NULL);
|
||||
path = g_file_get_path (file);
|
||||
backup = g_strconcat (path, "~", NULL);
|
||||
|
||||
success = gimp_config_file_copy (filename, backup, NULL, NULL, error);
|
||||
success = gimp_config_file_copy (path, backup, NULL, NULL, error);
|
||||
|
||||
if (success)
|
||||
g_message (_("There was an error parsing your '%s' file. "
|
||||
|
@ -233,6 +235,7 @@ gimp_config_file_backup_on_error (const gchar *filename,
|
|||
name, gimp_filename_to_utf8 (backup));
|
||||
|
||||
g_free (backup);
|
||||
g_free (path);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -26,10 +26,11 @@ gboolean gimp_config_file_copy (const gchar *source,
|
|||
const gchar *dest,
|
||||
const gchar *old_options_regexp,
|
||||
GRegexEvalCallback update_callback,
|
||||
GError **error);
|
||||
gboolean gimp_config_file_backup_on_error (const gchar *filename,
|
||||
const gchar *name,
|
||||
GError **error);
|
||||
GError **error);
|
||||
|
||||
gboolean gimp_config_file_backup_on_error (GFile *file,
|
||||
const gchar *name,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONFIG_FILE_H__ */
|
||||
|
|
|
@ -277,9 +277,13 @@ gimp_rc_load (GimpRc *rc)
|
|||
{
|
||||
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
g_message ("%s", error->message);
|
||||
|
||||
gimp_config_file_backup_on_error (rc->user_gimprc, "gimprc", NULL);
|
||||
file = g_file_new_for_path (rc->user_gimprc);
|
||||
gimp_config_file_backup_on_error (file, "gimprc", NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_clear_error (&error);
|
||||
|
|
|
@ -167,8 +167,6 @@ gimp_unitrc_load (Gimp *gimp)
|
|||
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
{
|
||||
gchar *tmp;
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
||||
_("fatal parse error"), TRUE);
|
||||
|
@ -176,9 +174,7 @@ gimp_unitrc_load (Gimp *gimp)
|
|||
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
tmp = g_file_get_path (file);
|
||||
gimp_config_file_backup_on_error (tmp, "unitrc", NULL);
|
||||
g_free (tmp);
|
||||
gimp_config_file_backup_on_error (file, "unitrc", NULL);
|
||||
}
|
||||
|
||||
gimp_scanner_destroy (scanner);
|
||||
|
|
|
@ -298,14 +298,10 @@ session_init (Gimp *gimp)
|
|||
|
||||
if (error)
|
||||
{
|
||||
gchar *tmp;
|
||||
|
||||
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
tmp = g_file_get_path (file);
|
||||
gimp_config_file_backup_on_error (tmp, "sessionrc", NULL);
|
||||
g_free (tmp);
|
||||
gimp_config_file_backup_on_error (file, "sessionrc", NULL);
|
||||
}
|
||||
|
||||
gimp_scanner_destroy (scanner);
|
||||
|
|
Loading…
Reference in New Issue