[gnome-control-center] datetime: Create filenames locale-independently



commit 83a437d2ff60505731203a52f88a3264efadb759
Author: Christian Persch <chpe gnome org>
Date:   Wed Feb 2 21:52:15 2011 +0100

    datetime: Create filenames locale-independently
    
    Bug #641294.

 panels/datetime/cc-timezone-map.c |    6 ++++--
 panels/datetime/test-timezone.c   |   10 +++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/panels/datetime/cc-timezone-map.c b/panels/datetime/cc-timezone-map.c
index 2c7924a..54fd370 100644
--- a/panels/datetime/cc-timezone-map.c
+++ b/panels/datetime/cc-timezone-map.c
@@ -335,6 +335,7 @@ cc_timezone_map_draw (GtkWidget *widget,
   gchar *file;
   GError *err = NULL;
   gdouble pointx, pointy;
+  char buf[16];
 
   gtk_widget_get_allocation (widget, &alloc);
 
@@ -343,8 +344,9 @@ cc_timezone_map_draw (GtkWidget *widget,
   cairo_paint (cr);
 
   /* paint hilight */
-  file = g_strdup_printf (DATADIR "/timezone_%g.png",
-                          priv->selected_offset);
+  file = g_strdup_printf (DATADIR "/timezone_%s.png",
+                          g_ascii_formatd (buf, sizeof (buf),
+                                           "%g", priv->selected_offset));
   orig_hilight = gdk_pixbuf_new_from_file (file, &err);
   g_free (file);
   file = NULL;
diff --git a/panels/datetime/test-timezone.c b/panels/datetime/test-timezone.c
index 2f3f17c..d667c42 100644
--- a/panels/datetime/test-timezone.c
+++ b/panels/datetime/test-timezone.c
@@ -1,3 +1,6 @@
+#include <config.h>
+#include <locale.h>
+
 #include "tz.h"
 
 int main (int argc, char **argv)
@@ -8,6 +11,8 @@ int main (int argc, char **argv)
 	char *pixmap_dir;
 	int retval = 0;
 
+        setlocale (LC_ALL, "");
+
 	if (argc == 2) {
 		pixmap_dir = g_strdup (argv[1]);
 	} else if (argc == 1) {
@@ -24,12 +29,15 @@ int main (int argc, char **argv)
 		TzInfo *info;
 		char *filename, *path;
 		gdouble selected_offset;
+                char buf[16];
 
 		info = tz_info_from_location (loc);
 		selected_offset = tz_location_get_utc_offset (loc)
 			/ (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
 
-		filename = g_strdup_printf ("timezone_%g.png", selected_offset);
+		filename = g_strdup_printf ("timezone_%s.png",
+                                            g_ascii_formatd (buf, sizeof (buf),
+                                                             "%g", selected_offset));
 		path = g_build_filename (pixmap_dir, filename, NULL);
 
 		if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]