aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-unicode.c
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 /widgets/misc/e-unicode.c
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 'widgets/misc/e-unicode.c')
-rw-r--r--widgets/misc/e-unicode.c42
1 files changed, 34 insertions, 8 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);