[gnome-boxes/osinfo-from-server: 51/53] recommended-downloads, Allow configuring recommended-downloads source URL




commit 665285b038b6b3b0000385a949ad21031ca0d3bf
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon Apr 25 15:02:00 2022 +0200

    recommended-downloads, Allow configuring recommended-downloads source URL
    
    One can set the org.gnome.boxes recommended-downloads-url gsetting
    key to override the default value.
    
    If the key is set to empty (""), Boxes will use the recommended-downloads.xml
    file in cache, and if there's no cache, it fallbacks to the recommended-downloads.xml
    file shipped/bundled in $SOURE/data/recommended-downloads.xml

 data/org.gnome.boxes.gschema.xml | 6 ++++++
 src/util-app.vala                | 8 ++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.boxes.gschema.xml b/data/org.gnome.boxes.gschema.xml
index e3b0d317..91f52f08 100644
--- a/data/org.gnome.boxes.gschema.xml
+++ b/data/org.gnome.boxes.gschema.xml
@@ -54,5 +54,11 @@
       <description>Variant array of shared folders’ names and path mapping</description>
     </key>
 
+    <key name="recommended-downloads-url" type="s">
+      <default>'https://gnome.pages.gitlab.gnome.org/gnome-boxes-logos/recommended-downloads.xml'</default>
+      <summary>Recommended Downloads Source URL</summary>
+      <description>An URL pointing at a recommended-downloads.xml file</description>
+    </key>
+
   </schema>
 </schemalist>
diff --git a/src/util-app.vala b/src/util-app.vala
index e11e76b2..9fbbe55c 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -182,9 +182,13 @@ public async GLib.List<Osinfo.Media>? get_recommended_downloads () {
             "resource:///org/gnome/Boxes/recommended-downloads.xml");
     }
 
-    private const string GNOME_UPSTREAM_RECOMMENDED_DOWNLOADS = 
"https://gnome.pages.gitlab.gnome.org/gnome-boxes-logos/recommended-downloads.xml";;
     public async GLib.List<Osinfo.Media>? fetch_recommended_downloads_from_net () {
-        var remote_file = GLib.File.new_for_uri (GNOME_UPSTREAM_RECOMMENDED_DOWNLOADS);
+        var settings = App.app.main_window.settings;
+        var url = settings.get_string ("recommended-downloads-url");
+        if (url == null || url == "")
+            return null;
+
+        var remote_file = GLib.File.new_for_uri (url);
         string cached_path = get_logo_cache ("recommended-downloads.xml");
         GLib.File cached_file = GLib.File.new_for_path (cached_path);
 


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