main.ui: Use HdyStatusPage for status pages

We now have a nice pre-built widget for status pages
with an icon, title, description, and children.
We should take advantage of that instead of manually
setting up each status page.
This commit is contained in:
Christopher Davis 2021-02-08 14:31:25 -08:00 committed by Georges Basile Stavracas Neto
parent 73c1d7f3fe
commit 554b390cd4
2 changed files with 34 additions and 150 deletions

View File

@ -77,8 +77,7 @@ struct _MctApplication
MctUserSelector *user_selector;
MctUserControls *user_controls;
GtkStack *main_stack;
GtkLabel *error_title;
GtkLabel *error_message;
HdyStatusPage *error_page;
GtkLockButton *lock_button;
GtkButton *user_accounts_panel_button;
GtkLabel *help_label;
@ -210,8 +209,7 @@ mct_application_activate (GApplication *application)
self->main_stack = GTK_STACK (gtk_builder_get_object (builder, "main_stack"));
self->user_selector = MCT_USER_SELECTOR (gtk_builder_get_object (builder, "user_selector"));
self->user_controls = MCT_USER_CONTROLS (gtk_builder_get_object (builder, "user_controls"));
self->error_title = GTK_LABEL (gtk_builder_get_object (builder, "error_title"));
self->error_message = GTK_LABEL (gtk_builder_get_object (builder, "error_message"));
self->error_page = HDY_STATUS_PAGE (gtk_builder_get_object (builder, "error_page"));
self->lock_button = GTK_LOCK_BUTTON (gtk_builder_get_object (builder, "lock_button"));
self->user_accounts_panel_button = GTK_BUTTON (gtk_builder_get_object (builder, "user_accounts_panel_button"));
@ -373,9 +371,9 @@ update_main_stack (MctApplication *self)
if ((is_user_manager_loaded && act_user_manager_no_service (self->user_manager)) ||
self->permission_error != NULL)
{
gtk_label_set_label (self->error_title,
hdy_status_page_set_title (self->error_page,
_("Failed to load user data from the system"));
gtk_label_set_label (self->error_message,
hdy_status_page_set_description (self->error_page,
_("Please make sure that the AccountsService is installed and enabled."));
new_page_name = "error";

View File

@ -74,43 +74,11 @@
</child>
<child>
<object class="GtkBox">
<object class="HdyStatusPage">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child type="center">
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="margin">18</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Permission Required</property>
<attributes>
<attribute name="scale" value="1.4"/>
</attributes>
<child internal-child="accessible">
<object class="AtkObject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Permission is required to view and change user parental controls settings.</property>
<property name="wrap">True</property>
<child internal-child="accessible">
<object class="AtkObject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
</child>
<property name="title" translatable="yes">Permission Required</property>
<property name="description" translatable="yes">Permission is required to view and change user parental controls settings.</property>
<property name="icon-name">org.freedesktop.MalcontentControl</property>
<child>
<object class="GtkLockButton" id="lock_button">
<property name="visible">True</property>
@ -118,10 +86,6 @@
<property name="can-default">True</property>
<property name="has-default">True</property>
<property name="can-focus">True</property>
<!-- Give 18px spacing between the label and the button -->
<property name="margin-top">6</property>
</object>
</child>
</object>
</child>
</object>
@ -131,57 +95,12 @@
</child>
<child>
<object class="GtkBox">
<object class="HdyStatusPage">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child type="center">
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="margin">18</property>
<child>
<object class="GtkImage">
<property name="icon-name">system-users-symbolic</property>
<property name="pixel-size">96</property>
<property name="visible">True</property>
<child internal-child="accessible">
<object class="AtkObject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">No Standard User Accounts</property>
<attributes>
<attribute name="scale" value="1.4"/>
</attributes>
<child internal-child="accessible">
<object class="AtkObject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="justify">center</property>
<property name="label" translatable="yes">Parental controls can only be applied to standard user
<property name="title" translatable="yes">No Standard User Accounts</property>
<property name="description" translatable="yes">Parental controls can only be applied to standard user
accounts. These can be created in the user settings.</property>
<property name="wrap">True</property>
<child internal-child="accessible">
<object class="AtkObject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="user_accounts_panel_button">
<property name="visible">True</property>
@ -191,16 +110,12 @@
<property name="has-default">True</property>
<property name="use-underline">True</property>
<property name="can-focus">True</property>
<!-- Give 18px spacing between the label and the button -->
<property name="margin-top">6</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">no-other-users</property>
</packing>
@ -233,38 +148,9 @@
</child>
<child>
<object class="GtkBox">
<object class="HdyStatusPage" id="error_page">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child type="center">
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="error_title">
<property name="visible">True</property>
<property name="label"></property>
<attributes>
<attribute name="scale" value="1.4"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel" id="error_message">
<property name="visible">True</property>
<property name="label"></property>
</object>
</child>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject">
<property name="AtkObject::accessible-role">alert</property>
</object>
</child>
<property name="icon-name">dialog-error-symbolic</property>
</object>
<packing>
<property name="name">error</property>