aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/addressbook.c26
-rw-r--r--addressbook/gui/component/addressbook.h4
-rw-r--r--addressbook/gui/component/e-address-popup.c37
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c18
-rw-r--r--addressbook/gui/widgets/e-minicard-control.c10
-rw-r--r--addressbook/gui/widgets/test-minicard-view.c5
6 files changed, 39 insertions, 61 deletions
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 9ab5d87320..5baaa05733 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -413,8 +413,7 @@ control_activate_cb (BonoboControl *control,
book = e_book_new ();
uri_data = e_book_expand_uri (view->uri);
- if (! addressbook_load_uri (book, uri_data, book_open_cb, view))
- printf ("error calling load_uri!\n");
+ addressbook_load_uri (book, uri_data, book_open_cb, view);
g_free(uri_data);
}
@@ -729,39 +728,27 @@ load_uri_cb (EBook *book, EBookStatus status, gpointer closure)
g_free (load_uri_data);
}
-gboolean
+void
addressbook_load_uri (EBook *book, const char *uri,
EBookCallback cb, gpointer closure)
{
LoadUriData *load_uri_data = g_new0 (LoadUriData, 1);
- gboolean rv;
load_uri_data->cb = cb;
load_uri_data->closure = closure;
- rv = e_book_load_uri (book, uri, load_uri_cb, load_uri_data);
-
- if (!rv)
- g_free (load_uri_data);
-
- return rv;
+ e_book_load_uri (book, uri, load_uri_cb, load_uri_data);
}
-gboolean
+void
addressbook_load_default_book (EBook *book, EBookCallback cb, gpointer closure)
{
LoadUriData *load_uri_data = g_new (LoadUriData, 1);
- gboolean rv;
load_uri_data->cb = cb;
load_uri_data->closure = closure;
- rv = e_book_load_default_book (book, load_uri_cb, load_uri_data);
-
- if (!rv)
- g_free (load_uri_data);
-
- return rv;
+ e_book_load_default_book (book, load_uri_cb, load_uri_data);
}
static void
@@ -796,8 +783,7 @@ set_prop (BonoboPropertyBag *bag,
uri_data = e_book_expand_uri (view->uri);
- if (! addressbook_load_uri (book, uri_data, book_open_cb, view))
- printf ("error calling load_uri!\n");
+ addressbook_load_uri (book, uri_data, book_open_cb, view);
g_free(uri_data);
diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h
index 3524f24b0c..3d4bba5187 100644
--- a/addressbook/gui/component/addressbook.h
+++ b/addressbook/gui/component/addressbook.h
@@ -9,8 +9,8 @@
/* use this instead of e_book_load_uri everywhere where you want the
authentication to be handled for you. */
-gboolean addressbook_load_uri (EBook *book, const char *uri, EBookCallback cb, gpointer closure);
-gboolean addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure);
+void addressbook_load_uri (EBook *book, const char *uri, EBookCallback cb, gpointer closure);
+void addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure);
BonoboControl *addressbook_new_control (void);
diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/component/e-address-popup.c
index 13baf28eec..39c51a3720 100644
--- a/addressbook/gui/component/e-address-popup.c
+++ b/addressbook/gui/component/e-address-popup.c
@@ -389,10 +389,11 @@ email_table_save_card_cb (EBook *book, EBookStatus status, gpointer closure)
{
ECard *card = E_CARD (closure);
- if (book) {
+ if (status == E_BOOK_STATUS_SUCCESS) {
e_book_commit_card (book, card, NULL, NULL);
- g_object_unref (book);
}
+ if (book)
+ g_object_unref (book);
g_object_unref (card);
}
@@ -406,10 +407,7 @@ add_card_idle_cb (gpointer closure)
EBook *book;
book = e_book_new ();
- if (!addressbook_load_default_book (book, email_table_save_card_cb, closure)) {
- g_object_unref (book);
- email_table_save_card_cb (NULL, E_BOOK_STATUS_OTHER_ERROR, closure);
- }
+ addressbook_load_default_book (book, email_table_save_card_cb, closure);
return 0;
}
@@ -956,11 +954,16 @@ emit_event (EAddressPopup *pop, const char *event)
static void
contact_editor_cb (EBook *book, EBookStatus status, gpointer closure)
{
- EAddressPopup *pop = E_ADDRESS_POPUP (closure);
- EContactEditor *ce = e_addressbook_show_contact_editor (book, pop->card, FALSE, TRUE);
- e_address_popup_cleanup (pop);
- emit_event (pop, "Destroy");
- e_contact_editor_raise (ce);
+ if (status == E_BOOK_STATUS_SUCCESS) {
+ EAddressPopup *pop = E_ADDRESS_POPUP (closure);
+ EContactEditor *ce = e_addressbook_show_contact_editor (book, pop->card, FALSE, TRUE);
+ e_address_popup_cleanup (pop);
+ emit_event (pop, "Destroy");
+ e_contact_editor_raise (ce);
+ }
+
+ if (book)
+ g_object_unref (book);
}
static void
@@ -970,10 +973,7 @@ edit_contact_info_cb (EAddressPopup *pop)
emit_event (pop, "Hide");
book = e_book_new ();
- if (!addressbook_load_default_book (book, contact_editor_cb, pop)) {
- g_object_unref (book);
- contact_editor_cb (NULL, E_BOOK_STATUS_OTHER_ERROR, pop);
- }
+ addressbook_load_default_book (book, contact_editor_cb, pop);
}
static void
@@ -1156,6 +1156,8 @@ start_query (EBook *book, EBookStatus status, gpointer closure)
if (status != E_BOOK_STATUS_SUCCESS) {
e_address_popup_no_matches (pop);
+ if (book)
+ g_object_unref (book);
return;
}
@@ -1184,10 +1186,7 @@ e_address_popup_query (EAddressPopup *pop)
book = e_book_new ();
g_object_ref (pop);
- if (!addressbook_load_default_book (book, start_query, pop)) {
- g_object_unref (book);
- start_query (NULL, E_BOOK_STATUS_OTHER_ERROR, pop);
- }
+ addressbook_load_default_book (book, start_query, pop);
}
/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index d19ffb364f..1ad469a0ed 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -132,13 +132,15 @@ merge_cb (EBook *book, EBookStatus status, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
- if (book != NULL) {
+ if (status == E_BOOK_STATUS_SUCCESS) {
e_card_merging_book_add_card (book, qa->card, NULL, NULL);
if (qa->cb)
qa->cb (qa->card, qa->closure);
g_object_unref (book);
} else {
/* Something went wrong. */
+ if (book)
+ g_object_unref (book);
if (qa->cb)
qa->cb (NULL, qa->closure);
}
@@ -154,10 +156,7 @@ quick_add_merge_card (QuickAdd *qa)
quick_add_ref (qa);
book = e_book_new ();
- if (!addressbook_load_default_book (book, merge_cb, qa)) {
- g_object_unref (book);
- merge_cb (book, E_BOOK_STATUS_OTHER_ERROR, qa);
- }
+ addressbook_load_default_book (book, merge_cb, qa);
}
@@ -197,7 +196,9 @@ ce_have_book (EBook *book, EBookStatus status, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
- if (book == NULL) {
+ if (status != E_BOOK_STATUS_SUCCESS) {
+ if (book)
+ g_object_unref (book);
g_warning ("Couldn't open local address book.");
quick_add_unref (qa);
} else {
@@ -232,10 +233,7 @@ edit_card (QuickAdd *qa)
{
EBook *book;
book = e_book_new ();
- if (!addressbook_load_default_book (book, ce_have_book, qa)) {
- g_object_unref (book);
- ce_have_book (book, E_BOOK_STATUS_OTHER_ERROR, qa);
- }
+ addressbook_load_default_book (book, ce_have_book, qa);
}
#define QUICK_ADD_RESPONSE_EDIT_FULL 2
diff --git a/addressbook/gui/widgets/e-minicard-control.c b/addressbook/gui/widgets/e-minicard-control.c
index 36f40d86d5..7cbcfb028a 100644
--- a/addressbook/gui/widgets/e-minicard-control.c
+++ b/addressbook/gui/widgets/e-minicard-control.c
@@ -249,13 +249,14 @@ static void
book_open_cb (EBook *book, EBookStatus status, gpointer closure)
{
GList *list = closure;
- if (book) {
+ if (status == E_BOOK_STATUS_SUCCESS) {
GList *p;
for (p = list; p; p = p->next) {
e_card_merging_book_add_card(book, p->data, NULL, NULL);
}
- g_object_unref (book);
}
+ if (book)
+ g_object_unref (book);
e_free_object_list (list);
}
@@ -273,10 +274,7 @@ save_in_addressbook(GtkWidget *button, gpointer data)
for (p = list; p; p = p->next)
g_object_ref (p->data);
- if (!addressbook_load_default_book (book, book_open_cb, list)) {
- g_object_unref (book);
- book_open_cb (NULL, E_BOOK_STATUS_OTHER_ERROR, list);
- }
+ addressbook_load_default_book (book, book_open_cb, list);
}
static void
diff --git a/addressbook/gui/widgets/test-minicard-view.c b/addressbook/gui/widgets/test-minicard-view.c
index 7abe611711..1a4ff8e07f 100644
--- a/addressbook/gui/widgets/test-minicard-view.c
+++ b/addressbook/gui/widgets/test-minicard-view.c
@@ -132,10 +132,7 @@ ebook_create (gpointer data)
}
- if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) {
- printf ("error calling load_uri!\n");
- }
-
+ e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL);
return FALSE;
}