diff --git a/sflphone-client-gnome/src/contacts/addressbook/eds.c b/sflphone-client-gnome/src/contacts/addressbook/eds.c index 86e814879d8168a59e24e3909e37b3e0decb742a..0c7fd77eea2615e1cf54fbe8bb823785249cca9f 100644 --- a/sflphone-client-gnome/src/contacts/addressbook/eds.c +++ b/sflphone-client-gnome/src/contacts/addressbook/eds.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * * File originally copied from evolution module of deskbar-applet 2.24.1 * Authors : @@ -70,6 +71,8 @@ static gchar *current_uri = NULL; static gchar *current_uid = NULL; static gchar *current_name = "Default"; +static EBookQueryTest current_test = E_BOOK_QUERY_BEGINS_WITH; + /** * Freeing a hit instance */ @@ -146,7 +149,7 @@ books_get_book_data_by_uid (gchar *uid) * nick name. */ static EBookQuery* -create_query (const char* s) +create_query (const char* s, EBookQueryTest test) { EBookQuery *equery; @@ -156,10 +159,10 @@ create_query (const char* s) int cpt = 0; // We could also use E_BOOK_QUERY_IS or E_BOOK_QUERY_BEGINS_WITH instead of E_BOOK_QUERY_CONTAINS - queries[cpt++] = e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_BEGINS_WITH, s); - queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_HOME, E_BOOK_QUERY_BEGINS_WITH, s); - queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_BUSINESS, E_BOOK_QUERY_BEGINS_WITH, s); - queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_MOBILE, E_BOOK_QUERY_BEGINS_WITH, s); + queries[cpt++] = e_book_query_field_test (E_CONTACT_FULL_NAME, test, s); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_HOME, test, s); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_BUSINESS, test, s); + queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_MOBILE, test, s); equery = e_book_query_or (cpt, queries, TRUE); @@ -585,7 +588,7 @@ search_async_by_contacts (const char *query, int max_results, SearchAsyncHandler had->user_data = user_data; had->hits = NULL; had->max_results_remaining = max_results; - had->equery = create_query (query); + had->equery = create_query (query, current_test); if (!current_uri) ERROR ("Addressbook: Error: Current addressbook uri not specified uri"); @@ -659,3 +662,16 @@ get_current_addressbook (void) { return current_name; } + + +void +set_current_addressbook_test (EBookQueryTest test) +{ + current_test = test; +} + +EBookQueryTest +get_current_addressbook_test (void) +{ + return current_test; +} diff --git a/sflphone-client-gnome/src/contacts/addressbook/eds.h b/sflphone-client-gnome/src/contacts/addressbook/eds.h index 2f4e47be8c87d669a96a9988c10b1ebc4cc9b647..2140184b8cb78ac2fc6ca0a52b29acfff298b675 100644 --- a/sflphone-client-gnome/src/contacts/addressbook/eds.h +++ b/sflphone-client-gnome/src/contacts/addressbook/eds.h @@ -158,6 +158,13 @@ set_current_addressbook (const gchar *name); const gchar * get_current_addressbook (void); +void +set_current_addressbook_test (EBookQueryTest test); + +EBookQueryTest +get_current_addressbook_test (void); + + G_END_DECLS #endif /* __EDS_H__ */ diff --git a/sflphone-client-gnome/src/contacts/searchbar.c b/sflphone-client-gnome/src/contacts/searchbar.c index 1188148d9d963124ed9c1d75e1219a3c7326e801..3d9d83441e5f6d937562ba6d51677a1dae6699f4 100644 --- a/sflphone-client-gnome/src/contacts/searchbar.c +++ b/sflphone-client-gnome/src/contacts/searchbar.c @@ -80,21 +80,26 @@ static void cbox_changed_cb (GtkWidget *widget, gpointer user_data) addressbook_search (GTK_ENTRY (addressbookentry)); } -static void select_addressbook (GtkWidget *item, GtkEntry *entry) +static void select_search_type (GtkWidget *item, GtkEntry *entry) { - DEBUG ("Searchbar: Selected item label %s", gtk_menu_item_get_label (item)); + DEBUG ("Searchbar: %s", gtk_menu_item_get_label (item)); - set_current_addressbook (gtk_menu_item_get_label (item)); - gchar *name = get_current_addressbook(); - gchar *searching = g_strjoin ("", "Click to select addressbook\n Searching in ", name, NULL); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (addressbookentry), GTK_ENTRY_ICON_PRIMARY, - searching); + gtk_menu_item_get_label (item)); + + + if (strcmp ("Search is", gtk_menu_item_get_label (item)) == 0) + set_current_addressbook_test (E_BOOK_QUERY_IS); + else if (strcmp ("Search begins with", gtk_menu_item_get_label (item)) == 0) + set_current_addressbook_test (E_BOOK_QUERY_BEGINS_WITH); + else if (strcmp ("Search contains", gtk_menu_item_get_label (item)) == 0) + set_current_addressbook_test (E_BOOK_QUERY_CONTAINS); addressbook_search (GTK_ENTRY (addressbookentry)); - g_free (searching); + } static void search_all (GtkWidget *item UNUSED, GtkEntry *entry) @@ -154,9 +159,9 @@ static void icon_press_cb (GtkEntry *entry, gint position, GdkEventButton *event gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); else if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree == contacts) { - //GtkWidget *addrbook_menu = addressbook_menu_new(); - //gtk_menu_popup (GTK_MENU (addrbook_menu), NULL, NULL, NULL, NULL, - // event->button, event->time); + GtkWidget *addrbook_menu = addressbook_menu_new(); + gtk_menu_popup (GTK_MENU (addrbook_menu), NULL, NULL, NULL, NULL, + event->button, event->time); } else gtk_entry_set_text (entry, ""); } @@ -176,22 +181,22 @@ GtkWidget *addressbook_menu_new (void) GtkWidget *menu, *item; - GSList *book_list_iterator; - book_data_t *book_data; - GSList *books_data = addressbook_get_books_data(); - // Create the menu menu = gtk_menu_new (); gtk_menu_attach_to_widget (GTK_MENU (menu), contacts->searchbar, NULL); // Populate menu - for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator - = book_list_iterator->next) { - book_data = (book_data_t *) book_list_iterator->data; - item = gtk_menu_item_new_with_label (book_data->name); - g_signal_connect (item, "activate", G_CALLBACK (select_addressbook), searchbox); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - } + item = gtk_menu_item_new_with_label ("Search is"); + g_signal_connect (item, "activate", G_CALLBACK (select_search_type), searchbox); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + item = gtk_menu_item_new_with_label ("Search begins with"); + g_signal_connect (item, "activate", G_CALLBACK (select_search_type), searchbox); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + item = gtk_menu_item_new_with_label ("Search contains"); + g_signal_connect (item, "activate", G_CALLBACK (select_search_type), searchbox); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show_all (menu); @@ -336,7 +341,7 @@ GtkWidget* contacts_searchbar_new () GdkPixbuf *pixbuf; gchar *current_addressbook = get_current_addressbook(); - gchar *tooltip_text = g_strjoin ("", "Click to select addressbook\n Searching in ", current_addressbook, NULL); + gchar *tooltip_text = g_strdup ("Search is"); addressbookentry = gtk_entry_new(); gtk_entry_set_icon_from_stock (GTK_ENTRY (addressbookentry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);