aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorLauris Kaplinski <lauris@src.gnome.org>2000-09-02 10:51:32 +0800
committerLauris Kaplinski <lauris@src.gnome.org>2000-09-02 10:51:32 +0800
commite8ae4bc97abed6ad8571908f5fc4ac6fd5565fde (patch)
treee81cd450c3094cf33bbda8d65508b6edd5654625 /widgets
parent16829497fd3a11bae35aaa440ee18ede4961ceb9 (diff)
downloadgsoc2013-evolution-e8ae4bc97abed6ad8571908f5fc4ac6fd5565fde.tar.gz
gsoc2013-evolution-e8ae4bc97abed6ad8571908f5fc4ac6fd5565fde.tar.zst
gsoc2013-evolution-e8ae4bc97abed6ad8571908f5fc4ac6fd5565fde.zip
A bit more e_utf8 wrappers here and there
svn path=/trunk/; revision=5180
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-text/e-text-test.c3
-rw-r--r--widgets/misc/e-unicode.c50
-rw-r--r--widgets/misc/e-unicode.h7
-rw-r--r--widgets/text/e-text-test.c3
4 files changed, 57 insertions, 6 deletions
diff --git a/widgets/e-text/e-text-test.c b/widgets/e-text/e-text-test.c
index 12a31cce7e..45fa1fc3d7 100644
--- a/widgets/e-text/e-text-test.c
+++ b/widgets/e-text/e-text-test.c
@@ -8,6 +8,7 @@
#include "e-text.h"
#include <gnome.h>
#include "e-util/e-canvas.h"
+#include "e-util/e-unicode.h"
GnomeCanvasItem *rect;
static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, GnomeCanvasItem *item)
@@ -55,7 +56,7 @@ change_text_cb (GtkEntry *entry,
{
gchar *str;
- str = gtk_entry_get_text (entry);
+ str = e_utf8_gtk_entry_get_text (entry);
gnome_canvas_item_set (GNOME_CANVAS_ITEM (text),
"text", str,
NULL);
diff --git a/widgets/misc/e-unicode.c b/widgets/misc/e-unicode.c
index cf8976f109..eba9bd56d1 100644
--- a/widgets/misc/e-unicode.c
+++ b/widgets/misc/e-unicode.c
@@ -11,6 +11,17 @@
#include <gdk/gdk.h>
#include "e-unicode.h"
+void
+e_unicode_init (void)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ unicode_init ();
+ initialized = TRUE;
+ }
+}
+
const gchar *
e_utf8_strstrcase (const gchar *haystack, const gchar *needle)
{
@@ -85,7 +96,7 @@ e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string)
if (!string) return NULL;
if (!uinit) {
- unicode_init ();
+ e_unicode_init ();
uiconv = unicode_iconv_open ("UTF-8", "iso-8859-1");
if (uiconv == (unicode_iconv_t) -1) {
uerror = TRUE;
@@ -123,7 +134,7 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
if (!string) return NULL;
if (!uinit) {
- unicode_init ();
+ e_unicode_init ();
uiconv = unicode_iconv_open ("UTF-8", "iso-8859-1");
if (uiconv == (unicode_iconv_t) -1) {
uerror = TRUE;
@@ -160,7 +171,7 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string)
if (!string) return NULL;
if (!uinit) {
- unicode_init ();
+ e_unicode_init ();
uiconv = unicode_iconv_open ("iso-8859-1", "UTF-8");
if (uiconv == (unicode_iconv_t) -1) {
uerror = TRUE;
@@ -233,6 +244,39 @@ e_utf8_gtk_menu_item_new_with_label (const gchar *label)
return w;
}
+void
+e_utf8_gtk_clist_set_text (GtkCList *clist, gint row, gint col, const gchar *text)
+{
+ gchar *s;
+
+ if (!text) return;
+
+ s = e_utf8_to_gtk_string ((GtkWidget *) clist, text);
+ gtk_clist_set_text (clist, row, col, s);
+
+ if (s) g_free (s);
+}
+
+gint
+e_utf8_gtk_clist_append (GtkCList *clist, gchar *text[])
+{
+ gint row, i;
+ gchar **v;
+
+ if (!text) return 0;
+
+ v = g_new (gchar *, clist->columns);
+ for (i = 0; i < clist->columns; i++)
+ v[i] = e_utf8_to_gtk_string ((GtkWidget *) clist, text[i]);
+
+ row = gtk_clist_append (clist, v);
+
+ for (i = 0; i < clist->columns; i++)
+ if (v[i]) g_free (v[i]);
+
+ return row;
+}
+
/**
* g_unichar_to_utf8:
* @ch: a ISO10646 character code
diff --git a/widgets/misc/e-unicode.h b/widgets/misc/e-unicode.h
index a69d1a3403..00cc3ab292 100644
--- a/widgets/misc/e-unicode.h
+++ b/widgets/misc/e-unicode.h
@@ -12,6 +12,8 @@
#define gnome_font_lookup_default gnome_font_get_glyph
#endif
+void e_unicode_init (void);
+
/*
* e_utf8_strstrcase
*/
@@ -31,15 +33,18 @@ gchar * e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string);
/* NB! This return newly allocated string, not const as gtk+ one */
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);
GtkWidget *e_utf8_gtk_menu_item_new_with_label (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[]);
+
gint g_unichar_to_utf8 (gint c, gchar *outbuf);
guint32 gdk_keyval_to_unicode (guint keysym);
#endif
+
diff --git a/widgets/text/e-text-test.c b/widgets/text/e-text-test.c
index 12a31cce7e..45fa1fc3d7 100644
--- a/widgets/text/e-text-test.c
+++ b/widgets/text/e-text-test.c
@@ -8,6 +8,7 @@
#include "e-text.h"
#include <gnome.h>
#include "e-util/e-canvas.h"
+#include "e-util/e-unicode.h"
GnomeCanvasItem *rect;
static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, GnomeCanvasItem *item)
@@ -55,7 +56,7 @@ change_text_cb (GtkEntry *entry,
{
gchar *str;
- str = gtk_entry_get_text (entry);
+ str = e_utf8_gtk_entry_get_text (entry);
gnome_canvas_item_set (GNOME_CANVAS_ITEM (text),
"text", str,
NULL);