diff options
author | Milan Crha <mcrha@redhat.com> | 2008-01-10 23:52:46 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2008-01-10 23:52:46 +0800 |
commit | f12f5298015788a18abf19470b0460f5a3bad1f5 (patch) | |
tree | 3ce816d662d259f5d1e98baef81026d5f359bba6 /addressbook | |
parent | 3b1751690acdcfc8abc5ceb0c374724ccf50df36 (diff) | |
download | gsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.tar gsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.tar.gz gsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.tar.bz2 gsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.tar.lz gsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.tar.xz gsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.tar.zst gsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.zip |
** Fix for bug #448441
2008-01-10 Milan Crha <mcrha@redhat.com>
** Fix for bug #448441
* addressbook.error.xml: New message "error-read-only" added.
* gui/contact-editor/e-contact-quick-add.c: (struct _QuickAdd),
(merge_cb), (sanitize_widgets), (source_changed),
(build_quick_add_dialog):
Disable "OK" and "Edit Full" buttons if no source is selected.
Also set always book from combo, do not use the new created.
svn path=/trunk/; revision=34791
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 11 | ||||
-rw-r--r-- | addressbook/addressbook.error.xml | 6 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-quick-add.c | 61 |
3 files changed, 71 insertions, 7 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 3fe5f989ad..7179531ad1 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,14 @@ +2008-01-10 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #448441 + + * addressbook.error.xml: New message "error-read-only" added. + * gui/contact-editor/e-contact-quick-add.c: (struct _QuickAdd), + (merge_cb), (sanitize_widgets), (source_changed), + (build_quick_add_dialog): + Disable "OK" and "Edit Full" buttons if no source is selected. + Also set always book from combo, do not use the new created. + 2008-01-07 Milan Crha <mcrha@redhat.com> ** Fix for bug #339813 diff --git a/addressbook/addressbook.error.xml b/addressbook/addressbook.error.xml index fd357cf2b3..a9da7ac38d 100644 --- a/addressbook/addressbook.error.xml +++ b/addressbook/addressbook.error.xml @@ -118,4 +118,10 @@ <_secondary>Permission Denied.</_secondary> </error> + <error id="error-read-only" type="error" default="GTK_RESPONSE_YES"> + <_primary>Cannot add new contact</_primary> + <_secondary>The address book {0} is read only, thus you cannot add contacts there. Select other address book, please.</_secondary> + <button stock ="gtk-ok" response="GTK_RESPONSE_YES"/> + </error> + </error-list> diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c index 5a89dea03d..e2c06256bc 100644 --- a/addressbook/gui/contact-editor/e-contact-quick-add.c +++ b/addressbook/gui/contact-editor/e-contact-quick-add.c @@ -43,6 +43,7 @@ #include "e-contact-editor.h" #include "e-contact-quick-add.h" #include "eab-contact-merging.h" +#include "e-util/e-error.h" typedef struct _QuickAdd QuickAdd; struct _QuickAdd { @@ -54,6 +55,7 @@ struct _QuickAdd { EContactQuickAddCallback cb; gpointer closure; + GtkWidget *dialog; GtkWidget *name_entry; GtkWidget *email_entry; GtkWidget *option_menu; @@ -122,7 +124,11 @@ merge_cb (EBook *book, EBookStatus status, gpointer closure) QuickAdd *qa = (QuickAdd *) closure; if (status == E_BOOK_ERROR_OK) { - eab_merging_book_add_contact (book, qa->contact, NULL, NULL); + if (e_book_is_writable (book)) + eab_merging_book_add_contact (book, qa->contact, NULL, NULL); + else + e_error_run (NULL, "addressbook:error-read-only", e_source_peek_name (e_book_get_source (book)), NULL); + if (qa->cb) qa->cb (qa->contact, qa->closure); g_object_unref (book); @@ -269,17 +275,35 @@ clicked_cb (GtkWidget *w, gint button, gpointer closure) } static void +sanitize_widgets (QuickAdd *qa) +{ + gboolean enabled = TRUE; + + g_return_if_fail (qa != NULL); + g_return_if_fail (qa->dialog != NULL); + + /* do not call here e_book_is_writable (qa->book), because it requires opened book, which takes time for remote books */ + enabled = qa->book != NULL && e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu)); + + gtk_dialog_set_response_sensitive (GTK_DIALOG (qa->dialog), QUICK_ADD_RESPONSE_EDIT_FULL, enabled); + gtk_dialog_set_response_sensitive (GTK_DIALOG (qa->dialog), GTK_RESPONSE_OK, enabled); +} + +static void source_changed (ESourceComboBox *source_combo_box, QuickAdd *qa) { ESource *source; source = e_source_combo_box_get_active (source_combo_box); - - if (qa->book) { - g_object_unref (qa->book); - qa->book = NULL; + if (source != NULL) { + if (qa->book) { + g_object_unref (qa->book); + qa->book = NULL; + } + qa->book = e_book_new (source, NULL); } - qa->book = e_book_new (source, NULL); + + sanitize_widgets (qa); } static GtkWidget * @@ -311,6 +335,8 @@ build_quick_add_dialog (QuickAdd *qa) g_signal_connect (dialog, "response", G_CALLBACK (clicked_cb), qa); + qa->dialog = dialog; + qa->name_entry = gtk_entry_new (); if (qa->name) gtk_entry_set_text (GTK_ENTRY (qa->name_entry), qa->name); @@ -328,11 +354,32 @@ build_quick_add_dialog (QuickAdd *qa) e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (qa->option_menu), e_book_get_source (book)); + + if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu))) { + /* this means the e_book_new_default_addressbook didn't find any "default" nor "system" source, + and created new one for us. That is wrong, choose one from combo instead. */ + + if (book) { + g_object_unref (book); + book = NULL; + } + + book = e_book_new (e_source_list_peek_source_any (source_list), NULL); + e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (qa->option_menu), e_book_get_source (book)); + + if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu))) { + /* Does it failed again? What is going on? */ + if (book) + g_object_unref (book); + book = NULL; + } + } + if (qa->book) { g_object_unref (qa->book); qa->book = NULL; } - qa->book = book ; + qa->book = book; source_changed (E_SOURCE_COMBO_BOX (qa->option_menu), qa); g_signal_connect ( qa->option_menu, "changed", |