aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook/e-book-shell-view-actions.c
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 /modules/addressbook/e-book-shell-view-actions.c
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
Diffstat (limited to 'modules/addressbook/e-book-shell-view-actions.c')
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c67
1 files changed, 67 insertions, 0 deletions
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" },