Blame SOURCES/0001-Make-the-Don-t-ask-again-checkbox-work-properly.patch

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