apps: Don't use AdwStatusPage inside an AdwPreferencesPage

Both AdwStatusPage and AdwPreferencesPage have a GtkScrolledWindow.
This can cause scrolling to break. To fix this, separate both widgets
into their own stack pages.

Also, remove "app_search_stack_page" object ID, as it's unused by the
C code.
This commit is contained in:
Automeris naranja 2024-05-19 15:02:09 -03:00 committed by Matthijs Velsink
parent cd97e4f518
commit c3239fd5ef
2 changed files with 49 additions and 43 deletions

View file

@ -59,10 +59,9 @@ struct _CcApplicationsPanel
CcRemovableMediaSettings *removable_media_settings;
AdwNavigationPage *app_settings_page;
GtkStack *main_page_stack;
GtkListBox *app_listbox;
GtkEntry *app_search_entry;
GtkWidget *no_apps_page;
GtkStack *app_listbox_stack;
GAppInfoMonitor *monitor;
gulong monitor_id;
GListModel *app_model;
@ -1218,11 +1217,9 @@ on_items_changed_cb (GListModel *list,
CcApplicationsPanel *self = data;
if (g_list_model_get_n_items (list) == 0)
gtk_stack_set_visible_child (self->app_listbox_stack,
self->no_apps_page);
gtk_stack_set_visible_child_name (self->main_page_stack, "no-apps-found-page");
else
gtk_stack_set_visible_child (self->app_listbox_stack,
GTK_WIDGET (self->app_listbox));
gtk_stack_set_visible_child_name (self->main_page_stack, "apps-page");
}
static void
@ -1764,8 +1761,6 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, clear_cache_button);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, storage_dialog_data_row);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, default_apps_page);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_apps_page);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, app_listbox_stack);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_dialog);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_page);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_file_group);
@ -1776,6 +1771,7 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, integration_section);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, launch_button);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, location);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, main_page_stack);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, microphone);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_camera);
gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, no_location);

View file

@ -33,58 +33,68 @@
</child>
<property name="content">
<object class="AdwPreferencesPage" id="app_search_stack_page">
<object class="GtkStack" id="main_page_stack">
<!-- Default Apps Row -->
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="CcListRow">
<property name="title" translatable="yes">_Default Apps</property>
<property name="show-arrow">True</property>
<property name="action-name">navigation.push</property>
<property name="action-target">'default-apps'</property>
</object>
</child>
</object>
</child>
<object class="GtkStackPage">
<property name="name">apps-page</property>
<property name="child">
<object class="AdwPreferencesPage">
<!-- Apps List -->
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="GtkStack" id="app_listbox_stack">
<property name="vhomogeneous">False</property>
<!-- Empty search results placeholder -->
<!-- Default Apps Row -->
<child>
<object class="AdwStatusPage" id="no_apps_page">
<property name="icon-name">computer-fail-symbolic</property>
<property name="title" translatable="yes">No Apps Found</property>
<object class="AdwPreferencesGroup">
<child>
<object class="GtkButton" id="install_button">
<property name="label" translatable="yes">_Find in Software</property>
<property name="use_underline">True</property>
<property name="halign">center</property>
<signal name="clicked" handler="open_software_cb" object="CcApplicationsPanel" swapped="yes"/>
<object class="CcListRow">
<property name="title" translatable="yes">_Default Apps</property>
<property name="show-arrow">True</property>
<property name="action-name">navigation.push</property>
<property name="action-target">'default-apps'</property>
</object>
</child>
</object>
</child>
<!-- Apps List -->
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="GtkListBox" id="app_listbox">
<property name="selection-mode">none</property>
<style>
<class name="pill"/>
<class name="suggested-action"/>
<class name="boxed-list" />
</style>
</object>
</child>
</object>
</child>
<!-- App List -->
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">no-apps-found-page</property>
<property name="child">
<object class="AdwStatusPage">
<property name="icon-name">computer-fail-symbolic</property>
<property name="title" translatable="yes">No Apps Found</property>
<child>
<object class="GtkListBox" id="app_listbox">
<property name="selection-mode">none</property>
<object class="GtkButton" id="install_button">
<property name="label" translatable="yes">_Find in Software</property>
<property name="use_underline">True</property>
<property name="halign">center</property>
<signal name="clicked" handler="open_software_cb" object="CcApplicationsPanel" swapped="yes"/>
<style>
<class name="boxed-list" />
<class name="pill"/>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
</child>
</property>
</object>
</child>