Use macros for refcount types API
[glib.git] / gio / gwin32notificationbackend.c
blob7200fdffb5f9576a86f8a27cc73d07ab4d541ea9
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/>.
20 * Authors:
21 * - Philip Withnall <withnall@endlessm.com>
24 #include "config.h"
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))
49 static gboolean
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. */
54 return TRUE;
57 static void
58 g_win32_notification_backend_send_notification (GNotificationBackend *backend,
59 const gchar *id,
60 GNotification *notification)
62 /* FIXME: See https://bugzilla.gnome.org/show_bug.cgi?id=776583. This backend
63 * exists purely to stop crashes when applications use g_notification*()
64 * on Windows, by providing a dummy backend implementation. (The alternative
65 * was to modify all of the backend call sites in g_notification*(), which
66 * seemed less scalable.) */
67 g_warning ("Notifications are not yet supported on Windows.");
70 static void
71 g_win32_notification_backend_withdraw_notification (GNotificationBackend *backend,
72 const gchar *id)
74 /* FIXME: Nothing needs doing here until send_notification() is implemented. */
77 static void
78 g_win32_notification_backend_init (GWin32NotificationBackend *backend)
82 static void
83 g_win32_notification_backend_class_init (GWin32NotificationBackendClass *class)
85 GNotificationBackendClass *backend_class = G_NOTIFICATION_BACKEND_CLASS (class);
87 backend_class->is_supported = g_win32_notification_backend_is_supported;
88 backend_class->send_notification = g_win32_notification_backend_send_notification;
89 backend_class->withdraw_notification = g_win32_notification_backend_withdraw_notification;