diff options
author | Lauris Kaplinski <lauris@src.gnome.org> | 2000-09-08 02:30:30 +0800 |
---|---|---|
committer | Lauris Kaplinski <lauris@src.gnome.org> | 2000-09-08 02:30:30 +0800 |
commit | 0db696fa4205edb578c56cade278061b4bbe54f2 (patch) | |
tree | b481424b3de3f269586f7658dd463864974bda6c /widgets | |
parent | 722a05828e68522a639a04ae0b13855e6b70820b (diff) | |
download | gsoc2013-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 'widgets')
-rw-r--r-- | widgets/misc/e-unicode.c | 42 | ||||
-rw-r--r-- | widgets/misc/e-unicode.h | 5 |
2 files changed, 38 insertions, 9 deletions
diff --git a/widgets/misc/e-unicode.c b/widgets/misc/e-unicode.c index 0946647fd8..8357977f8e 100644 --- a/widgets/misc/e-unicode.c +++ b/widgets/misc/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/widgets/misc/e-unicode.h b/widgets/misc/e-unicode.h index 00cc3ab292..654d8d94ee 100644 --- a/widgets/misc/e-unicode.h +++ b/widgets/misc/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[]); |