mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-06 10:50:08 +00:00
GtkApplication: Add support for the Xfce session manager
Xfce4-session-manager added support for managing dbus based clients. This patch adds support for checking if Xfce session manager is around after trying the gnome one. https://bugzilla.gnome.org/show_bug.cgi?id=693203
This commit is contained in:
parent
22b6df025e
commit
3c7cd7ac23
@ -27,6 +27,14 @@
|
|||||||
|
|
||||||
G_DEFINE_TYPE (GtkApplicationImplDBus, gtk_application_impl_dbus, GTK_TYPE_APPLICATION_IMPL)
|
G_DEFINE_TYPE (GtkApplicationImplDBus, gtk_application_impl_dbus, GTK_TYPE_APPLICATION_IMPL)
|
||||||
|
|
||||||
|
#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"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unregister_client (GtkApplicationImplDBus *dbus)
|
unregister_client (GtkApplicationImplDBus *dbus)
|
||||||
@ -103,6 +111,45 @@ client_proxy_signal (GDBusProxy *proxy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
g_return_val_if_fail (connection != NULL, NULL);
|
||||||
|
g_return_val_if_fail (bus_name != NULL, NULL);
|
||||||
|
g_return_val_if_fail (object_path != NULL, NULL);
|
||||||
|
g_return_val_if_fail (interface != NULL, NULL);
|
||||||
|
|
||||||
|
proxy = g_dbus_proxy_new_sync (connection,
|
||||||
|
flags,
|
||||||
|
NULL,
|
||||||
|
bus_name,
|
||||||
|
object_path,
|
||||||
|
interface,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
|
/* is there anyone actually providing the service? */
|
||||||
|
owner = g_dbus_proxy_get_name_owner (proxy);
|
||||||
|
if (owner == NULL)
|
||||||
|
{
|
||||||
|
g_clear_object (&proxy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_free (owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
||||||
gboolean register_session)
|
gboolean register_session)
|
||||||
@ -136,23 +183,42 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|||||||
|
|
||||||
g_debug ("Connecting to session manager");
|
g_debug ("Connecting to session manager");
|
||||||
|
|
||||||
dbus->sm_proxy = g_dbus_proxy_new_sync (dbus->session,
|
/* Try the GNOME session manager first */
|
||||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
dbus->sm_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
|
||||||
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
||||||
NULL,
|
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
||||||
"org.gnome.SessionManager",
|
GNOME_DBUS_NAME,
|
||||||
"/org/gnome/SessionManager",
|
GNOME_DBUS_OBJECT_PATH,
|
||||||
"org.gnome.SessionManager",
|
GNOME_DBUS_INTERFACE,
|
||||||
NULL,
|
&error);
|
||||||
&error);
|
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
g_warning ("Failed to get a session proxy: %s", error->message);
|
g_warning ("Failed to get the GNOME session proxy: %s", error->message);
|
||||||
g_error_free (error);
|
g_clear_error (&error);
|
||||||
|
g_clear_object (&dbus->sm_proxy);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!dbus->sm_proxy)
|
||||||
|
{
|
||||||
|
/* Fallback to trying the Xfce session manager */
|
||||||
|
dbus->sm_proxy = gtk_application_get_proxy_if_service_present (dbus->session,
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
g_warning ("Failed to get the Xfce session proxy: %s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!register_session)
|
if (!register_session)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -179,23 +245,37 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|||||||
|
|
||||||
g_debug ("Registered client at '%s'", dbus->client_path);
|
g_debug ("Registered client at '%s'", dbus->client_path);
|
||||||
|
|
||||||
dbus->client_proxy = g_dbus_proxy_new_sync (dbus->session, 0,
|
/* Try the GNOME client interface */
|
||||||
NULL,
|
dbus->client_proxy = gtk_application_get_proxy_if_service_present (dbus->session, 0,
|
||||||
"org.gnome.SessionManager",
|
GNOME_DBUS_NAME,
|
||||||
dbus->client_path,
|
dbus->client_path,
|
||||||
"org.gnome.SessionManager.ClientPrivate",
|
GNOME_DBUS_CLIENT_INTERFACE,
|
||||||
NULL,
|
&error);
|
||||||
&error);
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
g_warning ("Failed to get client proxy: %s", error->message);
|
g_warning ("Failed to connect to the GNOME client proxy: %s", error->message);
|
||||||
g_error_free (error);
|
g_clear_error (&error);
|
||||||
g_clear_object (&dbus->sm_proxy);
|
|
||||||
g_free (dbus->client_path);
|
|
||||||
dbus->client_path = NULL;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!dbus->client_proxy)
|
||||||
|
{
|
||||||
|
/* Fallback to trying the Xfce client interface */
|
||||||
|
dbus->client_proxy = gtk_application_get_proxy_if_service_present (dbus->session, 0,
|
||||||
|
XFCE_DBUS_NAME,
|
||||||
|
dbus->client_path,
|
||||||
|
XFCE_DBUS_CLIENT_INTERFACE,
|
||||||
|
&error);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
g_warning ("Failed to connect to the Xfce client proxy: %s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
g_free (dbus->client_path);
|
||||||
|
dbus->client_path = NULL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (dbus->client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), dbus);
|
g_signal_connect (dbus->client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), dbus);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
Loading…
Reference in New Issue
Block a user