[gnome-builder] flatpak: override some settings in flatpak environment
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: override some settings in flatpak environment
- Date: Mon, 29 Nov 2021 23:54:23 +0000 (UTC)
commit 298f10c01307b388d73936c2b2467c599819a6b8
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 29 15:54:00 2021 -0800
flatpak: override some settings in flatpak environment
We want to make sure that applications can use things like the GTK
inspector out of the box. This makes it a bit easier by writing to the
keyfile that will be used by the flatpak application.
In the future, we want a more generic way to handle this so that we can
provide additional features in the Run popover such as theme.
Fixes #1264
src/plugins/flatpak/gbp-flatpak-runner.c | 49 +++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-runner.c b/src/plugins/flatpak/gbp-flatpak-runner.c
index 3dff40428..90796a71e 100644
--- a/src/plugins/flatpak/gbp-flatpak-runner.c
+++ b/src/plugins/flatpak/gbp-flatpak-runner.c
@@ -19,10 +19,12 @@
*/
#define G_LOG_DOMAIN "gbp-flatpak-runner"
+#define G_SETTINGS_ENABLE_BACKEND
#include <errno.h>
-#include <stdlib.h>
+#include <gio/gsettingsbackend.h>
#include <glib/gi18n.h>
+#include <stdlib.h>
#include <unistd.h>
#include "gbp-flatpak-aux.h"
@@ -223,6 +225,50 @@ gbp_flatpak_runner_new (IdeContext *context,
return g_steal_pointer (&self);
}
+static void
+override_settings (GbpFlatpakRunner *self)
+{
+ g_autoptr(GSettingsBackend) backend = NULL;
+ g_autoptr(GSettings) settings = NULL;
+ g_autofree char *filename = NULL;
+ IdeConfigManager *config_manager;
+ IdeContext *context;
+ const char *app_id;
+ IdeConfig *config;
+
+ g_assert (GBP_IS_FLATPAK_RUNNER (self));
+
+ if (!(context = ide_object_get_context (IDE_OBJECT (self))) ||
+ !(config_manager = ide_config_manager_from_context (context)) ||
+ !(config = ide_config_manager_get_current (config_manager)) ||
+ !(app_id = ide_config_get_app_id (config)))
+ return;
+
+ filename = g_build_filename (g_get_home_dir (), ".var", "app", app_id,
+ "config", "glib-2.0", "settings", "keyfile",
+ NULL);
+ backend = g_keyfile_settings_backend_new (filename, "/", NULL);
+ settings = g_settings_new_with_backend ("org.gtk.Settings.Debug", backend);
+
+ g_settings_set_boolean (settings, "enable-inspector-keybinding", TRUE);
+}
+
+static void
+gbp_flatpak_runner_run_async (IdeRunner *runner,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GbpFlatpakRunner *self = (GbpFlatpakRunner *)runner;
+
+ g_assert (GBP_IS_FLATPAK_RUNNER (self));
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ override_settings (self);
+
+ IDE_RUNNER_CLASS (gbp_flatpak_runner_parent_class)->run_async (runner, cancellable, callback, user_data);
+}
+
static void
gbp_flatpak_runner_finalize (GObject *object)
{
@@ -244,6 +290,7 @@ gbp_flatpak_runner_class_init (GbpFlatpakRunnerClass *klass)
runner_class->create_launcher = gbp_flatpak_runner_create_launcher;
runner_class->fixup_launcher = gbp_flatpak_runner_fixup_launcher;
+ runner_class->run_async = gbp_flatpak_runner_run_async;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]