Commit f18fc5ee authored by Tristan Matthews's avatar Tristan Matthews

* #19035: addressbook: return all contacts with phones on empty search

parent ab3287fa
......@@ -100,6 +100,9 @@ update_current_addressbook(GtkWidget *widget)
addrbook->set_current_book(string);
g_free(string);
}
AddressBook_Config *addressbook_config = addressbook_config_load_parameters();
addrbook->search(addrbook->search_cb, GTK_ENTRY(addressbookentry), addressbook_config);
}
static void
......@@ -108,9 +111,6 @@ cbox_changed_cb(GtkWidget *widget, gpointer user_data UNUSED)
if (!addrbook)
return;
update_current_addressbook(widget);
AddressBook_Config *addressbook_config = addressbook_config_load_parameters();
addrbook->search(addrbook->search_cb, GTK_ENTRY(addressbookentry), addressbook_config);
}
void
......
......@@ -107,6 +107,5 @@ void addressbook_set_search_type(AddrbookSearchType searchType) {
}
void addressbook_set_current_book(const gchar *current) {
g_print("Setting addressbook to %s\n", current);
set_current_addressbook(current);
}
......@@ -153,18 +153,39 @@ create_query(const char* s, EBookQueryTest test, AddressBook_Config *conf)
queries[cpt++] = e_book_query_field_test(E_CONTACT_FULL_NAME, test, s);
if (conf->search_phone_home)
if (!conf || conf->search_phone_home)
queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_HOME, test, s);
if (conf->search_phone_business)
if (!conf || conf->search_phone_business)
queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_BUSINESS, test, s);
if (conf->search_phone_mobile)
if (!conf || conf->search_phone_mobile)
queries[cpt++] = e_book_query_field_test(E_CONTACT_PHONE_MOBILE, test, s);
return e_book_query_or(cpt, queries, TRUE);
}
/**
* Create a query which looks any contact with a phone number
*/
static EBookQuery*
create_query_all_phones(AddressBook_Config *conf)
{
EBookQuery *queries[3];
int cpt = 0;
if (!conf || conf->search_phone_home)
queries[cpt++] = e_book_query_field_exists(E_CONTACT_PHONE_HOME);
if (!conf || conf->search_phone_business)
queries[cpt++] = e_book_query_field_exists(E_CONTACT_PHONE_BUSINESS);
if (!conf || conf->search_phone_mobile)
queries[cpt++] = e_book_query_field_exists(E_CONTACT_PHONE_MOBILE);
return e_book_query_or(cpt, queries, TRUE);
}
/**
* Retrieve the contact's picture
*/
......@@ -463,9 +484,9 @@ search_async_by_contacts(const char *query, int max_results, SearchAsyncHandler
had->hits = NULL;
had->max_results_remaining = max_results;
if (!g_strcmp0(query, ""))
had->equery = e_book_query_any_field_contains("");
had->equery = create_query_all_phones(user_data);
else
had->equery = create_query(query, current_test, (AddressBook_Config *) (user_data));
had->equery = create_query(query, current_test, user_data);
#if EDS_CHECK_VERSION(3,5,3)
......
......@@ -20,6 +20,9 @@ static GtkListStore *list_store;
static void
add_contact(const gchar *name, const char *phone, GdkPixbuf *photo)
{
if (g_strcmp0(phone, "") == 0)
return;
g_print("name: %s, phone: %s, photo: %p\n", name, phone, photo);
GtkTreeIter iter;
// Add a new row to the model
......@@ -55,6 +58,14 @@ handler_async_search(GList *hits, G_GNUC_UNUSED gpointer data)
g_list_free(hits);
}
static void
text_changed_cb(GtkEntry *entry)
{
g_print("Text changed to %s\n", gtk_entry_get_text(entry));
gtk_list_store_clear(list_store);
addressbook_search(handler_async_search, entry, NULL);
}
int
main(int argc, char *argv[])
{
......@@ -94,6 +105,7 @@ main(int argc, char *argv[])
gtk_container_add(GTK_CONTAINER(window), vbox);
addressbook_search(handler_async_search, GTK_ENTRY(entry), NULL);
g_signal_connect(entry, "notify::text", G_CALLBACK(text_changed_cb), NULL);
gtk_widget_show_all(window);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment