diff options
author | Lauris Kaplinski <lauris@src.gnome.org> | 2000-08-24 11:25:53 +0800 |
---|---|---|
committer | Lauris Kaplinski <lauris@src.gnome.org> | 2000-08-24 11:25:53 +0800 |
commit | 8d63772a7dffe54c6320a70021110e33dfe7c1ba (patch) | |
tree | 8414f5588b54d8df4b006b4effd8e6cc740f70a6 /e-util | |
parent | 9e945f485b3dd9456db54f1004eb37b31acbe412 (diff) | |
download | gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar.gz gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar.bz2 gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar.lz gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar.xz gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.tar.zst gsoc2013-evolution-8d63772a7dffe54c6320a70021110e33dfe7c1ba.zip |
Unicode in addressbook basically works, including simple searching
svn path=/trunk/; revision=4997
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/ChangeLog | 5 | ||||
-rw-r--r-- | e-util/e-unicode.c | 42 | ||||
-rw-r--r-- | e-util/e-unicode.h | 6 | ||||
-rw-r--r-- | e-util/ename/Makefile.am | 5 | ||||
-rw-r--r-- | e-util/ename/test-ename-western-gtk.c | 10 |
5 files changed, 65 insertions, 3 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index e3b81f816e..3e9465814b 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,8 @@ +2000-08-23 Lauris Kaplinski <lauris@helixcode.com> + + * e-unicode.h: + * e-unicode.c (e_utf8_strstrcase): New function + 2000-08-23 Federico Mena Quintero <federico@helixcode.com> * e-dialog-widgets.c (e_dialog_editable_set): Constify. diff --git a/e-util/e-unicode.c b/e-util/e-unicode.c index a865a7d0fa..8612048e21 100644 --- a/e-util/e-unicode.c +++ b/e-util/e-unicode.c @@ -10,6 +10,48 @@ #include <unicode.h> #include "e-unicode.h" +const gchar * +e_utf8_strstrcase (const gchar *haystack, const gchar *needle) +{ + gchar *p; + unicode_char_t *huni, *nuni; + unicode_char_t unival; + gint hlen, nlen, hp, np; + + if (haystack == NULL) return NULL; + if (needle == NULL) return NULL; + if (strlen (needle) == 0) return haystack; + + huni = alloca (sizeof (unicode_char_t) * strlen (haystack)); + + for (hlen = 0, p = unicode_get_utf8 (haystack, &unival); p && unival; hlen++, p = unicode_get_utf8 (p, &unival)) { + huni[hlen] = unicode_tolower (unival); + } + + if (!p) return NULL; + if (hlen == 0) return NULL; + + nuni = alloca (sizeof (unicode_char_t) * strlen (needle)); + + for (nlen = 0, p = unicode_get_utf8 (needle, &unival); p && unival; nlen++, p = unicode_get_utf8 (p, &unival)) { + nuni[nlen] = unicode_tolower (unival); + } + + if (!p) return NULL; + if (nlen == 0) return NULL; + + if (hlen < nlen) return NULL; + + for (hp = 0; hp <= hlen - nlen; hp++) { + for (np = 0; np < nlen; np++) { + if (huni[hp + np] != nuni[np]) break; + } + if (np == nlen) return haystack + unicode_offset_to_index (haystack, hp); + } + + return NULL; +} + gchar * e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string) { diff --git a/e-util/e-unicode.h b/e-util/e-unicode.h index 7bfba7e532..7bd46397e4 100644 --- a/e-util/e-unicode.h +++ b/e-util/e-unicode.h @@ -5,6 +5,12 @@ #include <glib.h> #include <gtk/gtk.h> +/* + * e_utf8_strstrcase + */ + +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); diff --git a/e-util/ename/Makefile.am b/e-util/ename/Makefile.am index 25a67a929c..6e4d3818f2 100644 --- a/e-util/ename/Makefile.am +++ b/e-util/ename/Makefile.am @@ -47,4 +47,7 @@ test_ename_western_LDADD = $(ename_libs) test_ename_western_gtk_SOURCES = \ test-ename-western-gtk.c -test_ename_western_gtk_LDADD = $(ename_libs) $(gnome_libs) +test_ename_western_gtk_LDADD = \ + $(ename_libs) \ + $(top_builddir)/e-util/libeutil.la \ + $(gnome_libs) diff --git a/e-util/ename/test-ename-western-gtk.c b/e-util/ename/test-ename-western-gtk.c index 17daf42b30..38f3c1e0fe 100644 --- a/e-util/ename/test-ename-western-gtk.c +++ b/e-util/ename/test-ename-western-gtk.c @@ -1,4 +1,5 @@ #include <gnome.h> +#include <e-util/e-unicode.h> #include <ename/e-name-western.h> ENameWestern *name; @@ -14,7 +15,7 @@ static void fill_entries (void) { -#define SET(a,b) (gtk_entry_set_text (GTK_ENTRY (a), (b) == NULL ? "" : (b))) +#define SET(a,b) (e_utf8_gtk_entry_set_text (GTK_ENTRY (a), (b) == NULL ? "" : (b))) SET(prefix, name->prefix); SET(first, name->first); SET(middle, name->middle); @@ -26,9 +27,14 @@ fill_entries (void) static void full_changed_cb (GtkEntry *fulle) { + gchar *str; + e_name_western_free (name); - name = e_name_western_parse (gtk_entry_get_text (fulle)); + str = e_utf8_gtk_entry_get_text (fulle); + name = e_name_western_parse (str); fill_entries (); + + g_free (str); } static void |