mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
GApplication: add accessor for DBus information
Provide public access to the GDBusConnect and object path that GApplication is using. Prevents others from having to guess these things for themselves based on the application ID. https://bugzilla.gnome.org/show_bug.cgi?id=671249
This commit is contained in:
parent
16f92a33ac
commit
eb5381b862
@ -2897,6 +2897,9 @@ g_application_set_inactivity_timeout
|
||||
g_application_get_flags
|
||||
g_application_set_flags
|
||||
<SUBSECTION>
|
||||
g_application_get_dbus_connection
|
||||
g_application_get_dbus_object_path
|
||||
<SUBSECTION>
|
||||
g_application_set_action_group
|
||||
<SUBSECTION>
|
||||
g_application_get_is_registered
|
||||
|
@ -1085,7 +1085,7 @@ g_application_set_inactivity_timeout (GApplication *application,
|
||||
g_object_notify (G_OBJECT (application), "inactivity-timeout");
|
||||
}
|
||||
}
|
||||
/* Read-only property getters (is registered, is remote) {{{1 */
|
||||
/* Read-only property getters (is registered, is remote, dbus stuff) {{{1 */
|
||||
/**
|
||||
* g_application_get_is_registered:
|
||||
* @application: a #GApplication
|
||||
@ -1135,6 +1135,69 @@ g_application_get_is_remote (GApplication *application)
|
||||
return application->priv->is_remote;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_application_get_dbus_connection:
|
||||
* @application: a #GApplication
|
||||
*
|
||||
* Gets the #GDBusConnection being used by the application, or %NULL.
|
||||
*
|
||||
* If #GApplication is using its D-Bus backend then this function will
|
||||
* return the #GDBusConnection being used for uniqueness and
|
||||
* communication with the desktop environment and other instances of the
|
||||
* application.
|
||||
*
|
||||
* If #GApplication is not using D-Bus then this function will return
|
||||
* %NULL. This includes the situation where the D-Bus backend would
|
||||
* normally be in use but we were unable to connect to the bus.
|
||||
*
|
||||
* This function must not be called before the application has been
|
||||
* registered. See g_application_get_is_registered().
|
||||
*
|
||||
* Returns: (transfer none): a #GDBusConnection, or %NULL
|
||||
*
|
||||
* Since: 2.34
|
||||
**/
|
||||
GDBusConnection *
|
||||
g_application_get_dbus_connection (GApplication *application)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
|
||||
g_return_val_if_fail (application->priv->is_registered, FALSE);
|
||||
|
||||
return g_application_impl_get_dbus_connection (application->priv->impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_application_get_dbus_object_path:
|
||||
* @application: a #GApplication
|
||||
*
|
||||
* Gets the D-Bus object path being used by the application, or %NULL.
|
||||
*
|
||||
* If #GApplication is using its D-Bus backend then this function will
|
||||
* return the D-Bus object path that #GApplication is using. If the
|
||||
* application is the primary instance then there is an object published
|
||||
* at this path. If the application is not the primary instance then
|
||||
* the result of this function is undefined.
|
||||
*
|
||||
* If #GApplication is not using D-Bus then this function will return
|
||||
* %NULL. This includes the situation where the D-Bus backend would
|
||||
* normally be in use but we were unable to connect to the bus.
|
||||
*
|
||||
* This function must not be called before the application has been
|
||||
* registered. See g_application_get_is_registered().
|
||||
*
|
||||
* Returns: the object path, or %NULL
|
||||
*
|
||||
* Since: 2.34
|
||||
**/
|
||||
const gchar *
|
||||
g_application_get_dbus_object_path (GApplication *application)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
|
||||
g_return_val_if_fail (application->priv->is_registered, FALSE);
|
||||
|
||||
return g_application_impl_get_dbus_object_path (application->priv->impl);
|
||||
}
|
||||
|
||||
/* Register {{{1 */
|
||||
/**
|
||||
* g_application_register:
|
||||
|
@ -105,6 +105,11 @@ const gchar * g_application_get_application_id (GApplic
|
||||
void g_application_set_application_id (GApplication *application,
|
||||
const gchar *application_id);
|
||||
|
||||
GLIB_AVAILABLE_IN_2_34
|
||||
GDBusConnection * g_application_get_dbus_connection (GApplication *application);
|
||||
GLIB_AVAILABLE_IN_2_34
|
||||
const gchar * g_application_get_dbus_object_path (GApplication *application);
|
||||
|
||||
guint g_application_get_inactivity_timeout (GApplication *application);
|
||||
void g_application_set_inactivity_timeout (GApplication *application,
|
||||
guint inactivity_timeout);
|
||||
|
@ -597,6 +597,17 @@ g_application_impl_flush (GApplicationImpl *impl)
|
||||
g_dbus_connection_flush_sync (impl->session_bus, NULL, NULL);
|
||||
}
|
||||
|
||||
GDBusConnection *
|
||||
g_application_impl_get_dbus_connection (GApplicationImpl *impl)
|
||||
{
|
||||
return impl->session_bus;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
g_application_impl_get_dbus_object_path (GApplicationImpl *impl)
|
||||
{
|
||||
return impl->object_path;
|
||||
}
|
||||
|
||||
/* GDBusCommandLine implementation {{{1 */
|
||||
|
||||
|
@ -41,3 +41,9 @@ int g_application_impl_command_line (GApplic
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void g_application_impl_flush (GApplicationImpl *impl);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GDBusConnection * g_application_impl_get_dbus_connection (GApplicationImpl *impl);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
const gchar * g_application_impl_get_dbus_object_path (GApplicationImpl *impl);
|
||||
|
@ -14,6 +14,8 @@ g_application_get_type
|
||||
g_application_activate
|
||||
g_application_flags_get_type
|
||||
g_application_get_application_id
|
||||
g_application_get_dbus_connection
|
||||
g_application_get_dbus_object_path
|
||||
g_application_get_default
|
||||
g_application_get_flags
|
||||
g_application_get_inactivity_timeout
|
||||
|
Loading…
Reference in New Issue
Block a user