add prototypes for addressbook_config_database, and

2001-10-26  Chris Toshok  <toshok@ximian.com>

	* gui/component/addressbook.h: add prototypes for
	addressbook_config_database, and addressbook_load_default_book.

	* gui/component/addressbook.c (addressbook_config_database): new
	function, so we aren't activating the db everywhere we need to use
	it.
	(addressbook_load_default_book): load the default book, after
	getting the uri from bonobo-config.

svn path=/trunk/; revision=14200
This commit is contained in:
Chris Toshok
2001-10-27 04:25:42 +00:00
committed by Chris Toshok
parent d08917c280
commit 1d0c3ca254
3 changed files with 60 additions and 0 deletions

View File

@ -1,3 +1,14 @@
2001-10-26 Chris Toshok <toshok@ximian.com>
* gui/component/addressbook.h: add prototypes for
addressbook_config_database, and addressbook_load_default_book.
* gui/component/addressbook.c (addressbook_config_database): new
function, so we aren't activating the db everywhere we need to use
it.
(addressbook_load_default_book): load the default book, after
getting the uri from bonobo-config.
2001-10-26 Jon Trowbridge <trow@ximian.com> 2001-10-26 Jon Trowbridge <trow@ximian.com>
* backend/ebook/e-book-util.c (simple_query_card_added_cb): Return * backend/ebook/e-book-util.c (simple_query_card_added_cb): Return

View File

@ -41,6 +41,7 @@
#include "addressbook/printing/e-contact-print.h" #include "addressbook/printing/e-contact-print.h"
#include <ebook/e-book.h> #include <ebook/e-book.h>
#include <ebook/e-book-util.h>
#include <widgets/misc/e-search-bar.h> #include <widgets/misc/e-search-bar.h>
#include <widgets/misc/e-filter-bar.h> #include <widgets/misc/e-filter-bar.h>
@ -664,6 +665,38 @@ addressbook_load_uri (EBook *book, const char *uri,
return rv; return rv;
} }
gboolean
addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure)
{
char *val;
gboolean rv;
CORBA_Environment ev;
Bonobo_ConfigDatabase config_db;
g_return_val_if_fail (book != NULL, FALSE);
g_return_val_if_fail (E_IS_BOOK (book), FALSE);
g_return_val_if_fail (open_response != NULL, FALSE);
CORBA_exception_init (&ev);
config_db = addressbook_config_database (&ev);
val = bonobo_config_get_string (config_db, "/Addressbook/default_book_uri", &ev);
CORBA_exception_free (&ev);
if (val) {
rv = addressbook_load_uri (book, val, open_response, closure);
g_free (val);
}
else {
rv = e_book_load_local_address_book (book, open_response, closure);
}
if (!rv) {
g_warning ("Couldn't load default addressbook");
}
return rv;
}
static void static void
set_prop (BonoboPropertyBag *bag, set_prop (BonoboPropertyBag *bag,
const BonoboArg *arg, const BonoboArg *arg,
@ -920,7 +953,17 @@ set_folder_bar_label (EAddressbookView *eav, const char *message, AddressbookVie
CORBA_exception_free (&ev); CORBA_exception_free (&ev);
} }
/* Our global singleton config database */
static Bonobo_ConfigDatabase config_db = NULL;
Bonobo_ConfigDatabase
addressbook_config_database (CORBA_Environment *ev)
{
if (config_db == NULL)
config_db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", ev);
return config_db;
}
BonoboControl * BonoboControl *
addressbook_factory_new_control (void) addressbook_factory_new_control (void)

View File

@ -2,14 +2,20 @@
#define __ADDRESSBOOK_H__ #define __ADDRESSBOOK_H__
#include <bonobo/bonobo-control.h> #include <bonobo/bonobo-control.h>
#include <bonobo-conf/bonobo-config-database.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-moniker-util.h>
#include <ebook/e-book.h> #include <ebook/e-book.h>
Bonobo_ConfigDatabase addressbook_config_database (CORBA_Environment *ev);
/* expand file:///foo/foo/ to file:///foo/foo/addressbook.db */ /* expand file:///foo/foo/ to file:///foo/foo/addressbook.db */
char * addressbook_expand_uri (const char *uri); char * addressbook_expand_uri (const char *uri);
/* use this instead of e_book_load_uri everywhere where you want the /* use this instead of e_book_load_uri everywhere where you want the
authentication to be handled for you. */ authentication to be handled for you. */
gboolean addressbook_load_uri (EBook *book, const char *uri, EBookCallback cb, gpointer closure); 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);
BonoboControl *addressbook_factory_new_control (void); BonoboControl *addressbook_factory_new_control (void);
void addressbook_factory_init (void); void addressbook_factory_init (void);