aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauris Kaplinski <lauris@src.gnome.org>2000-08-24 11:25:53 +0800
committerLauris Kaplinski <lauris@src.gnome.org>2000-08-24 11:25:53 +0800
commit8d63772a7dffe54c6320a70021110e33dfe7c1ba (patch)
tree8414f5588b54d8df4b006b4effd8e6cc740f70a6
parent9e945f485b3dd9456db54f1004eb37b31acbe412 (diff)
downloadgsoc2013-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
-rw-r--r--addressbook/ChangeLog16
-rw-r--r--addressbook/backend/pas/pas-backend-file.c3
-rw-r--r--addressbook/contact-editor/e-contact-editor-fullname.c5
-rw-r--r--addressbook/contact-editor/e-contact-editor.c6
-rw-r--r--addressbook/ename/Makefile.am5
-rw-r--r--addressbook/ename/test-ename-western-gtk.c10
-rw-r--r--addressbook/gui/component/addressbook.c9
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-fullname.c5
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c6
-rw-r--r--e-util/ChangeLog5
-rw-r--r--e-util/e-unicode.c42
-rw-r--r--e-util/e-unicode.h6
-rw-r--r--e-util/ename/Makefile.am5
-rw-r--r--e-util/ename/test-ename-western-gtk.c10
-rw-r--r--widgets/e-text/e-text.c2
-rw-r--r--widgets/misc/e-unicode.c42
-rw-r--r--widgets/misc/e-unicode.h6
-rw-r--r--widgets/text/e-text.c2
18 files changed, 163 insertions, 22 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 14ffc2f9c2..4493f31f32 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,19 @@
+2000-08-23 Lauris Kaplinski <lauris@helixcode.com>
+
+ * backend/pas/pas-backend-file.c (func_contains): Use e_utf8_strstrcase
+
+ * contact-editor/e-contact-editor-fullname.c (fill_in_field): Use e_utf8 wrapper
+ (extract_field): Same
+
+ * contact-editor/e-contact-editor.c (full_name_clicked): Don't crash
+
+ * ename/Makefile.am: Link demo with libeutil.la
+
+ * ename/test-ename-western-gtk.c (full_changed_cb): Use e_utf8 wrapper
+
+ * gui/component/addressbook.c (find_contact_cb): Use e_utf8 wrapper
+ (search_entry_activated): Same
+
2000-08-22 Christopher James Lahey <clahey@helixcode.com>
* gui/search/e-addressbook-search-dialog.c: Fix an error in the
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c
index 3cf0586afe..dbcae01d25 100644
--- a/addressbook/backend/pas/pas-backend-file.c
+++ b/addressbook/backend/pas/pas-backend-file.c
@@ -27,6 +27,7 @@
#include <ebook/e-card-simple.h>
#include <e-util/e-sexp.h>
#include <e-util/e-util.h>
+#include <e-util/e-unicode.h>
#define PAS_BACKEND_FILE_VERSION_NAME "PAS-DB-VERSION"
#define PAS_BACKEND_FILE_VERSION "0.1"
@@ -300,7 +301,7 @@ func_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data
{
PASBackendFileSearchContext *ctx = data;
- return entry_compare (ctx, f, argc, argv, (char *(*)(const char*, const char*)) e_strstrcase);
+ return entry_compare (ctx, f, argc, argv, (char *(*)(const char*, const char*)) e_utf8_strstrcase);
}
static char *
diff --git a/addressbook/contact-editor/e-contact-editor-fullname.c b/addressbook/contact-editor/e-contact-editor-fullname.c
index b2e598fdde..d455640164 100644
--- a/addressbook/contact-editor/e-contact-editor-fullname.c
+++ b/addressbook/contact-editor/e-contact-editor-fullname.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <gnome.h>
+#include <e-util/e-unicode.h>
#include <e-contact-editor-fullname.h>
static void e_contact_editor_fullname_init (EContactEditorFullname *card);
@@ -171,7 +172,7 @@ fill_in_field(EContactEditorFullname *editor, char *field, char *string)
GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field));
if (entry) {
if (string)
- gtk_entry_set_text(entry, string);
+ e_utf8_gtk_entry_set_text(entry, string);
else
gtk_entry_set_text(entry, "");
}
@@ -195,7 +196,7 @@ extract_field(EContactEditorFullname *editor, char *field)
{
GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field));
if (entry)
- return g_strdup(gtk_entry_get_text(entry));
+ return e_utf8_gtk_entry_get_text(entry);
else
return NULL;
}
diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c
index ddd232b157..aa9b1ff9c9 100644
--- a/addressbook/contact-editor/e-contact-editor.c
+++ b/addressbook/contact-editor/e-contact-editor.c
@@ -359,8 +359,8 @@ file_as_set_style(EContactEditor *editor, int style)
if (style == -1) {
- string = e_utf8_gtk_entry_get_text(file_as);
- strings = g_list_append(strings, string);
+ string = gtk_entry_get_text(file_as);
+ strings = g_list_append(strings, g_strdup(string));
}
widget = glade_xml_get_widget(editor->gui, "combo-file-as");
@@ -479,7 +479,7 @@ full_name_clicked(GtkWidget *button, EContactEditor *editor)
GnomeDialog *dialog = GNOME_DIALOG(e_contact_editor_fullname_new(editor->name));
int result;
gtk_widget_show(GTK_WIDGET(dialog));
- result = gnome_dialog_run_and_close (dialog);
+ result = gnome_dialog_run (dialog);
if (result == 0) {
ECardName *name;
GtkWidget *fname_widget;
diff --git a/addressbook/ename/Makefile.am b/addressbook/ename/Makefile.am
index 25a67a929c..6e4d3818f2 100644
--- a/addressbook/ename/Makefile.am
+++ b/addressbook/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/addressbook/ename/test-ename-western-gtk.c b/addressbook/ename/test-ename-western-gtk.c
index 17daf42b30..38f3c1e0fe 100644
--- a/addressbook/ename/test-ename-western-gtk.c
+++ b/addressbook/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
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 9c0213edd8..12f9dbf9e0 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -19,6 +19,7 @@
#include <ebook/e-book.h>
#include <e-util/e-util.h>
#include <e-util/e-popup-menu.h>
+#include <e-util/e-unicode.h>
#include "e-minicard-view-widget.h"
#include "addressbook/gui/search/e-addressbook-search-dialog.h"
@@ -298,7 +299,7 @@ find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
GNOME_STOCK_BUTTON_CANCEL, NULL);
search_text = get_query (view);
- gtk_entry_set_text(GTK_ENTRY(search_entry), search_text);
+ e_utf8_gtk_entry_set_text(GTK_ENTRY(search_entry), search_text);
g_free (search_text);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox),
@@ -311,8 +312,9 @@ find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
/* If the user clicks "okay"...*/
if (result == 0) {
- search_text = gtk_entry_get_text(GTK_ENTRY(search_entry));
+ search_text = e_utf8_gtk_entry_get_text(GTK_ENTRY(search_entry));
set_query (view, search_text);
+ g_free (search_text);
}
}
@@ -450,7 +452,7 @@ static GnomeUIInfo gnome_toolbar [] = {
static void
search_entry_activated (GtkWidget* widget, gpointer user_data)
{
- char* search_word = gtk_entry_get_text(GTK_ENTRY(widget));
+ char* search_word = e_utf8_gtk_entry_get_text(GTK_ENTRY(widget));
char* search_query;
AddressbookView *view = (AddressbookView *) user_data;
@@ -465,6 +467,7 @@ search_entry_activated (GtkWidget* widget, gpointer user_data)
set_query(view, search_query);
g_free (search_query);
+ g_free (search_word);
}
static GtkWidget*
diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.c b/addressbook/gui/contact-editor/e-contact-editor-fullname.c
index b2e598fdde..d455640164 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-fullname.c
+++ b/addressbook/gui/contact-editor/e-contact-editor-fullname.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <gnome.h>
+#include <e-util/e-unicode.h>
#include <e-contact-editor-fullname.h>
static void e_contact_editor_fullname_init (EContactEditorFullname *card);
@@ -171,7 +172,7 @@ fill_in_field(EContactEditorFullname *editor, char *field, char *string)
GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field));
if (entry) {
if (string)
- gtk_entry_set_text(entry, string);
+ e_utf8_gtk_entry_set_text(entry, string);
else
gtk_entry_set_text(entry, "");
}
@@ -195,7 +196,7 @@ extract_field(EContactEditorFullname *editor, char *field)
{
GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field));
if (entry)
- return g_strdup(gtk_entry_get_text(entry));
+ return e_utf8_gtk_entry_get_text(entry);
else
return NULL;
}
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index ddd232b157..aa9b1ff9c9 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -359,8 +359,8 @@ file_as_set_style(EContactEditor *editor, int style)
if (style == -1) {
- string = e_utf8_gtk_entry_get_text(file_as);
- strings = g_list_append(strings, string);
+ string = gtk_entry_get_text(file_as);
+ strings = g_list_append(strings, g_strdup(string));
}
widget = glade_xml_get_widget(editor->gui, "combo-file-as");
@@ -479,7 +479,7 @@ full_name_clicked(GtkWidget *button, EContactEditor *editor)
GnomeDialog *dialog = GNOME_DIALOG(e_contact_editor_fullname_new(editor->name));
int result;
gtk_widget_show(GTK_WIDGET(dialog));
- result = gnome_dialog_run_and_close (dialog);
+ result = gnome_dialog_run (dialog);
if (result == 0) {
ECardName *name;
GtkWidget *fname_widget;
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
diff --git a/widgets/e-text/e-text.c b/widgets/e-text/e-text.c
index ea2a655932..ed87f21c95 100644
--- a/widgets/e-text/e-text.c
+++ b/widgets/e-text/e-text.c
@@ -851,7 +851,7 @@ split_into_lines (EText *text)
laststart = text->text;
cp = text->text;
- for (p = unicode_get_utf8 (cp, &unival); line_num < text->num_lines && unival; cp = p, p = unicode_get_utf8 (p, &unival)) {
+ for (p = unicode_get_utf8 (cp, &unival); p && unival && line_num < text->num_lines; cp = p, p = unicode_get_utf8 (p, &unival)) {
gboolean handled = FALSE;
if (len == 0)
lines->text = cp;
diff --git a/widgets/misc/e-unicode.c b/widgets/misc/e-unicode.c
index a865a7d0fa..8612048e21 100644
--- a/widgets/misc/e-unicode.c
+++ b/widgets/misc/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/widgets/misc/e-unicode.h b/widgets/misc/e-unicode.h
index 7bfba7e532..7bd46397e4 100644
--- a/widgets/misc/e-unicode.h
+++ b/widgets/misc/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/widgets/text/e-text.c b/widgets/text/e-text.c
index ea2a655932..ed87f21c95 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -851,7 +851,7 @@ split_into_lines (EText *text)
laststart = text->text;
cp = text->text;
- for (p = unicode_get_utf8 (cp, &unival); line_num < text->num_lines && unival; cp = p, p = unicode_get_utf8 (p, &unival)) {
+ for (p = unicode_get_utf8 (cp, &unival); p && unival && line_num < text->num_lines; cp = p, p = unicode_get_utf8 (p, &unival)) {
gboolean handled = FALSE;
if (len == 0)
lines->text = cp;