[Fwd: gkrellm strftime on none UTF-8 locales]

Takao Fujiwara - Tokyo S/W Center <[email protected]>
Newsgroups gmane.comp.gnome.apps.gkrellm
Organization Sun Microsystems
Message-ID <[email protected]>
Resending..
Could you integrate the patch?

-------- Original Message --------
Subject: [Gkrellm] gkrellm strftime on none UTF-8 locales
Date: Fri, 12 Sep 2008 22:20:06 +0900
From: Takao Fujiwara - Tokyo S/W Center <[email protected]>
Reply-To: [email protected]
Organization: Sun Microsystems
To: [email protected]
CC: Takao Fujiwara - Tokyo S/W Center <[email protected]>

Hi,

I cannot customize the Calendar format on none UTF-8 locales because strftime() fails with UTF-8 strings.

To reproduce:
1. Invoke gkrellm on none UTF-8(e.g. ja_JP.eucJP)
2. Right click on the window and choose [Configuration]
3. Select [Builtins] -> [Clock] in [Monitors] left pane.
4. Select [Options] tab in the right pane.
5. Type [Display format string:] text field in Calendar.
e.g.
%a <span foreground="$A"><big><big>%e日</big></big></span> %b

Then the format is not reflected.

I'm attaching the patch.
The patch gives strftime() the current encoding and I think it's better to customize the default format by .mo file since the visiblity is a bit
strange on some locales.
I also would like to suggest the default width is 100. Since some locales have multi-byte strings and the width is larger than C locale.

Thanks,
fujiwara
gkrellm-xx-g11n-i18n-strftime.txt (text/plain, 1.6 KB)
--- gkrellm-2.3.1/src/clock.c.orig	2008-09-12 19:54:29.470419000 +0900
+++ gkrellm-2.3.1/src/clock.c	2008-09-12 20:32:22.901338000 +0900
@@ -24,9 +24,9 @@
 
 
 #define	DEFAULT_CLOCK_FORMAT \
-	"%l:%M <span foreground=\"$A\"><small>%S</small></span>"
+	_("%l:%M <span foreground=\"$A\"><small>%S</small></span>")
 #define	DEFAULT_CAL_FORMAT \
-	"%a <span foreground=\"$A\"><big><big>%e</big></big></span> %b"
+	_("%a <span foreground=\"$A\"><big><big>%e</big></big></span> %b")
 
 
 static GkrellmMonitor
@@ -166,6 +166,7 @@ static gchar *
 strftime_format(gchar *format, gchar *alt_color)
 	{
 	struct tm	*t;
+	gchar		*locale_format = NULL;
 	gchar		buf1[512], buf2[512];
 
 	if (_GK.client_mode)
@@ -173,12 +174,14 @@ strftime_format(gchar *format, gchar *al
 	else
 		t = &gkrellm_current_tm;
 
-	strftime(buf1, sizeof(buf1), format, t);
+	locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
+	strftime(buf1, sizeof(buf1), locale_format, t);
+	g_free (locale_format);
 	format_alt_color(buf1, buf2, sizeof(buf2), alt_color);
 
 // printf("%s\n", buf2);
 
-	return g_strdup(buf2);
+	return g_locale_to_utf8 (buf2, -1, NULL, NULL, NULL);
 	}
 
 static gint
--- gkrellm-2.3.1/src/config.c.orig	2008-09-12 20:41:22.273112000 +0900
+++ gkrellm-2.3.1/src/config.c	2008-09-12 20:46:40.341525000 +0900
@@ -2290,7 +2290,7 @@ gkrellm_load_user_config(GkrellmMonitor 
 		_GK.enable_hostname = TRUE;
 		_GK.hostname_short = FALSE;
 		_GK.enable_system_name = FALSE;
-		_GK.chart_width = 60;
+		_GK.chart_width = 100;
 		_GK.update_HZ = 10;
 		_GK.theme_scale = 100;
 		_GK.float_factor = 1.0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.