lazily start the daemon
notify_init() caused the daemon to be D-Bus activated already, even if the program that calls it doesn't send an actual notification for a long time (or potentially not at all). In order to optimize desktop startup speed, and to avoid unnecessary processes, launch the daemon on demand only. https://bugzilla.gnome.org/show_bug.cgi?id=610880
This commit is contained in:
parent
3de71571ea
commit
3dc04fac90
|
@ -77,9 +77,6 @@ _notify_update_spec_version (void)
|
||||||
gboolean
|
gboolean
|
||||||
notify_init (const char *app_name)
|
notify_init (const char *app_name)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
|
||||||
DBusGConnection *bus = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (app_name != NULL, FALSE);
|
g_return_val_if_fail (app_name != NULL, FALSE);
|
||||||
g_return_val_if_fail (*app_name != '\0', FALSE);
|
g_return_val_if_fail (*app_name != '\0', FALSE);
|
||||||
|
|
||||||
|
@ -90,46 +87,6 @@ notify_init (const char *app_name)
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
|
|
||||||
|
|
||||||
if (error != NULL) {
|
|
||||||
g_message ("Unable to get session bus: %s", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_proxy = dbus_g_proxy_new_for_name (bus,
|
|
||||||
NOTIFY_DBUS_NAME,
|
|
||||||
NOTIFY_DBUS_CORE_OBJECT,
|
|
||||||
NOTIFY_DBUS_CORE_INTERFACE);
|
|
||||||
dbus_g_connection_unref (bus);
|
|
||||||
|
|
||||||
dbus_g_object_register_marshaller (notify_marshal_VOID__UINT_UINT,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_UINT, G_TYPE_INVALID);
|
|
||||||
|
|
||||||
dbus_g_object_register_marshaller (notify_marshal_VOID__UINT_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_STRING, G_TYPE_INVALID);
|
|
||||||
|
|
||||||
dbus_g_proxy_add_signal (_proxy,
|
|
||||||
"NotificationClosed",
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_INVALID);
|
|
||||||
dbus_g_proxy_add_signal (_proxy,
|
|
||||||
"ActionInvoked",
|
|
||||||
G_TYPE_UINT,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_INVALID);
|
|
||||||
|
|
||||||
if (!_notify_update_spec_version ()) {
|
|
||||||
g_message ("Error getting spec version");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_initted = TRUE;
|
_initted = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -205,6 +162,53 @@ _notify_get_dbus_g_conn (void)
|
||||||
DBusGProxy *
|
DBusGProxy *
|
||||||
_notify_get_g_proxy (void)
|
_notify_get_g_proxy (void)
|
||||||
{
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
DBusGConnection *bus = NULL;
|
||||||
|
|
||||||
|
if (_proxy != NULL)
|
||||||
|
return _proxy;
|
||||||
|
|
||||||
|
/* lazily initialize D-Bus connection */
|
||||||
|
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
|
||||||
|
|
||||||
|
if (error != NULL) {
|
||||||
|
g_message ("Unable to get session bus: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_proxy = dbus_g_proxy_new_for_name (bus,
|
||||||
|
NOTIFY_DBUS_NAME,
|
||||||
|
NOTIFY_DBUS_CORE_OBJECT,
|
||||||
|
NOTIFY_DBUS_CORE_INTERFACE);
|
||||||
|
dbus_g_connection_unref (bus);
|
||||||
|
|
||||||
|
dbus_g_object_register_marshaller (notify_marshal_VOID__UINT_UINT,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
G_TYPE_UINT,
|
||||||
|
G_TYPE_UINT, G_TYPE_INVALID);
|
||||||
|
|
||||||
|
dbus_g_object_register_marshaller (notify_marshal_VOID__UINT_STRING,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
G_TYPE_UINT,
|
||||||
|
G_TYPE_STRING, G_TYPE_INVALID);
|
||||||
|
|
||||||
|
dbus_g_proxy_add_signal (_proxy,
|
||||||
|
"NotificationClosed",
|
||||||
|
G_TYPE_UINT,
|
||||||
|
G_TYPE_UINT,
|
||||||
|
G_TYPE_INVALID);
|
||||||
|
dbus_g_proxy_add_signal (_proxy,
|
||||||
|
"ActionInvoked",
|
||||||
|
G_TYPE_UINT,
|
||||||
|
G_TYPE_STRING,
|
||||||
|
G_TYPE_INVALID);
|
||||||
|
|
||||||
|
if (!_notify_update_spec_version ()) {
|
||||||
|
g_message ("Error getting spec version");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return _proxy;
|
return _proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue