|
|
f4d81a |
From 9c19d7fedadf38cc4fec21efdb3908572448f658 Mon Sep 17 00:00:00 2001
|
|
|
f4d81a |
From: Matthias Clasen <mclasen@redhat.com>
|
|
|
f4d81a |
Date: Thu, 30 May 2013 19:21:11 -0400
|
|
|
f4d81a |
Subject: [PATCH] Make the 'Don't ask again' checkbox work properly
|
|
|
f4d81a |
|
|
|
f4d81a |
We used to remove the user-dirs.locale file when this is checked,
|
|
|
f4d81a |
but that prevents xdg-user-dirs-gtk-update from ever running again.
|
|
|
f4d81a |
Instead, update it with the current locale. This has the effect
|
|
|
f4d81a |
of keeping xdg-user-dirs-gtk-update from running until the locale
|
|
|
f4d81a |
changes again, which is probably closer to the intended effect.
|
|
|
f4d81a |
|
|
|
f4d81a |
https://bugzilla.redhat.com/show_bug.cgi?id=968955
|
|
|
f4d81a |
---
|
|
|
f4d81a |
update.c | 40 +++++++++++++++++++++++++++++++---------
|
|
|
f4d81a |
1 file changed, 31 insertions(+), 9 deletions(-)
|
|
|
f4d81a |
|
|
|
f4d81a |
diff --git a/update.c b/update.c
|
|
|
f4d81a |
index 4697913..8710c79 100644
|
|
|
f4d81a |
--- a/update.c
|
|
|
f4d81a |
+++ b/update.c
|
|
|
f4d81a |
@@ -48,12 +48,40 @@ has_xdg_translation (void)
|
|
|
f4d81a |
if (strncmp (locale, "en_US", 5) == 0 ||
|
|
|
f4d81a |
strcmp (locale, "C") == 0)
|
|
|
f4d81a |
return TRUE;
|
|
|
f4d81a |
-
|
|
|
f4d81a |
+
|
|
|
f4d81a |
str = "Desktop";
|
|
|
f4d81a |
return dgettext ("xdg-user-dirs", str) != str;
|
|
|
f4d81a |
}
|
|
|
f4d81a |
|
|
|
f4d81a |
static void
|
|
|
f4d81a |
+save_locale (void)
|
|
|
f4d81a |
+{
|
|
|
f4d81a |
+ FILE *file;
|
|
|
f4d81a |
+ char *user_locale_file;
|
|
|
f4d81a |
+ char *locale, *dot;
|
|
|
f4d81a |
+
|
|
|
f4d81a |
+ user_locale_file = g_build_filename (g_get_user_config_dir (),
|
|
|
f4d81a |
+ "user-dirs.locale", NULL);
|
|
|
f4d81a |
+ file = fopen (user_locale_file, "w");
|
|
|
f4d81a |
+ g_free (user_locale_file);
|
|
|
f4d81a |
+
|
|
|
f4d81a |
+ if (file == NULL)
|
|
|
f4d81a |
+ {
|
|
|
f4d81a |
+ fprintf (stderr, "Can't save user-dirs.locale\n");
|
|
|
f4d81a |
+ return;
|
|
|
f4d81a |
+ }
|
|
|
f4d81a |
+
|
|
|
f4d81a |
+ locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
|
|
f4d81a |
+ /* Skip encoding part */
|
|
|
f4d81a |
+ dot = strchr (locale, '.');
|
|
|
f4d81a |
+ if (dot)
|
|
|
f4d81a |
+ *dot = 0;
|
|
|
f4d81a |
+ fprintf (file, "%s", locale);
|
|
|
f4d81a |
+ g_free (locale);
|
|
|
f4d81a |
+ fclose (file);
|
|
|
f4d81a |
+}
|
|
|
f4d81a |
+
|
|
|
f4d81a |
+static void
|
|
|
f4d81a |
update_locale (XdgDirEntry *old_entries)
|
|
|
f4d81a |
{
|
|
|
f4d81a |
XdgDirEntry *new_entries, *entry;
|
|
|
f4d81a |
@@ -91,10 +119,9 @@ update_locale (XdgDirEntry *old_entries)
|
|
|
f4d81a |
g_free (std_out);
|
|
|
f4d81a |
g_free (std_err);
|
|
|
f4d81a |
g_free (cmdline);
|
|
|
f4d81a |
-
|
|
|
f4d81a |
if (!WIFEXITED(exit_status) || WEXITSTATUS(exit_status) != 0)
|
|
|
f4d81a |
return;
|
|
|
f4d81a |
-
|
|
|
f4d81a |
+
|
|
|
f4d81a |
new_entries = parse_xdg_dirs (filename);
|
|
|
f4d81a |
g_unlink (filename);
|
|
|
f4d81a |
g_free (filename);
|
|
|
f4d81a |
@@ -254,12 +281,7 @@ update_locale (XdgDirEntry *old_entries)
|
|
|
f4d81a |
|
|
|
f4d81a |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
|
|
|
f4d81a |
{
|
|
|
f4d81a |
- char *file;
|
|
|
f4d81a |
-
|
|
|
f4d81a |
- file = g_build_filename (g_get_user_config_dir (),
|
|
|
f4d81a |
- "user-dirs.locale", NULL);
|
|
|
f4d81a |
- g_unlink (file);
|
|
|
f4d81a |
- g_free (file);
|
|
|
f4d81a |
+ save_locale ();
|
|
|
f4d81a |
}
|
|
|
f4d81a |
|
|
|
f4d81a |
g_free (new_entries);
|
|
|
f4d81a |
--
|
|
|
f4d81a |
1.8.2.1
|
|
|
f4d81a |
|