[gnome-builder/wip/greeter] greeter: hide groups when no items are visible
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/greeter] greeter: hide groups when no items are visible
- Date: Sun, 10 May 2015 20:55:01 +0000 (UTC)
commit 2244881900d76f4a4fc6d3c168b2e2cdc3a4c832
Author: Christian Hergert <christian hergert me>
Date: Sun May 10 13:54:51 2015 -0700
greeter: hide groups when no items are visible
data/ui/gb-greeter-window.ui | 106 +++++++++++++++++++++++----------------
src/greeter/gb-greeter-window.c | 30 +++++++++++
2 files changed, 92 insertions(+), 44 deletions(-)
---
diff --git a/data/ui/gb-greeter-window.ui b/data/ui/gb-greeter-window.ui
index 4d14d12..dfed5bb 100644
--- a/data/ui/gb-greeter-window.ui
+++ b/data/ui/gb-greeter-window.ui
@@ -91,36 +91,48 @@
<object class="GtkBox">
<property name="margin-top">32</property>
<property name="margin-bottom">32</property>
- <property name="spacing">6</property>
+ <property name="spacing">32</property>
<property name="orientation">vertical</property>
<property name="visible">true</property>
<child>
- <object class="GtkLabel" id="my_projects_label">
- <property name="halign">center</property>
- <property name="label" translatable="yes">My Projects</property>
+ <object class="GtkBox" id="my_projects_container">
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<property name="visible">true</property>
- <property name="xalign">0.0</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkFrame" id="my_projects_frame">
- <property name="halign">center</property>
- <property name="visible">true</property>
- <property name="shadow-type">in</property>
<child>
- <object class="GbScrolledWindow">
- <property name="min-content-height">100</property>
- <property name="min-content-width">475</property>
- <property name="max-content-width">600</property>
+ <object class="GtkLabel" id="my_projects_label">
+ <property name="halign">center</property>
+ <property name="label" translatable="yes">My Projects</property>
+ <property name="visible">true</property>
+ <property name="xalign">0.0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFrame" id="my_projects_frame">
+ <property name="halign">center</property>
<property name="visible">true</property>
- <property name="vscrollbar-policy">never</property>
+ <property name="shadow-type">in</property>
<child>
- <object class="GtkListBox" id="my_projects_list_box">
+ <object class="GbScrolledWindow">
+ <property name="min-content-height">100</property>
+ <property name="min-content-width">475</property>
+ <property name="max-content-width">600</property>
<property name="visible">true</property>
- <property name="selection-mode">none</property>
+ <property name="vscrollbar-policy">never</property>
+ <child>
+ <object class="GtkListBox" id="my_projects_list_box">
+ <property name="visible">true</property>
+ <property name="selection-mode">none</property>
+ <child type="placeholder">
+ <object class="GtkLabel" id="my_projects_placeholder">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -128,33 +140,39 @@
</object>
</child>
<child>
- <object class="GtkLabel" id="other_projects_label">
- <property name="halign">center</property>
- <property name="label" translatable="yes">Other Projects</property>
- <property name="margin-top">32</property>
- <property name="visible">true</property>
- <property name="xalign">0.0</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkFrame" id="other_projects_frame">
- <property name="halign">center</property>
- <property name="shadow-type">in</property>
+ <object class="GtkBox" id="other_projects_container">
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<property name="visible">true</property>
<child>
- <object class="GbScrolledWindow">
- <property name="min-content-height">100</property>
- <property name="min-content-width">300</property>
- <property name="max-content-width">600</property>
+ <object class="GtkLabel" id="other_projects_label">
+ <property name="halign">center</property>
+ <property name="label" translatable="yes">Other Projects</property>
+ <property name="visible">true</property>
+ <property name="xalign">0.0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFrame" id="other_projects_frame">
+ <property name="halign">center</property>
+ <property name="shadow-type">in</property>
<property name="visible">true</property>
- <property name="vscrollbar-policy">never</property>
<child>
- <object class="GtkListBox" id="other_projects_list_box">
+ <object class="GbScrolledWindow">
+ <property name="min-content-height">100</property>
+ <property name="min-content-width">300</property>
+ <property name="max-content-width">600</property>
<property name="visible">true</property>
- <property name="selection-mode">none</property>
+ <property name="vscrollbar-policy">never</property>
+ <child>
+ <object class="GtkListBox" id="other_projects_list_box">
+ <property name="visible">true</property>
+ <property name="selection-mode">none</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/greeter/gb-greeter-window.c b/src/greeter/gb-greeter-window.c
index e875175..3e9194e 100644
--- a/src/greeter/gb-greeter-window.c
+++ b/src/greeter/gb-greeter-window.c
@@ -37,7 +37,10 @@ struct _GbGreeterWindow
IdePatternSpec *pattern_spec;
GtkWidget *header_bar;
+ GtkBox *my_projects_container;
+ GtkLabel *my_projects_placeholder;
GtkListBox *my_projects_list_box;
+ GtkBox *other_projects_container;
GtkListBox *other_projects_list_box;
GtkSearchEntry *search_entry;
};
@@ -61,10 +64,23 @@ gb_greeter_window_get_recent_projects (GbGreeterWindow *self)
}
static void
+foreach_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ gboolean *visible = user_data;
+
+ g_assert (GB_IS_GREETER_PROJECT_ROW (widget));
+
+ if (gtk_widget_get_child_visible (widget))
+ *visible = TRUE;
+}
+
+static void
gb_greeter_window__search_entry_changed (GbGreeterWindow *self,
GtkSearchEntry *search_entry)
{
const gchar *text;
+ gboolean visible;
g_assert (GB_IS_GREETER_WINDOW (self));
g_assert (GTK_IS_SEARCH_ENTRY (search_entry));
@@ -77,7 +93,18 @@ gb_greeter_window__search_entry_changed (GbGreeterWindow *self,
self->pattern_spec = ide_pattern_spec_new (text);
gtk_list_box_invalidate_filter (self->my_projects_list_box);
+ visible = FALSE;
+ gtk_container_foreach (GTK_CONTAINER (self->my_projects_list_box),
+ foreach_cb,
+ &visible);
+ gtk_widget_set_visible (GTK_WIDGET (self->my_projects_container), visible);
+
gtk_list_box_invalidate_filter (self->other_projects_list_box);
+ visible = FALSE;
+ gtk_container_foreach (GTK_CONTAINER (self->other_projects_list_box),
+ foreach_cb,
+ &visible);
+ gtk_widget_set_visible (GTK_WIDGET (self->other_projects_container), visible);
}
static void
@@ -251,7 +278,10 @@ gb_greeter_window_class_init (GbGreeterWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/gb-greeter-window.ui");
gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, header_bar);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, my_projects_container);
gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, my_projects_list_box);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, my_projects_placeholder);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, other_projects_container);
gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, other_projects_list_box);
gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, search_entry);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]