libpurple/purplenotificationmanager.c

Fri, 27 Sep 2024 02:21:36 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 27 Sep 2024 02:21:36 -0500
changeset 42984
818220289e67
parent 42962
a2c1926ce7b2
child 42985
66ad6fc11879
permissions
-rw-r--r--

Update the gi-docgen subproject and fix some new issues it found

These aren't new issues per se, there were issues that it didn't warn/error
about previously.

Testing Done:
Updated subprojects and called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/3552/

41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
7 * source distribution.
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
12 * any later version.
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
17 * more details.
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
18 *
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "purplenotificationmanager.h"
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "purpleprivate.h"
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 enum {
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
30 PROP_0,
42662
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
31 PROP_ITEM_TYPE,
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
32 PROP_N_ITEMS,
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 PROP_UNREAD_COUNT,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 N_PROPERTIES,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 };
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
36 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 enum {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 SIG_ADDED,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 SIG_REMOVED,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 SIG_READ,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 SIG_UNREAD,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 N_SIGNALS,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 };
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
45 static guint signals[N_SIGNALS] = {0, };
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 struct _PurpleNotificationManager {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 GObject parent;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
50 GPtrArray *notifications;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 guint unread_count;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 };
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 static PurpleNotificationManager *default_manager = NULL;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 * Helpers
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 purple_notification_manager_set_unread_count(PurpleNotificationManager *manager,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 guint unread_count)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 if(manager->unread_count != unread_count) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 manager->unread_count = unread_count;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 g_object_notify_by_pspec(G_OBJECT(manager),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 properties[PROP_UNREAD_COUNT]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 static inline void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 purple_notification_manager_increment_unread_count(PurpleNotificationManager *manager)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 if(manager->unread_count < G_MAXUINT) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 purple_notification_manager_set_unread_count(manager,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 manager->unread_count + 1);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 static inline void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 purple_notification_manager_decrement_unread_count(PurpleNotificationManager *manager)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 if(manager->unread_count > 0) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 purple_notification_manager_set_unread_count(manager,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 manager->unread_count - 1);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 * Callbacks
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 purple_notification_manager_notify_cb(GObject *obj,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 G_GNUC_UNUSED GParamSpec *pspec,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 gpointer data)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 PurpleNotificationManager *manager = data;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 guint signal_id = 0;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 /* This function is called after the property is changed. So we need to
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 * get the new value to determine how the state changed.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 if(purple_notification_get_read(notification)) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 purple_notification_manager_decrement_unread_count(manager);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 signal_id = signals[SIG_READ];
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 } else {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 purple_notification_manager_increment_unread_count(manager);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 signal_id = signals[SIG_UNREAD];
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 g_signal_emit(manager, signal_id, 0, notification);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
42962
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
119 static void
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
120 purple_notification_manager_deleted_cb(PurpleNotification *notification,
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
121 gpointer data)
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
122 {
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
123 PurpleNotificationManager *manager = data;
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
124
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
125 purple_notification_manager_remove(manager, notification);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
126 }
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
127
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 /******************************************************************************
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
129 * GListModel Implementation
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
130 *****************************************************************************/
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
131 static GType
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
132 purple_notification_manager_get_item_type(G_GNUC_UNUSED GListModel *list) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
133 return PURPLE_TYPE_NOTIFICATION;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
134 }
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
135
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
136 static guint
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
137 purple_notification_manager_get_n_items(GListModel *list) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
138 PurpleNotificationManager *manager = PURPLE_NOTIFICATION_MANAGER(list);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
139
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
140 return manager->notifications->len;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
141 }
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
142
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
143 static gpointer
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
144 purple_notification_manager_get_item(GListModel *list, guint position) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
145 PurpleNotificationManager *manager = PURPLE_NOTIFICATION_MANAGER(list);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
146 PurpleNotification *notification = NULL;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
147
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
148 if(position < manager->notifications->len) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
149 notification = g_ptr_array_index(manager->notifications, position);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
150 g_object_ref(notification);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
151 }
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
152
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
153 return notification;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
154 }
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
155
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
156 static void
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
157 purple_notification_manager_list_model_init(GListModelInterface *iface) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
158 iface->get_item_type = purple_notification_manager_get_item_type;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
159 iface->get_n_items = purple_notification_manager_get_n_items;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
160 iface->get_item = purple_notification_manager_get_item;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
161 }
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
162
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
163 /******************************************************************************
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 * GObject Implementation
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 *****************************************************************************/
42576
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42565
diff changeset
166 G_DEFINE_FINAL_TYPE_WITH_CODE(PurpleNotificationManager, purple_notification_manager,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42565
diff changeset
167 G_TYPE_OBJECT,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42565
diff changeset
168 G_IMPLEMENT_INTERFACE(G_TYPE_LIST_MODEL,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42565
diff changeset
169 purple_notification_manager_list_model_init));
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
170
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
171
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 purple_notification_manager_get_property(GObject *obj, guint param_id,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 GValue *value, GParamSpec *pspec)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 PurpleNotificationManager *manager = PURPLE_NOTIFICATION_MANAGER(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 switch(param_id) {
42662
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
179 case PROP_ITEM_TYPE:
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
180 g_value_set_gtype(value,
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
181 purple_notification_manager_get_item_type(G_LIST_MODEL(manager)));
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
182 break;
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
183 case PROP_N_ITEMS:
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
184 g_value_set_uint(value,
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
185 purple_notification_manager_get_n_items(G_LIST_MODEL(manager)));
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
186 break;
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
187 case PROP_UNREAD_COUNT:
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
188 g_value_set_uint(value,
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
189 purple_notification_manager_get_unread_count(manager));
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
190 break;
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
191 default:
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
192 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
193 break;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 purple_notification_manager_finalize(GObject *obj) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 PurpleNotificationManager *manager = NULL;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 manager = PURPLE_NOTIFICATION_MANAGER(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
203 g_ptr_array_free(manager->notifications, TRUE);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
204 manager->notifications = NULL;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 G_OBJECT_CLASS(purple_notification_manager_parent_class)->finalize(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 purple_notification_manager_init(PurpleNotificationManager *manager) {
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
211 manager->notifications = g_ptr_array_new_full(0,
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
212 (GDestroyNotify)g_object_unref);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 purple_notification_manager_class_init(PurpleNotificationManagerClass *klass) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 obj_class->get_property = purple_notification_manager_get_property;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 obj_class->finalize = purple_notification_manager_finalize;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221
42662
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
222 /**
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
223 * PurpleNotificationManager:item-type:
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
224 *
42984
818220289e67 Update the gi-docgen subproject and fix some new issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42962
diff changeset
225 * The type of items. See [vfunc@Gio.ListModel.get_item_type].
42662
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
226 *
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
227 * Since: 3.0
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
228 */
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
229 properties[PROP_ITEM_TYPE] = g_param_spec_gtype(
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
230 "item-type", "item-type",
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
231 "The type of the contained items.",
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
232 G_TYPE_OBJECT,
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
233 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
234
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
235 /**
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
236 * PurpleNotificationManager:n-items:
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
237 *
42984
818220289e67 Update the gi-docgen subproject and fix some new issues it found
Gary Kramlich <grim@reaperworld.com>
parents: 42962
diff changeset
238 * The number of items. See [vfunc@Gio.ListModel.get_n_items].
42662
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
239 *
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
240 * Since: 3.0
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
241 */
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
242 properties[PROP_N_ITEMS] = g_param_spec_uint(
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
243 "n-items", "n-items",
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
244 "The number of contained items.",
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
245 0, G_MAXUINT, 0,
f1f61c62fea6 Add item-type and n-items properties to PurpleNotificationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
246 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 /**
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 * PurpleNotificationManager:unread-count:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 * The number of unread notifications in the manager.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
253 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 properties[PROP_UNREAD_COUNT] = g_param_spec_uint(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 "unread-count", "unread-count",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 "The number of unread messages in the manager.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 0, G_MAXUINT, 0,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 /**
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 * PurpleNotificationManager::added:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 * @manager: The instance.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 * @notification: The [class@Notification] that was added.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 * Emitted after @notification has been added to @manager.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
270 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 signals[SIG_ADDED] = g_signal_new_class_handler(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 "added",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 G_OBJECT_CLASS_TYPE(klass),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 G_SIGNAL_RUN_LAST,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 G_TYPE_NONE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 1,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 PURPLE_TYPE_NOTIFICATION);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 /**
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 * PurpleNotificationManager::removed:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 * @manager: The instance.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 * @notification: The [class@Notification] that was removed.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 * Emitted after @notification has been removed from @manager.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
291 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 signals[SIG_REMOVED] = g_signal_new_class_handler(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 "removed",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 G_OBJECT_CLASS_TYPE(klass),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 G_SIGNAL_RUN_LAST,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 G_TYPE_NONE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 1,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 PURPLE_TYPE_NOTIFICATION);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 /**
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 * PurpleNotificationManager::read:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 * @manager: The instance.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 * @notification: The [class@Notification].
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 * Emitted after @notification has been marked as read.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
312 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 signals[SIG_READ] = g_signal_new_class_handler(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 "read",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 G_OBJECT_CLASS_TYPE(klass),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 G_SIGNAL_RUN_LAST,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 G_TYPE_NONE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 1,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 PURPLE_TYPE_NOTIFICATION);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 /**
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 * PurpleNotificationManager::unread:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 * @manager: The instance.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 * @notification: The [class@Notification].
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 * Emitted after @notification has been marked as unread.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
333 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 signals[SIG_UNREAD] = g_signal_new_class_handler(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 "unread",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 G_OBJECT_CLASS_TYPE(klass),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 G_SIGNAL_RUN_LAST,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 G_TYPE_NONE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 1,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 PURPLE_TYPE_NOTIFICATION);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 * Private API
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 purple_notification_manager_startup(void) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 if(default_manager == NULL) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 default_manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
355 g_object_add_weak_pointer(G_OBJECT(default_manager),
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
356 (gpointer *)&default_manager);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 purple_notification_manager_shutdown(void) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 g_clear_object(&default_manager);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 * Public API
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 PurpleNotificationManager *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 purple_notification_manager_get_default(void) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 return default_manager;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
373 GListModel *
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
374 purple_notification_manager_get_default_as_model(void) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
375 if(PURPLE_IS_NOTIFICATION_MANAGER(default_manager)) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
376 return G_LIST_MODEL(default_manager);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
377 }
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
378
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
379 return NULL;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
380 }
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
381
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 purple_notification_manager_add(PurpleNotificationManager *manager,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 PurpleNotification *notification)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 g_return_if_fail(PURPLE_IS_NOTIFICATION_MANAGER(manager));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
389 if(g_ptr_array_find(manager->notifications, notification, NULL)) {
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
390 const gchar *id = purple_notification_get_id(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 g_warning("double add detected for notification %s", id);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 return;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
397 g_ptr_array_insert(manager->notifications, 0, g_object_ref(notification));
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399 /* Connect to the notify signal for the read property only so we can
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 * propagate out changes for any notification.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 g_signal_connect_object(notification, "notify::read",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 G_CALLBACK(purple_notification_manager_notify_cb),
42962
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
404 manager, G_CONNECT_DEFAULT);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
405 g_signal_connect_object(notification, "deleted",
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
406 G_CALLBACK(purple_notification_manager_deleted_cb),
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
407 manager, G_CONNECT_DEFAULT);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 /* If the notification is not read, we need to increment the unread count.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 if(!purple_notification_get_read(notification)) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 purple_notification_manager_increment_unread_count(manager);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, notification);
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
416 g_list_model_items_changed(G_LIST_MODEL(manager), 0, 0, 1);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
419 void
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 purple_notification_manager_remove(PurpleNotificationManager *manager,
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
421 PurpleNotification *notification)
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 {
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
423 guint index = 0;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
425 g_return_if_fail(PURPLE_IS_NOTIFICATION_MANAGER(manager));
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
426 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
427
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
428 if(g_ptr_array_find(manager->notifications, notification, &index)) {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 /* Reference the notification so we can emit the signal after it's been
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 * removed from the hash table.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431 */
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
432 g_object_ref(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
434 g_ptr_array_remove_index(manager->notifications, index);
42565
c035e2eba80d Fix several minor typos
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42246
diff changeset
435 /* Remove the notify signal handler for the read state in case someone
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436 * else added a reference to the notification which would then mess
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 * with our unread count accounting.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 */
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
439 g_signal_handlers_disconnect_by_func(notification,
42246
3230f1a1fb8f Remove unnecessary casting from g_signal_handlers_disconnect
Gary Kramlich <grim@reaperworld.com>
parents: 41936
diff changeset
440 purple_notification_manager_notify_cb,
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 manager);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 /* If the notification is not read, we need to decrement the unread
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444 * count.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
445 */
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
446 if(!purple_notification_get_read(notification)) {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447 purple_notification_manager_decrement_unread_count(manager);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
450 g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, notification);
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
451 g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0);
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
452
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
453 g_object_unref(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
454 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
455 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
457 /*
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
458 This function uses the following algorithm to optimally remove items from the
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
459 g_ptr_array to minimize the number of calls to g_list_model_items_changed. See
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
460 the pseudo code below for an easier to follow version.
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
461
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
462 A
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
463 A B C
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
464 B C
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
465 A A B C
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
466 B A C
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
467 B A A C
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
468 B C A
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
469 B C A A
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
470
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
471 set len = number_of_items
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
472 set pos = 0
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
473 set have_same = false
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
474 while pos < len
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
475 check item at pos
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
476 if same
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
477 if not have_same
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
478 reset count = 0
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
479 set start = pos
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
480 set have_same = TRUE
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
481
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
482 set count = count + 1
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
483 else
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
484 if have_same
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
485 remove count items from start
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
486 set pos = pos - count
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
487 set len = len - count
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
488 set have_same = FALSE
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
489 set pos = pos + 1
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
490 if have_same
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
491 remove count items from start
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
492 */
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
493 void
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
494 purple_notification_manager_remove_with_account(PurpleNotificationManager *manager,
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
495 PurpleAccount *account,
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
496 gboolean all)
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
497 {
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
498 GListModel *model = NULL;
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
499 guint pos = 0, len = 0;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
500 guint start = 0, count = 0;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
501 gboolean have_same = FALSE;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
502
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
503 g_return_if_fail(PURPLE_IS_NOTIFICATION_MANAGER(manager));
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
504 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
505
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
506 model = G_LIST_MODEL(manager);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
507
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
508 for(pos = 0; pos < manager->notifications->len; pos++) {
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
509 PurpleAccount *account2 = NULL;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
510 PurpleNotification *notification = NULL;
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
511 PurpleNotificationType type;
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
512 gboolean can_remove = TRUE;
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
513
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
514 notification = g_ptr_array_index(manager->notifications, pos);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
515
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
516 /* If the notification's type is connection error, set can_remove to
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
517 * the value of the all parameter.
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
518 */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42662
diff changeset
519 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
520 type = purple_notification_get_notification_type(notification);
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42662
diff changeset
521 G_GNUC_END_IGNORE_DEPRECATIONS
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
522 if(type == PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR) {
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
523 can_remove = all;
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
524 }
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
525
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
526 account2 = purple_notification_get_account(notification);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
527 if(account == account2 && can_remove) {
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
528 /* If this is the first item with the right account store its
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
529 * position.
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
530 */
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
531 if(!have_same) {
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
532 count = 0;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
533 start = pos;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
534 have_same = TRUE;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
535 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
536
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
537 /* Increment the count of items starting at the start position. */
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
538 count++;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
539 } else {
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
540 if(have_same) {
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
541 /* Remove the run of items from the list. */
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
542 g_ptr_array_remove_range(manager->notifications, start, count);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
543 g_list_model_items_changed(model, start, count, 0);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
544
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
545 /* Adjust pos and len for the items that we removed. */
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
546 pos = pos - count;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
547 len = len - count;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
548
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
549 have_same = FALSE;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
550 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
551 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
552 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
553
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
554 /* Clean up the last bit if the last item needs to be removed. */
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
555 if(have_same) {
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
556 g_ptr_array_remove_range(manager->notifications, start, count);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
557 g_list_model_items_changed(model, start, count, 0);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
558 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
559 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
560
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
561 guint
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
562 purple_notification_manager_get_unread_count(PurpleNotificationManager *manager) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
563 g_return_val_if_fail(PURPLE_IS_NOTIFICATION_MANAGER(manager), 0);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
564
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
565 return manager->unread_count;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
566 }
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
567
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
568 void
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
569 purple_notification_manager_clear(PurpleNotificationManager *manager) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
570 guint count = 0;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
571
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
572 g_return_if_fail(PURPLE_IS_NOTIFICATION_MANAGER(manager));
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
573
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
574 count = manager->notifications->len;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
575
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
576 for(guint pos = 0; pos < count; pos++) {
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
577 PurpleNotification *notification = NULL;
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
578
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
579 notification = g_ptr_array_index(manager->notifications, pos);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
580
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
581 g_signal_emit(manager, signals[SIG_REMOVED], 0, notification);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
582 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
583
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
584 g_ptr_array_remove_range(manager->notifications, 0, count);
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
585
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
586 g_list_model_items_changed(G_LIST_MODEL(manager), 0, count, 0);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
587 }

mercurial