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; MctUserSelector *user_selector;
MctUserControls *user_controls; MctUserControls *user_controls;
GtkStack *main_stack; GtkStack *main_stack;
GtkLabel *error_title; HdyStatusPage *error_page;
GtkLabel *error_message;
GtkLockButton *lock_button; GtkLockButton *lock_button;
GtkButton *user_accounts_panel_button; GtkButton *user_accounts_panel_button;
GtkLabel *help_label; 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->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_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->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_page = HDY_STATUS_PAGE (gtk_builder_get_object (builder, "error_page"));
self->error_message = GTK_LABEL (gtk_builder_get_object (builder, "error_message"));
self->lock_button = GTK_LOCK_BUTTON (gtk_builder_get_object (builder, "lock_button")); 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")); 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)) || if ((is_user_manager_loaded && act_user_manager_no_service (self->user_manager)) ||
self->permission_error != NULL) 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")); _("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.")); _("Please make sure that the AccountsService is installed and enabled."));
new_page_name = "error"; new_page_name = "error";

View File

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