[gnome-photos/gnome-3-28] flatpak, utils: Add a Flatpak-friendly method to spawn the GOA panel
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/gnome-3-28] flatpak, utils: Add a Flatpak-friendly method to spawn the GOA panel
- Date: Fri, 29 Jun 2018 12:20:30 +0000 (UTC)
commit 04bfedcea47d6f0b91a6b92f1a51e46f484352f1
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Jun 29 13:22:54 2018 +0200
flatpak, utils: Add a Flatpak-friendly method to spawn the GOA panel
The Flatpak bundle doesn't include the gnome-control-center binary,
and the sandbox prevents it from accessing one that's part of the host
operating system or a different bundle. Therefore, it's not possible
to use g_app_info_create_from_commandline to launch the Online
Accounts panel when running as a Flatpak.
However, with a hole poked in the sandbox, it will be able to see the
org.gtk.Actions-based [1] D-Bus API offered by gnome-control-center
[2], which can be conveniently accessed through GApplication's remote
GActionGroup implementation.
This will be used by the subsequent commit.
[1] https://wiki.gnome.org/Projects/GLib/GApplication/DBusAPI
[2] gnome-control-center commit ab0576f1f00172c4
https://bugzilla.gnome.org/show_bug.cgi?id=696054
flatpak/org.gnome.Photos.json | 1 +
src/photos-utils.c | 35 ++++++++++++++++++++++++++++++++++-
src/photos-utils.h | 4 +++-
3 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/flatpak/org.gnome.Photos.json b/flatpak/org.gnome.Photos.json
index dae2928b..00f908ce 100644
--- a/flatpak/org.gnome.Photos.json
+++ b/flatpak/org.gnome.Photos.json
@@ -21,6 +21,7 @@
"--talk-name=org.freedesktop.Tracker1",
"--talk-name=org.freedesktop.Tracker1.Miner.Extract",
"--talk-name=com.intel.dleyna-renderer",
+ "--talk-name=org.gnome.ControlCenter",
"--talk-name=org.gnome.SettingsDaemon",
"--talk-name=org.gtk.vfs",
"--talk-name=org.gtk.vfs.*"
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 893da6c6..9a947950 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 – 2017 Red Hat, Inc.
+ * Copyright © 2012 – 2018 Red Hat, Inc.
* Copyright © 2009 Yorba Foundation
*
* This program is free software: you can redistribute it and/or modify
@@ -1080,6 +1080,39 @@ photos_utils_get_version (void)
}
+gboolean
+photos_utils_launch_online_accounts (const gchar *account_id, GError **error)
+{
+ GVariant *parameters;
+ g_autoptr (GApplication) control_center = NULL;
+ g_auto (GVariantBuilder) panel_parameters = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("av"));
+ gboolean ret_val = FALSE;
+ const gchar *control_center_id = "org.gnome.ControlCenter";
+
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ control_center = g_application_new (control_center_id, G_APPLICATION_IS_LAUNCHER);
+ if (!g_application_register (control_center, NULL, error))
+ goto out;
+
+ if (account_id != NULL && account_id[0] != '\0')
+ {
+ GVariant *account_id_variant;
+
+ account_id_variant = g_variant_new_string (account_id);
+ g_variant_builder_add (&panel_parameters, "v", account_id_variant);
+ }
+
+ parameters = g_variant_new ("(s@av)", "online-accounts", g_variant_builder_end (&panel_parameters));
+ g_action_group_activate_action (G_ACTION_GROUP (control_center), "launch-panel", parameters);
+
+ ret_val = TRUE;
+
+ out:
+ return ret_val;
+}
+
+
void
photos_utils_list_box_header_func (GtkListBoxRow *row, GtkListBoxRow *before, gpointer user_data)
{
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 2f228383..ee205070 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 – 2017 Red Hat, Inc.
+ * Copyright © 2012 – 2018 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -146,6 +146,8 @@ GList *photos_utils_get_urns_from_items (GList *items);
const gchar *photos_utils_get_version (void);
+gboolean photos_utils_launch_online_accounts (const gchar *account_id, GError **error);
+
void photos_utils_list_box_header_func (GtkListBoxRow *row,
GtkListBoxRow *before,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]