static void set_empty_message (EMinicardView *view) { gchar *empty_message; gboolean editable = FALSE, perform_initial_query = FALSE, searching = FALSE; if (view->adapter) { EAddressbookModel *model = NULL; EBookClient *book_client = NULL; g_object_get ( view->adapter, "editable", &editable, "model", &model, "client", &book_client, NULL); if (book_client && !e_client_check_capability (E_CLIENT (book_client), "do-initial-query")) perform_initial_query = TRUE; searching = model && e_addressbook_model_can_stop (model); if (book_client) g_object_unref (book_client); if (model) g_object_unref (model); } if (searching) { empty_message = _("\n\nSearching for the Contacts..."); } else if (editable) { if (perform_initial_query) empty_message = _("\n\nSearch for the Contact\n\n" "or double-click here to create a new Contact."); else empty_message = _("\n\nThere are no items to show in this view.\n\n" "Double-click here to create a new Contact."); } else { if (perform_initial_query) empty_message = _("\n\nSearch for the Contact."); else empty_message = _("\n\nThere are no items to show in this view."); } g_object_set ( view, "empty_message", empty_message, NULL); }
static guint32 book_shell_content_check_state (EShellContent *shell_content) { EBookShellContent *book_shell_content; ESelectionModel *selection_model; EAddressbookModel *model; EAddressbookView *view; gboolean has_email = TRUE; gboolean is_contact_list = TRUE; guint32 state = 0; gint n_selected; struct { EAddressbookModel *model; GList *list; } foreach_data; book_shell_content = E_BOOK_SHELL_CONTENT (shell_content); view = e_book_shell_content_get_current_view (book_shell_content); model = e_addressbook_view_get_model (view); selection_model = e_addressbook_view_get_selection_model (view); n_selected = (selection_model != NULL) ? e_selection_model_selected_count (selection_model) : 0; foreach_data.model = model; foreach_data.list = NULL; if (selection_model != NULL) e_selection_model_foreach ( selection_model, (EForeachFunc) book_shell_content_check_state_foreach, &foreach_data); while (foreach_data.list != NULL) { EContact *contact = E_CONTACT (foreach_data.list->data); GList *email_list; email_list = e_contact_get (contact, E_CONTACT_EMAIL); has_email &= (email_list != NULL); g_list_foreach (email_list, (GFunc) g_free, NULL); g_list_free (email_list); is_contact_list &= (e_contact_get (contact, E_CONTACT_IS_LIST) != NULL); g_object_unref (contact); foreach_data.list = g_list_delete_link ( foreach_data.list, foreach_data.list); } if (n_selected == 1) state |= E_BOOK_SHELL_CONTENT_SELECTION_SINGLE; if (n_selected > 1) state |= E_BOOK_SHELL_CONTENT_SELECTION_MULTIPLE; if (n_selected > 0 && has_email) state |= E_BOOK_SHELL_CONTENT_SELECTION_HAS_EMAIL; if (n_selected == 1 && is_contact_list) state |= E_BOOK_SHELL_CONTENT_SELECTION_IS_CONTACT_LIST; if (e_addressbook_model_can_stop (model)) state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY; if (e_addressbook_model_get_editable (model)) state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE; return state; }