libpurple/purplenotification.c

Tue, 15 Oct 2024 00:47:42 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 15 Oct 2024 00:47:42 -0500
changeset 43011
ce3144e2bc33
parent 42988
c2357ee36551
child 43181
ccc35f487917
permissions
-rw-r--r--

Port prefs to AdwSwitchRow

Now that we depend on Adwaita 1.4, we can flip the switch on using these (pun intended).

This also simplifies some extra tracking we needed to do for activations and focus, since the Adwaita widgets do that for us.

Testing Done:
Opened prefs, confirmed all the switches were there, and toggled them all without any warnings.

Also used the mnemonics to toggle the switches from the keyboard.

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

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
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
23 #include <glib/gi18n-lib.h>
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
24
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
25 #include <birb.h>
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
26
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "purplenotification.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 #include "purpleenums.h"
42922
46b64a8cbec4 Create Purple.NotificationAddContact
Gary Kramlich <grim@reaperworld.com>
parents: 42914
diff changeset
30 #include "purplenotificationaddcontact.h"
42929
e9cc6fc1f717 Update Purple.NotificationAuthorizationRequest to take an id and auto populate account
Gary Kramlich <grim@reaperworld.com>
parents: 42928
diff changeset
31 #include "purplenotificationauthorizationrequest.h"
42985
66ad6fc11879 Create Purple.NotificationConnectionError
Gary Kramlich <grim@reaperworld.com>
parents: 42929
diff changeset
32 #include "purplenotificationconnectionerror.h"
42725
ceb13f1de2d2 Remove PurpleBuddy
Gary Kramlich <grim@reaperworld.com>
parents: 42648
diff changeset
33 #include "util.h"
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
35 typedef struct {
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
36 char *id;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PurpleAccount *account;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GDateTime *created_timestamp;
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
40 char *title;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
41 char *subtitle;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
42
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
43 char *icon_name;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 gboolean read;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 gboolean interactive;
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
46 gboolean persistent;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 gpointer data;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 GDestroyNotify data_destroy_func;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
50
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
51 gboolean deleted;
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
52 } PurpleNotificationPrivate;
41433
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 enum {
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
55 SIG_DELETED,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
56 N_SIGNALS,
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
57 };
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
58 static guint signals[N_SIGNALS] = {0, };
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
59
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
60 enum {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 PROP_0,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 PROP_ID,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 PROP_ACCOUNT,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 PROP_CREATED_TIMESTAMP,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 PROP_TITLE,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
66 PROP_SUBTITLE,
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 PROP_ICON_NAME,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 PROP_READ,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 PROP_INTERACTIVE,
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
70 PROP_PERSISTENT,
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 N_PROPERTIES,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 };
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
75 G_DEFINE_TYPE_WITH_PRIVATE(PurpleNotification, purple_notification,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
76 G_TYPE_OBJECT)
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
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 * Helpers
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 void
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
82 purple_notification_set_id(PurpleNotification *notification, const char *id) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
83 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
84
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
87 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
88
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 if(id == NULL) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
90 priv->id = g_uuid_string_random();
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 } else {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
92 priv->id = g_strdup(id);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 g_object_notify_by_pspec(G_OBJECT(notification), properties[PROP_ID]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }
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 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 * GObject Implementation
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 purple_notification_get_property(GObject *obj, guint param_id, GValue *value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 GParamSpec *pspec)
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 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 switch(param_id) {
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
108 case PROP_ID:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
109 g_value_set_string(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
110 purple_notification_get_id(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
111 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
112 case PROP_ACCOUNT:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
113 g_value_set_object(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
114 purple_notification_get_account(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
115 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
116 case PROP_CREATED_TIMESTAMP:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
117 g_value_set_boxed(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
118 purple_notification_get_created_timestamp(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
119 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
120 case PROP_TITLE:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
121 g_value_set_string(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
122 purple_notification_get_title(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
123 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
124 case PROP_SUBTITLE:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
125 g_value_set_string(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
126 purple_notification_get_subtitle(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
127 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
128 case PROP_ICON_NAME:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
129 g_value_set_string(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
130 purple_notification_get_icon_name(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
131 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
132 case PROP_READ:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
133 g_value_set_boolean(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
134 purple_notification_get_read(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
135 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
136 case PROP_INTERACTIVE:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
137 g_value_set_boolean(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
138 purple_notification_get_interactive(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
139 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
140 case PROP_PERSISTENT:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
141 g_value_set_boolean(value,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
142 purple_notification_get_persistent(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
143 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
144 default:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
145 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
146 break;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 purple_notification_set_property(GObject *obj, guint param_id,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 const GValue *value, GParamSpec *pspec)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 switch(param_id) {
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
157 case PROP_ID:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
158 purple_notification_set_id(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
159 g_value_get_string(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
160 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
161 case PROP_ACCOUNT:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
162 purple_notification_set_account(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
163 g_value_get_object(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
164 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
165 case PROP_CREATED_TIMESTAMP:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
166 purple_notification_set_created_timestamp(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
167 g_value_get_boxed(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
168 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
169 case PROP_TITLE:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
170 purple_notification_set_title(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
171 g_value_get_string(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
172 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
173 case PROP_SUBTITLE:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
174 purple_notification_set_subtitle(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
175 g_value_get_string(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
176 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
177 case PROP_ICON_NAME:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
178 purple_notification_set_icon_name(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
179 g_value_get_string(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
180 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
181 case PROP_READ:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
182 purple_notification_set_read(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
183 g_value_get_boolean(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
184 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
185 case PROP_INTERACTIVE:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
186 purple_notification_set_interactive(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
187 g_value_get_boolean(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
188 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
189 case PROP_PERSISTENT:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
190 purple_notification_set_persistent(notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
191 g_value_get_boolean(value));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
192 break;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
193 default:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
194 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
195 break;
41433
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 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 purple_notification_finalize(GObject *obj) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
202 PurpleNotificationPrivate *priv = NULL;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
204 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
205
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
206 g_clear_pointer(&priv->id, g_free);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
207 g_clear_object(&priv->account);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
209 birb_date_time_clear(&priv->created_timestamp);
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
210 g_clear_pointer(&priv->title, g_free);
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
211 g_clear_pointer(&priv->subtitle, g_free);
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
212 g_clear_pointer(&priv->icon_name, g_free);
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 G_OBJECT_CLASS(purple_notification_parent_class)->finalize(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 static void
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
218 purple_notification_init(G_GNUC_UNUSED PurpleNotification *notification) {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 purple_notification_class_init(PurpleNotificationClass *klass) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 obj_class->get_property = purple_notification_get_property;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 obj_class->set_property = purple_notification_set_property;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 obj_class->finalize = purple_notification_finalize;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 /**
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
230 * PurpleNotification:id:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
231 *
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
232 * The ID of the notification.
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
233 *
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
234 * This used for things that need to address it.
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
235 *
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
236 * If not set, this will be auto populated at creation time.
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
237 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
238 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
239 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
240 properties[PROP_ID] = g_param_spec_string(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
241 "id", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
242 NULL,
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
243 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
244
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
245 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
246 * PurpleNotification:account:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
247 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
248 * An optional [class@Account] that this notification is for.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
249 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
250 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
251 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
252 properties[PROP_ACCOUNT] = g_param_spec_object(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
253 "account", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
254 PURPLE_TYPE_ACCOUNT,
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
255 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
256
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
257 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
258 * PurpleNotification:created-timestamp:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
259 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
260 * The creation time of this notification. This always represented as UTC
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
261 * internally, and will be set to UTC now by default.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
262 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
263 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
264 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
265 properties[PROP_CREATED_TIMESTAMP] = g_param_spec_boxed(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
266 "created-timestamp", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
267 G_TYPE_DATE_TIME,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
268 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
269
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
270 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
271 * PurpleNotification:title:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
272 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
273 * An optional title for this notification. A user interface may or may not
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
274 * choose to use this when displaying the notification. Regardless, this
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
275 * should be a translated string.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
276 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
277 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
278 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
279 properties[PROP_TITLE] = g_param_spec_string(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
280 "title", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
281 NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
282 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
283
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
284 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
285 * PurpleNotification:subtitle:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
286 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
287 * An optional subtitle for this notification. A user interface may or may
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
288 * not choose to use this when displaying the notification. Regardless,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
289 * this should be a translated string.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
290 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
291 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
292 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
293 properties[PROP_SUBTITLE] = g_param_spec_string(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
294 "subtitle", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
295 NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
296 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
297
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
298 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
299 * PurpleNotification:icon-name:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
300 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
301 * The icon-name in the icon theme to use for the notification. A user
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
302 * interface may or may not choose to use this when display the
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
303 * notification.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
304 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
305 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
306 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
307 properties[PROP_ICON_NAME] = g_param_spec_string(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
308 "icon-name", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
309 NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
310 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
311
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
312 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
313 * PurpleNotification:read:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
314 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
315 * Whether or not the notification has been read.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
316 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
317 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
318 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
319 properties[PROP_READ] = g_param_spec_boolean(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
320 "read", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
321 FALSE,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
322 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
323
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
324 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
325 * PurpleNotification:interactive:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
326 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
327 * Whether or not the notification can be interacted with.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
328 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
329 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
330 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
331 properties[PROP_INTERACTIVE] = g_param_spec_boolean(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
332 "interactive", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
333 FALSE,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
334 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
335
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
336 /**
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
337 * PurpleNotification:persistent:
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
338 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
339 * Whether or not the notification can be dismissed by users.
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
340 *
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
341 * Since: 3.0
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
342 */
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
343 properties[PROP_PERSISTENT] = g_param_spec_boolean(
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
344 "persistent", NULL, NULL,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
345 FALSE,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
346 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
347
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
348 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
349
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
350 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
351 * PurpleNotification::deleted:
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
352 * @notification: The instance.
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
353 *
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
354 * Emitted when the notification is deleted. This is typically done by a
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
355 * user interface calling [method@PurpleNotification.delete].
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
356 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
357 * Since: 3.0
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
358 */
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
359 signals[SIG_DELETED] = g_signal_new_class_handler(
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
360 "deleted",
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
361 G_OBJECT_CLASS_TYPE(klass),
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
362 G_SIGNAL_RUN_LAST,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
363 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
364 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
365 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
366 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
367 G_TYPE_NONE,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
368 0);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370
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 * Public API
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 PurpleNotification *
42988
c2357ee36551 Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents: 42987
diff changeset
375 purple_notification_new(const char *id, const char *title) {
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
376 return g_object_new(PURPLE_TYPE_NOTIFICATION,
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
377 "id", id,
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
378 "title", title,
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
379 NULL);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
382 const char *
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 purple_notification_get_id(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
384 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
385
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
388 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
389
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
390 return priv->id;
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
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 PurpleAccount *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 purple_notification_get_account(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
395 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
396
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
399 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
400
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
401 return priv->account;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
404 void
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
405 purple_notification_set_account(PurpleNotification *notification,
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
406 PurpleAccount *account)
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
407 {
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
408 PurpleNotificationPrivate *priv = NULL;
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
409
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
410 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
411
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
412 priv = purple_notification_get_instance_private(notification);
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
413
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
414 if(g_set_object(&priv->account, account)) {
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
415 g_object_notify_by_pspec(G_OBJECT(notification),
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
416 properties[PROP_ACCOUNT]);
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
417 }
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
418 }
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42922
diff changeset
419
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 GDateTime *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421 purple_notification_get_created_timestamp(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
422 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
423
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
425
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
426 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
427
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
428 return priv->created_timestamp;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432 purple_notification_set_created_timestamp(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 GDateTime *timestamp)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
435 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
436
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
439 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
440
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
441 if(birb_date_time_set(&priv->created_timestamp, timestamp)) {
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
442 g_object_notify_by_pspec(G_OBJECT(notification),
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
443 properties[PROP_CREATED_TIMESTAMP]);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
444 }
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
445 }
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
447 void
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
448 purple_notification_set_created_timestamp_now(PurpleNotification *notification)
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
449 {
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
450 GDateTime *timestamp = NULL;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
452 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
453
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
454 timestamp = g_date_time_new_now_local();
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
455 purple_notification_set_created_timestamp(notification, timestamp);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
456 g_date_time_unref(timestamp);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
459 const char *
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 purple_notification_get_title(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
461 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
462
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
465 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
466
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
467 return priv->title;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
470 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 purple_notification_set_title(PurpleNotification *notification,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
472 const char *title)
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
473 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
474 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
475
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
478 priv = purple_notification_get_instance_private(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42725
diff changeset
480 if(g_set_str(&priv->title, title)) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
481 g_object_notify_by_pspec(G_OBJECT(notification),
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
482 properties[PROP_TITLE]);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
483 }
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
484 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
485
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
486 const char *
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
487 purple_notification_get_subtitle(PurpleNotification *notification) {
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
488 PurpleNotificationPrivate *priv = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
489
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
490 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
491
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
492 priv = purple_notification_get_instance_private(notification);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
493
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
494 return priv->subtitle;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
495 }
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
496
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
497 void
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
498 purple_notification_set_subtitle(PurpleNotification *notification,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
499 const char *subtitle)
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
500 {
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
501 PurpleNotificationPrivate *priv = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
502
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
503 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
504
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
505 priv = purple_notification_get_instance_private(notification);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
506
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42725
diff changeset
507 if(g_set_str(&priv->subtitle, subtitle)) {
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
508 g_object_notify_by_pspec(G_OBJECT(notification),
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
509 properties[PROP_SUBTITLE]);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
510 }
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
511 }
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
512
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
513 const char *
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
514 purple_notification_get_icon_name(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
515 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
516
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
517 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
518
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
519 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
520
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
521 return priv->icon_name;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
522 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
523
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
524 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
525 purple_notification_set_icon_name(PurpleNotification *notification,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
526 const char *icon_name)
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
527 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
528 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
529
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
531
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
532 priv = purple_notification_get_instance_private(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
533
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42725
diff changeset
534 if(g_set_str(&priv->icon_name, icon_name)) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
535 g_object_notify_by_pspec(G_OBJECT(notification),
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
536 properties[PROP_ICON_NAME]);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
537 }
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
538 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
539
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
540 gboolean
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
541 purple_notification_get_read(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
542 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
543
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
544 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), FALSE);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
545
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
546 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
547
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
548 return priv->read;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
549 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
550
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
551 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
552 purple_notification_set_read(PurpleNotification *notification, gboolean read) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
553 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
554
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
555 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
557 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
558
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
559 if(priv->read != read) {
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
560 priv->read = read;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
561
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
562 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
563 properties[PROP_READ]);
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 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
566
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
567 gboolean
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568 purple_notification_get_interactive(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
569 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
570
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
571 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), FALSE);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
572
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
573 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
574
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
575 return priv->interactive;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
576 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
577
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
578 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579 purple_notification_set_interactive(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
580 gboolean interactive)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
581 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
582 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
583
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
584 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
585
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
586 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
587
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
588 if(priv->interactive != interactive) {
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
589 priv->interactive = interactive;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
590
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
591 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
592 properties[PROP_INTERACTIVE]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
594 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
595
42909
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
596 gboolean
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
597 purple_notification_get_persistent(PurpleNotification *notification) {
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
598 PurpleNotificationPrivate *priv = NULL;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
599
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
600 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), FALSE);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
601
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
602 priv = purple_notification_get_instance_private(notification);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
603
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
604 return priv->persistent;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
605 }
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
606
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
607 void
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
608 purple_notification_set_persistent(PurpleNotification *notification,
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
609 gboolean persistent)
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
610 {
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
611 PurpleNotificationPrivate *priv = NULL;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
612
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
613 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
614
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
615 priv = purple_notification_get_instance_private(notification);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
616
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
617 if(priv->persistent != persistent) {
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
618 priv->persistent = persistent;
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
619
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
620 g_object_notify_by_pspec(G_OBJECT(notification),
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
621 properties[PROP_PERSISTENT]);
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
622 }
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
623 }
440ed16de928 Add a persistent property to Purple.Notification
Gary Kramlich <grim@reaperworld.com>
parents: 42805
diff changeset
624
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
625 int
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
626 purple_notification_compare(gconstpointer a, gconstpointer b) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
627 PurpleNotification *notification_a = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
628 PurpleNotification *notification_b = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
629 PurpleNotificationPrivate *priv_a = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
630 PurpleNotificationPrivate *priv_b = NULL;
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
631
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
632 if(a == NULL && b == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
633 return 0;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
634 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
635
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
636 if(a == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
637 return -1;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
638 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
639
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
640 if(b == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
641 return 1;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
642 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
643
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
644 notification_a = (PurpleNotification *)a;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
645 notification_b = (PurpleNotification *)b;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
646
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
647 priv_a = purple_notification_get_instance_private(notification_a);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
648 priv_b = purple_notification_get_instance_private(notification_b);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
649
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
650 return g_date_time_compare(priv_a->created_timestamp,
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
651 priv_b->created_timestamp);
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
652 }
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
653
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
654 void
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
655 purple_notification_delete(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
656 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
657
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
658 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
659
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
660 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
661
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
662 /* Calling this multiple times is a programming error. */
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
663 g_return_if_fail(priv->deleted == FALSE);
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
664
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
665 priv->deleted = TRUE;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
666
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
667 g_signal_emit(notification, signals[SIG_DELETED], 0);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
668 }

mercurial