diff -u contact-lookup-applet-0.8/src/contact-lookup-applet.c contact-lookup-applet-0.8new/src/contact-lookup-applet.c --- contact-lookup-applet-0.8/src/contact-lookup-applet.c 2004-08-24 10:48:50.000000000 +0200 +++ contact-lookup-applet-0.8new/src/contact-lookup-applet.c 2004-10-04 20:22:50.249080972 +0200 @@ -259,26 +259,19 @@ } } -/** - * GConf callback, the source key has changed. Free old book and load the new - * one. - */ static void -source_changed_cb (GConfClient* client, guint cnxn_id, GConfEntry *entry, gpointer user_data) +book_open (const char *xml, EvoLookupApplet *applet) { - EvoLookupApplet *applet = NULL; - const char* xml; ESource *source; - g_return_if_fail (user_data != NULL); - applet = (EvoLookupApplet*)user_data; - if (entry->value == NULL) { + g_return_if_fail (applet != NULL); + + if (xml == NULL) { /* Someone has unset this key, unref and disable the UI */ g_object_unref (applet->book); update_widgets (applet, FALSE); return; } - xml = gconf_value_get_string (entry->value); - g_return_if_fail (xml != NULL); + source = e_source_new_from_standalone_xml (xml); /* If loaded, unload or if we haven't been created yet . . */ if (!applet->book || e_book_get_uri (applet->book)) { @@ -310,6 +303,28 @@ } /** + * GConf callback, the source key has changed. Free old book and load the new + * one. + */ +static void +source_changed_cb (GConfClient* client, guint cnxn_id, GConfEntry *entry, gpointer user_data) +{ + EvoLookupApplet *applet = NULL; + const char* xml; + g_return_if_fail (user_data != NULL); + applet = (EvoLookupApplet*)user_data; + + if (entry->value == NULL) { + /* Someone has unset this key, unref and disable the UI */ + book_open (NULL, applet); + return; + } + xml = gconf_value_get_string (entry->value); + g_return_if_fail (xml != NULL); + book_open (xml, applet); +} + +/** * Panel callback, the size of the applet has changed. */ static void @@ -647,12 +662,14 @@ s = panel_applet_gconf_get_full_key (parent_applet, "source"); applet->source_notify_id = gconf_client_notify_add (applet->gconf_client, s, source_changed_cb, applet, NULL, NULL); g_free (s); + /* Check for unset prefs */ s = panel_applet_gconf_get_string (parent_applet, "source", NULL); if (s == NULL) { /* Fire the prefs callback */ prefs_cb (NULL, applet, NULL); } else { + book_open (s, applet); g_free (s); }