pidgin/pidginnotificationlist.c

Tue, 09 Apr 2024 22:49:24 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 09 Apr 2024 22:49:24 -0500
changeset 42664
88cf3cdfd5d9
parent 42629
03341514e25a
child 42758
f95b932717bb
permissions
-rw-r--r--

Add item-type and n-items properties to PurplePresenceManager

Testing Done:
Compiled

Bugs closed: PIDGIN-17856

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

41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidgin/pidginnotificationlist.h"
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
29 #include "pidgin/pidginnotificationaddcontact.h"
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
30 #include "pidgin/pidginnotificationauthorizationrequest.h"
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 #include "pidgin/pidginnotificationconnectionerror.h"
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 struct _PidginNotificationList {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 GtkBox parent;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
36 GtkStack *stack;
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
37 GtkSingleSelection *selection_model;
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 };
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
42575
580339aa47cc Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42195
diff changeset
40 G_DEFINE_FINAL_TYPE(PidginNotificationList, pidgin_notification_list,
580339aa47cc Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42195
diff changeset
41 GTK_TYPE_BOX)
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 /******************************************************************************
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 * Helpers
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 *****************************************************************************/
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
46 static gboolean
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
47 pidgin_notification_gpointer_to_char(G_GNUC_UNUSED GBinding *binding,
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
48 const GValue *from_value,
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
49 GValue *to_value,
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
50 G_GNUC_UNUSED gpointer user_data)
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
51 {
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
52 g_value_set_string(to_value, (char *)g_value_get_pointer(from_value));
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
53
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
54 return TRUE;
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
55 }
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
56
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 static GtkWidget *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 pidgin_notification_list_unknown_notification(PurpleNotification *notification) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 GtkWidget *widget = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 gchar *label = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 const gchar *title = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 title = purple_notification_get_title(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 if(title != NULL) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 label = g_strdup_printf(_("Unknown notification type %d: %s"),
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 purple_notification_get_notification_type(notification),
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 title);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 } else {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 label = g_strdup_printf(_("Unknown notification type %d"),
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 purple_notification_get_notification_type(notification));
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 widget = gtk_label_new(label);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 g_free(label);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 return widget;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 static GtkWidget *
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
81 pidgin_notification_generic_new(PurpleNotification *notification) {
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
82 GtkWidget *row = NULL;
42195
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
83 GtkWidget *icon = NULL;
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
84
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
85 icon = gtk_image_new();
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
86 gtk_image_set_icon_size(GTK_IMAGE(icon), GTK_ICON_SIZE_LARGE);
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
87 g_object_bind_property(notification, "icon-name", icon, "icon-name",
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
88 G_BINDING_SYNC_CREATE);
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
89
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
90 row = adw_action_row_new();
42195
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
91 adw_action_row_add_prefix(ADW_ACTION_ROW(row), icon);
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
92
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
93 g_object_bind_property(notification, "title", row, "title",
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
94 G_BINDING_SYNC_CREATE);
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
95 g_object_bind_property_full(notification, "data", row, "subtitle",
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
96 G_BINDING_SYNC_CREATE,
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
97 pidgin_notification_gpointer_to_char,
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
98 NULL,
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
99 NULL,
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
100 NULL);
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
101
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
102 return row;
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
103 }
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
104
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
105 /******************************************************************************
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
106 * Callbacks
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
107 *****************************************************************************/
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
108 static void
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
109 pidgin_notification_list_items_changed_cb(GListModel *model,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
110 G_GNUC_UNUSED guint position,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
111 G_GNUC_UNUSED guint added,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
112 G_GNUC_UNUSED guint removed,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
113 gpointer data)
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
114 {
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
115 PidginNotificationList *list = data;
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
116
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
117 if(g_list_model_get_n_items(model) != 0) {
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
118 gtk_stack_set_visible_child_name(list->stack, "view");
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
119 } else {
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
120 gtk_stack_set_visible_child_name(list->stack, "placeholder");
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
121 }
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
122 }
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
123
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
124 static void
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
125 pidgin_notification_list_bind_cb(G_GNUC_UNUSED GtkSignalListItemFactory *self,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
126 GObject *object,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
127 G_GNUC_UNUSED gpointer data)
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41936
diff changeset
128 {
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
129 PurpleNotification *notification = NULL;
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
130 GtkListItem *item = GTK_LIST_ITEM(object);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 GtkWidget *widget = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
133 notification = gtk_list_item_get_item(item);
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
134
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 switch(purple_notification_get_notification_type(notification)) {
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
136 case PURPLE_NOTIFICATION_TYPE_GENERIC:
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
137 widget = pidgin_notification_generic_new(notification);
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
138 break;
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 case PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR:
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 widget = pidgin_notification_connection_error_new(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 break;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
142 case PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST:
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
143 widget = pidgin_notification_authorization_request_new(notification);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
144 break;
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
145 case PURPLE_NOTIFICATION_TYPE_ADD_CONTACT:
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
146 widget = pidgin_notification_add_contact_new(notification);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
147 break;
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 default:
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 widget = pidgin_notification_list_unknown_notification(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 break;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 if(!GTK_IS_WIDGET(widget)) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 widget = pidgin_notification_list_unknown_notification(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
157 gtk_list_item_set_child(item, widget);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 /******************************************************************************
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 * GObject Implementation
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 *****************************************************************************/
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 static void
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 pidgin_notification_list_init(PidginNotificationList *list) {
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
165 GListModel *model = NULL;
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
166
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 gtk_widget_init_template(GTK_WIDGET(list));
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
169 model = purple_notification_manager_get_default_as_model();
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
170 gtk_single_selection_set_model(list->selection_model, model);
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
171 g_signal_connect(model, "items-changed",
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
172 G_CALLBACK(pidgin_notification_list_items_changed_cb),
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
173 list);
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
174 pidgin_notification_list_items_changed_cb(model, 0, 0, 0, list);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 static void
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 pidgin_notification_list_class_init(PidginNotificationListClass *klass) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 gtk_widget_class_set_template_from_resource(
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 widget_class,
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
183 "/im/pidgin/Pidgin3/notificationlist.ui"
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 );
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 gtk_widget_class_bind_template_child(widget_class, PidginNotificationList,
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
187 stack);
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
188 gtk_widget_class_bind_template_child(widget_class, PidginNotificationList,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
189 selection_model);
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
190
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
191 gtk_widget_class_bind_template_callback(widget_class,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
192 pidgin_notification_list_bind_cb);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 /******************************************************************************
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 * API
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 *****************************************************************************/
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 GtkWidget *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 pidgin_notification_list_new(void) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 return g_object_new(PIDGIN_TYPE_NOTIFICATION_LIST, NULL);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 }

mercurial