aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-01-10 23:52:46 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-01-10 23:52:46 +0800
commitf12f5298015788a18abf19470b0460f5a3bad1f5 (patch)
tree3ce816d662d259f5d1e98baef81026d5f359bba6 /addressbook/gui
parent3b1751690acdcfc8abc5ceb0c374724ccf50df36 (diff)
downloadgsoc2013-evolution-f12f5298015788a18abf19470b0460f5a3bad1f5.tar.gz
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/gui')
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c61
1 files changed, 54 insertions, 7 deletions
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",