[gnome-control-center] background: Remove files that don't exist



commit 5ca53670182c769757a5eda54faed7c6f4548ecf
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 14 15:11:17 2011 +0000

    background: Remove files that don't exist
    
    If an xml file references a wallpaper that doesn't exist
    (as seen by installing the desktop-backgrounds-basic package
    on Fedora), then just don't add it to the list of wallpapers.
    
    Reported by Matthias Clasen

 panels/background/cc-background-xml.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c
index 84ee0df..12d747a 100644
--- a/panels/background/cc-background-xml.c
+++ b/panels/background/cc-background-xml.c
@@ -266,6 +266,23 @@ cc_background_xml_load_xml_internal (CcBackgroundXml *xml,
 	}
       }
 
+      /* Check whether the target file exists */
+      {
+        GFile *file;
+        const char *uri;
+
+	uri = cc_background_item_get_uri (item);
+	if (uri != NULL)
+	  {
+            file = g_file_new_for_uri (uri);
+	    if (g_file_query_exists (file, NULL) == FALSE)
+	      {
+	        g_object_unref (item);
+	        continue;
+	      }
+	  }
+      }
+
       /* FIXME, this is a broken way of doing,
        * need to use proper code here */
       uri = g_filename_to_uri (filename, NULL, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]