gio/tests/gsubprocess.c: Fix on Windows
[glib.git] / gio / gnotificationbackend.c
blob98b60bbbbf69621370f143e8caba689857de543b
1 /*
2 * Copyright © 2013 Lars Uebernickel
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; either version 2 of the licence or (at
7 * your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Authors: Lars Uebernickel <lars@uebernic.de>
22 #include "gnotificationbackend.h"
24 #include "gnotification.h"
25 #include "gapplication.h"
26 #include "gactiongroup.h"
27 #include "giomodule-priv.h"
29 G_DEFINE_TYPE (GNotificationBackend, g_notification_backend, G_TYPE_OBJECT);
31 static void
32 g_notification_backend_class_init (GNotificationBackendClass *class)
36 static void
37 g_notification_backend_init (GNotificationBackend *backend)
41 GNotificationBackend *
42 g_notification_backend_new_default (GApplication *application)
44 GType backend_type;
45 GNotificationBackend *backend;
47 g_return_val_if_fail (G_IS_APPLICATION (application), NULL);
49 backend_type = _g_io_module_get_default_type (G_NOTIFICATION_BACKEND_EXTENSION_POINT_NAME,
50 "GNOTIFICATION_BACKEND",
51 G_STRUCT_OFFSET (GNotificationBackendClass, is_supported));
53 backend = g_object_new (backend_type, NULL);
55 /* Avoid ref cycle by not taking a ref to the application at all. The
56 * backend only lives as long as the application does.
58 backend->application = application;
60 backend->dbus_connection = g_object_ref (g_application_get_dbus_connection (application));
62 return backend;
65 void
66 g_notification_backend_send_notification (GNotificationBackend *backend,
67 const gchar *id,
68 GNotification *notification)
70 g_return_if_fail (G_IS_NOTIFICATION_BACKEND (backend));
71 g_return_if_fail (G_IS_NOTIFICATION (notification));
73 G_NOTIFICATION_BACKEND_GET_CLASS (backend)->send_notification (backend, id, notification);
76 void
77 g_notification_backend_withdraw_notification (GNotificationBackend *backend,
78 const gchar *id)
80 g_return_if_fail (G_IS_NOTIFICATION_BACKEND (backend));
81 g_return_if_fail (id != NULL);
83 G_NOTIFICATION_BACKEND_GET_CLASS (backend)->withdraw_notification (backend, id);