[evolution] Bug #705685 - Contact(-list)-editor - reject save when book is still opening



commit 10032e2479eb6fc9f5684346364ec52c246a5969
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 30 15:52:45 2013 +0200

    Bug #705685 - Contact(-list)-editor - reject save when book is still opening

 addressbook/addressbook.error.xml                  |   10 +++++++-
 addressbook/gui/contact-editor/e-contact-editor.c  |   21 ++++++++++++++++++-
 .../contact-list-editor/e-contact-list-editor.c    |   20 ++++++++++++++++++-
 addressbook/gui/widgets/eab-gui-util.c             |    2 +
 4 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/addressbook/addressbook.error.xml b/addressbook/addressbook.error.xml
index 23dd3a2..18e00d8 100644
--- a/addressbook/addressbook.error.xml
+++ b/addressbook/addressbook.error.xml
@@ -56,8 +56,8 @@
   </error>
 
   <error id="load-error" type="error">
-    <_primary>Unable to open address book</_primary>
-    <secondary>{0}</secondary>
+    <_primary>Unable to open address book '{0}'</_primary>
+    <secondary>{1}</secondary>
   </error>
 
   <error id="search-error" type="error">
@@ -125,4 +125,10 @@
     <_secondary>'{0}' is a read-only address book and cannot be modified. Please select a different address 
book from the side bar in the Contacts view.</_secondary>
   </error>
 
+  <error id="error-still-opening" type="error" default="GTK_RESPONSE_YES">
+    <_primary>Cannot save a contact, address book is still opening</_primary>
+    <!-- For Translators: {0} is the name of the address book source -->
+    <_secondary>Cannot save a contact to the address book '{0}', because it is still opening. Either wait 
till it's opened, or select a different address book.</_secondary>
+  </error>
+
 </error-list>
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c 
b/addressbook/gui/contact-editor/e-contact-editor.c
index bf6cf9e..1a771fe 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -3153,7 +3153,7 @@ contact_editor_get_client_cb (GObject *source_object,
 
                e_source_combo_box_set_active (
                        E_SOURCE_COMBO_BOX (combo_box),
-                       closure->source);
+                       e_client_get_source (E_CLIENT (closure->editor->target_client)));
 
                g_error_free (error);
                goto exit;
@@ -3711,11 +3711,28 @@ save_contact (EContactEditor *ce,
        const gchar *name_entry_string;
        const gchar *file_as_entry_string;
        const gchar *company_name_string;
-       GtkWidget *entry_fullname, *entry_file_as, *company_name;
+       GtkWidget *entry_fullname, *entry_file_as, *company_name, *client_combo_box;
+       ESource *active_source;
 
        if (!ce->target_client)
                return;
 
+       client_combo_box = e_builder_get_widget (ce->builder, "client-combo-box");
+       active_source = e_source_combo_box_ref_active (E_SOURCE_COMBO_BOX (client_combo_box));
+       g_return_if_fail (active_source != NULL);
+
+       if (!e_source_equal (e_client_get_source (E_CLIENT (ce->target_client)), active_source)) {
+               e_alert_run_dialog_for_args (
+                               GTK_WINDOW (ce->app),
+                               "addressbook:error-still-opening",
+                               e_source_get_display_name (active_source),
+                               NULL);
+               g_object_unref (active_source);
+               return;
+       }
+
+       g_object_unref (active_source);
+
        if (ce->target_editable && e_client_is_readonly (E_CLIENT (ce->source_client))) {
                if (e_alert_run_dialog_for_args (
                                GTK_WINDOW (ce->app),
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c 
b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 4f5e397..4bcaa9b 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -352,7 +352,7 @@ contact_list_editor_get_client_cb (GObject *source_object,
 
                e_source_combo_box_set_active (
                        E_SOURCE_COMBO_BOX (combo_box),
-                       closure->source);
+                       e_client_get_source (E_CLIENT (editor->priv->book_client)));
 
                g_error_free (error);
                goto exit;
@@ -1524,6 +1524,8 @@ contact_list_editor_save_contact (EABEditor *eab_editor,
        EditorCloseStruct *ecs;
        EContact *contact;
        EShell *shell;
+       GtkWidget *client_combo_box;
+       ESource *active_source;
 
        shell = eab_editor_get_shell (eab_editor);
        registry = e_shell_get_registry (shell);
@@ -1533,6 +1535,22 @@ contact_list_editor_save_contact (EABEditor *eab_editor,
        if (priv->book_client == NULL)
                return;
 
+       client_combo_box = WIDGET (CLIENT_COMBO_BOX);
+       active_source = e_source_combo_box_ref_active (E_SOURCE_COMBO_BOX (client_combo_box));
+       g_return_if_fail (active_source != NULL);
+
+       if (!e_source_equal (e_client_get_source (E_CLIENT (priv->book_client)), active_source)) {
+               e_alert_run_dialog_for_args (
+                               GTK_WINDOW (WIDGET (DIALOG)),
+                               "addressbook:error-still-opening",
+                               e_source_get_display_name (active_source),
+                               NULL);
+               g_object_unref (active_source);
+               return;
+       }
+
+       g_object_unref (active_source);
+
        ecs = g_new (EditorCloseStruct, 1);
        ecs->editor = g_object_ref (editor);
        ecs->should_close = should_close;
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 70e5682..f64bd2d 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -179,6 +179,7 @@ eab_load_error_dialog (GtkWidget *parent,
        if (alert_sink) {
                e_alert_submit (
                        alert_sink, "addressbook:load-error",
+                       e_source_get_display_name (source),
                        label_string, NULL);
        } else {
                GtkWidget *dialog;
@@ -186,6 +187,7 @@ eab_load_error_dialog (GtkWidget *parent,
                dialog  = e_alert_dialog_new_for_args (
                        (GtkWindow *) parent,
                        "addressbook:load-error",
+                       e_source_get_display_name (source),
                        label_string, NULL);
                g_signal_connect (
                        dialog, "response",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]