[gnome-control-center] background: Add function to load a single XML file
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] background: Add function to load a single XML file
- Date: Mon, 14 Feb 2011 09:44:37 +0000 (UTC)
commit 66ee58bf52e9822826f1840b4be9a60447b1af26
Author: Bastien Nocera <hadess hadess net>
Date: Sun Feb 13 02:33:03 2011 +0000
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.
panels/background/cc-background-xml.c | 27 +++++++++++++++++++++++++++
panels/background/cc-background-xml.h | 1 +
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c
index 0cb2596..5ba155c 100644
--- a/panels/background/cc-background-xml.c
+++ b/panels/background/cc-background-xml.c
@@ -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) {
diff --git a/panels/background/cc-background-xml.h b/panels/background/cc-background-xml.h
index 31da25c..a5e2628 100644
--- a/panels/background/cc-background-xml.h
+++ b/panels/background/cc-background-xml.h
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]