pidgin/pidgin

Restore placeholder page for notification list

2 months ago, Elliott Sales de Andrade
03341514e25a
Parents b069ea54b906
Children 4895793f3298
Restore placeholder page for notification list

Testing Done:
Opened Notifications tab, and saw the placeholder tab. Triggered a notification from the Demo protocol, and the list view appeared. Cleared notifications, and it went back to the placeholder.

Reviewed at https://reviews.imfreedom.org/r/3013/
--- a/pidgin/pidginnotificationlist.c Thu Mar 07 23:58:52 2024 -0600
+++ b/pidgin/pidginnotificationlist.c Fri Mar 08 01:05:27 2024 -0600
@@ -33,7 +33,7 @@
struct _PidginNotificationList {
GtkBox parent;
- GtkWidget *list_view;
+ GtkStack *stack;
GtkSingleSelection *selection_model;
};
@@ -106,6 +106,22 @@
* Callbacks
*****************************************************************************/
static void
+pidgin_notification_list_items_changed_cb(GListModel *model,
+ G_GNUC_UNUSED guint position,
+ G_GNUC_UNUSED guint added,
+ G_GNUC_UNUSED guint removed,
+ gpointer data)
+{
+ PidginNotificationList *list = data;
+
+ if(g_list_model_get_n_items(model) != 0) {
+ gtk_stack_set_visible_child_name(list->stack, "view");
+ } else {
+ gtk_stack_set_visible_child_name(list->stack, "placeholder");
+ }
+}
+
+static void
pidgin_notification_list_bind_cb(G_GNUC_UNUSED GtkSignalListItemFactory *self,
GObject *object,
G_GNUC_UNUSED gpointer data)
@@ -152,6 +168,10 @@
model = purple_notification_manager_get_default_as_model();
gtk_single_selection_set_model(list->selection_model, model);
+ g_signal_connect(model, "items-changed",
+ G_CALLBACK(pidgin_notification_list_items_changed_cb),
+ list);
+ pidgin_notification_list_items_changed_cb(model, 0, 0, 0, list);
}
static void
@@ -164,7 +184,7 @@
);
gtk_widget_class_bind_template_child(widget_class, PidginNotificationList,
- list_view);
+ stack);
gtk_widget_class_bind_template_child(widget_class, PidginNotificationList,
selection_model);
--- a/pidgin/resources/notificationlist.ui Thu Mar 07 23:58:52 2024 -0600
+++ b/pidgin/resources/notificationlist.ui Fri Mar 08 01:05:27 2024 -0600
@@ -18,6 +18,7 @@
-->
<interface>
<requires lib="gtk" version="4.0"/>
+ <requires lib="Adw" version="1.0"/>
<!-- interface-license-type gplv2 -->
<!-- interface-name Pidgin -->
<!-- interface-description Internet Messenger -->
@@ -25,29 +26,39 @@
<template class="PidginNotificationList" parent="GtkBox">
<property name="orientation">vertical</property>
<child>
- <object class="GtkListView" id="list_view">
- <property name="model">
- <object class="GtkSingleSelection" id="selection_model"/>
- </property>
- <property name="factory">
- <object class="GtkSignalListItemFactory">
- <signal name="bind" handler="pidgin_notification_list_bind_cb"/>
- </object>
- </property>
-<!--
- <child type="placeholder">
- <object class="AdwStatusPage">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">mail-read-symbolic</property>
- <property name="title" translatable="1">Notifications</property>
- <property name="description" translatable="1">You&apos;re all caught up!</property>
- <child>
- <placeholder/>
- </child>
+ <object class="GtkStack" id="stack">
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">view</property>
+ <property name="child">
+ <object class="GtkListView">
+ <property name="model">
+ <object class="GtkSingleSelection" id="selection_model"/>
+ </property>
+ <property name="factory">
+ <object class="GtkSignalListItemFactory">
+ <signal name="bind" handler="pidgin_notification_list_bind_cb"/>
+ </object>
+ </property>
+ </object>
+ </property>
</object>
</child>
--->
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">placeholder</property>
+ <property name="child">
+ <object class="AdwStatusPage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">mail-read-symbolic</property>
+ <property name="title" translatable="1">Notifications</property>
+ <property name="description" translatable="1">You&apos;re all caught up!</property>
+ </object>
+ </property>
+ </object>
+ </child>
</object>
</child>
</template>