mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
GNotification: some final cleanups
Move a method from GNotificationBackend into the fdo backend (since it was only used from here). Remove the accessors for the already-public (in private header) ->dbus_connect and ->application on GNotificationBackend. https://bugzilla.gnome.org/show_bug.cgi?id=688492
This commit is contained in:
parent
766f5584ce
commit
51fac60a92
@ -25,6 +25,7 @@
|
|||||||
#include "giomodule-priv.h"
|
#include "giomodule-priv.h"
|
||||||
#include "gnotification-private.h"
|
#include "gnotification-private.h"
|
||||||
#include "gdbusconnection.h"
|
#include "gdbusconnection.h"
|
||||||
|
#include "gactiongroup.h"
|
||||||
#include "gaction.h"
|
#include "gaction.h"
|
||||||
#include "gfileicon.h"
|
#include "gfileicon.h"
|
||||||
#include "gfile.h"
|
#include "gfile.h"
|
||||||
@ -106,6 +107,24 @@ g_fdo_notification_backend_find_notification_by_notify_id (GFdoNotificationBacke
|
|||||||
return NULL;
|
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
|
static void
|
||||||
notify_signal (GDBusConnection *connection,
|
notify_signal (GDBusConnection *connection,
|
||||||
const gchar *sender_name,
|
const gchar *sender_name,
|
||||||
@ -141,9 +160,7 @@ notify_signal (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
if (g_str_equal (action, "default"))
|
if (g_str_equal (action, "default"))
|
||||||
{
|
{
|
||||||
g_notification_backend_activate_action (G_NOTIFICATION_BACKEND (backend),
|
activate_action (backend, n->default_action, n->default_action_target);
|
||||||
n->default_action,
|
|
||||||
n->default_action_target);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -152,7 +169,7 @@ notify_signal (GDBusConnection *connection,
|
|||||||
|
|
||||||
if (g_action_parse_detailed_name (action, &name, &target, NULL))
|
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);
|
g_free (name);
|
||||||
if (target)
|
if (target)
|
||||||
g_variant_unref (target);
|
g_variant_unref (target);
|
||||||
@ -292,7 +309,7 @@ g_fdo_notification_backend_dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
GDBusConnection *session_bus;
|
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);
|
g_dbus_connection_signal_unsubscribe (session_bus, backend->notify_subscription);
|
||||||
backend->notify_subscription = 0;
|
backend->notify_subscription = 0;
|
||||||
}
|
}
|
||||||
@ -328,7 +345,7 @@ g_fdo_notification_backend_send_notification (GNotificationBackend *backend,
|
|||||||
if (self->notify_subscription == 0)
|
if (self->notify_subscription == 0)
|
||||||
{
|
{
|
||||||
self->notify_subscription =
|
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",
|
||||||
"org.freedesktop.Notifications", NULL,
|
"org.freedesktop.Notifications", NULL,
|
||||||
"/org/freedesktop/Notifications", NULL,
|
"/org/freedesktop/Notifications", NULL,
|
||||||
@ -355,9 +372,7 @@ g_fdo_notification_backend_send_notification (GNotificationBackend *backend,
|
|||||||
|
|
||||||
g_notification_get_default_action (notification, &n->default_action, &n->default_action_target);
|
g_notification_get_default_action (notification, &n->default_action, &n->default_action_target);
|
||||||
|
|
||||||
call_notify (g_notification_backend_get_dbus_connection (backend),
|
call_notify (backend->dbus_connection, backend->application, n->notify_id, notification, notification_sent, n);
|
||||||
g_notification_backend_get_application (backend),
|
|
||||||
n->notify_id, notification, notification_sent, n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -372,7 +387,7 @@ g_fdo_notification_backend_withdraw_notification (GNotificationBackend *backend,
|
|||||||
{
|
{
|
||||||
if (n->notify_id > 0)
|
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",
|
"/org/freedesktop/Notifications",
|
||||||
"org.freedesktop.Notifications", "CloseNotification",
|
"org.freedesktop.Notifications", "CloseNotification",
|
||||||
|
@ -91,16 +91,13 @@ g_gtk_notification_backend_send_notification (GNotificationBackend *backend,
|
|||||||
const gchar *id,
|
const gchar *id,
|
||||||
GNotification *notification)
|
GNotification *notification)
|
||||||
{
|
{
|
||||||
GApplication *application;
|
|
||||||
GVariant *params;
|
GVariant *params;
|
||||||
|
|
||||||
application = g_notification_backend_get_application (backend);
|
params = g_variant_new ("(ss@a{sv})", g_application_get_application_id (backend->application),
|
||||||
|
|
||||||
params = g_variant_new ("(ss@a{sv})", g_application_get_application_id (application),
|
|
||||||
id,
|
id,
|
||||||
g_notification_serialize (notification));
|
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", "/org/gtk/Notifications",
|
||||||
"org.gtk.Notifications", "AddNotification", params,
|
"org.gtk.Notifications", "AddNotification", params,
|
||||||
G_VARIANT_TYPE_UNIT,
|
G_VARIANT_TYPE_UNIT,
|
||||||
@ -112,12 +109,9 @@ g_gtk_notification_backend_withdraw_notification (GNotificationBackend *backend,
|
|||||||
const gchar *id)
|
const gchar *id)
|
||||||
{
|
{
|
||||||
GGtkNotificationBackend *self = G_GTK_NOTIFICATION_BACKEND (backend);
|
GGtkNotificationBackend *self = G_GTK_NOTIFICATION_BACKEND (backend);
|
||||||
GApplication *application;
|
|
||||||
GVariant *params;
|
GVariant *params;
|
||||||
|
|
||||||
application = g_notification_backend_get_application (backend);
|
params = g_variant_new ("(ss)", g_application_get_application_id (backend->application), id);
|
||||||
|
|
||||||
params = g_variant_new ("(ss)", g_application_get_application_id (application), id);
|
|
||||||
|
|
||||||
g_dbus_connection_call (self->session_bus, "org.gtk.Notifications",
|
g_dbus_connection_call (self->session_bus, "org.gtk.Notifications",
|
||||||
"/org/gtk/Notifications", "org.gtk.Notifications",
|
"/org/gtk/Notifications", "org.gtk.Notifications",
|
||||||
|
@ -82,37 +82,3 @@ g_notification_backend_withdraw_notification (GNotificationBackend *backend,
|
|||||||
|
|
||||||
G_NOTIFICATION_BACKEND_GET_CLASS (backend)->withdraw_notification (backend, id);
|
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;
|
|
||||||
}
|
|
||||||
|
@ -70,14 +70,6 @@ void g_notification_backend_send_notification (GNotifi
|
|||||||
void g_notification_backend_withdraw_notification (GNotificationBackend *backend,
|
void g_notification_backend_withdraw_notification (GNotificationBackend *backend,
|
||||||
const gchar *id);
|
const gchar *id);
|
||||||
|
|
||||||
GApplication * g_notification_backend_get_application (GNotificationBackend *backend);
|
|
||||||
|
|
||||||
void g_notification_backend_activate_action (GNotificationBackend *backend,
|
|
||||||
const gchar *name,
|
|
||||||
GVariant *parameter);
|
|
||||||
|
|
||||||
GDBusConnection * g_notification_backend_get_dbus_connection (GNotificationBackend *backend);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user