[gnome-control-center] power: Use HdyPreferencesGroup
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] power: Use HdyPreferencesGroup
- Date: Fri, 7 May 2021 02:53:33 +0000 (UTC)
commit a5c0934b4d2d97693954e47310fc6e2d1c6c6524
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Jan 7 13:49:36 2021 +0100
power: Use HdyPreferencesGroup
panels/power/cc-power-panel.c | 60 ++------------
panels/power/cc-power-panel.ui | 175 ++++++-----------------------------------
2 files changed, 30 insertions(+), 205 deletions(-)
---
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 22d91c564..96558c778 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -66,36 +66,29 @@ struct _CcPowerPanel
GtkDialog *automatic_suspend_dialog;
GtkLabel *automatic_suspend_label;
GtkListBoxRow *automatic_suspend_row;
- GtkLabel *battery_heading;
GtkListBox *battery_listbox;
HdyActionRow *battery_percentage_row;
GtkSwitch *battery_percentage_switch;
GtkSizeGroup *battery_row_sizegroup;
- GtkBox *battery_section;
+ HdyPreferencesGroup *battery_section;
HdyComboRow *blank_screen_row;
GtkListBoxRow *brightness_row;
CcBrightnessScale *brightness_scale;
GtkListBoxRow *bt_row;
GtkSwitch *bt_switch;
- GtkLabel *device_heading;
GtkListBox *device_listbox;
- GtkBox *device_section;
+ HdyPreferencesGroup *device_section;
GtkListBoxRow *dim_screen_row;
GtkSwitch *dim_screen_switch;
- GtkLabel *general_heading;
- GtkListBox *general_listbox;
- GtkBox *general_section;
+ HdyPreferencesGroup *general_section;
GtkListBoxRow *kbd_brightness_row;
CcBrightnessScale *kbd_brightness_scale;
GtkSizeGroup *level_sizegroup;
GtkListBoxRow *mobile_row;
GtkSwitch *mobile_switch;
HdyComboRow *power_button_row;
- GtkLabel *power_profile_heading;
GtkListBox *power_profile_listbox;
- GtkBox *power_profile_section;
- GtkLabel *power_saving_heading;
- GtkListBox *power_saving_listbox;
+ HdyPreferencesGroup *power_profile_section;
GtkSizeGroup *row_sizegroup;
GtkComboBox *suspend_on_battery_delay_combo;
GtkLabel *suspend_on_battery_delay_label;
@@ -259,7 +252,6 @@ up_client_changed (CcPowerPanel *self)
guint n_batteries;
gboolean on_ups;
g_autoptr(UpDevice) composite = NULL;
- g_autofree gchar *s = NULL;
battery_children = gtk_container_get_children (GTK_CONTAINER (self->battery_listbox));
for (l = battery_children; l != NULL; l = l->next)
@@ -390,10 +382,9 @@ up_client_changed (CcPowerPanel *self)
}
if (n_batteries > 1)
- s = g_strdup_printf ("<b>%s</b>", _("Batteries"));
+ hdy_preferences_group_set_title (self->battery_section, _("Batteries"));
else
- s = g_strdup_printf ("<b>%s</b>", _("Battery"));
- gtk_label_set_label (GTK_LABEL (self->battery_heading), s);
+ hdy_preferences_group_set_title (self->battery_section, _("Battery"));
if (!on_ups && n_batteries > 1)
add_battery (self, composite, TRUE);
@@ -1697,7 +1688,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, automatic_suspend_dialog);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, automatic_suspend_label);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, automatic_suspend_row);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_heading);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_percentage_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_percentage_switch);
@@ -1708,13 +1698,10 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, brightness_scale);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, bt_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, bt_switch);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, device_heading);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, device_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, device_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, dim_screen_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, dim_screen_switch);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, general_heading);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, general_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, general_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_scale);
@@ -1722,11 +1709,8 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, mobile_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, mobile_switch);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_button_row);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_heading);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_section);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_saving_heading);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_saving_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, row_sizegroup);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_battery_delay_combo);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_battery_delay_label);
@@ -1755,11 +1739,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
static void
cc_power_panel_init (CcPowerPanel *self)
{
- g_autofree gchar *battery_label = NULL;
- g_autofree gchar *device_label = NULL;
- g_autofree gchar *power_profile_label = NULL;
- g_autofree gchar *power_saving_label = NULL;
- g_autofree gchar *general_label = NULL;
guint i;
g_resources_register (cc_power_get_resource ());
@@ -1776,46 +1755,19 @@ cc_power_panel_init (CcPowerPanel *self)
self->session_settings = g_settings_new ("org.gnome.desktop.session");
self->interface_settings = g_settings_new ("org.gnome.desktop.interface");
- battery_label = g_markup_printf_escaped ("<b>%s</b>", _("Battery"));
- gtk_label_set_markup (self->battery_heading, battery_label);
-
- gtk_list_box_set_header_func (self->battery_listbox,
- cc_list_box_update_header_func,
- NULL, NULL);
gtk_list_box_set_sort_func (self->battery_listbox,
(GtkListBoxSortFunc)battery_sort_func, NULL, NULL);
- device_label = g_markup_printf_escaped ("<b>%s</b>", _("Devices"));
- gtk_label_set_markup (self->device_heading, device_label);
-
- gtk_list_box_set_header_func (self->device_listbox,
- cc_list_box_update_header_func,
- NULL, NULL);
gtk_list_box_set_sort_func (self->device_listbox,
(GtkListBoxSortFunc)battery_sort_func, NULL, NULL);
- power_profile_label = g_strdup_printf ("<b>%s</b>", _("Power Mode"));
- gtk_label_set_markup (self->power_profile_heading, power_profile_label);
gtk_list_box_set_sort_func (self->power_profile_listbox,
perf_profile_list_box_sort,
NULL, NULL);
- gtk_list_box_set_header_func (self->power_profile_listbox,
- cc_list_box_update_header_func,
- NULL, NULL);
setup_power_profiles (self);
- power_saving_label = g_strdup_printf ("<b>%s</b>", _("Power Saving"));
- gtk_label_set_markup (self->power_saving_heading, power_saving_label);
- gtk_list_box_set_header_func (self->power_saving_listbox,
- cc_list_box_update_header_func,
- NULL, NULL);
setup_power_saving (self);
- general_label = g_markup_printf_escaped ("<b>%s</b>", _("Suspend & Power Button"));
- gtk_label_set_markup (self->general_heading, general_label);
- gtk_list_box_set_header_func (self->general_listbox,
- cc_list_box_update_header_func,
- NULL, NULL);
setup_general_section (self);
/* populate batteries */
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index 12df3aa4a..26d6ffddc 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -55,124 +55,60 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkScrolledWindow">
+ <object class="HdyPreferencesPage">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscrollbar_policy">never</property>
- <child>
- <object class="HdyClamp">
- <property name="visible">True</property>
- <property name="margin_top">32</property>
- <property name="margin_bottom">32</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <child>
- <object class="GtkBox" id="power_vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">3</property>
- <property name="hexpand">True</property>
<child>
- <object class="GtkBox" id="battery_section">
+ <object class="HdyPreferencesGroup" id="battery_section">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin_bottom">32</property>
- <child>
- <object class="GtkLabel" id="battery_heading">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="halign">start</property>
- <property name="margin_bottom">12</property>
+ <property name="title" translatable="yes">Battery</property>
<accessibility>
<relation target="battery_listbox" type="label-for"/>
</accessibility>
- </object>
- </child>
- <child>
- <object class="GtkFrame">
- <property name="visible">True</property>
- <property name="shadow-type">in</property>
<child>
<object class="GtkListBox" id="battery_listbox">
<property name="visible">True</property>
<property name="selection-mode">none</property>
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel"
swapped="yes"/>
<accessibility>
- <relation target="battery_heading" type="labelled-by"/>
+ <relation target="battery_section" type="labelled-by"/>
</accessibility>
+ <style>
+ <class name="content"/>
+ </style>
</object>
</child>
- </object>
- </child>
</object>
</child>
<child>
- <object class="GtkBox" id="device_section">
+ <object class="HdyPreferencesGroup" id="device_section">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">32</property>
- <child>
- <object class="GtkLabel" id="device_heading">
- <property name="visible">True</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0</property>
- <property name="use-markup">True</property>
- <property name="halign">start</property>
- <property name="margin_bottom">12</property>
+ <property name="title" translatable="yes">Devices</property>
<accessibility>
<relation target="device_listbox" type="label-for"/>
</accessibility>
- </object>
- </child>
- <child>
- <object class="GtkFrame">
- <property name="visible">True</property>
- <property name="shadow-type">in</property>
<child>
<object class="GtkListBox" id="device_listbox">
<property name="visible">True</property>
<property name="selection-mode">none</property>
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel"
swapped="yes"/>
<accessibility>
- <relation target="device_heading" type="labelled-by"/>
+ <relation target="device_section" type="labelled-by"/>
</accessibility>
+ <style>
+ <class name="content"/>
+ </style>
</object>
</child>
- </object>
- </child>
</object>
</child>
<child>
- <object class="GtkBox" id="power_profile_section">
+ <object class="HdyPreferencesGroup" id="power_profile_section">
<property name="visible">False</property>
- <property name="orientation">vertical</property>
- <property name="margin_bottom">32</property>
- <child>
- <object class="GtkLabel" id="power_profile_heading">
- <property name="visible">True</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0</property>
- <property name="use-markup">True</property>
- <property name="halign">start</property>
+ <property name="title" translatable="yes">Power Mode</property>
+ <property name="description" translatable="yes">Affects system performance and power
usage.</property>
<accessibility>
<relation target="power_profile_listbox" type="label-for"/>
</accessibility>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="margin-bottom">6</property>
- <property name="label" translatable="yes">Affects system performance and power
usage.</property>
- </object>
- </child>
- <child>
- <object class="GtkFrame">
- <property name="visible">True</property>
- <property name="shadow-type">in</property>
<child>
<object class="GtkListBox" id="power_profile_listbox">
<property name="visible">True</property>
@@ -180,45 +116,19 @@
<signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel"
swapped="yes"/>
<signal name="row-activated" handler="power_profiles_row_activated_cb"
object="CcPowerPanel" swapped="yes"/>
<accessibility>
- <relation target="device_heading" type="labelled-by"/>
+ <relation target="power_profile_section" type="labelled-by"/>
</accessibility>
+ <style>
+ <class name="content"/>
+ </style>
</object>
</child>
- </object>
- </child>
</object>
</child>
<child>
- <object class="GtkBox">
+ <object class="HdyPreferencesGroup" id="power_saving_section">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin_bottom">32</property>
- <child>
- <object class="GtkLabel" id="power_saving_heading">
- <property name="visible">True</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0</property>
- <property name="use-markup">True</property>
- <property name="halign">start</property>
- <property name="margin_bottom">12</property>
- <accessibility>
- <relation target="power_saving_listbox" type="label-for"/>
- </accessibility>
- </object>
- </child>
- <child>
- <object class="GtkFrame">
- <property name="visible">True</property>
- <property name="shadow-type">in</property>
- <child>
- <object class="GtkListBox" id="power_saving_listbox">
- <property name="visible">True</property>
- <property name="selection-mode">none</property>
- <signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel"
swapped="yes"/>
- <signal name="row-activated" handler="power_saving_listbox_row_activated_cb"
object="CcPowerPanel" swapped="yes"/>
- <accessibility>
- <relation target="power_saving_heading" type="labelled-by"/>
- </accessibility>
+ <property name="title" translatable="yes">Power Saving</property>
<child>
<object class="HdyActionRow" id="brightness_row">
<property name="visible">True</property>
@@ -349,41 +259,12 @@
</child>
</object>
</child>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
<child>
- <object class="GtkBox" id="general_section">
+ <object class="HdyPreferencesGroup" id="general_section">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">32</property>
- <child>
- <object class="GtkLabel" id="general_heading">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="halign">start</property>
- <property name="margin_bottom">12</property>
- <accessibility>
- <relation target="general_listbox" type="label-for"/>
- </accessibility>
- </object>
- </child>
- <child>
- <object class="GtkFrame">
- <property name="visible">True</property>
- <property name="shadow-type">in</property>
- <child>
- <object class="GtkListBox" id="general_listbox">
- <property name="visible">True</property>
- <property name="selection-mode">none</property>
- <signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel"
swapped="yes"/>
- <accessibility>
- <relation target="general_heading" type="labelled-by"/>
- </accessibility>
+ <property name="title" translatable="yes">Suspend & Power Button</property>
<child>
<object class="HdyComboRow" id="power_button_row">
<property name="visible">False</property>
@@ -406,16 +287,8 @@
</child>
</object>
</child>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]