Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv31359/src
Modified Files:
charset.c prefs.c prefs.h
Log Message:
Redid charset patch.
Index: charset.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/charset.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- charset.c 22 Jun 2006 14:29:23 -0000 1.26
+++ charset.c 25 Jun 2006 04:16:52 -0000 1.27
@@ -41,7 +41,7 @@
set with each call of charset_to_utf8(). You can get a copy of its
value by calling charset_get_auto().
This variable will only be reset by calling charset_reset_auto(). */
-static const gchar *auto_charset = NULL;
+static gchar *auto_charset = NULL;
typedef struct {
gchar *descr;
@@ -300,15 +300,22 @@
/* return the charset actually used for the "auto detection"
* feature. So far only Japanese Auto Detecion is implemented */
-static const gchar *charset_check_auto (const gchar *str)
+static gchar *charset_check_auto (const gchar *str)
{
- const gchar *charset;
+ gchar *charset;
+ gchar *result;
if (str == NULL) return NULL; /* sanity */
- charset = prefs_get_charset ();
+
+ charset = prefs_get_string("charset");
+
if (charset && (strcmp (charset, GTKPOD_JAPAN_AUTOMATIC) == 0))
- return (charset_check_k_code (str));
- return NULL;
+ result = g_strdup(charset_check_k_code (str));
+ else
+ result = NULL;
+
+ g_free(charset);
+ return result;
}
/* See description at the definition of gchar *auto_charset; for
@@ -330,23 +337,31 @@
/* Must free the returned string yourself */
gchar *charset_to_utf8 (const gchar *str)
{
- const gchar *charset;
+ gchar *charset; /* From prefs */
+ const gchar *locale_charset; /* Used if prefs doesn't have a charset */
+ gchar *result;
if (str == NULL) return NULL; /* sanity */
charset = charset_check_auto (str);
if (charset)
{
- auto_charset = charset;
+ g_free(auto_charset);
+ auto_charset = g_strdup(charset);
}
else
{
- charset = prefs_get_charset ();
+ charset = prefs_get_string("charset");
if (!charset || !strlen (charset))
{ /* use standard locale charset */
- g_get_charset (&charset);
+ g_free(charset);
+ g_get_charset (&locale_charset);
+ charset = g_strdup(locale_charset);
}
}
- return charset_to_charset ((gchar *)charset, "UTF-8", str);
+
+ result = charset_to_charset ((gchar *)charset, "UTF-8", str);
+ g_free(charset);
+ return result;
}
@@ -356,15 +371,23 @@
/* Must free the returned string yourself */
gchar *charset_from_utf8 (const gchar *str)
{
- const gchar *charset;
+ gchar *charset;
+ const gchar *locale_charset;
+ gchar *result;
if (str == NULL) return NULL; /* sanity */
- charset = prefs_get_charset ();
+ charset = prefs_get_string("charset");
if (!charset || !strlen (charset))
- { /* use standard locale charset */
- g_get_charset (&charset);
+ {
+ /* use standard locale charset */
+ g_free(charset);
+ g_get_charset (&locale_charset);
+ charset = g_strdup(locale_charset);
}
- return charset_to_charset ("UTF-8", (gchar *)charset, str);
+
+ result = charset_to_charset ("UTF-8", (gchar *)charset, str);
+ g_free(charset);
+ return result;
}
/* Convert "str" from utf8 to the charset specified in @s->charset. If
@@ -373,7 +396,9 @@
/* Must free the returned string yourself */
gchar *charset_track_charset_from_utf8 (Track *s, const gchar *str)
{
- const gchar *charset = NULL;
+ gchar *charset;
+ const gchar *locale_charset;
+ gchar *result;
ExtraTrackData *etd;
g_return_val_if_fail (s, NULL);
@@ -385,12 +410,17 @@
if (etd->charset && strlen (etd->charset))
charset = etd->charset;
- else charset = prefs_get_charset ();
+ else charset = prefs_get_string("charset");
if (!charset || !strlen (charset))
{ /* use standard locale charset */
- g_get_charset (&charset);
+ g_free(charset);
+ g_get_charset (&locale_charset);
+ charset = g_strdup(locale_charset);
}
- return charset_to_charset ("UTF-8", (gchar *)charset, str);
+
+ result = charset_to_charset ("UTF-8", (gchar *)charset, str);
+ g_free(charset);
+ return result;
}
/* Convert "str" from "from_charset" to "to_charset", trying to skip
Index: prefs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.c,v
retrieving revision 1.262
retrieving revision 1.263
diff -u -d -r1.262 -r1.263
--- prefs.c 24 Jun 2006 16:19:57 -0000 1.262
+++ prefs.c 25 Jun 2006 04:16:52 -0000 1.263
@@ -382,11 +382,7 @@
/* Copy key data from the temp prefs tree to the hash table */
static gboolean copy_key(gpointer key, gpointer value, gpointer user_data)
{
- if (prefs_table)
- {
- g_hash_table_replace(prefs_table, (gpointer)g_strdup(key),
- (gpointer)g_strdup(value));
- }
+ prefs_set_string(key, value);
return FALSE;
}
@@ -1493,8 +1489,6 @@
if (value)
g_tree_insert (temp_prefs->tree, g_strdup(key), g_strdup(value));
- else
- g_tree_remove (temp_prefs->tree, key);
}
/* Add an integer value to temp prefs */
Index: prefs.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.h,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- prefs.h 24 Jun 2006 16:19:57 -0000 1.187
+++ prefs.h 25 Jun 2006 04:16:52 -0000 1.188
@@ -197,10 +197,6 @@
gboolean read_prefs_old (GtkWidget *gtkpod, int argc, char *argv[]);
void prefs_set_md5tracks(gboolean active);
-void prefs_set_charset (gchar *charset);
-void prefs_cfg_set_charset (struct cfg *cfg, gchar *charset);
-
-gchar * prefs_get_charset (void);
gboolean prefs_get_md5tracks(void);
#endif
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2