restrict-applications-selector: Hide placeholder when list isn't empty

Prevents a broken bottom border radius on the list.
This commit is contained in:
Christopher Davis 2021-02-08 06:21:37 -08:00 committed by Georges Basile Stavracas Neto
parent 9ed46ae597
commit 73c1d7f3fe
2 changed files with 9 additions and 1 deletions

View File

@ -61,6 +61,7 @@ struct _MctRestrictApplicationsSelector
GtkBox parent_instance;
GtkListBox *listbox;
GtkLabel *placeholder;
GList *cached_apps; /* (nullable) (owned) (element-type GAppInfo) */
GListStore *apps; /* (owned) */
@ -223,11 +224,14 @@ mct_restrict_applications_selector_class_init (MctRestrictApplicationsSelectorCl
gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentUi/ui/restrict-applications-selector.ui");
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsSelector, listbox);
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsSelector, placeholder);
}
static void
mct_restrict_applications_selector_init (MctRestrictApplicationsSelector *self)
{
guint n_apps;
gtk_widget_init_template (GTK_WIDGET (self));
self->apps = g_list_store_new (G_TYPE_APP_INFO);
@ -244,6 +248,10 @@ mct_restrict_applications_selector_init (MctRestrictApplicationsSelector *self)
self,
NULL);
/* Hide placeholder if not empty */
n_apps = g_list_model_get_n_items (G_LIST_MODEL (self->apps));
gtk_widget_set_visible (GTK_WIDGET (self->placeholder), n_apps != 0);
self->blocklisted_apps = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
g_object_unref,

View File

@ -9,7 +9,7 @@
<property name="selection-mode">none</property>
<child type="placeholder">
<object class="GtkLabel">
<object class="GtkLabel" id="placeholder">
<property name="visible">True</property>
<property name="label" translatable="yes">No applications found to restrict.</property>
</object>