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