Thu, 25 Aug 2022 21:34:06 -0500
Remove some old resources that aren't being used but were left around.
Testing Done:
Compiled and ran, opened a few things made sure there weren't any errors.
Reviewed at https://reviews.imfreedom.org/r/1641/
|
41510
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Finch - Universal Text Chat Client |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Finch is the legal property of its developers, whose names are too numerous |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <config.h> |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include <glib.h> |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include <glib/gi18n-lib.h> |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include <glib/gstdio.h> |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | #include <purple.h> |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | #include <gnt.h> |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | #include "finchnotifications.h" |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | #include "gntaccount.h" |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | static struct { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | GntWidget *window; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | GntWidget *list; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | } notifications; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | /******************************************************************************* |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | * Helpers |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | ******************************************************************************/ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | finch_notifications_update(GntTree *list, GListModel *model) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | guint index = 0; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | gnt_tree_remove_all(GNT_TREE(list)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | for(index = 0; index < g_list_model_get_n_items(model); index++) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | PurpleNotification *notification = g_list_model_get_item(model, index); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | GntTreeRow *row = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | row = gnt_tree_create_row(list, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | purple_notification_get_title(notification)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | gnt_tree_add_row_last(list, notification, row, NULL); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | finch_notification_delete_notification(PurpleNotification *notification) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | if(PURPLE_IS_NOTIFICATION(notification)) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | PurpleNotificationManager *manager = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | |
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
66 | purple_notification_delete(notification); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
67 | |
|
41510
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | manager = purple_notification_manager_get_default(); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | purple_notification_manager_remove(manager, notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | /******************************************************************************* |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | * Finch Notification Callbacks |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | ******************************************************************************/ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | finch_notification_delete(G_GNUC_UNUSED GntWidget *widget, gpointer data) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | PurpleNotification *notification = g_object_get_data(data, "notification"); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | finch_notification_delete_notification(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | gnt_widget_destroy(GNT_WIDGET(data)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | finch_notification_reconnect_account(G_GNUC_UNUSED GntWidget *widget, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | gpointer data) |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | PurpleNotification *notification = g_object_get_data(data, "notification"); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | PurpleAccount *account = purple_notification_get_account(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | if(PURPLE_IS_ACCOUNT(account)) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | purple_account_connect(account); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | gnt_widget_destroy(GNT_WIDGET(data)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | finch_notification_reenable_account(G_GNUC_UNUSED GntWidget *widget, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | gpointer data) |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | PurpleNotification *notification = g_object_get_data(data, "notification"); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | PurpleAccount *account = purple_notification_get_account(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | if(PURPLE_IS_ACCOUNT(account)) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | purple_account_set_enabled(account, TRUE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | gnt_widget_destroy(GNT_WIDGET(data)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | finch_notification_modify_account(G_GNUC_UNUSED GntWidget *widget, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | gpointer data) |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | PurpleNotification *notification = g_object_get_data(data, "notification"); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | PurpleAccount *account = purple_notification_get_account(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | if(PURPLE_IS_ACCOUNT(account)) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | finch_account_dialog_show(account); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | gnt_widget_destroy(GNT_WIDGET(data)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | |
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
127 | static void |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
128 | finch_notification_contact_authorize(G_GNUC_UNUSED GntWidget *widget, |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
129 | gpointer data) |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
130 | { |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
131 | PurpleAccount *account = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
132 | PurpleNotification *notification = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
133 | PurpleNotificationManager *manager = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
134 | PurpleAuthorizationRequest *auth_request = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
135 | const gchar *alias = NULL, *username = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
136 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
137 | /* Get the notification and authorization request from the data. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
138 | notification = g_object_get_data(data, "notification"); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
139 | auth_request = purple_notification_get_data(notification); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
140 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
141 | /* Accept the authorization request. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
142 | purple_authorization_request_accept(auth_request); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
143 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
144 | /* Remove the notification from the manager. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
145 | manager = purple_notification_manager_get_default(); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
146 | purple_notification_manager_remove(manager, notification); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
147 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
148 | /* Request the user to add the person they just authorized. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
149 | account = purple_authorization_request_get_account(auth_request); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
150 | alias = purple_authorization_request_get_alias(auth_request); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
151 | username = purple_authorization_request_get_username(auth_request); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
152 | purple_blist_request_add_buddy(account, username, NULL, alias); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
153 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
154 | /* Destroy the dialog. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
155 | gnt_widget_destroy(GNT_WIDGET(data)); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
156 | } |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
157 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
158 | static void |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
159 | finch_notification_contact_deny(G_GNUC_UNUSED GntWidget *widget, gpointer data) |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
160 | { |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
161 | PurpleNotification *notification = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
162 | PurpleNotificationManager *manager = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
163 | PurpleAuthorizationRequest *auth_request = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
164 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
165 | /* Get the notification and authorization request from the data. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
166 | notification = g_object_get_data(data, "notification"); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
167 | auth_request = purple_notification_get_data(notification); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
168 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
169 | /* Deny the request. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
170 | purple_authorization_request_deny(auth_request, NULL); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
171 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
172 | /* Remove the notification from the manager. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
173 | manager = purple_notification_manager_get_default(); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
174 | purple_notification_manager_remove(manager, notification); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
175 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
176 | /* Destroy the dialog. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
177 | gnt_widget_destroy(GNT_WIDGET(data)); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
178 | } |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
179 | |
|
41510
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | /******************************************************************************* |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | * Finch Notification API |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | ******************************************************************************/ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | finch_notification_show(PurpleNotification *notification) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | GntWidget *dialog = NULL, *label = NULL, *hbox = NULL, *button = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | PurpleAccount *account = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | PurpleNotificationType type; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | gpointer data = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | account = purple_notification_get_account(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | dialog = gnt_box_new(FALSE, TRUE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | gnt_box_set_toplevel(GNT_BOX(dialog), TRUE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | gnt_box_set_alignment(GNT_BOX(dialog), GNT_ALIGN_MID); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | g_object_set_data(G_OBJECT(dialog), "notification", notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | label = gnt_label_new(purple_notification_get_title(notification)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | gnt_box_add_widget(GNT_BOX(dialog), label); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | hbox = gnt_box_new(FALSE, FALSE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | type = purple_notification_get_notification_type(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | data = purple_notification_get_data(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | if(type == PURPLE_NOTIFICATION_TYPE_GENERIC) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | gnt_box_set_title(GNT_BOX(dialog), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | purple_notification_get_title(notification)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | label = gnt_label_new(purple_notification_get_data(notification)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | } else if(type == PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | PurpleConnectionErrorInfo *info = data; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | |
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
212 | /* Set the title. */ |
|
41510
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | gnt_box_set_title(GNT_BOX(dialog), _("Connection Error")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | /* Add the connection error reason. */ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | label = gnt_label_new(info->description); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | gnt_box_add_widget(GNT_BOX(dialog), label); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | /* Add the buttons. */ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | if(purple_account_get_enabled(account)) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | button = gnt_button_new(_("Reconnect")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | g_signal_connect(button, "activate", |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | G_CALLBACK(finch_notification_reconnect_account), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | dialog); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | } else { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | button = gnt_button_new(_("Re-enable")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | g_signal_connect(button, "activate", |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | G_CALLBACK(finch_notification_reenable_account), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | dialog); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | gnt_box_add_widget(GNT_BOX(hbox), button); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | button = gnt_button_new(_("Modify Account")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | g_signal_connect(button, "activate", |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | G_CALLBACK(finch_notification_modify_account), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | dialog); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | gnt_box_add_widget(GNT_BOX(hbox), button); |
|
41514
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
238 | } else if(type == PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST) { |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
239 | PurpleAuthorizationRequest *auth_request = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
240 | const gchar *message = NULL; |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
241 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
242 | /* Set the title. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
243 | gnt_box_set_title(GNT_BOX(dialog), _("Authorization Request")); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
244 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
245 | auth_request = purple_notification_get_data(notification); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
246 | message = purple_authorization_request_get_message(auth_request); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
247 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
248 | /* Add the message if we have one. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
249 | if(message != NULL && *message != '\0') { |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
250 | label = gnt_label_new(message); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
251 | gnt_box_add_widget(GNT_BOX(dialog), label); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
252 | } |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
253 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
254 | /* Add the buttons. */ |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
255 | button = gnt_button_new(_("Authorize")); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
256 | g_signal_connect(button, "activate", |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
257 | G_CALLBACK(finch_notification_contact_authorize), |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
258 | dialog); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
259 | gnt_box_add_widget(GNT_BOX(hbox), button); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
260 | |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
261 | button = gnt_button_new(_("Deny")); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
262 | g_signal_connect(button, "activate", |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
263 | G_CALLBACK(finch_notification_contact_deny), dialog); |
|
a96768bacb59
Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents:
41510
diff
changeset
|
264 | gnt_box_add_widget(GNT_BOX(hbox), button); |
|
41510
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | gnt_box_add_widget(GNT_BOX(dialog), hbox); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | button = gnt_button_new(_("Delete")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | g_signal_connect(button, "activate", |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | G_CALLBACK(finch_notification_delete), dialog); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | gnt_box_add_widget(GNT_BOX(hbox), button); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | gnt_widget_show(dialog); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | /******************************************************************************* |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | * Callbacks |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | ******************************************************************************/ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | finch_notifications_changed_cb(GListModel *model, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | G_GNUC_UNUSED guint position, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | G_GNUC_UNUSED guint removed, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | guint added, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | gpointer data) |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | finch_notifications_update(data, model); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | if(added > 0) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | gnt_widget_set_urgent(notifications.window); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | finch_notifications_open_cb(G_GNUC_UNUSED GntWidget *w, gpointer data) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | PurpleNotification *notification = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | notification = gnt_tree_get_selection_data(GNT_TREE(notifications.list)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | if(!PURPLE_IS_NOTIFICATION(notification)) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | return; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | finch_notification_show(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | finch_notifications_delete_cb(G_GNUC_UNUSED GntWidget *widget, gpointer data) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | PurpleNotification *notification = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | notification = gnt_tree_get_selection_data(GNT_TREE(notifications.list)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | finch_notification_delete_notification(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | static void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | finch_notifications_activate_cb(G_GNUC_UNUSED GntWidget *w, |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | G_GNUC_UNUSED gpointer data) |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | PurpleNotification *notification = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | notification = gnt_tree_get_selection_data(GNT_TREE(notifications.list)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | finch_notification_show(notification); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | /******************************************************************************* |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | * Public API |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | ******************************************************************************/ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | finch_notifications_window_show(void) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | PurpleNotificationManager *manager = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | GntWidget *wid, *box; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | GListModel *model = NULL; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | if(notifications.window) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | gnt_window_present(notifications.window); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | return; |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | notifications.window = gnt_vbox_new(FALSE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | gnt_box_set_toplevel(GNT_BOX(notifications.window), TRUE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | gnt_box_set_fill(GNT_BOX(notifications.window), TRUE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | gnt_box_set_title(GNT_BOX(notifications.window), _("Notifications")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | gnt_box_set_alignment(GNT_BOX(notifications.window), GNT_ALIGN_MID); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | gnt_box_set_pad(GNT_BOX(notifications.window), 0); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | gnt_widget_set_name(notifications.window, "notifications"); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | /* Create the box that lists all of the notifications. */ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | notifications.list = gnt_tree_new_with_columns(1); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | gnt_tree_set_compare_func(GNT_TREE(notifications.list), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | purple_notification_compare); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | gnt_widget_set_has_border(notifications.list, FALSE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | gnt_box_add_widget(GNT_BOX(notifications.window), notifications.list); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | g_signal_connect(notifications.list, "activate", |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | G_CALLBACK(finch_notifications_activate_cb), NULL); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | /* Get the notification manager to get the model and populate the list. */ |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | manager = purple_notification_manager_get_default(); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | model = purple_notification_manager_get_model(manager); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | finch_notifications_update(GNT_TREE(notifications.list), model); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | g_signal_connect_object(model, "items-changed", |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | G_CALLBACK(finch_notifications_changed_cb), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | notifications.list, 0); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | gnt_box_add_widget(GNT_BOX(notifications.window), gnt_line_new(FALSE)); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | box = gnt_hbox_new(FALSE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | gnt_box_set_fill(GNT_BOX(box), FALSE); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | wid = gnt_button_new(_("Open")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | g_signal_connect(wid, "activate", G_CALLBACK(finch_notifications_open_cb), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | NULL); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | gnt_box_add_widget(GNT_BOX(box), wid); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | wid = gnt_button_new(_("Delete")); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | g_signal_connect(wid, "activate", G_CALLBACK(finch_notifications_delete_cb), |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | NULL); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | gnt_box_add_widget(GNT_BOX(box), wid); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
382 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
383 | gnt_box_add_widget(GNT_BOX(notifications.window), box); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | gnt_widget_show(notifications.window); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | finch_notifications_init(void) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
390 | } |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
392 | void |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
393 | finch_notifications_uninit(void) { |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | g_clear_pointer(¬ifications.window, gnt_widget_destroy); |
|
630da93b9984
Implement notifications in Finch
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | } |