[gnome-software/1166-repository-dialog-design-updates: 44/51] flatpak: Extract scope ensure code into a separate function
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1166-repository-dialog-design-updates: 44/51] flatpak: Extract scope ensure code into a separate function
- Date: Thu, 5 Aug 2021 15:49:30 +0000 (UTC)
commit 8a82759429dd850e0eda234449ede3950e5aa91c
Author: Milan Crha <mcrha redhat com>
Date: Tue Jul 27 15:14:48 2021 +0200
flatpak: Extract scope ensure code into a separate function
Will be used on multiple places later.
plugins/flatpak/gs-plugin-flatpak.c | 40 ++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 3f19c40ef..94c8134cf 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -929,13 +929,35 @@ app_has_local_source (GsApp *app)
return FALSE;
}
+static void
+gs_plugin_flatpak_ensure_scope (GsPlugin *plugin,
+ GsApp *app)
+{
+ GsPluginData *priv = gs_plugin_get_data (plugin);
+
+ if (gs_app_get_scope (app) == AS_COMPONENT_SCOPE_UNKNOWN) {
+ g_autoptr(GSettings) settings = g_settings_new ("org.gnome.software");
+
+ /* get the new GsFlatpak for handling of local files */
+ gs_app_set_scope (app, g_settings_get_boolean (settings, "install-bundles-system-wide") ?
+ AS_COMPONENT_SCOPE_SYSTEM : AS_COMPONENT_SCOPE_USER);
+ if (!priv->has_system_helper) {
+ g_info ("no flatpak system helper is available, using user");
+ gs_app_set_scope (app, AS_COMPONENT_SCOPE_USER);
+ }
+ if (priv->destdir_for_tests != NULL) {
+ g_debug ("in self tests, using user");
+ gs_app_set_scope (app, AS_COMPONENT_SCOPE_USER);
+ }
+ }
+}
+
gboolean
gs_plugin_app_install (GsPlugin *plugin,
GsApp *app,
GCancellable *cancellable,
GError **error)
{
- GsPluginData *priv = gs_plugin_get_data (plugin);
GsFlatpak *flatpak;
g_autoptr(FlatpakTransaction) transaction = NULL;
g_autoptr(GError) error_local = NULL;
@@ -950,21 +972,7 @@ gs_plugin_app_install (GsPlugin *plugin,
}
/* set the app scope */
- if (gs_app_get_scope (app) == AS_COMPONENT_SCOPE_UNKNOWN) {
- g_autoptr(GSettings) settings = g_settings_new ("org.gnome.software");
-
- /* get the new GsFlatpak for handling of local files */
- gs_app_set_scope (app, g_settings_get_boolean (settings, "install-bundles-system-wide") ?
- AS_COMPONENT_SCOPE_SYSTEM : AS_COMPONENT_SCOPE_USER);
- if (!priv->has_system_helper) {
- g_info ("no flatpak system helper is available, using user");
- gs_app_set_scope (app, AS_COMPONENT_SCOPE_USER);
- }
- if (priv->destdir_for_tests != NULL) {
- g_debug ("in self tests, using user");
- gs_app_set_scope (app, AS_COMPONENT_SCOPE_USER);
- }
- }
+ gs_plugin_flatpak_ensure_scope (plugin, app);
/* not supported */
flatpak = gs_plugin_flatpak_get_handler (plugin, app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]