Blame gio/gnotificationbackend.c

Packit ae235b
/*
Packit ae235b
 * Copyright © 2013 Lars Uebernickel
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General
Packit ae235b
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 *
Packit ae235b
 * Authors: Lars Uebernickel <lars@uebernic.de>
Packit ae235b
 */
Packit ae235b
Packit ae235b
#include "gnotificationbackend.h"
Packit ae235b
Packit ae235b
#include "gnotification.h"
Packit ae235b
#include "gapplication.h"
Packit ae235b
#include "gactiongroup.h"
Packit ae235b
#include "giomodule-priv.h"
Packit ae235b
Packit ae235b
G_DEFINE_TYPE (GNotificationBackend, g_notification_backend, G_TYPE_OBJECT)
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_notification_backend_class_init (GNotificationBackendClass *class)
Packit ae235b
{
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_notification_backend_init (GNotificationBackend *backend)
Packit ae235b
{
Packit ae235b
}
Packit ae235b
Packit ae235b
GNotificationBackend *
Packit ae235b
g_notification_backend_new_default (GApplication *application)
Packit ae235b
{
Packit ae235b
  GType backend_type;
Packit ae235b
  GNotificationBackend *backend;
Packit ae235b
Packit ae235b
  g_return_val_if_fail (G_IS_APPLICATION (application), NULL);
Packit ae235b
Packit ae235b
  backend_type = _g_io_module_get_default_type (G_NOTIFICATION_BACKEND_EXTENSION_POINT_NAME,
Packit ae235b
                                                "GNOTIFICATION_BACKEND",
Packit ae235b
                                                G_STRUCT_OFFSET (GNotificationBackendClass, is_supported));
Packit ae235b
Packit ae235b
  backend = g_object_new (backend_type, NULL);
Packit ae235b
Packit ae235b
  /* Avoid ref cycle by not taking a ref to the application at all. The
Packit ae235b
   * backend only lives as long as the application does.
Packit ae235b
   */
Packit ae235b
  backend->application = application;
Packit ae235b
Packit ae235b
  backend->dbus_connection = g_application_get_dbus_connection (application);
Packit ae235b
  if (backend->dbus_connection)
Packit ae235b
    g_object_ref (backend->dbus_connection);
Packit ae235b
Packit ae235b
  return backend;
Packit ae235b
}
Packit ae235b
Packit ae235b
void
Packit ae235b
g_notification_backend_send_notification (GNotificationBackend *backend,
Packit ae235b
                                          const gchar          *id,
Packit ae235b
                                          GNotification        *notification)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (G_IS_NOTIFICATION_BACKEND (backend));
Packit ae235b
  g_return_if_fail (G_IS_NOTIFICATION (notification));
Packit ae235b
Packit ae235b
  G_NOTIFICATION_BACKEND_GET_CLASS (backend)->send_notification (backend, id, notification);
Packit ae235b
}
Packit ae235b
Packit ae235b
void
Packit ae235b
g_notification_backend_withdraw_notification (GNotificationBackend *backend,
Packit ae235b
                                              const gchar          *id)
Packit ae235b
{
Packit ae235b
  g_return_if_fail (G_IS_NOTIFICATION_BACKEND (backend));
Packit ae235b
  g_return_if_fail (id != NULL);
Packit ae235b
Packit ae235b
  G_NOTIFICATION_BACKEND_GET_CLASS (backend)->withdraw_notification (backend, id);
Packit ae235b
}