GNotification: some final cleanups
authorRyan Lortie <desrt@desrt.ca>
Mon, 21 Oct 2013 16:54:19 +0000 (12:54 -0400)
committerRyan Lortie <desrt@desrt.ca>
Mon, 21 Oct 2013 18:30:30 +0000 (14:30 -0400)
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

gio/gfdonotificationbackend.c
gio/ggtknotificationbackend.c
gio/gnotificationbackend.c
gio/gnotificationbackend.h

index ad665be..a12203e 100644 (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"
@@ -107,6 +108,24 @@ g_fdo_notification_backend_find_notification_by_notify_id (GFdoNotificationBacke
 }
 
 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,
                const gchar     *object_path,
@@ -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",
index 79486b1..412cec8 100644 (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",
index a3bcde5..98b60bb 100644 (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;
-}
index 508e428..178331d 100644 (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