pidgin/pidginnotificationlist.c

Sat, 21 Sep 2024 16:22:31 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Sat, 21 Sep 2024 16:22:31 -0500
changeset 42960
f80f044d734c
parent 42951
37816f063275
child 42961
9b94dce254d8
permissions
-rw-r--r--

Fix keep-aspect-ratio deprecation

We require a new enough GTK to use the new property.

Testing Done:
Compiled, ran, and didn't see the warning any more.

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

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
42940
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
27 #include "pidginnotificationlist.h"
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
42940
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
29 #include "pidginnotifiable.h"
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
30 #include "pidginnotification.h"
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
31 #include "pidginnotificationaddcontact.h"
42951
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents: 42940
diff changeset
32 #include "pidginnotificationlink.h"
41441
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 *****************************************************************************/
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
53 static guint
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
54 pidgin_notification_list_get_count(PidginNotificationList *list) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
55 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
56
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
57 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
58 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
59
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
60 static gboolean
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
61 pidgin_notification_list_get_needs_attention(PidginNotificationList *list) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
62 guint count = 0;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
63
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
64 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
65
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
66 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
67
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
68 return (count > 0);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
69 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
70
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
71 /******************************************************************************
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
72 * Callbacks
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
73 *****************************************************************************/
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
74 static void
42629
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
75 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
76 G_GNUC_UNUSED guint position,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
77 G_GNUC_UNUSED guint added,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
78 G_GNUC_UNUSED guint removed,
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
79 gpointer data)
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
80 {
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
81 PidginNotificationList *list = data;
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
82 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
83
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
84 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
85 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
86 } else {
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
87 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
88 }
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
89
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
90 g_object_freeze_notify(obj);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
91 g_object_notify(obj, "needs-attention");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
92 g_object_notify(obj, "notification-count");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
93 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
94 }
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
95
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
96 static void
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
97 pidgin_notification_list_bind_cb(G_GNUC_UNUSED GtkSignalListItemFactory *self,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
98 GObject *object,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
99 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
100 {
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
101 PurpleNotification *notification = NULL;
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
102 GtkListItem *item = GTK_LIST_ITEM(object);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 GtkWidget *widget = NULL;
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
105 notification = gtk_list_item_get_item(item);
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
106
42940
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
107 if(PURPLE_IS_NOTIFICATION_ADD_CONTACT(notification)) {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
108 widget = pidgin_notification_add_contact_new(notification);
42951
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents: 42940
diff changeset
109 } else if(PURPLE_IS_NOTIFICATION_LINK(notification)) {
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents: 42940
diff changeset
110 widget = pidgin_notification_link_new(notification);
42940
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
111 } else {
240eb66a3795 Create Pidgin.Notification to simplify the custom widgets
Gary Kramlich <grim@reaperworld.com>
parents: 42917
diff changeset
112 widget = pidgin_notification_new(notification);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
115 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
116 }
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 /******************************************************************************
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
119 * PidginNotifiable Implementation
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
120 *****************************************************************************/
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
121 static void
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
122 pidgin_notification_list_notifiable_init(G_GNUC_UNUSED PidginNotifiableInterface *iface) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
123 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
124
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
125 /******************************************************************************
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 * GObject Implementation
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 *****************************************************************************/
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
128 G_DEFINE_FINAL_TYPE_WITH_CODE(
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
129 PidginNotificationList,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
130 pidgin_notification_list,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
131 GTK_TYPE_BOX,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
132 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
133
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
134 static void
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
135 pidgin_notification_list_get_property(GObject *obj, guint param_id,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
136 GValue *value, GParamSpec *pspec)
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
137 {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
138 PidginNotificationList *list = PIDGIN_NOTIFICATION_LIST(obj);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
139
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
140 switch(param_id) {
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
141 case PROP_NEEDS_ATTENTION:
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
142 g_value_set_boolean(value,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
143 pidgin_notification_list_get_needs_attention(list));
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
144 break;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
145 case PROP_NOTIFICATION_COUNT:
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
146 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
147 break;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
148 default:
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
149 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
150 break;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
151 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
152 }
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
153
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 static void
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 pidgin_notification_list_init(PidginNotificationList *list) {
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
156 GListModel *model = NULL;
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
157
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 gtk_widget_init_template(GTK_WIDGET(list));
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
160 model = purple_notification_manager_get_default_as_model();
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
161 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
162 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
163 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
164 list);
03341514e25a Restore placeholder page for notification list
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42627
diff changeset
165 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
166 }
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 static void
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 pidgin_notification_list_class_init(PidginNotificationListClass *klass) {
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
170 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
171 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172
42758
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
173 obj_class->get_property = pidgin_notification_list_get_property;
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
174
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
175 g_object_class_override_property(obj_class, PROP_NEEDS_ATTENTION,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
176 "needs-attention");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
177 g_object_class_override_property(obj_class, PROP_NOTIFICATION_COUNT,
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
178 "notification-count");
f95b932717bb Implement PidginNotifiable on PidginNotificationList
Gary Kramlich <grim@reaperworld.com>
parents: 42629
diff changeset
179
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 gtk_widget_class_set_template_from_resource(
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 widget_class,
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
182 "/im/pidgin/Pidgin3/notificationlist.ui"
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 );
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 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
186 stack);
42627
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
187 gtk_widget_class_bind_template_child(widget_class, PidginNotificationList,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
188 selection_model);
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
189
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
190 gtk_widget_class_bind_template_callback(widget_class,
8378ac3ef0f1 Convert PidginNotificationList to GtkListView
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
191 pidgin_notification_list_bind_cb);
41441
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 }
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 * API
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 *****************************************************************************/
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 GtkWidget *
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 pidgin_notification_list_new(void) {
e114ed471a1e Implement the UI for the new Notifications API.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 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
200 }

mercurial