--- a/pidgin/pidginnotificationlist.c Tue May 07 22:57:09 2024 -0500
+++ b/pidgin/pidginnotificationlist.c Tue May 07 23:01:07 2024 -0500
@@ -26,10 +26,20 @@
#include "pidgin/pidginnotificationlist.h"
+#include "pidgin/pidginnotifiable.h" #include "pidgin/pidginnotificationaddcontact.h"
#include "pidgin/pidginnotificationauthorizationrequest.h"
#include "pidgin/pidginnotificationconnectionerror.h"
+ PROP_NEEDS_ATTENTION = N_PROPERTIES, + PROP_NOTIFICATION_COUNT, +/* There's no global properties because we only have overrides right now. */ struct _PidginNotificationList {
@@ -37,9 +47,6 @@
GtkSingleSelection *selection_model;
-G_DEFINE_FINAL_TYPE(PidginNotificationList, pidgin_notification_list,
/******************************************************************************
*****************************************************************************/
@@ -102,6 +109,24 @@
+pidgin_notification_list_get_count(PidginNotificationList *list) { + g_return_val_if_fail(PIDGIN_IS_NOTIFICATION_LIST(list), 0); + return g_list_model_get_n_items(G_LIST_MODEL(list->selection_model)); +pidgin_notification_list_get_needs_attention(PidginNotificationList *list) { + g_return_val_if_fail(PIDGIN_IS_NOTIFICATION_LIST(list), FALSE); + count = g_list_model_get_n_items(G_LIST_MODEL(list->selection_model)); /******************************************************************************
*****************************************************************************/
@@ -113,12 +138,18 @@
PidginNotificationList *list = data;
+ GObject *obj = G_OBJECT(list); if(g_list_model_get_n_items(model) != 0) {
gtk_stack_set_visible_child_name(list->stack, "view");
gtk_stack_set_visible_child_name(list->stack, "placeholder");
+ g_object_freeze_notify(obj); + g_object_notify(obj, "needs-attention"); + g_object_notify(obj, "notification-count"); + g_object_thaw_notify(obj); @@ -158,8 +189,41 @@
/******************************************************************************
+ * PidginNotifiable Implementation + *****************************************************************************/ +pidgin_notification_list_notifiable_init(G_GNUC_UNUSED PidginNotifiableInterface *iface) { +/****************************************************************************** *****************************************************************************/
+G_DEFINE_FINAL_TYPE_WITH_CODE( + PidginNotificationList, + pidgin_notification_list, + G_IMPLEMENT_INTERFACE(PIDGIN_TYPE_NOTIFIABLE, pidgin_notification_list_notifiable_init)) +pidgin_notification_list_get_property(GObject *obj, guint param_id, + GValue *value, GParamSpec *pspec) + PidginNotificationList *list = PIDGIN_NOTIFICATION_LIST(obj); + case PROP_NEEDS_ATTENTION: + g_value_set_boolean(value, + pidgin_notification_list_get_needs_attention(list)); + case PROP_NOTIFICATION_COUNT: + g_value_set_uint(value, pidgin_notification_list_get_count(list)); + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); pidgin_notification_list_init(PidginNotificationList *list) {
GListModel *model = NULL;
@@ -176,8 +240,16 @@
pidgin_notification_list_class_init(PidginNotificationListClass *klass) {
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ obj_class->get_property = pidgin_notification_list_get_property; + g_object_class_override_property(obj_class, PROP_NEEDS_ATTENTION, + g_object_class_override_property(obj_class, PROP_NOTIFICATION_COUNT, gtk_widget_class_set_template_from_resource(
"/im/pidgin/Pidgin3/notificationlist.ui"
--- a/pidgin/resources/Display/window.ui Tue May 07 22:57:09 2024 -0500
+++ b/pidgin/resources/Display/window.ui Tue May 07 23:01:07 2024 -0500
@@ -52,6 +52,12 @@
+ <binding name="needs-attention"> + <lookup name="needs-attention">notification_list</lookup> + <binding name="badge-number"> + <lookup name="notification-count">notification_list</lookup> @@ -159,58 +165,7 @@
<property name="factory">
<object class="GtkBuilderListItemFactory">
- <property name="bytes">
-<?xml version="1.0" encoding="UTF-8"?>
- <template class="GtkListItem">
- <property name="child">
- <object class="GtkTreeExpander" id="expander">
- <binding name="list-row">
- <lookup name="item">GtkListItem</lookup>
- <property name="child">
- <object class="GtkBox">
- <property name="orientation">horizontal</property>
- <property name="spacing">6</property>
- <object class="GtkLabel">
- <property name="xalign">0</property>
- <property name="hexpand">0</property>
- <lookup name="title" type="PidginDisplayItem">
- <lookup name="item">expander</lookup>
- <object class="GtkLabel">
- <class name="circular"/>
- <property name="halign">end</property>
- <binding name="visible">
- <lookup name="needs-attention" type="PidginDisplayItem">
- <lookup name="item">expander</lookup>
- <lookup name="badge-number" type="PidginDisplayItem">
- <lookup name="item">expander</lookup>
+ <property name="resource">/im/pidgin/Pidgin3/display-item.ui</property> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/display-item.ui Tue May 07 23:01:07 2024 -0500
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?> + <template class="GtkListItem"> + <property name="child"> + <object class="GtkTreeExpander" id="expander"> + <binding name="list-row"> + <lookup name="item">GtkListItem</lookup> + <property name="child"> + <object class="GtkBox"> + <property name="orientation">horizontal</property> + <property name="spacing">6</property> + <object class="GtkLabel"> + <property name="xalign">0</property> + <property name="hexpand">0</property> + <lookup name="title" type="PidginDisplayItem"> + <lookup name="item">expander</lookup> + <object class="GtkLabel"> + <class name="circular"/> + <property name="halign">end</property> + <binding name="visible"> + <lookup name="needs-attention" type="PidginDisplayItem"> + <lookup name="item">expander</lookup> + <lookup name="badge-number" type="PidginDisplayItem"> + <lookup name="item">expander</lookup> --- a/pidgin/resources/pidgin.gresource.xml Tue May 07 22:57:09 2024 -0500
+++ b/pidgin/resources/pidgin.gresource.xml Tue May 07 23:01:07 2024 -0500
@@ -36,6 +36,7 @@
<file compressed="true" preprocess="xml-stripblanks">contactlist.ui</file>
<file compressed="true" preprocess="xml-stripblanks">contactlistitem.ui</file>
<file compressed="true" preprocess="xml-stripblanks">conversationmemberlistitem.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">display-item.ui</file> <file compressed="true" preprocess="xml-stripblanks">infopane.ui</file>
<file compressed="true" preprocess="xml-stripblanks">notificationlist.ui</file>
<file compressed="true" preprocess="xml-stripblanks">presenceicon.ui</file>