background: Add function to load a single XML file

And its item out of it. So that we can load a file on startup
and check whether it corresponds to our configuration.
This commit is contained in:
Bastien Nocera 2011-02-13 02:33:03 +00:00
parent 7448e7698e
commit 66ee58bf52
2 changed files with 28 additions and 0 deletions

View file

@ -474,6 +474,33 @@ cc_background_xml_load_xml (CcBackgroundXml *xml,
return cc_background_xml_load_xml_internal (xml, filename, FALSE);
}
static void
single_xml_added (CcBackgroundXml *xml,
CcBackgroundItem *item,
CcBackgroundItem **ret)
{
g_assert (*ret == NULL);
*ret = g_object_ref (item);
}
CcBackgroundItem *
cc_background_xml_get_item (const char *filename)
{
CcBackgroundXml *xml;
CcBackgroundItem *item;
xml = cc_background_xml_new ();
item = NULL;
g_signal_connect (G_OBJECT (xml), "added",
G_CALLBACK (single_xml_added), &item);
if (cc_background_xml_load_xml (xml, filename) == FALSE) {
g_object_unref (xml);
return NULL;
}
return item;
}
#if 0
static void gnome_wp_list_flatten (const gchar * key, CcBackgroundXml * item,
GSList ** list) {

View file

@ -54,6 +54,7 @@ CcBackgroundXml *cc_background_xml_new (void);
void cc_background_xml_save_list (CcBackgroundXml *data);
CcBackgroundItem *cc_background_xml_get_item (const char *filename);
gboolean cc_background_xml_load_xml (CcBackgroundXml *data,
const char *filename);
void cc_background_xml_load_list_async (CcBackgroundXml *data,