Commit 16fa656c authored by Christopher Davis's avatar Christopher Davis
Browse files

power: Split panel into two stack pages

parent b66b2396
Pipeline #369683 passed with stages
in 5 minutes and 18 seconds
......@@ -41,6 +41,7 @@ struct _CcPowerPanel
GtkListBoxRow *als_row;
GtkSwitch *als_switch;
AdwPreferencesGroup *automatic_suspend_group;
AdwPreferencesGroup *suspend_on_battery_group;
GtkListBox *battery_listbox;
AdwActionRow *battery_percentage_row;
GtkSwitch *battery_percentage_switch;
......@@ -56,6 +57,7 @@ struct _CcPowerPanel
GtkListBox *power_profile_listbox;
GtkListBox *power_profile_info_listbox;
AdwPreferencesGroup *power_profile_section;
AdwPreferencesGroup *power_saver_group;
AdwActionRow *power_saver_low_battery_row;
GtkSwitch *power_saver_low_battery_switch;
AdwComboRow *suspend_on_battery_combo_row;
......@@ -183,6 +185,15 @@ empty_listbox (GtkListBox *listbox)
gtk_list_box_remove (listbox, child);
}
static void
update_power_saver_group_visibility (CcPowerPanel *self)
{
gtk_widget_set_visible (GTK_WIDGET (self->power_saver_group),
gtk_widget_get_visible (GTK_WIDGET (self->dim_screen_row)) ||
gtk_widget_get_visible (GTK_WIDGET (self->power_saver_low_battery_row)) ||
gtk_widget_get_visible (GTK_WIDGET (self->als_row)));
}
static void
update_power_saver_low_battery_row_visibility (CcPowerPanel *self)
{
......@@ -193,6 +204,8 @@ update_power_saver_low_battery_row_visibility (CcPowerPanel *self)
g_object_get (composite, "kind", &kind, NULL);
gtk_widget_set_visible (GTK_WIDGET (self->power_saver_low_battery_row),
self->power_profiles_proxy && kind == UP_DEVICE_KIND_BATTERY);
update_power_saver_group_visibility (self);
}
static void
......@@ -345,6 +358,7 @@ als_enabled_state_changed (CcPowerPanel *self)
g_signal_handlers_block_by_func (self->als_switch, als_switch_changed_cb, self);
gtk_switch_set_active (self->als_switch, enabled);
gtk_widget_set_visible (GTK_WIDGET (self->als_row), visible && self->has_brightness);
update_power_saver_group_visibility (self);
g_signal_handlers_unblock_by_func (self->als_switch, als_switch_changed_cb, self);
}
......@@ -427,11 +441,9 @@ set_ac_battery_ui_mode (CcPowerPanel *self)
if (!self->has_batteries)
{
gtk_widget_hide (GTK_WIDGET (self->suspend_on_battery_row));
gtk_widget_hide (GTK_WIDGET (self->suspend_on_battery_group));
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self->suspend_on_ac_row),
_("When _Idle"));
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self->suspend_on_ac_combo_row),
_("Delay When Idle"));
}
}
......@@ -1305,6 +1317,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, als_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, als_switch);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, automatic_suspend_group);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_battery_group);
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);
......@@ -1320,6 +1333,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_info_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_saver_group);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_saver_low_battery_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_saver_low_battery_switch);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_battery_combo_row);
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment