summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2008-07-24 13:25:49 +0000
committerCosimo Cecchi <cosimoc@src.gnome.org>2008-07-24 13:25:49 +0000
commitb1da346906605c4d3d91898e3e72dec571e78370 (patch)
tree7942e4d1ee11b059315d687b845a376bfb8c6e0b
parent82d174b173f973afdeac8062367d2989a82fc287 (diff)
downloadnautilus-b1da346906605c4d3d91898e3e72dec571e78370.tar.gz
Don't use setlocale () just to printf a float, but use g_ascii_dtostr ()
2008-07-24 Cosimo Cecchi <cosimoc@gnome.org> * src/file-manager/fm-icon-view.c: (get_stored_icon_position_callback), (icon_position_changed_callback): Don't use setlocale () just to printf a float, but use g_ascii_dtostr () instead. Initial patch by Christian Persch (#461804). svn path=/trunk/; revision=14412
-rw-r--r--ChangeLog9
-rw-r--r--src/file-manager/fm-icon-view.c50
2 files changed, 18 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 1607d8efe..aed45aa54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2008-07-24 Cosimo Cecchi <cosimoc@gnome.org>
+ * src/file-manager/fm-icon-view.c:
+ (get_stored_icon_position_callback),
+ (icon_position_changed_callback):
+ Don't use setlocale () just to printf a float, but use
+ g_ascii_dtostr () instead.
+ Initial patch by Christian Persch (#461804).
+
+2008-07-24 Cosimo Cecchi <cosimoc@gnome.org>
+
* libnautilus-private/nautilus-file-operations.c:
(is_all_button_text), (do_run_simple_dialog),
(run_simple_dialog_va), (run_error), (run_warning), (run_question),
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 675815130..a5186d605 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -234,8 +234,7 @@ get_stored_icon_position_callback (NautilusIconContainer *container,
FMIconView *icon_view)
{
char *position_string, *scale_string;
- gboolean position_good, scale_good;
- char *locale;
+ gboolean position_good;
char c;
g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
@@ -247,15 +246,6 @@ get_stored_icon_position_callback (NautilusIconContainer *container,
return FALSE;
}
- /* Doing parsing in the "C" locale instead of the one set
- * by the user ensures that data in the metafile is not in
- * a locale-specific format. It's only necessary for floating
- * point values since there aren't locale-specific formats for
- * integers in C stdio.
- */
- locale = g_strdup (setlocale (LC_NUMERIC, NULL));
- setlocale (LC_NUMERIC, "C");
-
/* Get the current position of this icon from the metadata. */
position_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_ICON_POSITION, "");
@@ -269,17 +259,12 @@ get_stored_icon_position_callback (NautilusIconContainer *container,
/* Get the scale of the icon from the metadata. */
scale_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_ICON_SCALE, "1");
- scale_good = sscanf
- (scale_string, " %lf",
- &position->scale) == 1;
- if (!scale_good) {
- position->scale = 1.0;
- }
+ position->scale = g_ascii_strtod (scale_string, NULL);
+ if (errno != 0) {
+ position->scale = 1.0;
+ }
g_free (scale_string);
-
- setlocale (LC_NUMERIC, locale);
- g_free (locale);
return position_good;
}
@@ -2267,22 +2252,12 @@ icon_position_changed_callback (NautilusIconContainer *container,
FMIconView *icon_view)
{
char *position_string;
- char *scale_string;
- char *locale;
+ char scale_string[G_ASCII_DTOSTR_BUF_SIZE];
g_assert (FM_IS_ICON_VIEW (icon_view));
g_assert (container == get_icon_container (icon_view));
g_assert (NAUTILUS_IS_FILE (file));
- /* Doing formatting in the "C" locale instead of the one set
- * by the user ensures that data in the metafile is not in
- * a locale-specific format. It's only necessary for floating
- * point values since there aren't locale-specific formats for
- * integers in C stdio.
- */
- locale = g_strdup (setlocale (LC_NUMERIC, NULL));
- setlocale (LC_NUMERIC, "C");
-
/* Schedule updating menus for the next idle. Doing it directly here
* noticeably slows down icon stretching. The other work here to
* store the icon position and scale does not seem to noticeably
@@ -2307,18 +2282,11 @@ icon_position_changed_callback (NautilusIconContainer *container,
g_free (position_string);
}
- /* FIXME bugzilla.gnome.org 40662:
- * %.2f is not a good format for the scale factor. We'd like it to
- * say "2" or "2x" instead of "2.00".
- */
- scale_string = g_strdup_printf ("%.2f", position->scale);
+
+ g_ascii_dtostr (scale_string, sizeof (scale_string), position->scale);
nautilus_file_set_metadata
(file, NAUTILUS_METADATA_KEY_ICON_SCALE,
- "1.00", scale_string);
- g_free (scale_string);
-
- setlocale (LC_NUMERIC, locale);
- g_free (locale);
+ "1.0", scale_string);
}
/* Attempt to change the filename to the new text. Notify user if operation fails. */