aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook/e-book-shell-backend.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-07-13 00:55:10 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-07-13 04:00:54 +0800
commit0d6061a4ebf34cbe4f640e755372c38bd698ed25 (patch)
tree9ae7c1391e0103d959896b7db9b296bcb61e5f6d /modules/addressbook/e-book-shell-backend.c
parentc4d1d29eaaae6c2668599de0c989f5fe2b189c1e (diff)
downloadgsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.gz
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.bz2
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.lz
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.xz
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.zst
gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.zip
Add a "quit-requested" signal to the shutdown protocol.
The contact and contact-list editors now demonstrate this part of the shutdown protocol. They listen for the "quit-requested" signal from the shell and prompt to save changes, discard changes or cancel. If the user cancels, the editor calls e_shell_cancel_quit() to do just that.
Diffstat (limited to 'modules/addressbook/e-book-shell-backend.c')
-rw-r--r--modules/addressbook/e-book-shell-backend.c70
1 files changed, 42 insertions, 28 deletions
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index 53737b538e..9fe000aea8 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -226,30 +226,50 @@ book_shell_backend_init_importers (void)
}
static void
-book_shell_backend_book_loaded_cb (EBook *book,
+book_shell_backend_new_contact_cb (EBook *book,
EBookStatus status,
gpointer user_data)
{
+ EShell *shell;
EContact *contact;
- GtkAction *action;
- GtkWidget *editor;
- const gchar *action_name;
+ EABEditor *editor;
/* XXX Handle errors better. */
if (status != E_BOOK_ERROR_OK)
return;
contact = e_contact_new ();
- action = GTK_ACTION (user_data);
- action_name = gtk_action_get_name (action);
+ shell = E_SHELL (user_data);
- if (strcmp (action_name, "contact-new") == 0)
- editor = e_contact_editor_new (book, contact, TRUE, TRUE);
+ editor = e_contact_editor_new (
+ shell, book, contact, TRUE, TRUE);
+
+ eab_editor_show (editor);
+
+ g_object_unref (contact);
+ g_object_unref (book);
+}
+
+static void
+book_shell_backend_new_contact_list_cb (EBook *book,
+ EBookStatus status,
+ gpointer user_data)
+{
+ EShell *shell;
+ EContact *contact;
+ EABEditor *editor;
+
+ /* XXX Handle errors better. */
+ if (status != E_BOOK_ERROR_OK)
+ return;
+
+ contact = e_contact_new ();
+ shell = E_SHELL (user_data);
- if (strcmp (action_name, "contact-new-list") == 0)
- editor = e_contact_list_editor_new (book, contact, TRUE, TRUE);
+ editor = e_contact_list_editor_new (
+ shell, book, contact, TRUE, TRUE);
- eab_editor_show (EAB_EDITOR (editor));
+ eab_editor_show (editor);
g_object_unref (contact);
g_object_unref (book);
@@ -263,6 +283,7 @@ action_contact_new_cb (GtkAction *action,
EBook *book = NULL;
GConfClient *client;
ESourceList *source_list;
+ const gchar *action_name;
const gchar *key;
gchar *uid;
@@ -275,6 +296,7 @@ action_contact_new_cb (GtkAction *action,
shell = e_shell_window_get_shell (shell_window);
client = e_shell_get_gconf_client (shell);
+ action_name = gtk_action_get_name (action);
key = "/apps/evolution/addressbook/display/primary_addressbook";
uid = gconf_client_get_string (client, key, NULL);
@@ -291,8 +313,15 @@ action_contact_new_cb (GtkAction *action,
if (book == NULL)
book = e_book_new_default_addressbook (NULL);
- e_book_async_open (
- book, FALSE, book_shell_backend_book_loaded_cb, action);
+ if (strcmp (action_name, "contact-new") == 0)
+ e_book_async_open (
+ book, FALSE,
+ book_shell_backend_new_contact_cb, shell);
+
+ if (strcmp (action_name, "contact-list-new") == 0)
+ e_book_async_open (
+ book, FALSE,
+ book_shell_backend_new_contact_list_cb, shell);
}
static void
@@ -396,16 +425,6 @@ book_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
}
static void
-book_shell_backend_prepare_for_shutdown_cb (EShellBackend *shell_backend,
- EActivity *activity)
-{
- /* FIXME Should specify whether Cancel is allowed. Currently,
- * clicking Cancel when prompted to save during shutdown
- * just discards changes. */
- eab_editor_request_close_all ();
-}
-
-static void
book_shell_backend_window_created_cb (EShellBackend *shell_backend,
GtkWindow *window)
{
@@ -486,11 +505,6 @@ book_shell_backend_constructed (GObject *object)
shell_backend);
g_signal_connect_swapped (
- shell, "prepare-for-shutdown",
- G_CALLBACK (book_shell_backend_prepare_for_shutdown_cb),
- shell_backend);
-
- g_signal_connect_swapped (
shell, "window-created",
G_CALLBACK (book_shell_backend_window_created_cb),
shell_backend);