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:
Ryan Lortie 2013-10-21 12:54:19 -04:00
parent 766f5584ce
commit 51fac60a92
4 changed files with 28 additions and 61 deletions

View File

@ -25,6 +25,7 @@
#include "giomodule-priv.h"
#include "gnotification-private.h"
#include "gdbusconnection.h"
#include "gactiongroup.h"
#include "gaction.h"
#include "gfileicon.h"
#include "gfile.h"
@ -106,6 +107,24 @@ g_fdo_notification_backend_find_notification_by_notify_id (GFdoNotificationBacke
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,
@ -141,9 +160,7 @@ notify_signal (GDBusConnection *connection,
{
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
{
@ -152,7 +169,7 @@ notify_signal (GDBusConnection *connection,
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);
@ -292,7 +309,7 @@ g_fdo_notification_backend_dispose (GObject *object)
{
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;
}
@ -328,7 +345,7 @@ g_fdo_notification_backend_send_notification (GNotificationBackend *backend,
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,
@ -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);
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
@ -372,7 +387,7 @@ g_fdo_notification_backend_withdraw_notification (GNotificationBackend *backend,
{
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",

View File

@ -91,16 +91,13 @@ g_gtk_notification_backend_send_notification (GNotificationBackend *backend,
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,
@ -112,12 +109,9 @@ g_gtk_notification_backend_withdraw_notification (GNotificationBackend *backend,
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",

View File

@ -82,37 +82,3 @@ g_notification_backend_withdraw_notification (GNotificationBackend *backend,
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;
}

View File

@ -70,14 +70,6 @@ void g_notification_backend_send_notification (GNotifi
void g_notification_backend_withdraw_notification (GNotificationBackend *backend,
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
#endif