pidgin/pidginnotification.c

Sun, 03 Nov 2024 00:05:44 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 03 Nov 2024 00:05:44 -0500
changeset 43045
308e8d0ce68c
parent 42940
240eb66a3795
child 43182
9e12c632516e
permissions
-rw-r--r--

remove purple3-url-handler.desktop.in.in

The application that did the launching was removed long ago. Also this should
be implemented by the user interfaces and they might provide separate files to
groups schemas as well.

Testing Done:
Called in the turtles.

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

42940
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidgin/pidginnotification.h"
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 typedef struct {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 PurpleNotification *notification;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 GtkWidget *details;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 GtkWidget *child;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 } PidginNotificationPrivate;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 enum {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PROP_0,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 PROP_NOTIFICATION,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PROP_CHILD,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 N_PROPERTIES,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 };
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 G_DEFINE_TYPE_WITH_PRIVATE(PidginNotification, pidgin_notification,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 GTK_TYPE_BOX)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 /******************************************************************************
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 * Helpers
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 *****************************************************************************/
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 static void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 pidgin_notification_set_notification(PidginNotification *pidgin_notification,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 PurpleNotification *purple_notification)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 PidginNotificationPrivate *priv = NULL;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 priv = pidgin_notification_get_instance_private(pidgin_notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 if(g_set_object(&priv->notification, purple_notification)) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 g_object_notify_by_pspec(G_OBJECT(pidgin_notification),
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 properties[PROP_NOTIFICATION]);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 /******************************************************************************
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 * Callbacks
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 *****************************************************************************/
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 static gboolean
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 pidgin_notification_show_subtitle(G_GNUC_UNUSED PidginNotification *notification,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 const char *subtitle)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 return !purple_strempty(subtitle);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 /******************************************************************************
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 * Widget Actions
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 *****************************************************************************/
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 static void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 pidgin_notification_close(GtkWidget *self,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 G_GNUC_UNUSED const char *action_name,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 G_GNUC_UNUSED GVariant *parameter)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 PidginNotification *notification = PIDGIN_NOTIFICATION(self);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 PidginNotificationPrivate *priv = NULL;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 PurpleNotificationManager *manager = NULL;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 priv = pidgin_notification_get_instance_private(notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 purple_notification_delete(priv->notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 manager = purple_notification_manager_get_default();
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 purple_notification_manager_remove(manager, priv->notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 /******************************************************************************
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 * GObject Implementation
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 *****************************************************************************/
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 static void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 pidgin_notification_get_property(GObject *obj, guint param_id, GValue *value,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 GParamSpec *pspec)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 PidginNotification *notification = PIDGIN_NOTIFICATION(obj);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 switch(param_id) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 case PROP_NOTIFICATION:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 g_value_set_object(value,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 pidgin_notification_get_notification(notification));
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 break;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 case PROP_CHILD:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 g_value_set_object(value,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 pidgin_notification_get_child(notification));
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 break;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 default:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 break;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 static void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 pidgin_notification_set_property(GObject *obj, guint param_id,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 const GValue *value, GParamSpec *pspec)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 PidginNotification *notification = PIDGIN_NOTIFICATION(obj);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 switch(param_id) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 case PROP_NOTIFICATION:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 pidgin_notification_set_notification(notification,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 g_value_get_object(value));
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 break;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 case PROP_CHILD:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 pidgin_notification_set_child(notification, g_value_get_object(value));
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 break;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 default:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 break;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 static void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 pidgin_notification_dispose(GObject *obj) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 PidginNotification *notification = PIDGIN_NOTIFICATION(obj);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 PidginNotificationPrivate *priv = NULL;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 priv = pidgin_notification_get_instance_private(notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 g_clear_object(&priv->notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 g_clear_pointer(&priv->child, gtk_widget_unparent);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 G_OBJECT_CLASS(pidgin_notification_parent_class)->dispose(obj);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 pidgin_notification_init(PidginNotification *notification) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 gtk_widget_init_template(GTK_WIDGET(notification));
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 static void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 pidgin_notification_class_init(PidginNotificationClass *klass) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 obj_class->get_property = pidgin_notification_get_property;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 obj_class->set_property = pidgin_notification_set_property;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 obj_class->dispose = pidgin_notification_dispose;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 /**
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 * PidginNotification:notification:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 * The [type@Purple.Notification] that is being displayed.
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 * Since: 3.0
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 */
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 properties[PROP_NOTIFICATION] = g_param_spec_object(
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 "notification", NULL, NULL,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 PURPLE_TYPE_NOTIFICATION,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 /**
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 * PidginNotification:child:
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 * Child widgets to show between the details and the close button.
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 * This is typically actions like message, add contact, etc.
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 * Since: 3.0
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 */
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 properties[PROP_CHILD] = g_param_spec_object(
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 "child", NULL, NULL,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 GTK_TYPE_WIDGET,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 /* Actions */
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 gtk_widget_class_install_action(widget_class, "notification.close",
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 NULL, pidgin_notification_close);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 /* Bindings */
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 gtk_widget_class_set_template_from_resource(widget_class,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 "/im/pidgin/Pidgin3/notification.ui");
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 gtk_widget_class_bind_template_child_private(widget_class,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 PidginNotification, details);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 gtk_widget_class_bind_template_callback(widget_class,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 pidgin_notification_show_subtitle);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 /******************************************************************************
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 * API
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 *****************************************************************************/
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 GtkWidget *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 pidgin_notification_new(PurpleNotification *notification) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 return g_object_new(
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 PIDGIN_TYPE_NOTIFICATION,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 "notification", notification,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 NULL);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 PurpleNotification *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 pidgin_notification_get_notification(PidginNotification *notification)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 PidginNotificationPrivate *priv = NULL;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 g_return_val_if_fail(PIDGIN_IS_NOTIFICATION(notification), NULL);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 priv = pidgin_notification_get_instance_private(notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 return priv->notification;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 GtkWidget *
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 pidgin_notification_get_child(PidginNotification *notification) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 PidginNotificationPrivate *priv = NULL;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 g_return_val_if_fail(PIDGIN_IS_NOTIFICATION(notification), NULL);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 priv = pidgin_notification_get_instance_private(notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 return priv->child;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 void
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 pidgin_notification_set_child(PidginNotification *notification,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 GtkWidget *child)
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 PidginNotificationPrivate *priv = NULL;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 g_return_if_fail(PIDGIN_IS_NOTIFICATION(notification));
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 priv = pidgin_notification_get_instance_private(notification);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 if(child == priv->child) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 return;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 g_clear_pointer(&priv->child, gtk_widget_unparent);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 if(GTK_IS_WIDGET(child)) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 priv->child = child;
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 gtk_box_insert_child_after(GTK_BOX(notification), child,
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 priv->details);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 }
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 g_object_notify_by_pspec(G_OBJECT(notification), properties[PROP_CHILD]);
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 }

mercurial