Commit 972953e0 authored by Christian Hergert's avatar Christian Hergert
Browse files

greeter: show empty state upon no search results

parent 573f795d
......@@ -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));
}
/**
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment