Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Codethink Limited
|
|
|
|
* Copyright © 2012 Red Hat, Inc.
|
|
|
|
* Copyright © 2013 Canonical Limited
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the licence, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Ryan Lortie <desrt@desrt.ca>
|
|
|
|
* Matthias Clasen <mclasen@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gtkapplicationprivate.h"
|
2014-06-30 16:16:19 +00:00
|
|
|
#include "gtksettings.h"
|
2018-08-30 20:38:03 +00:00
|
|
|
#include "gtkprivate.h"
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2019-03-20 19:04:51 +00:00
|
|
|
#include "gdk/gdk-private.h"
|
2019-03-17 20:29:59 +00:00
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
G_DEFINE_TYPE (GtkApplicationImplDBus, gtk_application_impl_dbus, GTK_TYPE_APPLICATION_IMPL)
|
|
|
|
|
2016-06-28 08:56:35 +00:00
|
|
|
#define GNOME_DBUS_NAME "org.gnome.SessionManager"
|
|
|
|
#define GNOME_DBUS_OBJECT_PATH "/org/gnome/SessionManager"
|
|
|
|
#define GNOME_DBUS_INTERFACE "org.gnome.SessionManager"
|
|
|
|
#define GNOME_DBUS_CLIENT_INTERFACE "org.gnome.SessionManager.ClientPrivate"
|
|
|
|
#define XFCE_DBUS_NAME "org.xfce.SessionManager"
|
|
|
|
#define XFCE_DBUS_OBJECT_PATH "/org/xfce/SessionManager"
|
|
|
|
#define XFCE_DBUS_INTERFACE "org.xfce.Session.Manager"
|
|
|
|
#define XFCE_DBUS_CLIENT_INTERFACE "org.xfce.Session.Client"
|
2018-08-30 05:06:51 +00:00
|
|
|
#define GNOME_SCREENSAVER_DBUS_NAME "org.gnome.ScreenSaver"
|
|
|
|
#define GNOME_SCREENSAVER_DBUS_OBJECT_PATH "/org/gnome/ScreenSaver"
|
|
|
|
#define GNOME_SCREENSAVER_DBUS_INTERFACE "org.gnome.ScreenSaver"
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
unregister_client (GtkApplicationImplDBus *dbus)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_debug ("Unregistering client");
|
|
|
|
|
|
|
|
g_dbus_proxy_call_sync (dbus->sm_proxy,
|
|
|
|
"UnregisterClient",
|
|
|
|
g_variant_new ("(o)", dbus->client_path),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("Failed to unregister client: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_object (&dbus->client_proxy);
|
|
|
|
|
|
|
|
g_free (dbus->client_path);
|
|
|
|
dbus->client_path = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_quit_response (GtkApplicationImplDBus *dbus,
|
|
|
|
gboolean will_quit,
|
|
|
|
const gchar *reason)
|
|
|
|
{
|
|
|
|
g_debug ("Calling EndSessionResponse %d '%s'", will_quit, reason);
|
|
|
|
|
|
|
|
g_dbus_proxy_call (dbus->client_proxy,
|
|
|
|
"EndSessionResponse",
|
|
|
|
g_variant_new ("(bs)", will_quit, reason ? reason : ""),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
client_proxy_signal (GDBusProxy *proxy,
|
|
|
|
const gchar *sender_name,
|
|
|
|
const gchar *signal_name,
|
|
|
|
GVariant *parameters,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = user_data;
|
|
|
|
|
|
|
|
if (g_str_equal (signal_name, "QueryEndSession"))
|
|
|
|
{
|
|
|
|
g_debug ("Received QueryEndSession");
|
2019-01-22 01:45:15 +00:00
|
|
|
g_signal_emit_by_name (dbus->impl.application, "query-end");
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
send_quit_response (dbus, TRUE, NULL);
|
|
|
|
}
|
|
|
|
else if (g_str_equal (signal_name, "CancelEndSession"))
|
|
|
|
{
|
|
|
|
g_debug ("Received CancelEndSession");
|
|
|
|
}
|
|
|
|
else if (g_str_equal (signal_name, "EndSession"))
|
|
|
|
{
|
|
|
|
g_debug ("Received EndSession");
|
|
|
|
send_quit_response (dbus, TRUE, NULL);
|
|
|
|
unregister_client (dbus);
|
|
|
|
g_application_quit (G_APPLICATION (dbus->impl.application));
|
|
|
|
}
|
|
|
|
else if (g_str_equal (signal_name, "Stop"))
|
|
|
|
{
|
|
|
|
g_debug ("Received Stop");
|
|
|
|
unregister_client (dbus);
|
|
|
|
g_application_quit (G_APPLICATION (dbus->impl.application));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 08:56:35 +00:00
|
|
|
static GDBusProxy*
|
|
|
|
gtk_application_get_proxy_if_service_present (GDBusConnection *connection,
|
|
|
|
GDBusProxyFlags flags,
|
|
|
|
const gchar *bus_name,
|
|
|
|
const gchar *object_path,
|
|
|
|
const gchar *interface,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GDBusProxy *proxy;
|
|
|
|
gchar *owner;
|
|
|
|
|
|
|
|
proxy = g_dbus_proxy_new_sync (connection,
|
|
|
|
flags,
|
|
|
|
NULL,
|
|
|
|
bus_name,
|
|
|
|
object_path,
|
|
|
|
interface,
|
|
|
|
NULL,
|
2016-07-03 21:22:14 +00:00
|
|
|
error);
|
2016-06-28 08:56:35 +00:00
|
|
|
|
2017-07-09 08:02:34 +00:00
|
|
|
if (!proxy)
|
|
|
|
return NULL;
|
|
|
|
|
2016-06-28 08:56:35 +00:00
|
|
|
/* is there anyone actually providing the service? */
|
|
|
|
owner = g_dbus_proxy_get_name_owner (proxy);
|
|
|
|
if (owner == NULL)
|
2016-07-25 13:11:21 +00:00
|
|
|
{
|
|
|
|
g_clear_object (&proxy);
|
|
|
|
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER,
|
|
|
|
"The name %s is not owned", bus_name);
|
|
|
|
}
|
2016-06-28 08:56:35 +00:00
|
|
|
else
|
2016-07-03 21:22:14 +00:00
|
|
|
g_free (owner);
|
2016-06-28 08:56:35 +00:00
|
|
|
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
|
2018-08-30 05:06:51 +00:00
|
|
|
static void
|
|
|
|
screensaver_signal_session (GDBusProxy *proxy,
|
|
|
|
const char *sender_name,
|
|
|
|
const char *signal_name,
|
|
|
|
GVariant *parameters,
|
|
|
|
GtkApplication *application)
|
|
|
|
{
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
if (!g_str_equal (signal_name, "ActiveChanged"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_variant_get (parameters, "(b)", &active);
|
|
|
|
gtk_application_set_screensaver_active (application, active);
|
|
|
|
}
|
|
|
|
|
2019-01-20 16:29:04 +00:00
|
|
|
enum {
|
|
|
|
UNKNOWN = 0,
|
|
|
|
RUNNING = 1,
|
|
|
|
QUERY_END = 2,
|
|
|
|
ENDING = 3
|
|
|
|
};
|
|
|
|
|
2018-08-30 05:06:51 +00:00
|
|
|
static void
|
|
|
|
screensaver_signal_portal (GDBusConnection *connection,
|
|
|
|
const char *sender_name,
|
|
|
|
const char *object_path,
|
|
|
|
const char *interface_name,
|
|
|
|
const char *signal_name,
|
|
|
|
GVariant *parameters,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2019-01-20 16:29:04 +00:00
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *)data;
|
|
|
|
GtkApplication *application = data;
|
2018-08-30 05:06:51 +00:00
|
|
|
gboolean active;
|
|
|
|
GVariant *state;
|
2019-01-20 16:29:04 +00:00
|
|
|
guint32 session_state = UNKNOWN;
|
2018-08-30 05:06:51 +00:00
|
|
|
|
|
|
|
if (!g_str_equal (signal_name, "StateChanged"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_variant_get (parameters, "(o@a{sv})", NULL, &state);
|
|
|
|
g_variant_lookup (state, "screensaver-active", "b", &active);
|
2019-01-20 16:29:04 +00:00
|
|
|
gtk_application_set_screensaver_active (dbus->impl.application, active);
|
|
|
|
|
|
|
|
g_variant_lookup (state, "session-state", "u", &session_state);
|
|
|
|
if (session_state != dbus->session_state)
|
|
|
|
{
|
|
|
|
dbus->session_state = session_state;
|
|
|
|
|
|
|
|
/* Note that we'll only ever get here if we get a session-state,
|
|
|
|
* in which case, the interface is new enough to have QueryEndResponse.
|
|
|
|
*/
|
|
|
|
if (session_state == ENDING)
|
|
|
|
{
|
|
|
|
g_application_quit (G_APPLICATION (application));
|
|
|
|
}
|
|
|
|
else if (session_state == QUERY_END)
|
|
|
|
{
|
2019-01-22 01:45:15 +00:00
|
|
|
g_signal_emit_by_name (dbus->impl.application, "query-end");
|
|
|
|
|
2019-01-20 16:29:04 +00:00
|
|
|
g_dbus_proxy_call (dbus->inhibit_proxy,
|
|
|
|
"QueryEndResponse",
|
|
|
|
g_variant_new ("(o)", dbus->session_id),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
2018-08-30 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_monitor_cb (GObject *source,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GDBusProxy *proxy = G_DBUS_PROXY (source);
|
|
|
|
GError *error = NULL;
|
|
|
|
GVariant *ret = NULL;
|
|
|
|
|
|
|
|
ret = g_dbus_proxy_call_finish (proxy, result, &error);
|
|
|
|
if (ret == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Creating a portal monitor failed: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_variant_unref (ret);
|
|
|
|
}
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|
|
|
gboolean register_session)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
GError *error = NULL;
|
|
|
|
GVariant *res;
|
2014-12-19 04:20:43 +00:00
|
|
|
gboolean same_bus;
|
2016-07-03 21:22:14 +00:00
|
|
|
const char *bus_name;
|
|
|
|
const char *client_interface;
|
2019-03-20 19:04:51 +00:00
|
|
|
const char *client_id = GDK_PRIVATE_CALL (gdk_get_desktop_autostart_id) ();
|
2017-11-29 04:27:57 +00:00
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
dbus->session = g_application_get_dbus_connection (G_APPLICATION (impl->application));
|
|
|
|
|
|
|
|
if (!dbus->session)
|
2014-12-19 04:20:43 +00:00
|
|
|
goto out;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
dbus->application_id = g_application_get_application_id (G_APPLICATION (impl->application));
|
|
|
|
dbus->object_path = g_application_get_dbus_object_path (G_APPLICATION (impl->application));
|
|
|
|
dbus->unique_name = g_dbus_connection_get_unique_name (dbus->session);
|
|
|
|
|
2018-08-30 20:38:03 +00:00
|
|
|
if (gtk_should_use_portal ())
|
|
|
|
goto out;
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
g_debug ("Connecting to session manager");
|
|
|
|
|
2016-06-28 08:56:35 +00:00
|
|
|
/* Try the GNOME session manager first */
|
|
|
|
dbus->sm_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
|
2016-07-25 13:11:21 +00:00
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
2016-06-28 08:56:35 +00:00
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
|
|
|
GNOME_DBUS_NAME,
|
|
|
|
GNOME_DBUS_OBJECT_PATH,
|
|
|
|
GNOME_DBUS_INTERFACE,
|
|
|
|
&error);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2016-12-15 22:09:49 +00:00
|
|
|
g_debug ("Failed to get the GNOME session proxy: %s", error->message);
|
2016-06-28 08:56:35 +00:00
|
|
|
g_clear_error (&error);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
2016-07-03 21:22:14 +00:00
|
|
|
if (!dbus->sm_proxy)
|
2016-06-28 08:56:35 +00:00
|
|
|
{
|
|
|
|
/* Fallback to trying the Xfce session manager */
|
|
|
|
dbus->sm_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
|
2016-07-25 13:11:21 +00:00
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
2016-06-28 08:56:35 +00:00
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
|
|
|
XFCE_DBUS_NAME,
|
|
|
|
XFCE_DBUS_OBJECT_PATH,
|
|
|
|
XFCE_DBUS_INTERFACE,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2016-12-15 22:09:49 +00:00
|
|
|
g_debug ("Failed to get the Xfce session proxy: %s", error->message);
|
2016-06-28 08:56:35 +00:00
|
|
|
g_clear_error (&error);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
if (!register_session)
|
2014-12-19 04:20:43 +00:00
|
|
|
goto out;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2018-08-30 05:06:51 +00:00
|
|
|
dbus->ss_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
|
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
|
|
|
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
GNOME_SCREENSAVER_DBUS_NAME,
|
|
|
|
GNOME_SCREENSAVER_DBUS_OBJECT_PATH,
|
|
|
|
GNOME_SCREENSAVER_DBUS_INTERFACE,
|
|
|
|
&error);
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_debug ("Failed to get the GNOME screensaver proxy: %s", error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
g_clear_object (&dbus->ss_proxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dbus->ss_proxy)
|
|
|
|
{
|
2019-09-06 13:59:07 +00:00
|
|
|
GVariant *active_var;
|
|
|
|
gboolean active;
|
|
|
|
|
2018-08-30 05:06:51 +00:00
|
|
|
g_signal_connect (dbus->ss_proxy, "g-signal",
|
|
|
|
G_CALLBACK (screensaver_signal_session), impl->application);
|
2019-09-06 13:59:07 +00:00
|
|
|
|
|
|
|
active_var = g_dbus_proxy_call_sync (dbus->ss_proxy,
|
|
|
|
"GetActive",
|
|
|
|
NULL,
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
if (!active_var)
|
|
|
|
{
|
|
|
|
g_debug ("Error calling GetActive on GNOME screensaver: %s",
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_variant_get (active_var, "(b)", &active);
|
|
|
|
g_variant_unref (active_var);
|
|
|
|
gtk_application_set_screensaver_active (dbus->impl.application, active);
|
|
|
|
}
|
2018-08-30 05:06:51 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 16:10:18 +00:00
|
|
|
g_debug ("Registering client '%s' '%s'", dbus->application_id, client_id);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
res = g_dbus_proxy_call_sync (dbus->sm_proxy,
|
|
|
|
"RegisterClient",
|
2016-03-04 16:10:18 +00:00
|
|
|
g_variant_new ("(ss)", dbus->application_id, client_id),
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("Failed to register client: %s", error->message);
|
2016-07-02 01:19:12 +00:00
|
|
|
g_clear_error (&error);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
g_clear_object (&dbus->sm_proxy);
|
2014-12-19 04:20:43 +00:00
|
|
|
goto out;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_variant_get (res, "(o)", &dbus->client_path);
|
|
|
|
g_variant_unref (res);
|
|
|
|
|
|
|
|
g_debug ("Registered client at '%s'", dbus->client_path);
|
|
|
|
|
2016-07-03 21:22:14 +00:00
|
|
|
if (g_str_equal (g_dbus_proxy_get_name (dbus->sm_proxy), GNOME_DBUS_NAME))
|
|
|
|
{
|
|
|
|
bus_name = GNOME_DBUS_NAME;
|
|
|
|
client_interface = GNOME_DBUS_CLIENT_INTERFACE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bus_name = XFCE_DBUS_NAME;
|
|
|
|
client_interface = XFCE_DBUS_CLIENT_INTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus->client_proxy = g_dbus_proxy_new_sync (dbus->session, 0,
|
|
|
|
NULL,
|
|
|
|
bus_name,
|
|
|
|
dbus->client_path,
|
|
|
|
client_interface,
|
|
|
|
NULL,
|
|
|
|
&error);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
if (error)
|
|
|
|
{
|
2016-07-02 01:19:12 +00:00
|
|
|
g_warning ("Failed to get client proxy: %s", error->message);
|
2016-06-28 08:56:35 +00:00
|
|
|
g_clear_error (&error);
|
2016-07-02 01:19:12 +00:00
|
|
|
g_free (dbus->client_path);
|
|
|
|
dbus->client_path = NULL;
|
2014-12-19 04:20:43 +00:00
|
|
|
goto out;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_connect (dbus->client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), dbus);
|
2014-12-19 04:20:43 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
same_bus = FALSE;
|
|
|
|
|
|
|
|
if (dbus->session)
|
|
|
|
{
|
|
|
|
const gchar *id;
|
|
|
|
const gchar *id2;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
g_value_init (&value, G_TYPE_STRING);
|
|
|
|
gdk_screen_get_setting (gdk_screen_get_default (), "gtk-session-bus-id", &value);
|
|
|
|
id = g_value_get_string (&value);
|
|
|
|
|
|
|
|
if (id && id[0])
|
|
|
|
{
|
|
|
|
res = g_dbus_connection_call_sync (dbus->session,
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
"GetId",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
-1,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
g_variant_get (res, "(&s)", &id2);
|
|
|
|
|
|
|
|
if (g_strcmp0 (id, id2) == 0)
|
|
|
|
same_bus = TRUE;
|
|
|
|
|
|
|
|
g_variant_unref (res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
same_bus = TRUE;
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!same_bus)
|
|
|
|
g_object_set (gtk_settings_get_default (),
|
|
|
|
"gtk-shell-shows-app-menu", FALSE,
|
|
|
|
"gtk-shell-shows-menubar", FALSE,
|
|
|
|
NULL);
|
2016-07-02 01:19:12 +00:00
|
|
|
|
2019-01-03 01:35:19 +00:00
|
|
|
if (dbus->sm_proxy == NULL && dbus->session)
|
2016-07-02 01:19:12 +00:00
|
|
|
{
|
2016-07-25 13:11:21 +00:00
|
|
|
dbus->inhibit_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
|
2016-08-24 14:54:00 +00:00
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
2016-07-25 13:11:21 +00:00
|
|
|
"org.freedesktop.portal.Desktop",
|
|
|
|
"/org/freedesktop/portal/desktop",
|
|
|
|
"org.freedesktop.portal.Inhibit",
|
|
|
|
&error);
|
2016-07-02 01:19:12 +00:00
|
|
|
if (error)
|
|
|
|
{
|
2016-12-15 22:09:49 +00:00
|
|
|
g_debug ("Failed to get an inhibit portal proxy: %s", error->message);
|
2016-07-02 01:19:12 +00:00
|
|
|
g_clear_error (&error);
|
2018-08-30 05:06:51 +00:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (register_session)
|
|
|
|
{
|
|
|
|
char *token;
|
|
|
|
GVariantBuilder opt_builder;
|
|
|
|
|
|
|
|
/* Monitor screensaver state */
|
|
|
|
|
|
|
|
dbus->session_id = gtk_get_portal_session_path (dbus->session, &token);
|
|
|
|
dbus->state_changed_handler =
|
|
|
|
g_dbus_connection_signal_subscribe (dbus->session,
|
|
|
|
"org.freedesktop.portal.Desktop",
|
|
|
|
"org.freedesktop.portal.Inhibit",
|
|
|
|
"StateChanged",
|
|
|
|
"/org/freedesktop/portal/desktop",
|
|
|
|
NULL,
|
|
|
|
G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE,
|
|
|
|
screensaver_signal_portal,
|
2019-01-20 16:29:04 +00:00
|
|
|
dbus,
|
2018-08-30 05:06:51 +00:00
|
|
|
NULL);
|
|
|
|
g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
|
|
|
|
g_variant_builder_add (&opt_builder, "{sv}",
|
|
|
|
"session_handle_token", g_variant_new_string (token));
|
|
|
|
g_dbus_proxy_call (dbus->inhibit_proxy,
|
|
|
|
"CreateMonitor",
|
|
|
|
g_variant_new ("(sa{sv})", "", &opt_builder),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
create_monitor_cb, dbus);
|
|
|
|
g_free (token);
|
2016-07-02 01:19:12 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-30 05:06:51 +00:00
|
|
|
|
|
|
|
end:;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_shutdown (GtkApplicationImpl *impl)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-06 01:21:49 +00:00
|
|
|
GQuark gtk_application_impl_dbus_export_id_quark (void);
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
G_DEFINE_QUARK (GtkApplicationImplDBus export id, gtk_application_impl_dbus_export_id)
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_window_added (GtkApplicationImpl *impl,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
GActionGroup *actions;
|
|
|
|
gchar *path;
|
|
|
|
guint id;
|
|
|
|
|
|
|
|
if (!dbus->session || !GTK_IS_APPLICATION_WINDOW (window))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Export the action group of this window, based on its id */
|
|
|
|
actions = gtk_application_window_get_action_group (GTK_APPLICATION_WINDOW (window));
|
|
|
|
|
|
|
|
path = gtk_application_impl_dbus_get_window_path (dbus, window);
|
|
|
|
id = g_dbus_connection_export_action_group (dbus->session, path, actions, NULL);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
g_object_set_qdata (G_OBJECT (window), gtk_application_impl_dbus_export_id_quark (), GUINT_TO_POINTER (id));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_window_removed (GtkApplicationImpl *impl,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
guint id;
|
|
|
|
|
|
|
|
id = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window), gtk_application_impl_dbus_export_id_quark ()));
|
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
g_dbus_connection_unexport_action_group (dbus->session, id);
|
|
|
|
g_object_set_qdata (G_OBJECT (window), gtk_application_impl_dbus_export_id_quark (), NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_active_window_changed (GtkApplicationImpl *impl,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_publish_menu (GtkApplicationImplDBus *dbus,
|
|
|
|
const gchar *type,
|
|
|
|
GMenuModel *model,
|
|
|
|
guint *id,
|
|
|
|
gchar **path)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (dbus->session == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* unexport any existing menu */
|
|
|
|
if (*id)
|
|
|
|
{
|
|
|
|
g_dbus_connection_unexport_menu_model (dbus->session, *id);
|
|
|
|
g_free (*path);
|
|
|
|
*path = NULL;
|
|
|
|
*id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* export the new menu, if there is one */
|
|
|
|
if (model != NULL)
|
|
|
|
{
|
|
|
|
/* try getting the preferred name */
|
|
|
|
*path = g_strconcat (dbus->object_path, "/menus/", type, NULL);
|
|
|
|
*id = g_dbus_connection_export_menu_model (dbus->session, *path, model, NULL);
|
|
|
|
|
|
|
|
/* keep trying until we get a working name... */
|
|
|
|
for (i = 0; *id == 0; i++)
|
|
|
|
{
|
|
|
|
g_free (*path);
|
|
|
|
*path = g_strdup_printf ("%s/menus/%s%d", dbus->object_path, type, i);
|
|
|
|
*id = g_dbus_connection_export_menu_model (dbus->session, *path, model, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_set_app_menu (GtkApplicationImpl *impl,
|
|
|
|
GMenuModel *app_menu)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
|
|
|
|
gtk_application_impl_dbus_publish_menu (dbus, "appmenu", app_menu, &dbus->app_menu_id, &dbus->app_menu_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_set_menubar (GtkApplicationImpl *impl,
|
|
|
|
GMenuModel *menubar)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
|
|
|
|
gtk_application_impl_dbus_publish_menu (dbus, "menubar", menubar, &dbus->menubar_id, &dbus->menubar_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
gtk_application_impl_dbus_real_get_window_system_id (GtkApplicationImplDBus *dbus,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
return g_variant_new_uint32 (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* returns floating */
|
|
|
|
static GVariant *
|
|
|
|
gtk_application_impl_dbus_get_window_system_id (GtkApplicationImplDBus *dbus,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
return GTK_APPLICATION_IMPL_DBUS_GET_CLASS (dbus)->get_window_system_id (dbus, window);
|
|
|
|
}
|
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
static int next_cookie;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *handle;
|
|
|
|
int cookie;
|
|
|
|
} InhibitHandle;
|
|
|
|
|
|
|
|
static void
|
|
|
|
inhibit_handle_free (gpointer data)
|
|
|
|
{
|
|
|
|
InhibitHandle *handle = data;
|
|
|
|
|
|
|
|
g_free (handle->handle);
|
|
|
|
g_free (handle);
|
|
|
|
}
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
static guint
|
|
|
|
gtk_application_impl_dbus_inhibit (GtkApplicationImpl *impl,
|
|
|
|
GtkWindow *window,
|
|
|
|
GtkApplicationInhibitFlags flags,
|
|
|
|
const gchar *reason)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
GVariant *res;
|
|
|
|
GError *error = NULL;
|
|
|
|
guint cookie;
|
2014-11-03 05:48:42 +00:00
|
|
|
static gboolean warned = FALSE;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
if (dbus->sm_proxy)
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
{
|
2016-07-02 01:19:12 +00:00
|
|
|
res = g_dbus_proxy_call_sync (dbus->sm_proxy,
|
|
|
|
"Inhibit",
|
|
|
|
g_variant_new ("(s@usu)",
|
|
|
|
dbus->application_id,
|
|
|
|
window ? gtk_application_impl_dbus_get_window_system_id (dbus, window) : g_variant_new_uint32 (0),
|
2018-09-14 03:28:16 +00:00
|
|
|
reason ? reason : "",
|
2016-07-02 01:19:12 +00:00
|
|
|
flags),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
|
|
|
|
if (res)
|
2014-11-03 05:48:42 +00:00
|
|
|
{
|
2016-07-02 01:19:12 +00:00
|
|
|
g_variant_get (res, "(u)", &cookie);
|
|
|
|
g_variant_unref (res);
|
|
|
|
return cookie;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
if (!warned)
|
|
|
|
{
|
|
|
|
g_warning ("Calling %s.Inhibit failed: %s",
|
|
|
|
g_dbus_proxy_get_interface_name (dbus->sm_proxy),
|
|
|
|
error->message);
|
|
|
|
warned = TRUE;
|
|
|
|
}
|
|
|
|
g_clear_error (&error);
|
2014-11-03 05:48:42 +00:00
|
|
|
}
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
2016-07-02 01:19:12 +00:00
|
|
|
else if (dbus->inhibit_proxy)
|
|
|
|
{
|
|
|
|
GVariantBuilder options;
|
|
|
|
|
|
|
|
g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
|
|
|
|
g_variant_builder_add (&options, "{sv}", "reason", g_variant_new_string (reason));
|
|
|
|
res = g_dbus_proxy_call_sync (dbus->inhibit_proxy,
|
|
|
|
"Inhibit",
|
|
|
|
g_variant_new ("(su@a{sv})",
|
|
|
|
"", /* window */
|
|
|
|
flags,
|
|
|
|
g_variant_builder_end (&options)),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
InhibitHandle *handle;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
handle = g_new (InhibitHandle, 1);
|
|
|
|
handle->cookie = ++next_cookie;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
g_variant_get (res, "(o)", &handle->handle);
|
|
|
|
g_variant_unref (res);
|
|
|
|
|
|
|
|
dbus->inhibit_handles = g_slist_prepend (dbus->inhibit_handles, handle);
|
|
|
|
|
|
|
|
return handle->cookie;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
if (!warned)
|
|
|
|
{
|
|
|
|
g_warning ("Calling %s.Inhibit failed: %s",
|
|
|
|
g_dbus_proxy_get_interface_name (dbus->inhibit_proxy),
|
|
|
|
error->message);
|
|
|
|
warned = TRUE;
|
|
|
|
}
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
}
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
return 0;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_uninhibit (GtkApplicationImpl *impl,
|
|
|
|
guint cookie)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
if (dbus->sm_proxy)
|
|
|
|
{
|
|
|
|
g_dbus_proxy_call (dbus->sm_proxy,
|
|
|
|
"Uninhibit",
|
|
|
|
g_variant_new ("(u)", cookie),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
else if (dbus->inhibit_proxy)
|
|
|
|
{
|
|
|
|
GSList *l;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
for (l = dbus->inhibit_handles; l; l = l->next)
|
|
|
|
{
|
|
|
|
InhibitHandle *handle = l->data;
|
|
|
|
if (handle->cookie == cookie)
|
|
|
|
{
|
|
|
|
g_dbus_connection_call (dbus->session,
|
|
|
|
"org.freedesktop.portal.Desktop",
|
|
|
|
handle->handle,
|
|
|
|
"org.freedesktop.portal.Request",
|
|
|
|
"Close",
|
|
|
|
g_variant_new ("()"),
|
|
|
|
G_VARIANT_TYPE_UNIT,
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
dbus->inhibit_handles = g_slist_remove (dbus->inhibit_handles, handle);
|
|
|
|
inhibit_handle_free (handle);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl *impl,
|
|
|
|
GtkApplicationInhibitFlags flags)
|
|
|
|
{
|
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
|
|
|
GVariant *res;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean inhibited;
|
2014-11-03 05:48:42 +00:00
|
|
|
static gboolean warned = FALSE;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
if (dbus->sm_proxy == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
res = g_dbus_proxy_call_sync (dbus->sm_proxy,
|
|
|
|
"IsInhibited",
|
|
|
|
g_variant_new ("(u)", flags),
|
|
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
|
|
G_MAXINT,
|
|
|
|
NULL,
|
|
|
|
&error);
|
|
|
|
if (error)
|
|
|
|
{
|
2014-11-03 05:48:42 +00:00
|
|
|
if (!warned)
|
|
|
|
{
|
2016-07-02 01:19:12 +00:00
|
|
|
g_warning ("Calling %s.IsInhibited failed: %s",
|
|
|
|
g_dbus_proxy_get_interface_name (dbus->sm_proxy),
|
|
|
|
error->message);
|
2014-11-03 05:48:42 +00:00
|
|
|
warned = TRUE;
|
|
|
|
}
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
g_error_free (error);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_variant_get (res, "(b)", &inhibited);
|
|
|
|
g_variant_unref (res);
|
|
|
|
|
|
|
|
return inhibited;
|
|
|
|
}
|
|
|
|
|
2014-06-30 16:16:19 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_application_impl_dbus_prefers_app_menu (GtkApplicationImpl *impl)
|
|
|
|
{
|
|
|
|
static gboolean decided;
|
|
|
|
static gboolean result;
|
|
|
|
|
|
|
|
/* We do not support notifying if/when the result changes, so make
|
|
|
|
* sure that once we give an answer, we will always give the same one.
|
|
|
|
*/
|
|
|
|
if (!decided)
|
|
|
|
{
|
|
|
|
GtkSettings *gtk_settings;
|
|
|
|
gboolean show_app_menu;
|
|
|
|
gboolean show_menubar;
|
|
|
|
|
|
|
|
gtk_settings = gtk_settings_get_default ();
|
|
|
|
g_object_get (G_OBJECT (gtk_settings),
|
|
|
|
"gtk-shell-shows-app-menu", &show_app_menu,
|
|
|
|
"gtk-shell-shows-menubar", &show_menubar,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* We prefer traditional menus when we have a shell that doesn't
|
|
|
|
* show the appmenu or we have a shell that shows menubars
|
|
|
|
* (ie: Unity)
|
|
|
|
*/
|
|
|
|
result = show_app_menu && !show_menubar;
|
|
|
|
decided = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_init (GtkApplicationImplDBus *dbus)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_finalize (GObject *object)
|
|
|
|
{
|
2014-03-30 09:57:23 +00:00
|
|
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) object;
|
|
|
|
|
2018-09-05 19:46:28 +00:00
|
|
|
if (dbus->session_id)
|
|
|
|
{
|
|
|
|
g_dbus_connection_call (dbus->session,
|
|
|
|
"org.freedesktop.portal.Desktop",
|
|
|
|
dbus->session_id,
|
|
|
|
"org.freedesktop.portal.Session",
|
|
|
|
"Close",
|
|
|
|
NULL, NULL, 0, -1, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
g_free (dbus->session_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dbus->state_changed_handler)
|
|
|
|
g_dbus_connection_signal_unsubscribe (dbus->session,
|
|
|
|
dbus->state_changed_handler);
|
|
|
|
|
2016-07-02 01:19:12 +00:00
|
|
|
g_clear_object (&dbus->inhibit_proxy);
|
|
|
|
g_slist_free_full (dbus->inhibit_handles, inhibit_handle_free);
|
2014-03-30 09:57:23 +00:00
|
|
|
g_free (dbus->app_menu_path);
|
|
|
|
g_free (dbus->menubar_path);
|
2016-07-25 13:11:21 +00:00
|
|
|
g_clear_object (&dbus->sm_proxy);
|
2018-08-30 05:06:51 +00:00
|
|
|
g_clear_object (&dbus->ss_proxy);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_application_impl_dbus_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_dbus_class_init (GtkApplicationImplDBusClass *class)
|
|
|
|
{
|
|
|
|
GtkApplicationImplClass *impl_class = GTK_APPLICATION_IMPL_CLASS (class);
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
class->get_window_system_id = gtk_application_impl_dbus_real_get_window_system_id;
|
|
|
|
|
|
|
|
impl_class->startup = gtk_application_impl_dbus_startup;
|
|
|
|
impl_class->shutdown = gtk_application_impl_dbus_shutdown;
|
|
|
|
impl_class->window_added = gtk_application_impl_dbus_window_added;
|
|
|
|
impl_class->window_removed = gtk_application_impl_dbus_window_removed;
|
|
|
|
impl_class->active_window_changed = gtk_application_impl_dbus_active_window_changed;
|
|
|
|
impl_class->set_app_menu = gtk_application_impl_dbus_set_app_menu;
|
|
|
|
impl_class->set_menubar = gtk_application_impl_dbus_set_menubar;
|
|
|
|
impl_class->inhibit = gtk_application_impl_dbus_inhibit;
|
|
|
|
impl_class->uninhibit = gtk_application_impl_dbus_uninhibit;
|
|
|
|
impl_class->is_inhibited = gtk_application_impl_dbus_is_inhibited;
|
2014-06-30 16:16:19 +00:00
|
|
|
impl_class->prefers_app_menu = gtk_application_impl_dbus_prefers_app_menu;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
gobject_class->finalize = gtk_application_impl_dbus_finalize;
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
gtk_application_impl_dbus_get_window_path (GtkApplicationImplDBus *dbus,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
if (dbus->session && GTK_IS_APPLICATION_WINDOW (window))
|
|
|
|
return g_strdup_printf ("%s/window/%d",
|
|
|
|
dbus->object_path,
|
|
|
|
gtk_application_window_get_id (GTK_APPLICATION_WINDOW (window)));
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|