[gnome-software] Install flatpak bundles system-wide by default



commit b4fe4d0369a53db5257d49bbf10d2cb90aedabab
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jun 7 09:58:36 2016 +0100

    Install flatpak bundles system-wide by default
    
    Also add a new GSetting to allow an admin to configure this in policy.

 data/org.gnome.software.gschema.xml    |    4 ++++
 src/plugins/gs-plugin-flatpak-system.c |   13 ++++++++++++-
 src/plugins/gs-plugin-flatpak-user.c   |   13 ++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml
index 1bb32b7..47c1cad 100644
--- a/data/org.gnome.software.gschema.xml
+++ b/data/org.gnome.software.gschema.xml
@@ -66,6 +66,10 @@
       <default>''</default>
       <summary>The licence URL to use when an application should be considered free software</summary>
     </key>
+    <key name="install-bundles-system-wide" type="b">
+      <default>true</default>
+      <summary>Install bundled applications for all users on the system where possible</summary>
+    </key>
     <key name="show-folder-management" type="b">
       <default>true</default>
       <summary>Show the folder management UI</summary>
diff --git a/src/plugins/gs-plugin-flatpak-system.c b/src/plugins/gs-plugin-flatpak-system.c
index 14a42e7..49d1cb3 100644
--- a/src/plugins/gs-plugin-flatpak-system.c
+++ b/src/plugins/gs-plugin-flatpak-system.c
@@ -37,12 +37,14 @@
 struct GsPluginData {
        FlatpakInstallation     *installation;
        GFileMonitor            *monitor;
+       GSettings               *settings;
 };
 
 void
 gs_plugin_initialize (GsPlugin *plugin)
 {
-       gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+       GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+       priv->settings = g_settings_new ("org.gnome.software");
 
        /* getting app properties from appstream is quicker */
        gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
@@ -54,6 +56,7 @@ gs_plugin_destroy (GsPlugin *plugin)
        GsPluginData *priv = gs_plugin_get_data (plugin);
        g_clear_object (&priv->installation);
        g_clear_object (&priv->monitor);
+       g_clear_object (&priv->settings);
 }
 
 void
@@ -194,6 +197,14 @@ gs_plugin_file_to_app (GsPlugin *plugin,
                       GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
+
+       /* only handle when installing bundles system-wide */
+       if (!g_settings_get_boolean (priv->settings,
+                                    "install-bundles-system-wide")) {
+               g_debug ("not handling bundle as per-user specified");
+               return TRUE;
+       }
+
        return gs_flatpak_file_to_app (plugin, priv->installation, list, file,
                                       cancellable, error);
 }
diff --git a/src/plugins/gs-plugin-flatpak-user.c b/src/plugins/gs-plugin-flatpak-user.c
index aa8251f..9a2fb94 100644
--- a/src/plugins/gs-plugin-flatpak-user.c
+++ b/src/plugins/gs-plugin-flatpak-user.c
@@ -37,12 +37,14 @@
 struct GsPluginData {
        FlatpakInstallation     *installation;
        GFileMonitor            *monitor;
+       GSettings               *settings;
 };
 
 void
 gs_plugin_initialize (GsPlugin *plugin)
 {
-       gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+       GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+       priv->settings = g_settings_new ("org.gnome.software");
 
        /* getting app properties from appstream is quicker */
        gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
@@ -54,6 +56,7 @@ gs_plugin_destroy (GsPlugin *plugin)
        GsPluginData *priv = gs_plugin_get_data (plugin);
        g_clear_object (&priv->installation);
        g_clear_object (&priv->monitor);
+       g_clear_object (&priv->settings);
 }
 
 void
@@ -194,6 +197,14 @@ gs_plugin_file_to_app (GsPlugin *plugin,
                       GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
+
+       /* only handle when installing bundles user-wide */
+       if (g_settings_get_boolean (priv->settings,
+                                   "install-bundles-system-wide")) {
+               g_debug ("not handling bundle as per-system specified");
+               return TRUE;
+       }
+
        return gs_flatpak_file_to_app (plugin, priv->installation, list, file,
                                       cancellable, error);
 }


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