restrict-applications-selector: Fix display of placeholder

The `GtkListBox` already correctly works out when to show/hide the
placeholder; we don’t need to do that ourselves. It actually breaks
things if we hide the placeholder, since `GtkListBox` then doesn’t
re-show it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2023-10-13 11:24:50 +01:00
parent 537d4bf791
commit 13c8a88e17
2 changed files with 1 additions and 7 deletions

View File

@ -61,7 +61,6 @@ struct _MctRestrictApplicationsSelector
GtkBox parent_instance; GtkBox parent_instance;
GtkListBox *listbox; GtkListBox *listbox;
GtkLabel *placeholder;
GList *cached_apps; /* (nullable) (owned) (element-type GAppInfo) */ GList *cached_apps; /* (nullable) (owned) (element-type GAppInfo) */
GListStore *apps; GListStore *apps;
@ -223,7 +222,6 @@ 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_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, listbox);
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsSelector, placeholder);
gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsSelector, apps); gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsSelector, apps);
} }
@ -245,10 +243,6 @@ mct_restrict_applications_selector_init (MctRestrictApplicationsSelector *self)
self, self,
NULL); 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, self->blocklisted_apps = g_hash_table_new_full (g_direct_hash,
g_direct_equal, g_direct_equal,
g_object_unref, g_object_unref,

View File

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