#include "giomodule-priv.h"
#include "gnotification-private.h"
#include "gdbusconnection.h"
+#include "gactiongroup.h"
#include "gaction.h"
#include "gfileicon.h"
#include "gfile.h"
return NULL;
}
+static void
+activate_action (GFdoNotificationBackend *backend,
+ const gchar *name,
+ GVariant *parameter)
+{
+ GNotificationBackend *g_backend = G_NOTIFICATION_BACKEND (backend);
+
+ if (name)
+ {
+ if (g_str_has_prefix (name, "app."))
+ g_action_group_activate_action (G_ACTION_GROUP (g_backend->application), name + 4, parameter);
+ }
+ else
+ {
+ g_application_activate (g_backend->application);
+ }
+}
+
static void
notify_signal (GDBusConnection *connection,
const gchar *sender_name,
{
if (g_str_equal (action, "default"))
{
- g_notification_backend_activate_action (G_NOTIFICATION_BACKEND (backend),
- n->default_action,
- n->default_action_target);
+ activate_action (backend, n->default_action, n->default_action_target);
}
else
{
if (g_action_parse_detailed_name (action, &name, &target, NULL))
{
- g_notification_backend_activate_action (G_NOTIFICATION_BACKEND (backend), name, target);
+ activate_action (backend, name, target);
g_free (name);
if (target)
g_variant_unref (target);
{
GDBusConnection *session_bus;
- session_bus = g_notification_backend_get_dbus_connection (G_NOTIFICATION_BACKEND (backend));
+ session_bus = G_NOTIFICATION_BACKEND (backend)->dbus_connection;
g_dbus_connection_signal_unsubscribe (session_bus, backend->notify_subscription);
backend->notify_subscription = 0;
}
if (self->notify_subscription == 0)
{
self->notify_subscription =
- g_dbus_connection_signal_subscribe (g_notification_backend_get_dbus_connection (backend),
+ g_dbus_connection_signal_subscribe (backend->dbus_connection,
"org.freedesktop.Notifications",
"org.freedesktop.Notifications", NULL,
"/org/freedesktop/Notifications", NULL,
g_notification_get_default_action (notification, &n->default_action, &n->default_action_target);
- call_notify (g_notification_backend_get_dbus_connection (backend),
- g_notification_backend_get_application (backend),
- n->notify_id, notification, notification_sent, n);
+ call_notify (backend->dbus_connection, backend->application, n->notify_id, notification, notification_sent, n);
}
static void
{
if (n->notify_id > 0)
{
- g_dbus_connection_call (g_notification_backend_get_dbus_connection (backend),
+ g_dbus_connection_call (backend->dbus_connection,
"org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications", "CloseNotification",
const gchar *id,
GNotification *notification)
{
- GApplication *application;
GVariant *params;
- application = g_notification_backend_get_application (backend);
-
- params = g_variant_new ("(ss@a{sv})", g_application_get_application_id (application),
+ params = g_variant_new ("(ss@a{sv})", g_application_get_application_id (backend->application),
id,
g_notification_serialize (notification));
- g_dbus_connection_call (g_notification_backend_get_dbus_connection (backend),
+ g_dbus_connection_call (backend->dbus_connection,
"org.gtk.Notifications", "/org/gtk/Notifications",
"org.gtk.Notifications", "AddNotification", params,
G_VARIANT_TYPE_UNIT,
const gchar *id)
{
GGtkNotificationBackend *self = G_GTK_NOTIFICATION_BACKEND (backend);
- GApplication *application;
GVariant *params;
- application = g_notification_backend_get_application (backend);
-
- params = g_variant_new ("(ss)", g_application_get_application_id (application), id);
+ params = g_variant_new ("(ss)", g_application_get_application_id (backend->application), id);
g_dbus_connection_call (self->session_bus, "org.gtk.Notifications",
"/org/gtk/Notifications", "org.gtk.Notifications",
G_NOTIFICATION_BACKEND_GET_CLASS (backend)->withdraw_notification (backend, id);
}
-
-GApplication *
-g_notification_backend_get_application (GNotificationBackend *backend)
-{
- g_return_val_if_fail (G_IS_NOTIFICATION_BACKEND (backend), NULL);
-
- return backend->application;
-}
-
-void
-g_notification_backend_activate_action (GNotificationBackend *backend,
- const gchar *name,
- GVariant *parameter)
-{
- g_return_if_fail (G_IS_NOTIFICATION_BACKEND (backend));
-
- if (name)
- {
- if (g_str_has_prefix (name, "app."))
- g_action_group_activate_action (G_ACTION_GROUP (backend->application), name + 4, parameter);
- }
- else
- {
- g_application_activate (backend->application);
- }
-}
-
-GDBusConnection *
-g_notification_backend_get_dbus_connection (GNotificationBackend *backend)
-{
- g_return_val_if_fail (G_IS_NOTIFICATION_BACKEND (backend), NULL);
-
- return backend->dbus_connection;
-}