aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-11-14 05:57:53 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-11-14 05:57:53 +0800
commitd428935b383f96cc8c95fd345b8cc5c68c6fde8d (patch)
tree327397d50ce885d81d3bf730d0f06f041425e485 /modules
parent3d4b38c997b20ddc706aa72b9c858b2548438e31 (diff)
downloadgsoc2013-evolution-d428935b383f96cc8c95fd345b8cc5c68c6fde8d.tar
gsoc2013-evolution-d428935b383f96cc8c95fd345b8cc5c68c6fde8d.tar.gz
gsoc2013-evolution-d428935b383f96cc8c95fd345b8cc5c68c6fde8d.tar.bz2
gsoc2013-evolution-d428935b383f96cc8c95fd345b8cc5c68c6fde8d.tar.lz
gsoc2013-evolution-d428935b383f96cc8c95fd345b8cc5c68c6fde8d.tar.xz
gsoc2013-evolution-d428935b383f96cc8c95fd345b8cc5c68c6fde8d.tar.zst
gsoc2013-evolution-d428935b383f96cc8c95fd345b8cc5c68c6fde8d.zip
BugĀ 601774 - "Send Message to Contact" is always disabled
Diffstat (limited to 'modules')
-rw-r--r--modules/addressbook/e-book-shell-content.c56
-rw-r--r--modules/addressbook/e-book-shell-content.h10
2 files changed, 59 insertions, 7 deletions
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index 1c121adc61..55b11fca5d 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -259,6 +259,23 @@ book_shell_content_constructed (GObject *object)
gconf_bridge_bind_property_delayed (bridge, key, object, "vposition");
}
+static void
+book_shell_content_check_state_foreach (gint row,
+ gpointer user_data)
+{
+ EContact *contact;
+
+ struct {
+ EAddressbookModel *model;
+ GList *list;
+ } *foreach_data = user_data;
+
+ contact = e_addressbook_model_get_contact (foreach_data->model, row);
+ g_return_if_fail (E_IS_CONTACT (contact));
+
+ foreach_data->list = g_list_prepend (foreach_data->list, contact);
+}
+
static guint32
book_shell_content_check_state (EShellContent *shell_content)
{
@@ -267,10 +284,17 @@ book_shell_content_check_state (EShellContent *shell_content)
EAddressbookModel *model;
EAddressbookView *view;
GtkClipboard *clipboard;
+ gboolean has_email = TRUE;
+ gboolean is_contact_list = TRUE;
guint32 state = 0;
gint n_contacts;
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);
@@ -281,13 +305,43 @@ book_shell_content_check_state (EShellContent *shell_content)
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);
+ }
+
clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- /* FIXME Finish the rest of the flags. */
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))
diff --git a/modules/addressbook/e-book-shell-content.h b/modules/addressbook/e-book-shell-content.h
index 138b60d175..5acfae46c8 100644
--- a/modules/addressbook/e-book-shell-content.h
+++ b/modules/addressbook/e-book-shell-content.h
@@ -60,12 +60,10 @@ enum {
E_BOOK_SHELL_CONTENT_SELECTION_MULTIPLE = 1 << 1,
E_BOOK_SHELL_CONTENT_SELECTION_HAS_EMAIL = 1 << 2,
E_BOOK_SHELL_CONTENT_SELECTION_IS_CONTACT_LIST = 1 << 3,
- E_BOOK_SHELL_CONTENT_SELECTION_HAS_HTTP_URI = 1 << 4,
- E_BOOK_SHELL_CONTENT_SELECTION_HAS_MAILTO_URI = 1 << 5,
- E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY = 1 << 6,
- E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE = 1 << 7,
- E_BOOK_SHELL_CONTENT_SOURCE_IS_EMPTY = 1 << 8,
- E_BOOK_SHELL_CONTENT_CLIPBOARD_HAS_DIRECTORY = 1 << 9
+ E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY = 1 << 4,
+ E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE = 1 << 5,
+ E_BOOK_SHELL_CONTENT_SOURCE_IS_EMPTY = 1 << 6,
+ E_BOOK_SHELL_CONTENT_CLIPBOARD_HAS_DIRECTORY = 1 << 7
};
struct _EBookShellContent {