1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* GIO - GLib Input, Output and Streaming Library
4 * Copyright © 2018 Endless Mobile, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
21 * - Philip Withnall <withnall@endlessm.com>
26 #include "gnotificationbackend.h"
28 #include "giomodule-priv.h"
29 #include "gnotification-private.h"
31 #define G_TYPE_WIN32_NOTIFICATION_BACKEND (g_win32_notification_backend_get_type ())
32 #define G_WIN32_NOTIFICATION_BACKEND(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_WIN32_NOTIFICATION_BACKEND, GWin32NotificationBackend))
34 typedef struct _GWin32NotificationBackend GWin32NotificationBackend
;
35 typedef GNotificationBackendClass GWin32NotificationBackendClass
;
37 struct _GWin32NotificationBackend
39 GNotificationBackend parent
;
42 GType
g_win32_notification_backend_get_type (void);
44 G_DEFINE_TYPE_WITH_CODE (GWin32NotificationBackend
, g_win32_notification_backend
, G_TYPE_NOTIFICATION_BACKEND
,
45 _g_io_modules_ensure_extension_points_registered ();
46 g_io_extension_point_implement (G_NOTIFICATION_BACKEND_EXTENSION_POINT_NAME
,
47 g_define_type_id
, "win32", 0))
50 g_win32_notification_backend_is_supported (void)
52 /* This is the only backend supported on Windows, and always needs to be
53 * present to avoid no backend being selected. */
58 g_win32_notification_backend_send_notification (GNotificationBackend
*backend
,
60 GNotification
*notification
)
62 static gsize warned
= 0;
64 /* FIXME: See https://bugzilla.gnome.org/show_bug.cgi?id=776583. This backend
65 * exists purely to stop crashes when applications use g_notification*()
66 * on Windows, by providing a dummy backend implementation. (The alternative
67 * was to modify all of the backend call sites in g_notification*(), which
68 * seemed less scalable.) */
69 if (g_once_init_enter (&warned
))
71 g_warning ("Notifications are not yet supported on Windows.");
72 g_once_init_leave (&warned
, 1);
77 g_win32_notification_backend_withdraw_notification (GNotificationBackend
*backend
,
80 /* FIXME: Nothing needs doing here until send_notification() is implemented. */
84 g_win32_notification_backend_init (GWin32NotificationBackend
*backend
)
89 g_win32_notification_backend_class_init (GWin32NotificationBackendClass
*class)
91 GNotificationBackendClass
*backend_class
= G_NOTIFICATION_BACKEND_CLASS (class);
93 backend_class
->is_supported
= g_win32_notification_backend_is_supported
;
94 backend_class
->send_notification
= g_win32_notification_backend_send_notification
;
95 backend_class
->withdraw_notification
= g_win32_notification_backend_withdraw_notification
;