[gnome-todo] sidebar: Add placeholder widget to archive list box
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] sidebar: Add placeholder widget to archive list box
- Date: Sun, 30 Jun 2019 00:52:31 +0000 (UTC)
commit d0900c2cfaa27d43856134bd0c443fe66009c33a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Jun 29 21:37:06 2019 -0300
sidebar: Add placeholder widget to archive list box
When there are no archived task lists, show a standard empty
placeholder instead of the provide rows.
src/sidebar/gtd-sidebar.c | 47 +++++++++++++++++++++++++++++++++++++---------
src/sidebar/gtd-sidebar.ui | 28 +++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 9 deletions(-)
---
diff --git a/src/sidebar/gtd-sidebar.c b/src/sidebar/gtd-sidebar.c
index 754e9df..ac6a210 100644
--- a/src/sidebar/gtd-sidebar.c
+++ b/src/sidebar/gtd-sidebar.c
@@ -530,24 +530,53 @@ on_task_list_removed_cb (GtdManager *manager,
gtk_list_box_invalidate_filter (listbox);
}
+static gboolean
+filter_archive_listbox_cb (GtkListBoxRow *row,
+ gpointer user_data)
+{
+ if (GTD_IS_SIDEBAR_LIST_ROW (row))
+ {
+ GtdTaskList *list;
+
+ list = gtd_sidebar_list_row_get_task_list (GTD_SIDEBAR_LIST_ROW (row));
+ return gtd_task_list_get_archived (list);
+ }
+ else if (GTD_IS_SIDEBAR_PROVIDER_ROW (row))
+ {
+ g_autoptr (GList) lists = NULL;
+ GtdProvider *provider;
+ GList *l;
+
+ provider = gtd_sidebar_provider_row_get_provider (GTD_SIDEBAR_PROVIDER_ROW (row));
+ lists = gtd_provider_get_task_lists (provider);
+
+ for (l = lists; l; l = l->next)
+ {
+ if (gtd_task_list_get_archived (l->data))
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ return FALSE;
+}
+
static gboolean
filter_listbox_cb (GtkListBoxRow *row,
gpointer user_data)
{
GtdTaskList *list;
- GtkListBox *parent;
- GtdSidebar *self;
- gboolean archive;
if (!GTD_IS_SIDEBAR_LIST_ROW (row))
return TRUE;
- self = GTD_SIDEBAR (user_data);
- parent = (GtkListBox *) gtk_widget_get_parent (GTK_WIDGET (row));
list = gtd_sidebar_list_row_get_task_list (GTD_SIDEBAR_LIST_ROW (row));
- archive = parent == self->archive_listbox;
-
- return gtd_task_list_get_archived (list) == archive;
+ return !gtd_task_list_get_archived (list);
}
static gint
@@ -718,7 +747,7 @@ gtd_sidebar_init (GtdSidebar *self)
gtk_list_box_set_filter_func (self->listbox, filter_listbox_cb, self, NULL);
gtk_list_box_set_sort_func (self->archive_listbox, sort_listbox_cb, self, NULL);
- gtk_list_box_set_filter_func (self->archive_listbox, filter_listbox_cb, self, NULL);
+ gtk_list_box_set_filter_func (self->archive_listbox, filter_archive_listbox_cb, self, NULL);
}
void
diff --git a/src/sidebar/gtd-sidebar.ui b/src/sidebar/gtd-sidebar.ui
index 70bc2cc..5e42f26 100644
--- a/src/sidebar/gtd-sidebar.ui
+++ b/src/sidebar/gtd-sidebar.ui
@@ -79,6 +79,34 @@
<property name="expand">1</property>
<property name="selection_mode">browse</property>
<signal name="row-activated" handler="on_listbox_row_activated_cb" object="GtdSidebar"
swapped="no"/>
+
+ <child type="placeholder">
+ <object class="GtkBox">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="hexpand">1</property>
+ <property name="vexpand">1</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkImage">
+ <property name="pixel_size">64</property>
+ <property name="icon_name">folder-symbolic</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">No archived lists</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</property>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]