aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2013-07-01 21:53:06 +0800
committerMilan Crha <mcrha@redhat.com>2013-07-01 21:53:06 +0800
commitbe217ae4c574b82a8ecbc7dbb506aca36f6e56fa (patch)
tree96d4039d8990188fc25417898de3400669d8a4f1
parent870bd532b542e49fa80f799c919d80b1728b6967 (diff)
downloadgsoc2013-evolution-be217ae4c574b82a8ecbc7dbb506aca36f6e56fa.tar
gsoc2013-evolution-be217ae4c574b82a8ecbc7dbb506aca36f6e56fa.tar.gz
gsoc2013-evolution-be217ae4c574b82a8ecbc7dbb506aca36f6e56fa.tar.bz2
gsoc2013-evolution-be217ae4c574b82a8ecbc7dbb506aca36f6e56fa.tar.lz
gsoc2013-evolution-be217ae4c574b82a8ecbc7dbb506aca36f6e56fa.tar.xz
gsoc2013-evolution-be217ae4c574b82a8ecbc7dbb506aca36f6e56fa.tar.zst
gsoc2013-evolution-be217ae4c574b82a8ecbc7dbb506aca36f6e56fa.zip
Contacts view: Add 'Refresh' into books context menu
Done as part of bug #700894
-rw-r--r--modules/addressbook/e-book-shell-sidebar.c13
-rw-r--r--modules/addressbook/e-book-shell-sidebar.h3
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c67
-rw-r--r--modules/addressbook/e-book-shell-view-actions.h2
-rw-r--r--modules/addressbook/e-book-shell-view.c7
-rw-r--r--ui/evolution-contacts.ui1
6 files changed, 92 insertions, 1 deletions
diff --git a/modules/addressbook/e-book-shell-sidebar.c b/modules/addressbook/e-book-shell-sidebar.c
index 9c655e7504..b29bd9a08f 100644
--- a/modules/addressbook/e-book-shell-sidebar.c
+++ b/modules/addressbook/e-book-shell-sidebar.c
@@ -194,6 +194,7 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
gboolean is_remote_deletable = FALSE;
gboolean in_collection = FALSE;
gboolean has_primary_source = FALSE;
+ gboolean refresh_supported = FALSE;
guint32 state = 0;
book_shell_sidebar = E_BOOK_SHELL_SIDEBAR (shell_sidebar);
@@ -202,6 +203,7 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
registry = e_source_selector_get_registry (selector);
if (source != NULL) {
+ EClient *client;
ESource *collection;
has_primary_source = TRUE;
@@ -217,6 +219,15 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
g_object_unref (collection);
}
+ client = e_client_selector_ref_cached_client (
+ E_CLIENT_SELECTOR (selector), source);
+
+ if (client != NULL) {
+ refresh_supported =
+ e_client_check_refresh_supported (client);
+ g_object_unref (client);
+ }
+
g_object_unref (source);
}
@@ -232,6 +243,8 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE;
if (in_collection)
state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION;
+ if (refresh_supported)
+ state |= E_BOOK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH;
return state;
}
diff --git a/modules/addressbook/e-book-shell-sidebar.h b/modules/addressbook/e-book-shell-sidebar.h
index 703d67cb0c..d79fb27f26 100644
--- a/modules/addressbook/e-book-shell-sidebar.h
+++ b/modules/addressbook/e-book-shell-sidebar.h
@@ -56,7 +56,8 @@ enum {
E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE = 1 << 2,
E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_CREATABLE = 1 << 3,
E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE = 1 << 4,
- E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION = 1 << 5
+ E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION = 1 << 5,
+ E_BOOK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH = 1 << 6
};
struct _EBookShellSidebar {
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 78ea77d1b2..9d72ef377c 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -200,6 +200,62 @@ action_address_book_properties_cb (GtkAction *action,
gtk_widget_show (dialog);
}
+static void
+address_book_refresh_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ EClient *client;
+ GError *error = NULL;
+
+ g_return_if_fail (E_IS_CLIENT (source_object));
+
+ client = E_CLIENT (source_object);
+
+ if (!e_client_refresh_finish (client, result, &error)) {
+ ESource *source = e_client_get_source (client);
+
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
+ !g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED))
+ g_warning (
+ "%s: Failed to refresh '%s', %s",
+ G_STRFUNC, e_source_get_display_name (source),
+ error ? error->message : "Unknown error");
+
+ g_clear_error (&error);
+ }
+}
+
+static void
+action_address_book_refresh_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EBookShellSidebar *book_shell_sidebar;
+ ESourceSelector *selector;
+ EClient *client = NULL;
+ ESource *source;
+
+ book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
+ selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
+
+ source = e_source_selector_ref_primary_selection (selector);
+
+ if (source != NULL) {
+ client = e_client_selector_ref_cached_client (
+ E_CLIENT_SELECTOR (selector), source);
+ g_object_unref (source);
+ }
+
+ if (client == NULL)
+ return;
+
+ g_return_if_fail (e_client_check_refresh_supported (client));
+
+ e_client_refresh (client, NULL, address_book_refresh_done_cb, book_shell_view);
+
+ g_object_unref (client);
+}
+
#ifdef WITH_CONTACT_MAPS
static void
contact_editor_contact_modified_cb (EABEditor *editor,
@@ -873,6 +929,13 @@ static GtkActionEntry contact_entries[] = {
N_("Show properties of the selected address book"),
G_CALLBACK (action_address_book_properties_cb) },
+ { "address-book-refresh",
+ GTK_STOCK_REFRESH,
+ N_("Re_fresh"),
+ NULL,
+ N_("Refresh the selected address book"),
+ G_CALLBACK (action_address_book_refresh_cb) },
+
{ "address-book-map",
NULL,
N_("Address Book _Map"),
@@ -984,6 +1047,10 @@ static EPopupActionEntry contact_popup_entries[] = {
N_("_Properties"),
"address-book-properties" },
+ { "address-book-popup-refresh",
+ NULL,
+ "address-book-refresh" },
+
{ "address-book-popup-map",
N_("Address Book Map"),
"address-book-map" },
diff --git a/modules/addressbook/e-book-shell-view-actions.h b/modules/addressbook/e-book-shell-view-actions.h
index 87eeaa8b17..32bf261a7c 100644
--- a/modules/addressbook/e-book-shell-view-actions.h
+++ b/modules/addressbook/e-book-shell-view-actions.h
@@ -37,6 +37,8 @@
E_SHELL_WINDOW_ACTION ((window), "address-book-print-preview")
#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_PROPERTIES(window) \
E_SHELL_WINDOW_ACTION ((window), "address-book-properties")
+#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_REFRESH(window) \
+ E_SHELL_WINDOW_ACTION ((window), "address-book-refresh")
#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_RENAME(window) \
E_SHELL_WINDOW_ACTION ((window), "address-book-rename")
#define E_SHELL_WINDOW_ACTION_ADDRESS_BOOK_SAVE_AS(window) \
diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c
index f2c06bbb8d..1f76cad705 100644
--- a/modules/addressbook/e-book-shell-view.c
+++ b/modules/addressbook/e-book-shell-view.c
@@ -205,6 +205,7 @@ book_shell_view_update_actions (EShellView *shell_view)
gboolean primary_source_is_removable;
gboolean primary_source_is_remote_deletable;
gboolean primary_source_in_collection;
+ gboolean refresh_supported;
gboolean single_contact_selected;
gboolean selection_is_contact_list;
gboolean selection_has_email;
@@ -245,6 +246,8 @@ book_shell_view_update_actions (EShellView *shell_view)
(state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE);
primary_source_in_collection =
(state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION);
+ refresh_supported =
+ (state & E_BOOK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH);
any_contacts_selected =
(single_contact_selected || multiple_contacts_selected);
@@ -271,6 +274,10 @@ book_shell_view_update_actions (EShellView *shell_view)
sensitive = primary_source_is_writable;
gtk_action_set_sensitive (action, sensitive);
+ action = ACTION (ADDRESS_BOOK_REFRESH);
+ sensitive = refresh_supported;
+ gtk_action_set_sensitive (action, sensitive);
+
action = ACTION (ADDRESS_BOOK_RENAME);
sensitive =
primary_source_is_writable &&
diff --git a/ui/evolution-contacts.ui b/ui/evolution-contacts.ui
index 45f1a4d201..36d640fc7e 100644
--- a/ui/evolution-contacts.ui
+++ b/ui/evolution-contacts.ui
@@ -59,6 +59,7 @@
<popup name='address-book-popup'>
<menuitem action='address-book-new'/>
<menuitem action='address-book-popup-rename'/>
+ <menuitem action='address-book-popup-refresh'/>
<menuitem action='address-book-popup-save-as'/>
<separator/>
<menuitem action='address-book-popup-delete'/>