Skip to content

Commit

Permalink
power: Load a different list for suspend-times when on mobile
Browse files Browse the repository at this point in the history
Using the systemd-hostnamed chassis-type to detect when running on
"tablet", "handset", or "watch" and setting a more reasonable list
of suspend time options for them.
  • Loading branch information
felipeborges committed Mar 21, 2024
1 parent f694945 commit 49e3560
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions panels/power/cc-power-panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct _CcPowerPanel
AdwPreferencesGroup *device_section;
AdwSwitchRow *dim_screen_row;
AdwPreferencesGroup *general_section;
GtkListStore *mobile_time_liststore;
AdwComboRow *power_button_row;
GtkListBox *power_profile_listbox;
GtkListBox *power_profile_info_listbox;
Expand Down Expand Up @@ -1383,6 +1384,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
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, general_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, mobile_time_liststore);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_button_row);
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);
Expand Down Expand Up @@ -1414,6 +1416,17 @@ cc_power_panel_init (CcPowerPanel *self)

self->chassis_type = cc_hostname_get_chassis_type (cc_hostname_get_default ());

/* Use a different list of suspend times based on the chassis type */
if (g_strcmp0 (self->chassis_type, "tablet") == 0 ||
g_strcmp0 (self->chassis_type, "watch") == 0 ||
g_strcmp0 (self->chassis_type, "handset") == 0)
{
gtk_combo_box_set_model (GTK_COMBO_BOX (self->suspend_on_battery_delay_combo),
GTK_TREE_MODEL (self->mobile_time_liststore));
gtk_combo_box_set_model (GTK_COMBO_BOX (self->suspend_on_ac_delay_combo),
GTK_TREE_MODEL (self->mobile_time_liststore));
}

self->up_client = up_client_new ();

self->gsd_settings = g_settings_new ("org.gnome.settings-daemon.plugins.power");
Expand Down

0 comments on commit 49e3560

Please sign in to comment.