aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorLauris Kaplinski <lauris@src.gnome.org>2000-09-08 02:30:30 +0800
committerLauris Kaplinski <lauris@src.gnome.org>2000-09-08 02:30:30 +0800
commit0db696fa4205edb578c56cade278061b4bbe54f2 (patch)
treeb481424b3de3f269586f7658dd463864974bda6c /e-util
parent722a05828e68522a639a04ae0b13855e6b70820b (diff)
downloadgsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar
gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar.gz
gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar.bz2
gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar.lz
gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar.xz
gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar.zst
gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.zip
Bunch of unicode related changes
svn path=/trunk/; revision=5235
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog10
-rw-r--r--e-util/e-dialog-widgets.c5
-rw-r--r--e-util/e-font.c33
-rw-r--r--e-util/e-unicode.c42
-rw-r--r--e-util/e-unicode.h5
5 files changed, 77 insertions, 18 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index e17f53ff4b..ddec5e90a4 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,13 @@
+2000-09-07 Lauris Kaplinski <lauris@helixcode.com>
+
+ * e-dialog-widgets.c (e_dialog_editable_get): Use UTF-8
+ (e_dialog_editable_set): Use UTF-8
+
+ * e-font.c (translate_encoding): More encodings
+ (e_gdk_font_encoding): Use experimental stuff
+
+ * e-unicode.* (e_utf8_gtk_editable_insert_text): New wrapper
+
2000-09-07 Federico Mena Quintero <federico@helixcode.com>
* e-canvas.c (emit_event): Remove incorrect optimization. Events
diff --git a/e-util/e-dialog-widgets.c b/e-util/e-dialog-widgets.c
index fd1b929c9f..4a4664cd41 100644
--- a/e-util/e-dialog-widgets.c
+++ b/e-util/e-dialog-widgets.c
@@ -30,6 +30,7 @@
#include <gtk/gtkspinbutton.h>
#include <libgnomeui/gnome-dateedit.h>
#include "e-dialog-widgets.h"
+#include "e-unicode.h"
@@ -351,7 +352,7 @@ e_dialog_editable_set (GtkWidget *widget, const char *value)
gint pos;
pos = 0;
- gtk_editable_insert_text (GTK_EDITABLE (widget), value, strlen (value), &pos);
+ e_utf8_gtk_editable_insert_text (GTK_EDITABLE (widget), value, strlen (value), &pos);
}
}
@@ -369,7 +370,7 @@ e_dialog_editable_get (GtkWidget *widget)
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (GTK_IS_EDITABLE (widget), NULL);
- return gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
+ return e_utf8_gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
}
/**
diff --git a/e-util/e-font.c b/e-util/e-font.c
index 6f46b07f03..cfee9f0923 100644
--- a/e-util/e-font.c
+++ b/e-util/e-font.c
@@ -143,6 +143,14 @@ translate_encoding (const gchar *encoding)
g_hash_table_insert (eh, "iso8859-3", "iso-8859-3");
g_hash_table_insert (eh, "iso8859-4", "iso-8859-4");
g_hash_table_insert (eh, "iso8859-5", "iso-8859-5");
+ g_hash_table_insert (eh, "iso8859-6", "iso-8859-6");
+ g_hash_table_insert (eh, "iso8859-7", "iso-8859-7");
+ g_hash_table_insert (eh, "iso8859-8", "iso-8859-8");
+ g_hash_table_insert (eh, "iso8859-9", "iso-8859-9");
+ g_hash_table_insert (eh, "iso8859-10", "iso-8859-10");
+ g_hash_table_insert (eh, "iso8859-13", "iso-8859-13");
+ g_hash_table_insert (eh, "iso8859-14", "iso-8859-14");
+ g_hash_table_insert (eh, "iso8859-15", "iso-8859-15");
g_hash_table_insert (eh, "iso10646-1", "UCS2");
}
@@ -159,6 +167,7 @@ e_gdk_font_encoding (GdkFont *font)
Bool status;
char *name, *p;
const gchar *encoding;
+ gint i;
if (!font) return NULL;
@@ -183,7 +192,15 @@ e_gdk_font_encoding (GdkFont *font)
if (!status) return NULL;
- name = gdk_atom_name (atom);
+ name = p = gdk_atom_name (atom);
+
+ for (i = 0; i < 13; i++) {
+ /* Skip hyphen */
+ while (*p && (*p != '-')) p++;
+ if (*p) p++;
+ }
+
+#if 0
p = strchr (name, '-'); /* Foundry */
p = strchr (p + 1, '-'); /* Family */
p = strchr (p + 1, '-'); /* Weight */
@@ -199,6 +216,11 @@ e_gdk_font_encoding (GdkFont *font)
p = strchr (p + 1, '-'); /* Charset */
encoding = translate_encoding (p + 1);
+#else
+ if (!*p) return NULL;
+
+ encoding = translate_encoding (p);
+#endif
g_free (name);
@@ -218,9 +240,7 @@ e_uiconv_from_gdk_font (GdkFont *font)
if (!enc) return (unicode_iconv_t) -1;
- if (!uh) {
- uh = g_hash_table_new (g_str_hash, g_str_equal);
- }
+ if (!uh) uh = g_hash_table_new (g_str_hash, g_str_equal);
uiconv = g_hash_table_lookup (uh, enc);
@@ -246,9 +266,7 @@ e_uiconv_to_gdk_font (GdkFont *font)
if (!enc) return (unicode_iconv_t) -1;
- if (!uh) {
- uh = g_hash_table_new (g_str_hash, g_str_equal);
- }
+ if (!uh) uh = g_hash_table_new (g_str_hash, g_str_equal);
uiconv = g_hash_table_lookup (uh, enc);
@@ -267,3 +285,4 @@ e_uiconv_to_gdk_font (GdkFont *font)
+
diff --git a/e-util/e-unicode.c b/e-util/e-unicode.c
index 0946647fd8..8357977f8e 100644
--- a/e-util/e-unicode.c
+++ b/e-util/e-unicode.c
@@ -13,7 +13,7 @@
#include "e-unicode.h"
#include "e-font.h"
-#undef FONT_TESTING
+#define FONT_TESTING
void
e_unicode_init (void)
@@ -89,7 +89,7 @@ e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string)
}
gchar *
-e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
+e_utf8_from_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes)
{
#ifndef FONT_TESTING
/* test it out with iso-8859-1 */
@@ -97,7 +97,6 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
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
@@ -113,6 +112,8 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
if (!string) return NULL;
+ g_return_val_if_fail (widget, NULL);
+
#ifndef FONT_TESTING
if (!uinit) {
e_unicode_init ();
@@ -129,7 +130,7 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
if (uiconv == (unicode_iconv_t) -1) return NULL;
#endif
- ibl = strlen (string);
+ ibl = bytes;
new = ob = g_new (gchar, ibl * 6 + 1);
obl = ibl * 6 + 1;
@@ -141,7 +142,13 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
}
gchar *
-e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
+e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
+{
+ return e_utf8_from_gtk_string_sized (widget, string, strlen (string));
+}
+
+gchar *
+e_utf8_to_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes)
{
#ifndef FONT_TESTING
/* test it out with iso-8859-1 */
@@ -161,6 +168,8 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
if (!string) return NULL;
+ g_return_val_if_fail (widget, NULL);
+
#ifndef FONT_TESTING
if (!uinit) {
e_unicode_init ();
@@ -177,7 +186,7 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
if (uiconv == (unicode_iconv_t) -1) return NULL;
#endif
- ibl = strlen (string);
+ ibl = bytes;
new = ob = g_new (gchar, ibl * 4 + 1);
obl = ibl * 4 + 1;
@@ -189,6 +198,11 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
}
gchar *
+e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
+{
+ return e_utf8_to_gtk_string_sized (widget, string, strlen (string));
+}
+gchar *
e_utf8_gtk_entry_get_text (GtkEntry *entry)
{
gchar *s, *u;
@@ -212,6 +226,18 @@ e_utf8_gtk_editable_get_chars (GtkEditable *editable, gint start, gint end)
}
void
+e_utf8_gtk_editable_insert_text (GtkEditable *editable, const gchar *text, gint length, gint *position)
+{
+ gchar *s;
+
+ s = e_utf8_to_gtk_string_sized ((GtkWidget *) editable, text, length);
+
+ gtk_editable_insert_text (editable, s, length, position);
+
+ g_free (s);
+}
+
+void
e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text)
{
gchar *s;
@@ -225,14 +251,14 @@ e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text)
}
GtkWidget *
-e_utf8_gtk_menu_item_new_with_label (const gchar *label)
+e_utf8_gtk_menu_item_new_with_label (GtkMenu *menu, const gchar *label)
{
GtkWidget *w;
gchar *s;
if (!label) return NULL;
- s = e_utf8_to_gtk_string (NULL, label);
+ s = e_utf8_to_gtk_string ((GtkWidget *) menu, label);
w = gtk_menu_item_new_with_label (s);
if (s) g_free (s);
diff --git a/e-util/e-unicode.h b/e-util/e-unicode.h
index 00cc3ab292..654d8d94ee 100644
--- a/e-util/e-unicode.h
+++ b/e-util/e-unicode.h
@@ -23,8 +23,10 @@ const gchar *e_utf8_strstrcase (const gchar *haystack, const gchar *needle);
gchar *e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string);
gchar *e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string);
+gchar *e_utf8_from_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes);
gchar * e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string);
+gchar * e_utf8_to_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes);
/*
* These are simple wrappers that save us some typing
@@ -36,8 +38,9 @@ gchar *e_utf8_gtk_entry_get_text (GtkEntry *entry);
void e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text);
gchar *e_utf8_gtk_editable_get_chars (GtkEditable *editable, gint start, gint end);
+void e_utf8_gtk_editable_insert_text (GtkEditable *editable, const gchar *text, gint length, gint *position);
-GtkWidget *e_utf8_gtk_menu_item_new_with_label (const gchar *label);
+GtkWidget *e_utf8_gtk_menu_item_new_with_label (GtkMenu *menu, const gchar *label);
void e_utf8_gtk_clist_set_text (GtkCList *clist, gint row, gint col, const gchar *text);
gint e_utf8_gtk_clist_append (GtkCList *clist, gchar *text[]);