aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
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 /addressbook/gui
parent5dfac3bcc19a0ab4095c9c29f2969e0fc95ccb9d (diff)
downloadgsoc2013-evolution-0f80005685978681896ccf1df105a74c217a1efc.tar.gz
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
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.c41
1 files changed, 33 insertions, 8 deletions
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
ions'>+4 * - Update to 2015.12.20sunpoet2015-12-222-3/+3 * Update Calligra to 2.9.10.rakuco2015-12-223-26/+39 * Update to 5.0.4.jkim2015-12-181-4/+4 * Fix usage of ${PERL5}.mat2015-12-181-2/+2 * - Update to 4.4sunpoet2015-12-112-4/+6 * - Update to 2015.12.06sunpoet2015-12-092-3/+3 * eric6 ports: Update to version 6.1.0.bsam2015-12-071-2/+2 * - Update to 2015.11.29sunpoet2015-12-022-3/+3 * Remove expired ports:rene2015-11-294-35/+0 * - Update to 2015.11.22sunpoet2015-11-242-3/+3 * - Update to 2015.11.15sunpoet2015-11-202-3/+3 * - Update to 2015.11.08sunpoet2015-11-102-3/+3 * Update to 5.0.3.jkim2015-11-041-4/+4 * - Update to 2015.10.25sunpoet2015-10-272-3/+3 * Deprecate ports broken for more than 6 monthsantoine2015-10-261-0/+2 * - Fix shebangsamdmi32015-10-251-2/+30 * - Update to 2015.10.18sunpoet2015-10-202-3/+3 * - Update to 2015.10.11sunpoet2015-10-162-3/+3 * - Update to 2015.10.04sunpoet2015-10-092-3/+3 * Remove trailing whitespace from Makefiles, A-L.olgeni2015-10-081-1/+1 * - Update to 2015.09.27sunpoet2015-10-042-3/+3 * - Update to 4.3.1sunpoet2015-10-012-3/+3 * - update to 4.4.10ohauer2015-09-302-5/+5 * Update to 5.0.2.jkim2015-09-242-6/+6 * - Update to 2015.09.20sunpoet2015-09-212-3/+3 * - Update to 2015.09.13sunpoet2015-09-152-3/+3 * - update bugzilla ports to 5.0.1 / 4.4.10ohauer2015-09-141-2/+2 * eric6 ports: Update to version 6.0.9.bsam2015-09-121-2/+2 * - Update to 2015.09.06sunpoet2015-09-082-3/+3 * Update LibreOffice to 5.0.1.jkim2015-09-021-4/+4 * - Update to 2015.08.30sunpoet2015-08-312-3/+3 * - Update to 2015.08.23sunpoet2015-08-252-3/+3 * - Update to version 10lme2015-08-23