diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-07-13 00:55:10 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-07-13 04:00:54 +0800 |
commit | 0d6061a4ebf34cbe4f640e755372c38bd698ed25 (patch) | |
tree | 9ae7c1391e0103d959896b7db9b296bcb61e5f6d /modules/addressbook | |
parent | c4d1d29eaaae6c2668599de0c989f5fe2b189c1e (diff) | |
download | gsoc2013-evolution-0d6061a4ebf34cbe4f640e755372c38bd698ed25.tar.gz 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')
-rw-r--r-- | modules/addressbook/e-book-shell-backend.c | 70 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-actions.c | 18 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-private.c | 15 |
3 files changed, 69 insertions, 34 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); diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c index 773eb3fa7a..9886e59dcd 100644 --- a/modules/addressbook/e-book-shell-view-actions.c +++ b/modules/addressbook/e-book-shell-view-actions.c @@ -332,6 +332,9 @@ static void action_contact_new_cb (GtkAction *action, EBookShellView *book_shell_view) { + EShell *shell; + EShellView *shell_view; + EShellWindow *shell_window; EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; @@ -339,6 +342,10 @@ action_contact_new_cb (GtkAction *action, GtkWidget *editor; EBook *book; + shell_view = E_SHELL_VIEW (book_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + shell = e_shell_window_get_shell (shell_window); + book_shell_content = book_shell_view->priv->book_shell_content; view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); @@ -348,7 +355,7 @@ action_contact_new_cb (GtkAction *action, g_return_if_fail (book != NULL); contact = e_contact_new (); - editor = e_contact_editor_new (book, contact, TRUE, TRUE); + editor = e_contact_editor_new (shell, book, contact, TRUE, TRUE); eab_editor_show (EAB_EDITOR (editor)); g_object_unref (contact); } @@ -357,6 +364,9 @@ static void action_contact_new_list_cb (GtkAction *action, EBookShellView *book_shell_view) { + EShell *shell; + EShellView *shell_view; + EShellWindow *shell_window; EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; @@ -364,6 +374,10 @@ action_contact_new_list_cb (GtkAction *action, GtkWidget *editor; EBook *book; + shell_view = E_SHELL_VIEW (book_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + shell = e_shell_window_get_shell (shell_window); + book_shell_content = book_shell_view->priv->book_shell_content; view = e_book_shell_content_get_current_view (book_shell_content); g_return_if_fail (view != NULL); @@ -373,7 +387,7 @@ action_contact_new_list_cb (GtkAction *action, g_return_if_fail (book != NULL); contact = e_contact_new (); - 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)); g_object_unref (contact); } diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c index ec3562e87a..95e4980c57 100644 --- a/modules/addressbook/e-book-shell-view-private.c +++ b/modules/addressbook/e-book-shell-view-private.c @@ -32,23 +32,30 @@ open_contact (EBookShellView *book_shell_view, gboolean is_new_contact, EAddressbookView *view) { + EShell *shell; + EShellView *shell_view; + EShellWindow *shell_window; EAddressbookModel *model; - GtkWidget *editor; + EABEditor *editor; EBook *book; gboolean editable; + shell_view = E_SHELL_VIEW (book_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + shell = e_shell_window_get_shell (shell_window); + model = e_addressbook_view_get_model (view); book = e_addressbook_model_get_book (model); editable = e_addressbook_model_get_editable (model); if (e_contact_get (contact, E_CONTACT_IS_LIST)) editor = e_contact_list_editor_new ( - book, contact, is_new_contact, editable); + shell, book, contact, is_new_contact, editable); else editor = e_contact_editor_new ( - book, contact, is_new_contact, editable); + shell, book, contact, is_new_contact, editable); - eab_editor_show (EAB_EDITOR (editor)); + eab_editor_show (editor); } static void |