[gnome-builder] greeter: show empty state upon no search results
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] greeter: show empty state upon no search results
- Date: Tue, 22 Jan 2019 03:26:32 +0000 (UTC)
commit 972953e05d864976e208340c66f4eb792d3a38b7
Author: Christian Hergert <chergert redhat com>
Date: Mon Jan 21 19:26:16 2019 -0800
greeter: show empty state upon no search results
src/libide/greeter/ide-greeter-workspace.c | 33 +++++++++++++++++++++++++++++
src/libide/greeter/ide-greeter-workspace.ui | 9 ++++++++
2 files changed, 42 insertions(+)
---
diff --git a/src/libide/greeter/ide-greeter-workspace.c b/src/libide/greeter/ide-greeter-workspace.c
index 35cfe89e2..62358edd1 100644
--- a/src/libide/greeter/ide-greeter-workspace.c
+++ b/src/libide/greeter/ide-greeter-workspace.c
@@ -68,6 +68,7 @@ struct _IdeGreeterWorkspace
GtkActionBar *projects_action_bar;
GtkLabel *title;
IdeGreeterButtonsSection *buttons_section;
+ DzlEmptyState *empty_state;
guint selection_mode : 1;
};
@@ -82,6 +83,31 @@ enum {
static GParamSpec *properties [N_PROPS];
+static void
+ide_greeter_workspace_has_match_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ gboolean *match = user_data;
+
+ if (IDE_IS_GREETER_SECTION (widget))
+ *match |= gtk_widget_get_visible (widget);
+}
+
+static gboolean
+ide_greeter_workspace_has_match (IdeGreeterWorkspace *self)
+{
+ gboolean match = FALSE;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (IDE_IS_GREETER_WORKSPACE (self));
+
+ gtk_container_foreach (GTK_CONTAINER (self->sections),
+ ide_greeter_workspace_has_match_cb,
+ &match);
+
+ return match;
+}
+
static void
ide_greeter_workspace_filter_sections (PeasExtensionSet *set,
PeasPluginInfo *plugin_info,
@@ -120,6 +146,9 @@ ide_greeter_workspace_apply_filter_all (IdeGreeterWorkspace *self)
peas_extension_set_foreach (self->addins,
ide_greeter_workspace_filter_sections,
self);
+
+ gtk_widget_set_visible (GTK_WIDGET (self->empty_state),
+ !ide_greeter_workspace_has_match (self));
}
static void
@@ -591,6 +620,7 @@ ide_greeter_workspace_class_init (IdeGreeterWorkspaceClass *klass)
gtk_widget_class_bind_template_child (widget_class, IdeGreeterWorkspace, back_button);
gtk_widget_class_bind_template_child (widget_class, IdeGreeterWorkspace, buttons_section);
gtk_widget_class_bind_template_child (widget_class, IdeGreeterWorkspace, clone_surface);
+ gtk_widget_class_bind_template_child (widget_class, IdeGreeterWorkspace, empty_state);
gtk_widget_class_bind_template_child (widget_class, IdeGreeterWorkspace, header_bar);
gtk_widget_class_bind_template_child (widget_class, IdeGreeterWorkspace, left_box);
gtk_widget_class_bind_template_child (widget_class, IdeGreeterWorkspace, projects_action_bar);
@@ -676,6 +706,9 @@ ide_greeter_workspace_add_section (IdeGreeterWorkspace *self,
gtk_widget_set_visible (GTK_WIDGET (section),
ide_greeter_section_filter (section, NULL));
+
+ gtk_widget_set_visible (GTK_WIDGET (self->empty_state),
+ !ide_greeter_workspace_has_match (self));
}
/**
diff --git a/src/libide/greeter/ide-greeter-workspace.ui b/src/libide/greeter/ide-greeter-workspace.ui
index f5753b769..506243fda 100644
--- a/src/libide/greeter/ide-greeter-workspace.ui
+++ b/src/libide/greeter/ide-greeter-workspace.ui
@@ -111,6 +111,15 @@
<property name="visible">true</property>
</object>
</child>
+ <child>
+ <object class="DzlEmptyState" id="empty_state">
+ <property name="icon-name">edit-find-symbolic</property>
+ <property name="pixel-size">64</property>
+ <property name="title" translatable="yes">No Projects Found</property>
+ <property name="vexpand">true</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]