gnome-commander r2104 - in trunk: . doc/C src
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r2104 - in trunk: . doc/C src
- Date: Wed, 24 Sep 2008 17:35:38 +0000 (UTC)
Author: epiotr
Date: Wed Sep 24 17:35:38 2008
New Revision: 2104
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2104&view=rev
Log:
Fixed problem #548947 (non-UTF8 locale date problem)
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/doc/C/gnome-commander.xml
trunk/src/gnome-cmd-data.cc
trunk/src/gnome-cmd-options-dialog.cc
trunk/src/utils.cc
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Wed Sep 24 17:35:38 2008
@@ -4,6 +4,7 @@
Bug fixes:
* Fixed problem #536446 (file name not focused for in-place renaming)
+ * Fixed problem #548947 (non-UTF8 locale date problem)
* Fixed problem #548948 (crash when home directory contains non-UTF8 characters)
* Fixed problem #548961 (support for input method when rename or quicksearch)
* Fixed problem with setting equal pane size in horizontal mode
Modified: trunk/doc/C/gnome-commander.xml
==============================================================================
--- trunk/doc/C/gnome-commander.xml (original)
+++ trunk/doc/C/gnome-commander.xml Wed Sep 24 17:35:38 2008
@@ -5938,6 +5938,9 @@
<para>Fixed problem #536446 (file name not focused for in-place renaming)</para>
</listitem>
<listitem>
+ <para>Fixed problem #548947 (non-UTF8 locale date problem)</para>
+ </listitem>
+ <listitem>
<para>Fixed problem #548948 (crash when home directory contains non-UTF8 characters)</para>
</listitem>
<listitem>
Modified: trunk/src/gnome-cmd-data.cc
==============================================================================
--- trunk/src/gnome-cmd-data.cc (original)
+++ trunk/src/gnome-cmd-data.cc Wed Sep 24 17:35:38 2008
@@ -51,7 +51,7 @@
GList *fav_apps;
GnomeCmdSizeDispMode size_disp_mode;
GnomeCmdPermDispMode perm_disp_mode;
- GnomeCmdDateFormat date_format;
+ GnomeCmdDateFormat date_format; // NOTE: internally stored as locale (which not always defaults to UTF8), needs converting from/to UTF8 for editing and cfg load/save
GnomeCmdLayout layout;
GnomeCmdColorTheme color_themes[GNOME_CMD_NUM_COLOR_MODES];
gchar *list_font;
@@ -1224,10 +1224,12 @@
priv->perm_disp_mode = (GnomeCmdPermDispMode) gnome_cmd_data_get_int ("/options/perm_disp_mode", GNOME_CMD_PERM_DISP_MODE_TEXT);
#ifdef HAVE_LOCALE_H
- priv->date_format = gnome_cmd_data_get_string ("/options/date_disp_mode", "%x %R");
+ gchar *utf8_date_format = gnome_cmd_data_get_string ("/options/date_disp_mode", "%x %R");
#else
- priv->date_format = gnome_cmd_data_get_string ("/options/date_disp_mode", "%D %R");
+ gchar *utf8_date_format = gnome_cmd_data_get_string ("/options/date_disp_mode", "%D %R");
#endif
+ priv->date_format = g_locale_from_utf8 (utf8_date_format, -1, NULL, NULL, NULL);
+ g_free (utf8_date_format);
priv->layout = (GnomeCmdLayout) gnome_cmd_data_get_int ("/options/layout", GNOME_CMD_LAYOUT_MIME_ICONS);
@@ -1593,10 +1595,13 @@
gnome_cmd_data_set_int ("/options/size_disp_mode", priv->size_disp_mode);
gnome_cmd_data_set_int ("/options/perm_disp_mode", priv->perm_disp_mode);
- gnome_cmd_data_set_string ("/options/date_disp_mode", priv->date_format);
gnome_cmd_data_set_int ("/options/layout", priv->layout);
gnome_cmd_data_set_int ("/options/list_row_height", list_row_height);
+ gchar *utf8_date_format = g_locale_to_utf8 (priv->date_format, -1, NULL, NULL, NULL);
+ gnome_cmd_data_set_string ("/options/date_disp_mode", utf8_date_format);
+ g_free (utf8_date_format);
+
gnome_cmd_data_set_bool ("/confirm/delete", confirm_delete);
gnome_cmd_data_set_int ("/confirm/copy_overwrite", confirm_copy_overwrite);
gnome_cmd_data_set_int ("/confirm/move_overwrite", confirm_move_overwrite);
Modified: trunk/src/gnome-cmd-options-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-options-dialog.cc (original)
+++ trunk/src/gnome-cmd-options-dialog.cc Wed Sep 24 17:35:38 2008
@@ -172,12 +172,16 @@
GtkWidget *test_label = lookup_widget (options_dialog, "date_format_test_label");
const char *format = gtk_entry_get_text (GTK_ENTRY (format_entry));
+ gchar *locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
char s[256];
time_t t = time (NULL);
- strftime (s, sizeof(s), format, localtime (&t));
+ strftime (s, sizeof(s), locale_format, localtime (&t));
+ gchar *utf8_str = g_locale_to_utf8 (s, -1, NULL, NULL, NULL);
- gtk_label_set_text (GTK_LABEL (test_label), s);
+ gtk_label_set_text (GTK_LABEL (test_label), utf8_str);
+ g_free (utf8_str);
+ g_free (locale_format);
}
@@ -245,8 +249,9 @@
label = create_label (parent, _("Format:"));
table_add (table, label, 0, 0, GTK_FILL);
- entry = create_entry (parent, "date_format_entry", gnome_cmd_data_get_date_format());
- gtk_entry_set_text (GTK_ENTRY (entry), gnome_cmd_data_get_date_format ());
+ gchar *utf8_date_format = g_locale_to_utf8 (gnome_cmd_data_get_date_format(), -1, NULL, NULL, NULL);
+ entry = create_entry (parent, "date_format_entry", utf8_date_format);
+ g_free (utf8_date_format);
gtk_widget_grab_focus (entry);
table_add (table, entry, 1, 0, GTK_FILL);
@@ -293,7 +298,7 @@
else
gnome_cmd_data_set_perm_disp_mode (GNOME_CMD_PERM_DISP_MODE_NUMBER);
- gnome_cmd_data_set_date_format (g_strdup (format));
+ gnome_cmd_data_set_date_format (g_locale_from_utf8 (format, -1, NULL, NULL, NULL));
}
Modified: trunk/src/utils.cc
==============================================================================
--- trunk/src/utils.cc (original)
+++ trunk/src/utils.cc Wed Sep 24 17:35:38 2008
@@ -420,12 +420,21 @@
const gchar *time2string (time_t t, const gchar *date_format)
{
+ // NOTE: date_format is passed in current locale format
+
static gchar buf[64];
struct tm lt;
localtime_r (&t, <);
strftime (buf, sizeof(buf), date_format, <);
+ // convert formatted date from current locale to UTF8
+ gchar *loc_date = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
+ if (loc_date)
+ strncpy (buf, loc_date, sizeof(buf)-1);
+
+ g_free (loc_date);
+
return buf;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]