aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-03-25 15:42:30 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-03-25 15:42:30 +0800
commit0f80005685978681896ccf1df105a74c217a1efc (patch)
tree25b756a5034df1795bf3fa9bfc3556cf7cb291fe
parent5dfac3bcc19a0ab4095c9c29f2969e0fc95ccb9d (diff)
downloadgsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.tar
gsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.tar.gz
gsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.tar.bz2
gsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.tar.lz
gsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.tar.xz
gsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.tar.zst
gsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.zip
Rather than starting the pending query by directly calling
2001-03-25 Jon Trowbridge <trow@ximian.com> * gui/component/select-names/e-select-names-completion.c (e_select_names_completion_seq_complete_cb): Rather than starting the pending query by directly calling e_select_names_completion_do_query, call e_completion_begin_search. Circumventing the ECompletion API was causing it to get confused in some cases. svn path=/trunk/; revision=8922
-rw-r--r--addressbook/ChangeLog9
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.c41
2 files changed, 42 insertions, 8 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 747c89f897..1c76f3d75b 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,12 @@
+2001-03-25 Jon Trowbridge <trow@ximian.com>
+
+ * gui/component/select-names/e-select-names-completion.c
+ (e_select_names_completion_seq_complete_cb): Rather than starting
+ the pending query by directly calling
+ e_select_names_completion_do_query, call
+ e_completion_begin_search. Circumventing the ECompletion API was
+ causing it to get confused in some cases.
+
2001-03-23 Jon Trowbridge <trow@ximian.com>
* gui/widgets/e-minicard-widget.c (e_minicard_widget_set_card):
diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c
index 9fbd6e5804..f1087bebeb 100644
--- a/addressbook/gui/component/select-names/e-select-names-completion.c
+++ b/addressbook/gui/component/select-names/e-select-names-completion.c
@@ -46,6 +46,7 @@ struct _ESelectNamesCompletionPrivate {
EBookView *book_view;
gchar *waiting_query;
+ gint waiting_pos, waiting_limit;
gchar *query_text;
gchar *cached_query_text;
@@ -62,7 +63,7 @@ static void e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus
static void e_select_names_completion_card_added_cb (EBookView *, const GList *cards, gpointer user_data);
static void e_select_names_completion_seq_complete_cb (EBookView *, gpointer user_data);
-static void e_select_names_completion_do_query (ESelectNamesCompletion *, const gchar *query_text);
+static void e_select_names_completion_do_query (ESelectNamesCompletion *, const gchar *query_text, gint pos, gint limit);
static void e_select_names_completion_begin (ECompletion *, const gchar *txt, gint pos, gint limit);
static void e_select_names_completion_end (ECompletion *);
@@ -189,6 +190,28 @@ enum {
MATCHED_FAMILY_NAME = 1<<2
};
+/*
+ Match text against every substring in fragment that follows whitespace.
+ This allows the fragment "de Icaza" to match against txt "ica".
+*/
+static gboolean
+match_name_fragment (const gchar *fragment, const gchar *txt)
+{
+ gint len = strlen (txt);
+
+ while (*fragment) {
+ if (!g_strncasecmp (fragment, txt, len))
+ return TRUE;
+
+ while (*fragment && !isspace ((gint) *fragment))
+ ++fragment;
+ while (*fragment && isspace ((gint) *fragment))
+ ++fragment;
+ }
+
+ return FALSE;
+}
+
static gchar *
match_name (ESelectNamesCompletion *comp, EDestination *dest, double *score)
{
@@ -213,20 +236,20 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest, double *score)
if (card->name->given
&& !(match & MATCHED_GIVEN_NAME)
- && !g_strncasecmp (card->name->given, strv[i], len)) {
+ && match_name_fragment (card->name->given, strv[i])) {
this_match = MATCHED_GIVEN_NAME;
}
else if (card->name->additional
- && !(match & MATCHED_ADDITIONAL_NAME)
- && !g_strncasecmp (card->name->additional, strv[i], len)) {
+ && !(match & MATCHED_ADDITIONAL_NAME)
+ && match_name_fragment (card->name->additional, strv[i])) {
this_match = MATCHED_ADDITIONAL_NAME;
} else if (card->name->family
&& !(match & MATCHED_FAMILY_NAME)
- && !g_strncasecmp (card->name->family, strv[i], len)) {
+ && match_name_fragment (card->name->family, strv[i])) {
this_match = MATCHED_FAMILY_NAME;
}
@@ -695,7 +718,7 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, gpointer user_d
if (comp->priv->waiting_query) {
gchar *s = comp->priv->waiting_query;
comp->priv->waiting_query = NULL;
- e_select_names_completion_do_query (comp, s);
+ e_completion_begin_search (E_COMPLETION (comp), s, comp->priv->waiting_pos, comp->priv->waiting_limit);
g_free (s);
}
}
@@ -779,7 +802,7 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar
}
static void
-e_select_names_completion_do_query (ESelectNamesCompletion *comp, const gchar *query_text)
+e_select_names_completion_do_query (ESelectNamesCompletion *comp, const gchar *query_text, gint pos, gint limit)
{
gchar *clean;
gboolean query_is_still_running, can_reuse_cached_cards;
@@ -811,6 +834,8 @@ e_select_names_completion_do_query (ESelectNamesCompletion *comp, const gchar *q
if (query_is_still_running) {
g_free (comp->priv->waiting_query);
comp->priv->waiting_query = clean;
+ comp->priv->waiting_pos = pos;
+ comp->priv->waiting_limit = limit;
if (out)
fprintf (out, "waiting for running query to complete: %s\n", comp->priv->waiting_query);
return;
@@ -907,7 +932,7 @@ e_select_names_completion_begin (ECompletion *comp, const gchar *text, gint pos,
}
}
- e_select_names_completion_do_query (selcomp, str);
+ e_select_names_completion_do_query (selcomp, str, pos, limit);
}
static void