aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorLauris Kaplinski <lauris@src.gnome.org>2000-09-05 07:27:06 +0800
committerLauris Kaplinski <lauris@src.gnome.org>2000-09-05 07:27:06 +0800
commit52bfd30b6c8cf8ab519fc3242b99f3a58e3629db (patch)
tree9fb2c16f1bd689f33e516676a813b6d1e5860bd0 /widgets/misc
parenta8a6e0d04c834a58f1ae71d89bfc24a89c2ae395 (diff)
downloadgsoc2013-evolution-52bfd30b6c8cf8ab519fc3242b99f3a58e3629db.tar.gz
gsoc2013-evolution-52bfd30b6c8cf8ab519fc3242b99f3a58e3629db.tar.zst
gsoc2013-evolution-52bfd30b6c8cf8ab519fc3242b99f3a58e3629db.zip
New font translation code for utf-8, but commented out at moment
svn path=/trunk/; revision=5194
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/e-unicode.c68
1 files changed, 32 insertions, 36 deletions
diff --git a/widgets/misc/e-unicode.c b/widgets/misc/e-unicode.c
index eba9bd56d1..0946647fd8 100644
--- a/widgets/misc/e-unicode.c
+++ b/widgets/misc/e-unicode.c
@@ -7,9 +7,13 @@
*/
#include <config.h>
+#include <string.h>
#include <unicode.h>
#include <gdk/gdk.h>
#include "e-unicode.h"
+#include "e-font.h"
+
+#undef FONT_TESTING
void
e_unicode_init (void)
@@ -82,57 +86,34 @@ e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string)
utf[unilen] = '\0';
return utf;
-#if 0
- /* test it out with iso-8859-1 */
-
- static gboolean uinit = FALSE;
- static gboolean uerror = FALSE;
- static unicode_iconv_t uiconv = (unicode_iconv_t) -1;
- char *new, *ob;
- size_t ibl, obl;
-
- if (uerror) return NULL;
-
- if (!string) return NULL;
-
- if (!uinit) {
- e_unicode_init ();
- uiconv = unicode_iconv_open ("UTF-8", "iso-8859-1");
- if (uiconv == (unicode_iconv_t) -1) {
- uerror = TRUE;
- return NULL;
- } else {
- uinit = TRUE;
- }
- }
-
- ibl = strlen (string);
- new = ob = g_new (gchar, ibl * 6 + 1);
- obl = ibl * 6 + 1;
-
- unicode_iconv (uiconv, &string, &ibl, &ob, &obl);
-
- *ob = '\0';
-
- return new;
-#endif
}
gchar *
e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
{
+#ifndef FONT_TESTING
/* test it out with iso-8859-1 */
static gboolean uinit = FALSE;
static gboolean uerror = FALSE;
static unicode_iconv_t uiconv = (unicode_iconv_t) -1;
+ const gchar *encoding;
+#else
+ unicode_iconv_t uiconv;
+#endif
char *new, *ob;
size_t ibl, obl;
+ g_return_val_if_fail (widget != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+#ifndef FONT_TESTING
if (uerror) return NULL;
+#endif
if (!string) return NULL;
+#ifndef FONT_TESTING
if (!uinit) {
e_unicode_init ();
uiconv = unicode_iconv_open ("UTF-8", "iso-8859-1");
@@ -143,6 +124,10 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
uinit = TRUE;
}
}
+#else
+ uiconv = e_uiconv_from_gdk_font (widget->style->font);
+ if (uiconv == (unicode_iconv_t) -1) return NULL;
+#endif
ibl = strlen (string);
new = ob = g_new (gchar, ibl * 6 + 1);
@@ -158,18 +143,25 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
gchar *
e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
{
+#ifndef FONT_TESTING
/* test it out with iso-8859-1 */
static gboolean uinit = FALSE;
static gboolean uerror = FALSE;
static unicode_iconv_t uiconv = (unicode_iconv_t) -1;
+#else
+ unicode_iconv_t uiconv;
+#endif
char *new, *ob;
size_t ibl, obl;
+#ifndef FONT_TESTING
if (uerror) return NULL;
+#endif
if (!string) return NULL;
+#ifndef FONT_TESTING
if (!uinit) {
e_unicode_init ();
uiconv = unicode_iconv_open ("iso-8859-1", "UTF-8");
@@ -180,10 +172,14 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
uinit = TRUE;
}
}
+#else
+ uiconv = e_uiconv_to_gdk_font (widget->style->font);
+ if (uiconv == (unicode_iconv_t) -1) return NULL;
+#endif
ibl = strlen (string);
- new = ob = g_new (gchar, ibl * 2 + 1);
- obl = ibl * 2 + 1;
+ new = ob = g_new (gchar, ibl * 4 + 1);
+ obl = ibl * 4 + 1;
unicode_iconv (uiconv, &string, &ibl, &ob, &obl);