evolution r34791 - in trunk/addressbook: . gui/contact-editor
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r34791 - in trunk/addressbook: . gui/contact-editor
- Date: Thu, 10 Jan 2008 15:52:47 +0000 (GMT)
Author: mcrha
Date: Thu Jan 10 15:52:46 2008
New Revision: 34791
URL: http://svn.gnome.org/viewvc/evolution?rev=34791&view=rev
Log:
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.
Modified:
trunk/addressbook/ChangeLog
trunk/addressbook/addressbook.error.xml
trunk/addressbook/gui/contact-editor/e-contact-quick-add.c
Modified: trunk/addressbook/addressbook.error.xml
==============================================================================
--- trunk/addressbook/addressbook.error.xml (original)
+++ trunk/addressbook/addressbook.error.xml Thu Jan 10 15:52:46 2008
@@ -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>
Modified: trunk/addressbook/gui/contact-editor/e-contact-quick-add.c
==============================================================================
--- trunk/addressbook/gui/contact-editor/e-contact-quick-add.c (original)
+++ trunk/addressbook/gui/contact-editor/e-contact-quick-add.c Thu Jan 10 15:52:46 2008
@@ -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 @@
EContactQuickAddCallback cb;
gpointer closure;
+ GtkWidget *dialog;
GtkWidget *name_entry;
GtkWidget *email_entry;
GtkWidget *option_menu;
@@ -122,7 +124,11 @@
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 @@
}
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 @@
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 @@
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",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]