Commit 556a9f30 authored by Debarshi Ray's avatar Debarshi Ray

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
parent 62e9ac80
......@@ -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.*"
......
/*
* 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)
{
......
/*
* 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment