pidgin/pidginnotificationlist.c

Tue, 06 Aug 2024 02:07:35 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 06 Aug 2024 02:07:35 -0500
changeset 42837
1f1614e5468b
parent 42829
329d418cb877
child 42917
8a44c2a3b041
permissions
-rw-r--r--

Remove the pidgin_text_buffer_api

The purposed for this code is being replaced by the markup api which we haven't
implemented yet, but nothing was using this, so we can remove it.

Testing Done:
Ran the turtles.

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

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
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
29 #include "pidgin/pidginnotifiable.h"
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
30 #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
31 #include "pidgin/pidginnotificationauthorizationrequest.h"
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 #include "pidgin/pidginnotificationconnectionerror.h"
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
34 enum {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
35 PROP_0,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
36 N_PROPERTIES,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
37 /* Overrides */
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
38 PROP_NEEDS_ATTENTION = N_PROPERTIES,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
39 PROP_NOTIFICATION_COUNT,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
40 };
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
41 /* There's no global properties because we only have overrides right now. */
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
42
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 struct _PidginNotificationList {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 GtkBox parent;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
46 GtkStack *stack;
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
47 GtkSingleSelection *selection_model;
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 };
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 /******************************************************************************
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 * Helpers
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 *****************************************************************************/
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 static GtkWidget *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 pidgin_notification_list_unknown_notification(PurpleNotification *notification) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 GtkWidget *widget = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 gchar *label = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 const gchar *title = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 title = purple_notification_get_title(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 if(title != NULL) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 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
62 purple_notification_get_notification_type(notification),
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 title);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 } else {
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"),
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 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 widget = gtk_label_new(label);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 g_free(label);
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 return widget;
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
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 static GtkWidget *
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
77 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
78 GtkWidget *row = NULL;
42195
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
79 GtkWidget *icon = NULL;
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
80
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
81 icon = gtk_image_new();
ce5c1634c6a1 Migrate away from AdwActionRow:icon-name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42193
diff changeset
82 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
83 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
84 G_BINDING_SYNC_CREATE);
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
85
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
86 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
87 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
88
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
89 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
90 G_BINDING_SYNC_CREATE);
42829
329d418cb877 Use the subtitle property instead of data when displaying notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42758
diff changeset
91 g_object_bind_property(notification, "subtitle", row, "subtitle",
329d418cb877 Use the subtitle property instead of data when displaying notifications
Gary Kramlich <grim@reaperworld.com>
parents: 42758
diff changeset
92 G_BINDING_SYNC_CREATE);
42193
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
93
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
94 return row;
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
95 }
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
96
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
97 static guint
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
98 pidgin_notification_list_get_count(PidginNotificationList *list) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
99 g_return_val_if_fail(PIDGIN_IS_NOTIFICATION_LIST(list), 0);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
100
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
101 return g_list_model_get_n_items(G_LIST_MODEL(list->selection_model));
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
102 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
103
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
104 static gboolean
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
105 pidgin_notification_list_get_needs_attention(PidginNotificationList *list) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
106 guint count = 0;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
107
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
108 g_return_val_if_fail(PIDGIN_IS_NOTIFICATION_LIST(list), FALSE);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
109
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
110 count = g_list_model_get_n_items(G_LIST_MODEL(list->selection_model));
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
111
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
112 return (count > 0);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
113 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
114
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
115 /******************************************************************************
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
116 * Callbacks
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
117 *****************************************************************************/
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
118 static void
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
119 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
120 G_GNUC_UNUSED guint position,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
121 G_GNUC_UNUSED guint added,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
122 G_GNUC_UNUSED guint removed,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
123 gpointer data)
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
124 {
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
125 PidginNotificationList *list = data;
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
126 GObject *obj = G_OBJECT(list);
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
127
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
128 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
129 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
130 } else {
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
131 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
132 }
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
133
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
134 g_object_freeze_notify(obj);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
135 g_object_notify(obj, "needs-attention");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
136 g_object_notify(obj, "notification-count");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
137 g_object_thaw_notify(obj);
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
138 }
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
139
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
140 static void
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
141 pidgin_notification_list_bind_cb(G_GNUC_UNUSED GtkSignalListItemFactory *self,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
142 GObject *object,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
143 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
144 {
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
145 PurpleNotification *notification = NULL;
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
146 GtkListItem *item = GTK_LIST_ITEM(object);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 GtkWidget *widget = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
149 notification = gtk_list_item_get_item(item);
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
150
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 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
152 case PURPLE_NOTIFICATION_TYPE_GENERIC:
9a7a47cdd0ba Add notifications when a saved plugin fails to load
Gary Kramlich <grim@reaperworld.com>
parents: 41947
diff changeset
153 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
154 break;
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 case PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR:
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 widget = pidgin_notification_connection_error_new(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 break;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
158 case PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST:
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
159 widget = pidgin_notification_authorization_request_new(notification);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41441
diff changeset
160 break;
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
161 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
162 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
163 break;
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 default:
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 widget = pidgin_notification_list_unknown_notification(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 break;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 if(!GTK_IS_WIDGET(widget)) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 widget = pidgin_notification_list_unknown_notification(notification);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
173 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
174 }
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 /******************************************************************************
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
177 * PidginNotifiable Implementation
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
178 *****************************************************************************/
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
179 static void
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
180 pidgin_notification_list_notifiable_init(G_GNUC_UNUSED PidginNotifiableInterface *iface) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
181 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
182
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
183 /******************************************************************************
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 * GObject Implementation
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 *****************************************************************************/
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
186 G_DEFINE_FINAL_TYPE_WITH_CODE(
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
187 PidginNotificationList,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
188 pidgin_notification_list,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
189 GTK_TYPE_BOX,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
190 G_IMPLEMENT_INTERFACE(PIDGIN_TYPE_NOTIFIABLE, pidgin_notification_list_notifiable_init))
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
191
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
192 static void
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
193 pidgin_notification_list_get_property(GObject *obj, guint param_id,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
194 GValue *value, GParamSpec *pspec)
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
195 {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
196 PidginNotificationList *list = PIDGIN_NOTIFICATION_LIST(obj);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
197
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
198 switch(param_id) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
199 case PROP_NEEDS_ATTENTION:
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
200 g_value_set_boolean(value,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
201 pidgin_notification_list_get_needs_attention(list));
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
202 break;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
203 case PROP_NOTIFICATION_COUNT:
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
204 g_value_set_uint(value, pidgin_notification_list_get_count(list));
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
205 break;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
206 default:
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
207 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
208 break;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
209 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
210 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
211
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 static void
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 pidgin_notification_list_init(PidginNotificationList *list) {
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
214 GListModel *model = NULL;
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
215
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 gtk_widget_init_template(GTK_WIDGET(list));
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
218 model = purple_notification_manager_get_default_as_model();
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
219 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
220 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
221 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
222 list);
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
223 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
224 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 static void
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 pidgin_notification_list_class_init(PidginNotificationListClass *klass) {
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
228 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
231 obj_class->get_property = pidgin_notification_list_get_property;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
232
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
233 g_object_class_override_property(obj_class, PROP_NEEDS_ATTENTION,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
234 "needs-attention");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
235 g_object_class_override_property(obj_class, PROP_NOTIFICATION_COUNT,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
236 "notification-count");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
237
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 gtk_widget_class_set_template_from_resource(
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 widget_class,
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
240 "/im/pidgin/Pidgin3/notificationlist.ui"
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 );
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 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
244 stack);
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
245 gtk_widget_class_bind_template_child(widget_class, PidginNotificationList,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
246 selection_model);
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
247
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
248 gtk_widget_class_bind_template_callback(widget_class,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
249 pidgin_notification_list_bind_cb);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 /******************************************************************************
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 * API
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 *****************************************************************************/
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 GtkWidget *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 pidgin_notification_list_new(void) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 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
258 }

mercurial