gnome-control-center/power-profiles-backport.patch
2021-08-20 21:05:35 +02:00

5103 lines
232 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 1e3569e2f6c2c418b84ea3aa6ce5f84166ec48a7 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 31 Mar 2021 11:06:44 +0200
Subject: [PATCH 01/33] power: Fix possible assertion on startup
When opening the Power panel, and if power-profiles-daemon isn't already
started, we'll be autostarting it, making it send signals about all the
changed properties, including "PerformanceInhibited" even if we
don't have a Performance row.
Ignore the property change if we don't have a row for it rather than
asserting.
#0 0x00007f73916bc292 in raise () from /lib64/libc.so.6
#1 0x00007f73916a58a4 in abort () from /lib64/libc.so.6
#2 0x00007f7393203ccc in g_assertion_message.cold () from /lib64/libglib-2.0.so.0
#3 0x00007f739325f22f in g_assertion_message_expr () from /lib64/libglib-2.0.so.0
#4 0x000055a4099e28ae in performance_profile_set_inhibited (self=0x55a40b37e320, self=0x55a40b37e320, performance_inhibited=<optimized out>) at ../panels/power/cc-power-panel.c:1366
#5 power_profiles_properties_changed_cb (self=0x55a40b37e320, changed_properties=<optimized out>, invalidated_properties=<optimized out>, proxy=<optimized out>) at ../panels/power/cc-power-panel.c:1425
#6 0x00007f7393332c2f in g_closure_invoke () from /lib64/libgobject-2.0.so.0
#7 0x00007f739334eea6 in signal_emit_unlocked_R () from /lib64/libgobject-2.0.so.0
1362 {
1363 CcPowerProfileRow *row;
1364
1365 row = self->power_profiles_row[CC_POWER_PROFILE_PERFORMANCE];
1366 g_assert (row != NULL);
1367 cc_power_profile_row_set_performance_inhibited (row, performance_inhibited);
1368 }
---
panels/power/cc-power-panel.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index c9c4705da..0b8226a29 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -1363,7 +1363,8 @@ performance_profile_set_inhibited (CcPowerPanel *self,
CcPowerProfileRow *row;
row = self->power_profiles_row[CC_POWER_PROFILE_PERFORMANCE];
- g_assert (row != NULL);
+ if (!row)
+ return;
cc_power_profile_row_set_performance_inhibited (row, performance_inhibited);
}
--
2.32.0
From da2248d43f519f13b57e89cdc80bbbfe346ad463 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Thu, 7 Jan 2021 14:00:15 +0100
Subject: [PATCH 02/33] power: Simplifies keyboard navigation
This drops the ability to loop through the page but significantly
simplifies the code. I think this is a good tradeoff as looping is a
rather unexpected behavior.
---
panels/power/cc-power-panel.c | 70 ++---------------------------------
1 file changed, 4 insertions(+), 66 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 0b8226a29..1d31a8a83 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -122,9 +122,6 @@ struct _CcPowerPanel
gboolean has_batteries;
char *chassis_type;
- GList *boxes;
- GList *boxes_reverse;
-
GDBusProxy *bt_rfkill;
GDBusProxy *bt_properties;
@@ -169,8 +166,6 @@ cc_power_panel_dispose (GObject *object)
#ifdef HAVE_NETWORK_MANAGER
g_clear_object (&self->nm_client);
#endif
- g_clear_pointer (&self->boxes, g_list_free);
- g_clear_pointer (&self->boxes_reverse, g_list_free);
if (self->iio_proxy_watch_id != 0)
g_bus_unwatch_name (self->iio_proxy_watch_id);
self->iio_proxy_watch_id = 0;
@@ -869,60 +864,12 @@ nm_client_ready_cb (GObject *source_object,
static gboolean
keynav_failed_cb (CcPowerPanel *self, GtkDirectionType direction, GtkWidget *list)
{
- GtkWidget *next_list = NULL;
- GList *item, *boxes_list;
- gdouble value, lower, upper, page;
-
- /* Find the list in the list of GtkListBoxes */
- if (direction == GTK_DIR_DOWN)
- boxes_list = self->boxes;
- else
- boxes_list = self->boxes_reverse;
-
- item = g_list_find (boxes_list, list);
- g_assert (item);
- item = item->next;
- while (1)
- {
- if (item == NULL)
- item = boxes_list;
-
- /* Avoid looping */
- if (item->data == list)
- break;
-
- if (gtk_widget_is_visible (item->data))
- {
- next_list = item->data;
- break;
- }
-
- item = item->next;
- }
-
- if (next_list)
- {
- gtk_widget_child_focus (next_list, direction);
- return TRUE;
- }
-
- value = gtk_adjustment_get_value (self->focus_adjustment);
- lower = gtk_adjustment_get_lower (self->focus_adjustment);
- upper = gtk_adjustment_get_upper (self->focus_adjustment);
- page = gtk_adjustment_get_page_size (self->focus_adjustment);
+ if (direction != GTK_DIR_UP && direction != GTK_DIR_DOWN)
+ return FALSE;
- if (direction == GTK_DIR_UP && value > lower)
- {
- gtk_adjustment_set_value (self->focus_adjustment, lower);
- return TRUE;
- }
- else if (direction == GTK_DIR_DOWN && value < upper - page)
- {
- gtk_adjustment_set_value (self->focus_adjustment, upper - page);
- return TRUE;
- }
+ direction == GTK_DIR_UP ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
- return FALSE;
+ return gtk_widget_child_focus (GTK_WIDGET (self), direction);
}
static void
@@ -1559,8 +1506,6 @@ setup_power_profiles (CcPowerPanel *self)
gtk_widget_show (GTK_WIDGET (self->power_profile_section));
- self->boxes_reverse = g_list_prepend (self->boxes_reverse, self->power_profile_listbox);
-
props = g_variant_get_child_value (variant, 0);
performance_inhibited = variant_lookup_string (props, "PerformanceInhibited");
active_profile = variant_lookup_string (props, "ActiveProfile");
@@ -1780,7 +1725,6 @@ cc_power_panel_init (CcPowerPanel *self)
battery_label = g_markup_printf_escaped ("<b>%s</b>", _("Battery"));
gtk_label_set_markup (self->battery_heading, battery_label);
- self->boxes_reverse = g_list_prepend (self->boxes_reverse, self->battery_listbox);
gtk_list_box_set_header_func (self->battery_listbox,
cc_list_box_update_header_func,
NULL, NULL);
@@ -1790,7 +1734,6 @@ cc_power_panel_init (CcPowerPanel *self)
device_label = g_markup_printf_escaped ("<b>%s</b>", _("Devices"));
gtk_label_set_markup (self->device_heading, device_label);
- self->boxes_reverse = g_list_prepend (self->boxes_reverse, self->device_listbox);
gtk_list_box_set_header_func (self->device_listbox,
cc_list_box_update_header_func,
NULL, NULL);
@@ -1809,7 +1752,6 @@ cc_power_panel_init (CcPowerPanel *self)
power_saving_label = g_strdup_printf ("<b>%s</b>", _("Power Saving"));
gtk_label_set_markup (self->power_saving_heading, power_saving_label);
- self->boxes_reverse = g_list_prepend (self->boxes_reverse, self->power_saving_listbox);
gtk_list_box_set_header_func (self->power_saving_listbox,
cc_list_box_update_header_func,
NULL, NULL);
@@ -1817,15 +1759,11 @@ cc_power_panel_init (CcPowerPanel *self)
general_label = g_markup_printf_escaped ("<b>%s</b>", _("Suspend & Power Button"));
gtk_label_set_markup (self->general_heading, general_label);
- self->boxes_reverse = g_list_prepend (self->boxes_reverse, self->general_listbox);
gtk_list_box_set_header_func (self->general_listbox,
cc_list_box_update_header_func,
NULL, NULL);
setup_general_section (self);
- self->boxes = g_list_copy (self->boxes_reverse);
- self->boxes = g_list_reverse (self->boxes);
-
/* populate batteries */
g_signal_connect_object (self->up_client, "device-added", G_CALLBACK (up_client_device_added), self, G_CONNECT_SWAPPED);
g_signal_connect_object (self->up_client, "device-removed", G_CALLBACK (up_client_device_removed), self, G_CONNECT_SWAPPED);
--
2.32.0
From 25027f6c3c6928eeedb440fe2ca84412dae49ab2 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Fri, 8 Jan 2021 16:00:25 +0100
Subject: [PATCH 03/33] power: Don't set the vadjustment
This is useless as GtkScrolledwindow already does it on the viewport it
creates.
---
panels/power/cc-power-panel.c | 9 ---------
panels/power/cc-power-panel.ui | 4 ++--
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 1d31a8a83..1a8cfa969 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -91,8 +91,6 @@ struct _CcPowerPanel
GtkListBoxRow *kbd_brightness_row;
CcBrightnessScale *kbd_brightness_scale;
GtkSizeGroup *level_sizegroup;
- GtkScrolledWindow *main_scroll;
- HdyClamp *main_box;
GtkListBoxRow *mobile_row;
GtkSwitch *mobile_switch;
GtkComboBox *power_button_combo;
@@ -136,8 +134,6 @@ struct _CcPowerPanel
#ifdef HAVE_NETWORK_MANAGER
NMClient *nm_client;
#endif
-
- GtkAdjustment *focus_adjustment;
};
CC_PANEL_REGISTER (CcPowerPanel, cc_power_panel)
@@ -1661,8 +1657,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_scale);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, level_sizegroup);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, main_scroll);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, main_box);
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_combo);
@@ -1775,7 +1769,4 @@ cc_power_panel_init (CcPowerPanel *self)
G_CALLBACK (up_client_changed), self, G_CONNECT_SWAPPED);
}
up_client_changed (self);
-
- self->focus_adjustment = gtk_scrolled_window_get_vadjustment (self->main_scroll);
- gtk_container_set_focus_vadjustment (GTK_CONTAINER (self->main_box), self->focus_adjustment);
}
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index ea3cf9322..d3e200d93 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -113,12 +113,12 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkScrolledWindow" id="main_scroll">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hscrollbar_policy">never</property>
<child>
- <object class="HdyClamp" id="main_box">
+ <object class="HdyClamp">
<property name="visible">True</property>
<property name="margin_top">32</property>
<property name="margin_bottom">32</property>
--
2.32.0
From caf3d70a7004552e0bb382a1a1220cdac9c0c1f0 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Fri, 8 Jan 2021 16:12:56 +0100
Subject: [PATCH 04/33] power: Use HdyComboRow for the Blank Screen row
This simplifies the code a bit and modernizes the UI.
---
panels/power/cc-power-panel.c | 110 ++++++++++++++++++++++++++-------
panels/power/cc-power-panel.ui | 88 ++------------------------
2 files changed, 92 insertions(+), 106 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 1a8cfa969..b046b2589 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -73,7 +73,7 @@ struct _CcPowerPanel
GtkSizeGroup *battery_row_sizegroup;
GtkBox *battery_section;
GtkSizeGroup *battery_sizegroup;
- GtkListBoxRow *blank_screen_row;
+ HdyComboRow *blank_screen_row;
GtkListBoxRow *brightness_row;
CcBrightnessScale *brightness_scale;
GtkListBoxRow *bt_row;
@@ -87,7 +87,6 @@ struct _CcPowerPanel
GtkLabel *general_heading;
GtkListBox *general_listbox;
GtkBox *general_section;
- GtkComboBox *idle_delay_combo;
GtkListBoxRow *kbd_brightness_row;
CcBrightnessScale *kbd_brightness_scale;
GtkSizeGroup *level_sizegroup;
@@ -577,6 +576,49 @@ set_value_for_combo (GtkComboBox *combo_box, gint value)
gtk_combo_box_set_active_iter (combo_box, &new);
}
+static void
+set_value_for_combo_row (HdyComboRow *combo_row, gint value)
+{
+ gboolean insert = FALSE;
+ guint insert_before = 0;
+ guint i;
+ HdyValueObject *new;
+ GListModel *model;
+ gint value_last = 0;
+ g_autofree gchar *text = NULL;
+
+ /* try to make the UI match the setting */
+ model = hdy_combo_row_get_model (combo_row);
+ for (i = 0; i < g_list_model_get_n_items (model); i++)
+ {
+ HdyValueObject *value_object = g_list_model_get_item (model, i);
+ gint value_tmp = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value"));
+ if (value_tmp == value)
+ {
+ hdy_combo_row_set_selected_index (combo_row, i);
+ return;
+ }
+
+ /* Insert before if the next value is larger or the value is lower
+ * again (i.e. "Never" is zero and last). */
+ if (!insert && (value_tmp > value || value_last > value_tmp))
+ {
+ insert = TRUE;
+ insert_before = i;
+ }
+
+ value_last = value_tmp;
+ }
+
+ /* The value is not listed, so add it at the best point (or the end). */
+ text = cc_util_time_to_string_text (value * 1000);
+ new = hdy_value_object_new_string (text);
+ g_object_set_data (G_OBJECT (new), "value",
+ GUINT_TO_POINTER (value));
+ g_list_store_insert (G_LIST_STORE (model), insert_before, new);
+ hdy_combo_row_set_selected_index (combo_row, insert_before);
+}
+
static void
set_ac_battery_ui_mode (CcPowerPanel *self)
{
@@ -869,25 +911,18 @@ keynav_failed_cb (CcPowerPanel *self, GtkDirectionType direction, GtkWidget *lis
}
static void
-idle_delay_combo_changed_cb (CcPowerPanel *self)
+blank_screen_row_changed_cb (CcPowerPanel *self)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
+ GListModel *model;
+ gint selected_index;
+ HdyValueObject *value_object;
gint value;
- gboolean ret;
- /* no selection */
- ret = gtk_combo_box_get_active_iter (self->idle_delay_combo, &iter);
- if (!ret)
- return;
+ model = hdy_combo_row_get_model (self->blank_screen_row);
+ selected_index = hdy_combo_row_get_selected_index (self->blank_screen_row);
+ value_object = g_list_model_get_item (model, selected_index);
+ value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value"));
- /* get entry */
- model = gtk_combo_box_get_model (self->idle_delay_combo);
- gtk_tree_model_get (model, &iter,
- 1, &value,
- -1);
-
- /* set both keys */
g_settings_set_uint (self->session_settings, "idle-delay", value);
}
@@ -1171,6 +1206,37 @@ has_kbd_brightness_cb (CcPowerPanel *self,
gtk_widget_set_visible (GTK_WIDGET (self->kbd_brightness_row), has_brightness);
}
+static void
+populate_blank_screen_row (HdyComboRow *combo_row)
+{
+ g_autoptr (GListStore) list_store = g_list_store_new (HDY_TYPE_VALUE_OBJECT);
+ gint minutes[] = { 1, 2, 3, 4, 5, 8, 10, 12, 15 };
+ guint i;
+ g_autoptr (HdyValueObject) never_value_object = NULL;
+
+ for (i = 0; i < G_N_ELEMENTS (minutes); i++)
+ {
+ gchar *text = NULL;
+ g_autoptr (HdyValueObject) value_object = NULL;
+
+ /* Translators: Option for "Blank Screen" in "Power" panel */
+ text = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "%d minute", "%d minutes", minutes[i]), minutes[i]);
+ value_object = hdy_value_object_new_take_string (text);
+
+ g_object_set_data (G_OBJECT (value_object), "value", GUINT_TO_POINTER (minutes[i] * 60));
+ g_list_store_append (list_store, value_object);
+ }
+
+ never_value_object = hdy_value_object_new_string (C_("Idle time", "Never"));
+ g_object_set_data (G_OBJECT (never_value_object), "value", GUINT_TO_POINTER (0));
+ g_list_store_append (list_store, never_value_object);
+
+ hdy_combo_row_bind_name_model (combo_row,
+ G_LIST_MODEL (list_store),
+ (HdyComboRowGetNameFunc) hdy_value_object_dup_string,
+ NULL, NULL);
+}
+
static void
setup_power_saving (CcPowerPanel *self)
{
@@ -1191,10 +1257,11 @@ setup_power_saving (CcPowerPanel *self)
self->dim_screen_switch, "active",
G_SETTINGS_BIND_DEFAULT);
+ g_signal_handlers_block_by_func (self->blank_screen_row, blank_screen_row_changed_cb, self);
+ populate_blank_screen_row (self->blank_screen_row);
value = g_settings_get_uint (self->session_settings, "idle-delay");
- g_signal_handlers_block_by_func (self->idle_delay_combo, idle_delay_combo_changed_cb, self);
- set_value_for_combo (self->idle_delay_combo, value);
- g_signal_handlers_unblock_by_func (self->idle_delay_combo, idle_delay_combo_changed_cb, self);
+ set_value_for_combo_row (self->blank_screen_row, value);
+ g_signal_handlers_unblock_by_func (self->blank_screen_row, blank_screen_row_changed_cb, self);
/* The default values for these settings are unfortunate for us;
* timeout == 0, action == suspend means 'do nothing' - just
@@ -1653,7 +1720,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
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, idle_delay_combo);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_scale);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, level_sizegroup);
@@ -1683,7 +1749,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, bt_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, has_brightness_cb);
gtk_widget_class_bind_template_callback (widget_class, has_kbd_brightness_cb);
- gtk_widget_class_bind_template_callback (widget_class, idle_delay_combo_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, blank_screen_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
gtk_widget_class_bind_template_callback (widget_class, mobile_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, power_button_combo_changed_cb);
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index d3e200d93..a9bb39b77 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -51,56 +51,6 @@
</row>
</data>
</object>
- <object class="GtkListStore" id="idle_time_liststore">
- <columns>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name value -->
- <column type="gint"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">1 minute</col>
- <col id="1">60</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">2 minutes</col>
- <col id="1">120</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">3 minutes</col>
- <col id="1">180</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">4 minutes</col>
- <col id="1">240</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">5 minutes</col>
- <col id="1">300</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">8 minutes</col>
- <col id="1">480</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">10 minutes</col>
- <col id="1">600</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">12 minutes</col>
- <col id="1">720</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">15 minutes</col>
- <col id="1">900</col>
- </row>
- <row>
- <col id="0" translatable="yes" context="blank_screen" comments="Translators: Option for &quot;Blank screen&quot; in &quot;Power&quot; panel.">Never</col>
- <col id="1">0</col>
- </row>
- </data>
- </object>
<object class="GtkListStore" id="power_button_liststore">
<columns>
<!-- column-name name -->
@@ -447,41 +397,11 @@
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="blank_screen_row">
+ <object class="HdyComboRow" id="blank_screen_row">
<property name="visible">True</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">_Blank Screen</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="expand">True</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">idle_delay_combo</property>
- </object>
- </child>
- <child>
- <object class="GtkComboBoxText" id="idle_delay_combo">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="entry-text-column">0</property>
- <property name="model">idle_time_liststore</property>
- <signal name="changed" handler="idle_delay_combo_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="title" translatable="yes">_Blank Screen</property>
+ <property name="use_underline">True</property>
+ <signal name="notify::selected-index" handler="blank_screen_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
<child>
--
2.32.0
From 7dbe681401f3f487f1e752a0569cf3d743a74187 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Fri, 8 Jan 2021 16:17:42 +0100
Subject: [PATCH 05/33] power: Use HdyComboRow for the Power Button Behavior
row
This simplifies the code a bit and modernizes the UI.
---
panels/power/cc-power-panel.c | 71 ++++++++++++++++++----------------
panels/power/cc-power-panel.ui | 46 ++--------------------
2 files changed, 42 insertions(+), 75 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index b046b2589..ea979cfc7 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -92,9 +92,7 @@ struct _CcPowerPanel
GtkSizeGroup *level_sizegroup;
GtkListBoxRow *mobile_row;
GtkSwitch *mobile_switch;
- GtkComboBox *power_button_combo;
- GtkListStore *power_button_liststore;
- GtkListBoxRow *power_button_row;
+ HdyComboRow *power_button_row;
GtkLabel *power_profile_heading;
GtkListBox *power_profile_listbox;
GtkBox *power_profile_section;
@@ -927,25 +925,18 @@ blank_screen_row_changed_cb (CcPowerPanel *self)
}
static void
-power_button_combo_changed_cb (CcPowerPanel *self)
+power_button_row_changed_cb (CcPowerPanel *self)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
+ GListModel *model;
+ gint selected_index;
+ HdyValueObject *value_object;
gint value;
- gboolean ret;
- /* no selection */
- ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->power_button_combo), &iter);
- if (!ret)
- return;
-
- /* get entry */
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->power_button_combo));
- gtk_tree_model_get (model, &iter,
- 1, &value,
- -1);
+ model = hdy_combo_row_get_model (self->power_button_row);
+ selected_index = hdy_combo_row_get_selected_index (self->power_button_row);
+ value_object = g_list_model_get_item (model, selected_index);
+ value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (value_object), "value"));
- /* set both keys */
g_settings_set_enum (self->gsd_settings, "power-button-action", value);
}
@@ -1048,10 +1039,11 @@ set_sleep_type (const GValue *value,
}
static void
-populate_power_button_model (GtkTreeModel *model,
- gboolean can_suspend,
- gboolean can_hibernate)
+populate_power_button_row (HdyComboRow *combo_row,
+ gboolean can_suspend,
+ gboolean can_hibernate)
{
+ g_autoptr (GListStore) list_store = NULL;
struct {
char *name;
GsdPowerButtonActionType value;
@@ -1063,20 +1055,28 @@ populate_power_button_model (GtkTreeModel *model,
};
guint i;
+ list_store = g_list_store_new (HDY_TYPE_VALUE_OBJECT);
for (i = 0; i < G_N_ELEMENTS (actions); i++)
{
+ g_autoptr (HdyValueObject) value_object = NULL;
+
if (!can_suspend && actions[i].value == GSD_POWER_BUTTON_ACTION_SUSPEND)
continue;
if (!can_hibernate && actions[i].value == GSD_POWER_BUTTON_ACTION_HIBERNATE)
continue;
- gtk_list_store_insert_with_values (GTK_LIST_STORE (model),
- NULL, -1,
- 0, _(actions[i].name),
- 1, actions[i].value,
- -1);
+ value_object = hdy_value_object_new_string (actions[i].name);
+ g_object_set_data (G_OBJECT (value_object),
+ "value",
+ GUINT_TO_POINTER (actions[i].value));
+ g_list_store_append (list_store, value_object);
}
+
+ hdy_combo_row_bind_name_model (combo_row,
+ G_LIST_MODEL (list_store),
+ (HdyComboRowGetNameFunc) hdy_value_object_dup_string,
+ NULL, NULL);
}
#define NEVER 0
@@ -1635,10 +1635,17 @@ setup_general_section (CcPowerPanel *self)
{
gtk_widget_show (GTK_WIDGET (self->power_button_row));
- populate_power_button_model (GTK_TREE_MODEL (self->power_button_liststore), can_suspend, can_hibernate);
- g_signal_handlers_block_by_func (self->power_button_combo, power_button_combo_changed_cb, self);
- set_value_for_combo (self->power_button_combo, g_settings_get_enum (self->gsd_settings, "power-button-action"));
- g_signal_handlers_unblock_by_func (self->power_button_combo, power_button_combo_changed_cb, self);
+ g_signal_handlers_block_by_func (self->power_button_row,
+ power_button_row_changed_cb,
+ self);
+ populate_power_button_row (self->power_button_row,
+ can_suspend,
+ can_hibernate);
+ set_value_for_combo_row (self->power_button_row,
+ g_settings_get_enum (self->gsd_settings, "power-button-action"));
+ g_signal_handlers_unblock_by_func (self->power_button_row,
+ power_button_row_changed_cb,
+ self);
show_section = TRUE;
}
@@ -1725,8 +1732,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, level_sizegroup);
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_combo);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_button_liststore);
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);
@@ -1752,7 +1757,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, blank_screen_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
gtk_widget_class_bind_template_callback (widget_class, mobile_switch_changed_cb);
- gtk_widget_class_bind_template_callback (widget_class, power_button_combo_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, power_button_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, power_profiles_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, power_saving_listbox_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, wifi_switch_changed_cb);
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index a9bb39b77..18fc0a8ac 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -51,14 +51,6 @@
</row>
</data>
</object>
- <object class="GtkListStore" id="power_button_liststore">
- <columns>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name value -->
- <column type="gint"/>
- </columns>
- </object>
<template class="CcPowerPanel" parent="CcPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -660,41 +652,11 @@
<relation target="general_heading" type="labelled-by"/>
</accessibility>
<child>
- <object class="GtkListBoxRow" id="power_button_row">
+ <object class="HdyComboRow" id="power_button_row">
<property name="visible">False</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">Po_wer Button Behavior</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="expand">True</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">power_button_combo</property>
- </object>
- </child>
- <child>
- <object class="GtkComboBoxText" id="power_button_combo">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="entry-text-column">0</property>
- <property name="model">power_button_liststore</property>
- <signal name="changed" handler="power_button_combo_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="title" translatable="yes">Po_wer Button Behavior</property>
+ <property name="use_underline">True</property>
+ <signal name="notify::selected-index" handler="power_button_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
<child>
--
2.32.0
From db131378d3a980dc243d704a91cf995d40df356b Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Thu, 7 Jan 2021 10:59:00 +0100
Subject: [PATCH 06/33] power: Use HdyActionRow to simplify the code
---
panels/power/cc-power-panel.c | 27 +--
panels/power/cc-power-panel.ui | 430 +++++----------------------------
2 files changed, 72 insertions(+), 385 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index ea979cfc7..22d91c564 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -68,17 +68,15 @@ struct _CcPowerPanel
GtkListBoxRow *automatic_suspend_row;
GtkLabel *battery_heading;
GtkListBox *battery_listbox;
- GtkListBoxRow *battery_percentage_row;
+ HdyActionRow *battery_percentage_row;
GtkSwitch *battery_percentage_switch;
GtkSizeGroup *battery_row_sizegroup;
GtkBox *battery_section;
- GtkSizeGroup *battery_sizegroup;
HdyComboRow *blank_screen_row;
GtkListBoxRow *brightness_row;
CcBrightnessScale *brightness_scale;
GtkListBoxRow *bt_row;
GtkSwitch *bt_switch;
- GtkSizeGroup *charge_sizegroup;
GtkLabel *device_heading;
GtkListBox *device_listbox;
GtkBox *device_section;
@@ -234,8 +232,6 @@ add_battery (CcPowerPanel *panel, UpDevice *device, gboolean primary)
CcBatteryRow *row = cc_battery_row_new (device, primary);
cc_battery_row_set_level_sizegroup (row, panel->level_sizegroup);
cc_battery_row_set_row_sizegroup (row, panel->battery_row_sizegroup);
- cc_battery_row_set_charge_sizegroup (row, panel->charge_sizegroup);
- cc_battery_row_set_battery_sizegroup (row, panel->battery_sizegroup);
gtk_container_add (GTK_CONTAINER (panel->battery_listbox), GTK_WIDGET (row));
gtk_widget_set_visible (GTK_WIDGET (panel->battery_section), TRUE);
@@ -247,8 +243,6 @@ add_device (CcPowerPanel *self, UpDevice *device)
CcBatteryRow *row = cc_battery_row_new (device, FALSE);
cc_battery_row_set_level_sizegroup (row, self->level_sizegroup);
cc_battery_row_set_row_sizegroup (row, self->row_sizegroup);
- cc_battery_row_set_charge_sizegroup (row, self->charge_sizegroup);
- cc_battery_row_set_battery_sizegroup (row, self->battery_sizegroup);
gtk_container_add (GTK_CONTAINER (self->device_listbox), GTK_WIDGET (row));
gtk_widget_set_visible (GTK_WIDGET (self->device_section), TRUE);
@@ -986,23 +980,20 @@ iio_proxy_vanished_cb (GDBusConnection *connection,
}
static void
-power_saving_listbox_row_activated_cb (CcPowerPanel *self, GtkListBoxRow *row)
+automatic_suspend_row_activated_cb (CcPowerPanel *self)
{
GtkWidget *toplevel;
- if (row == self->automatic_suspend_row)
- {
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
- gtk_window_set_transient_for (GTK_WINDOW (self->automatic_suspend_dialog), GTK_WINDOW (toplevel));
- gtk_window_set_modal (GTK_WINDOW (self->automatic_suspend_dialog), TRUE);
- gtk_window_present (GTK_WINDOW (self->automatic_suspend_dialog));
- }
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ gtk_window_set_transient_for (GTK_WINDOW (self->automatic_suspend_dialog), GTK_WINDOW (toplevel));
+ gtk_window_set_modal (GTK_WINDOW (self->automatic_suspend_dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (self->automatic_suspend_dialog));
}
static gboolean
automatic_suspend_label_mnemonic_activate_cb (CcPowerPanel *self)
{
- power_saving_listbox_row_activated_cb (self, self->automatic_suspend_row);
+ automatic_suspend_row_activated_cb (self);
return TRUE;
}
@@ -1712,13 +1703,11 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_percentage_switch);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_row_sizegroup);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_section);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_sizegroup);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, blank_screen_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, brightness_row);
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, charge_sizegroup);
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);
@@ -1759,7 +1748,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, mobile_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, power_button_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, power_profiles_row_activated_cb);
- gtk_widget_class_bind_template_callback (widget_class, power_saving_listbox_row_activated_cb);
+ gtk_widget_class_bind_template_callback (widget_class, automatic_suspend_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, wifi_switch_changed_cb);
}
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index 18fc0a8ac..12df3aa4a 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -220,170 +220,59 @@
<relation target="power_saving_heading" type="labelled-by"/>
</accessibility>
<child>
- <object class="GtkListBoxRow" id="brightness_row">
+ <object class="HdyActionRow" id="brightness_row">
<property name="visible">True</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">_Screen Brightness</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkBox">
+ <object class="CcBrightnessScale" id="brightness_scale">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="brightness_label">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">_Screen Brightness</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">brightness_scale</property>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkLabel" id="brightness_spacer">
- <property name="visible">True</property>
- </object>
- </child>
- <child>
- <object class="CcBrightnessScale" id="brightness_scale">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <property name="device">screen</property>
- <signal name="notify::has-brightness" handler="has_brightness_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="valign">center</property>
+ <property name="expand">True</property>
+ <property name="device">screen</property>
+ <signal name="notify::has-brightness" handler="has_brightness_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="als_row">
+ <object class="HdyActionRow" id="als_row">
<property name="visible">True</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">Automatic Brightness</property>
<child>
- <object class="GtkBox">
+ <object class="GtkSwitch" id="als_switch">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">Automatic Brightness</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="expand">True</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">als_switch</property>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="als_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="als_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="als_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="kbd_brightness_row">
+ <object class="HdyActionRow" id="kbd_brightness_row">
<property name="visible">True</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">_Keyboard Brightness</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkBox">
+ <object class="CcBrightnessScale" id="kbd_brightness_scale">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="kbd_brightness_label">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">_Keyboard Brightness</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">kbd_brightness_scale</property>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkLabel" id="kbd_brightness_spacer">
- <property name="visible">True</property>
- </object>
- </child>
- <child>
- <object class="CcBrightnessScale" id="kbd_brightness_scale">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <property name="device">kbd</property>
- <signal name="notify::has-brightness" handler="has_kbd_brightness_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="valign">center</property>
+ <property name="expand">True</property>
+ <property name="device">kbd</property>
+ <signal name="notify::has-brightness" handler="has_kbd_brightness_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="dim_screen_row">
+ <object class="HdyActionRow" id="dim_screen_row">
<property name="visible">True</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">Dim Screen When Inactive</property>
+ <property name="activatable_widget">dim_screen_switch</property>
<child>
- <object class="GtkBox">
+ <object class="GtkSwitch" id="dim_screen_switch">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">Dim Screen When Inactive</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="expand">True</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">dim_screen_switch</property>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="dim_screen_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- </object>
- </child>
+ <property name="valign">center</property>
</object>
</child>
</object>
@@ -397,221 +286,65 @@
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="automatic_suspend_row">
+ <object class="HdyActionRow" id="automatic_suspend_row">
<property name="visible">False</property>
+ <property name="title" translatable="yes">_Automatic Suspend</property>
+ <property name="use_underline">True</property>
+ <property name="activatable">True</property>
+ <signal name="activated" handler="automatic_suspend_row_activated_cb" swapped="yes"/>
<child>
- <object class="GtkBox">
+ <object class="GtkLabel" id="automatic_suspend_label">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">_Automatic Suspend</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="expand">True</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">automatic_suspend_label</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="automatic_suspend_label">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <signal name="mnemonic-activate" handler="automatic_suspend_label_mnemonic_activate_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
+ <property name="halign">end</property>
+ <signal name="mnemonic-activate" handler="automatic_suspend_label_mnemonic_activate_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="wifi_row">
+ <object class="HdyActionRow" id="wifi_row">
<property name="visible">False</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">_Wi-Fi</property>
+ <property name="subtitle" translatable="yes">Wi-Fi can be turned off to save power.</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">wifi_switch</property>
<child>
- <object class="GtkBox">
+ <object class="GtkSwitch" id="wifi_switch">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="spacing">4</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">_Wi-Fi</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">wifi_switch</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">Wi-Fi can be turned off to save power.</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <attributes>
- <attribute name="scale" value="0.9"/>
- </attributes>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="wifi_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="wifi_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="wifi_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="mobile_row">
+ <object class="HdyActionRow" id="mobile_row">
<property name="visible">False</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">_Mobile Broadband</property>
+ <property name="subtitle" translatable="yes">Mobile broadband (LTE, 4G, 3G, etc.) can be turned off to save power.</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">mobile_switch</property>
<child>
- <object class="GtkBox">
+ <object class="GtkSwitch" id="mobile_switch">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="spacing">4</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">_Mobile Broadband</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">mobile_switch</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">Mobile broadband (LTE, 4G, 3G, etc.) can be turned off to save power.</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <attributes>
- <attribute name="scale" value="0.9"/>
- </attributes>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="mobile_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="mobile_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="mobile_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="bt_row">
+ <object class="HdyActionRow" id="bt_row">
<property name="visible">False</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">_Bluetooth</property>
+ <property name="subtitle" translatable="yes">Bluetooth can be turned off to save power.</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">bt_switch</property>
<child>
- <object class="GtkBox">
+ <object class="GtkSwitch" id="bt_switch">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="spacing">4</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">_Bluetooth</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">bt_switch</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">Bluetooth can be turned off to save power.</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <attributes>
- <attribute name="scale" value="0.9"/>
- </attributes>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="bt_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="bt_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="bt_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
</object>
@@ -660,36 +393,15 @@
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="battery_percentage_row">
+ <object class="HdyActionRow" id="battery_percentage_row">
<property name="visible">False</property>
- <property name="selectable">False</property>
- <property name="activatable">False</property>
+ <property name="title" translatable="yes">Show Battery _Percentage</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">battery_percentage_switch</property>
<child>
- <object class="GtkBox">
+ <object class="GtkSwitch" id="battery_percentage_switch">
<property name="visible">True</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="use-markup">True</property>
- <property name="use-underline">True</property>
- <property name="ellipsize">end</property>
- <property name="label" translatable="yes">Show Battery _Percentage</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="expand">True</property>
- <property name="xalign">0</property>
- <property name="mnemonic_widget">battery_percentage_switch</property>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="battery_percentage_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- </object>
- </child>
+ <property name="valign">center</property>
</object>
</child>
</object>
@@ -710,20 +422,6 @@
<object class="GtkSizeGroup" id="battery_row_sizegroup">
<property name="mode">vertical</property>
</object>
- <object class="GtkSizeGroup" id="battery_sizegroup">
- <property name="mode">horizontal</property>
- <widgets>
- <widget name="brightness_label"/>
- <widget name="kbd_brightness_label"/>
- </widgets>
- </object>
- <object class="GtkSizeGroup" id="charge_sizegroup">
- <property name="mode">horizontal</property>
- <widgets>
- <widget name="brightness_spacer"/>
- <widget name="kbd_brightness_spacer"/>
- </widgets>
- </object>
<object class="GtkSizeGroup" id="level_sizegroup">
<property name="mode">horizontal</property>
<widgets>
--
2.32.0
From 93fa8d4dfaa206a763f678df2b2eb31e1599c7c8 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Thu, 7 Jan 2021 13:49:36 +0100
Subject: [PATCH 07/33] 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 &amp; 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>
--
2.32.0
From 58480754efd5fdc66db0940ce5c19abfbd2158b6 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Thu, 7 Jan 2021 14:37:56 +0100
Subject: [PATCH 08/33] power: Fix the indentation
The indentation was purposefully left incorrect in the previous commits
to ease the review of the actual changes, this fixes it.
---
panels/power/cc-power-panel.ui | 426 ++++++++++++++++-----------------
1 file changed, 213 insertions(+), 213 deletions(-)
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index 26d6ffddc..8e999c6d5 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -57,238 +57,238 @@
<child>
<object class="HdyPreferencesPage">
<property name="visible">True</property>
+ <child>
+ <object class="HdyPreferencesGroup" id="battery_section">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Battery</property>
+ <accessibility>
+ <relation target="battery_listbox" type="label-for"/>
+ </accessibility>
+ <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_section" type="labelled-by"/>
+ </accessibility>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup" id="device_section">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Devices</property>
+ <accessibility>
+ <relation target="device_listbox" type="label-for"/>
+ </accessibility>
+ <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_section" type="labelled-by"/>
+ </accessibility>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup" id="power_profile_section">
+ <property name="visible">False</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>
+ <child>
+ <object class="GtkListBox" id="power_profile_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_profiles_row_activated_cb" object="CcPowerPanel" swapped="yes"/>
+ <accessibility>
+ <relation target="power_profile_section" type="labelled-by"/>
+ </accessibility>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup" id="power_saving_section">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Power Saving</property>
+ <child>
+ <object class="HdyActionRow" id="brightness_row">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">_Screen Brightness</property>
+ <property name="use_underline">True</property>
<child>
- <object class="HdyPreferencesGroup" id="battery_section">
+ <object class="CcBrightnessScale" id="brightness_scale">
<property name="visible">True</property>
- <property name="title" translatable="yes">Battery</property>
- <accessibility>
- <relation target="battery_listbox" type="label-for"/>
- </accessibility>
- <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_section" type="labelled-by"/>
- </accessibility>
- <style>
- <class name="content"/>
- </style>
- </object>
- </child>
+ <property name="valign">center</property>
+ <property name="expand">True</property>
+ <property name="device">screen</property>
+ <signal name="notify::has-brightness" handler="has_brightness_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="als_row">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Automatic Brightness</property>
<child>
- <object class="HdyPreferencesGroup" id="device_section">
+ <object class="GtkSwitch" id="als_switch">
<property name="visible">True</property>
- <property name="title" translatable="yes">Devices</property>
- <accessibility>
- <relation target="device_listbox" type="label-for"/>
- </accessibility>
- <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_section" type="labelled-by"/>
- </accessibility>
- <style>
- <class name="content"/>
- </style>
- </object>
- </child>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="als_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="kbd_brightness_row">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">_Keyboard Brightness</property>
+ <property name="use_underline">True</property>
<child>
- <object class="HdyPreferencesGroup" id="power_profile_section">
- <property name="visible">False</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>
- <child>
- <object class="GtkListBox" id="power_profile_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_profiles_row_activated_cb" object="CcPowerPanel" swapped="yes"/>
- <accessibility>
- <relation target="power_profile_section" type="labelled-by"/>
- </accessibility>
- <style>
- <class name="content"/>
- </style>
- </object>
- </child>
+ <object class="CcBrightnessScale" id="kbd_brightness_scale">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="expand">True</property>
+ <property name="device">kbd</property>
+ <signal name="notify::has-brightness" handler="has_kbd_brightness_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="dim_screen_row">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Dim Screen When Inactive</property>
+ <property name="activatable_widget">dim_screen_switch</property>
<child>
- <object class="HdyPreferencesGroup" id="power_saving_section">
+ <object class="GtkSwitch" id="dim_screen_switch">
<property name="visible">True</property>
- <property name="title" translatable="yes">Power Saving</property>
- <child>
- <object class="HdyActionRow" id="brightness_row">
- <property name="visible">True</property>
- <property name="title" translatable="yes">_Screen Brightness</property>
- <property name="use_underline">True</property>
- <child>
- <object class="CcBrightnessScale" id="brightness_scale">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <property name="device">screen</property>
- <signal name="notify::has-brightness" handler="has_brightness_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="als_row">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Automatic Brightness</property>
- <child>
- <object class="GtkSwitch" id="als_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="als_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="kbd_brightness_row">
- <property name="visible">True</property>
- <property name="title" translatable="yes">_Keyboard Brightness</property>
- <property name="use_underline">True</property>
- <child>
- <object class="CcBrightnessScale" id="kbd_brightness_scale">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <property name="device">kbd</property>
- <signal name="notify::has-brightness" handler="has_kbd_brightness_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="dim_screen_row">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Dim Screen When Inactive</property>
- <property name="activatable_widget">dim_screen_switch</property>
- <child>
- <object class="GtkSwitch" id="dim_screen_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyComboRow" id="blank_screen_row">
- <property name="visible">True</property>
- <property name="title" translatable="yes">_Blank Screen</property>
- <property name="use_underline">True</property>
- <signal name="notify::selected-index" handler="blank_screen_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="automatic_suspend_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">_Automatic Suspend</property>
- <property name="use_underline">True</property>
- <property name="activatable">True</property>
- <signal name="activated" handler="automatic_suspend_row_activated_cb" swapped="yes"/>
- <child>
- <object class="GtkLabel" id="automatic_suspend_label">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <signal name="mnemonic-activate" handler="automatic_suspend_label_mnemonic_activate_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="wifi_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">_Wi-Fi</property>
- <property name="subtitle" translatable="yes">Wi-Fi can be turned off to save power.</property>
- <property name="use_underline">True</property>
- <property name="activatable_widget">wifi_switch</property>
- <child>
- <object class="GtkSwitch" id="wifi_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="wifi_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="mobile_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">_Mobile Broadband</property>
- <property name="subtitle" translatable="yes">Mobile broadband (LTE, 4G, 3G, etc.) can be turned off to save power.</property>
- <property name="use_underline">True</property>
- <property name="activatable_widget">mobile_switch</property>
- <child>
- <object class="GtkSwitch" id="mobile_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="mobile_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="bt_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">_Bluetooth</property>
- <property name="subtitle" translatable="yes">Bluetooth can be turned off to save power.</property>
- <property name="use_underline">True</property>
- <property name="activatable_widget">bt_switch</property>
- <child>
- <object class="GtkSwitch" id="bt_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="bt_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyComboRow" id="blank_screen_row">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">_Blank Screen</property>
+ <property name="use_underline">True</property>
+ <signal name="notify::selected-index" handler="blank_screen_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="automatic_suspend_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">_Automatic Suspend</property>
+ <property name="use_underline">True</property>
+ <property name="activatable">True</property>
+ <signal name="activated" handler="automatic_suspend_row_activated_cb" swapped="yes"/>
+ <child>
+ <object class="GtkLabel" id="automatic_suspend_label">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <signal name="mnemonic-activate" handler="automatic_suspend_label_mnemonic_activate_cb" object="CcPowerPanel" swapped="yes"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="wifi_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">_Wi-Fi</property>
+ <property name="subtitle" translatable="yes">Wi-Fi can be turned off to save power.</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">wifi_switch</property>
+ <child>
+ <object class="GtkSwitch" id="wifi_switch">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="wifi_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="mobile_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">_Mobile Broadband</property>
+ <property name="subtitle" translatable="yes">Mobile broadband (LTE, 4G, 3G, etc.) can be turned off to save power.</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">mobile_switch</property>
+ <child>
+ <object class="GtkSwitch" id="mobile_switch">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="mobile_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="bt_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">_Bluetooth</property>
+ <property name="subtitle" translatable="yes">Bluetooth can be turned off to save power.</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">bt_switch</property>
<child>
- <object class="HdyPreferencesGroup" id="general_section">
+ <object class="GtkSwitch" id="bt_switch">
<property name="visible">True</property>
- <property name="title" translatable="yes">Suspend &amp; Power Button</property>
- <child>
- <object class="HdyComboRow" id="power_button_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">Po_wer Button Behavior</property>
- <property name="use_underline">True</property>
- <signal name="notify::selected-index" handler="power_button_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="battery_percentage_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">Show Battery _Percentage</property>
- <property name="use_underline">True</property>
- <property name="activatable_widget">battery_percentage_switch</property>
- <child>
- <object class="GtkSwitch" id="battery_percentage_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- </object>
- </child>
- </object>
- </child>
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="bt_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup" id="general_section">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Suspend &amp; Power Button</property>
+ <child>
+ <object class="HdyComboRow" id="power_button_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">Po_wer Button Behavior</property>
+ <property name="use_underline">True</property>
+ <signal name="notify::selected-index" handler="power_button_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
+ </object>
+ </child>
+ <child>
+ <object class="HdyActionRow" id="battery_percentage_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">Show Battery _Percentage</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">battery_percentage_switch</property>
+ <child>
+ <object class="GtkSwitch" id="battery_percentage_switch">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</template>
--
2.32.0
From 036545ebc5b3deba1d4bb4ac82dc102413804e83 Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Fri, 8 Jan 2021 16:29:18 +0100
Subject: [PATCH 09/33] power: Hide the icon of the battery row when unused
This gives more room to the label.
---
panels/power/cc-battery-row.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/panels/power/cc-battery-row.c b/panels/power/cc-battery-row.c
index 55d7584d7..f6faca0c1 100644
--- a/panels/power/cc-battery-row.c
+++ b/panels/power/cc-battery-row.c
@@ -275,7 +275,12 @@ cc_battery_row_new (UpDevice *device,
/* Icon */
if (is_kind_battery && icon_name != NULL && icon_name[0] != '\0')
- gtk_image_set_from_icon_name (self->icon, icon_name, GTK_ICON_SIZE_BUTTON);
+ {
+ gtk_image_set_from_icon_name (self->icon, icon_name, GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (GTK_WIDGET (self->icon));
+ }
+ else
+ gtk_widget_hide (GTK_WIDGET (self->icon));
/* Percentage label */
if (battery_level == UP_DEVICE_LEVEL_NONE)
@@ -347,4 +352,4 @@ UpDeviceKind
cc_battery_row_get_kind (CcBatteryRow *self)
{
return self->kind;
-}
\ No newline at end of file
+}
--
2.32.0
From c4849778de730f37618120dbdd37f30515ecc77a Mon Sep 17 00:00:00 2001
From: Adrien Plazas <kekun.plazas@laposte.net>
Date: Fri, 8 Jan 2021 16:30:12 +0100
Subject: [PATCH 10/33] power: Ellipsize the labels of the battery row
This helps the window fit any size, including the narrow one of phones.
---
panels/power/cc-battery-row.ui | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/panels/power/cc-battery-row.ui b/panels/power/cc-battery-row.ui
index 932e5d39f..dec97a9fe 100644
--- a/panels/power/cc-battery-row.ui
+++ b/panels/power/cc-battery-row.ui
@@ -28,6 +28,8 @@
<child>
<object class="GtkLabel" id="name_label">
<property name="visible">True</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
</object>
</child>
<child>
@@ -79,6 +81,8 @@
<child>
<object class="GtkLabel" id="details_label">
<property name="visible">True</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
</object>
</child>
<child>
--
2.32.0
From 33d672d634a9e1d8a2cfa74dc4d503fb6f170ea1 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 15 Jul 2021 13:08:05 +0200
Subject: [PATCH 11/33] power: Fix keynav not working
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
gnome-control-center/panels/power/cc-power-panel.c: In function keynav_failed_cb:
gnome-control-center/panels/power/cc-power-panel.c:892:50: warning: statement with no effect [-Wunused-value]
892 | direction == GTK_DIR_UP ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
---
panels/power/cc-power-panel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 96558c778..d31d16d22 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -888,7 +888,7 @@ keynav_failed_cb (CcPowerPanel *self, GtkDirectionType direction, GtkWidget *lis
if (direction != GTK_DIR_UP && direction != GTK_DIR_DOWN)
return FALSE;
- direction == GTK_DIR_UP ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
+ direction = GTK_DIR_UP ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
return gtk_widget_child_focus (GTK_WIDGET (self), direction);
}
--
2.32.0
From 35b621ce5191461b16eefcb5e677496c0c48638c Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 15 Jul 2021 13:46:19 +0200
Subject: [PATCH 12/33] power: Simplify emptying listbox
We do that in a few places.
---
panels/power/cc-power-panel.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index d31d16d22..5d57afe59 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -242,25 +242,29 @@ add_device (CcPowerPanel *self, UpDevice *device)
}
static void
-up_client_changed (CcPowerPanel *self)
+empty_listbox (GtkListBox *listbox)
{
- g_autoptr(GList) battery_children = NULL;
- g_autoptr(GList) device_children = NULL;
+ g_autoptr(GList) children = NULL;
GList *l;
+
+ children = gtk_container_get_children (GTK_CONTAINER (listbox));
+ for (l = children; l != NULL; l = l->next)
+ gtk_container_remove (GTK_CONTAINER (listbox), l->data);
+}
+
+static void
+up_client_changed (CcPowerPanel *self)
+{
gint i;
UpDeviceKind kind;
guint n_batteries;
gboolean on_ups;
g_autoptr(UpDevice) composite = NULL;
- battery_children = gtk_container_get_children (GTK_CONTAINER (self->battery_listbox));
- for (l = battery_children; l != NULL; l = l->next)
- gtk_container_remove (GTK_CONTAINER (self->battery_listbox), l->data);
+ empty_listbox (self->battery_listbox);
gtk_widget_hide (GTK_WIDGET (self->battery_section));
- device_children = gtk_container_get_children (GTK_CONTAINER (self->device_listbox));
- for (l = device_children; l != NULL; l = l->next)
- gtk_container_remove (GTK_CONTAINER (self->device_listbox), l->data);
+ empty_listbox (self->device_listbox);
gtk_widget_hide (GTK_WIDGET (self->device_section));
#ifdef TEST_FAKE_DEVICES
--
2.32.0
From 7915830b4d8b691f4def35c83c06a658f5b14ac1 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 15 Jul 2021 14:39:58 +0200
Subject: [PATCH 13/33] power: Add new power profile info row widget
---
panels/power/cc-power-panel.c | 1 +
panels/power/cc-power-profile-info-row.c | 67 ++++++++++
panels/power/cc-power-profile-info-row.h | 36 ++++++
panels/power/cc-power-profile-info-row.ui | 44 +++++++
panels/power/icons/info-symbolic.svg | 150 ++++++++++++++++++++++
panels/power/icons/meson.build | 5 +
panels/power/meson.build | 1 +
panels/power/power.gresource.xml | 1 +
8 files changed, 305 insertions(+)
create mode 100644 panels/power/cc-power-profile-info-row.c
create mode 100644 panels/power/cc-power-profile-info-row.h
create mode 100644 panels/power/cc-power-profile-info-row.ui
create mode 100644 panels/power/icons/info-symbolic.svg
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 5d57afe59..8acf62dee 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -35,6 +35,7 @@
#include "cc-battery-row.h"
#include "cc-brightness-scale.h"
#include "cc-power-profile-row.h"
+#include "cc-power-profile-info-row.h"
#include "cc-power-panel.h"
#include "cc-power-resources.h"
#include "cc-util.h"
diff --git a/panels/power/cc-power-profile-info-row.c b/panels/power/cc-power-profile-info-row.c
new file mode 100644
index 000000000..92bb78834
--- /dev/null
+++ b/panels/power/cc-power-profile-info-row.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* cc-list-row.c
+ *
+ * Copyright 2020 Red Hat Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author(s):
+ * Bastien Nocera <hadess@hadess.net>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "cc-power-profile-info-row"
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include "cc-power-profile-info-row.h"
+
+struct _CcPowerProfileInfoRow
+{
+ GtkListBoxRow parent_instance;
+
+ GtkLabel *title_label;
+};
+
+G_DEFINE_TYPE (CcPowerProfileInfoRow, cc_power_profile_info_row, GTK_TYPE_LIST_BOX_ROW)
+
+static void
+cc_power_profile_info_row_class_init (CcPowerProfileInfoRowClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/power/cc-power-profile-info-row.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, CcPowerProfileInfoRow, title_label);
+}
+
+static void
+cc_power_profile_info_row_init (CcPowerProfileInfoRow *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+CcPowerProfileInfoRow *
+cc_power_profile_info_row_new (const char *text)
+{
+ CcPowerProfileInfoRow *self;
+
+ self = g_object_new (CC_TYPE_POWER_PROFILE_INFO_ROW, NULL);
+ gtk_label_set_markup (self->title_label, text);
+
+ return self;
+}
diff --git a/panels/power/cc-power-profile-info-row.h b/panels/power/cc-power-profile-info-row.h
new file mode 100644
index 000000000..52d055ab2
--- /dev/null
+++ b/panels/power/cc-power-profile-info-row.h
@@ -0,0 +1,36 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* cc-list-row.h
+ *
+ * Copyright 2020 Red Hat Inc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author(s):
+ * Bastien Nocera <hadess@hadess.net>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_POWER_PROFILE_INFO_ROW (cc_power_profile_info_row_get_type())
+G_DECLARE_FINAL_TYPE (CcPowerProfileInfoRow, cc_power_profile_info_row, CC, POWER_PROFILE_INFO_ROW, GtkListBoxRow)
+
+CcPowerProfileInfoRow *cc_power_profile_info_row_new (const char *text);
+
+G_END_DECLS
diff --git a/panels/power/cc-power-profile-info-row.ui b/panels/power/cc-power-profile-info-row.ui
new file mode 100644
index 000000000..d9291ff16
--- /dev/null
+++ b/panels/power/cc-power-profile-info-row.ui
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <template class="CcPowerProfileInfoRow" parent="GtkListBoxRow">
+ <property name="activatable">False</property>
+ <property name="selectable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <property name="margin-top">8</property>
+ <property name="margin-bottom">8</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkImage" id="icon_image">
+ <property name="visible">True</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">18</property>
+ <property name="icon-name">info-symbolic</property>
+ <property name="icon-size">5</property>
+ <style>
+ <class name="power-profile"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="expand">True</property>
+ <property name="use-markup">True</property>
+ <property name="use-underline">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="margin-end">6</property>
+ <property name="wrap">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/panels/power/icons/info-symbolic.svg b/panels/power/icons/info-symbolic.svg
new file mode 100644
index 000000000..502a98a50
--- /dev/null
+++ b/panels/power/icons/info-symbolic.svg
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <filter id="a" height="100%" width="100%" x="0%" y="0%">
+ <feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
+ </filter>
+ <mask id="b">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
+ </g>
+ </mask>
+ <clipPath id="c">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="d">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
+ </g>
+ </mask>
+ <clipPath id="e">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="f">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
+ </g>
+ </mask>
+ <clipPath id="g">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="h">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
+ </g>
+ </mask>
+ <clipPath id="i">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="j">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
+ </g>
+ </mask>
+ <clipPath id="k">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="l">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
+ </g>
+ </mask>
+ <clipPath id="m">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="n">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
+ </g>
+ </mask>
+ <clipPath id="o">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="p">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
+ </g>
+ </mask>
+ <clipPath id="q">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="r">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
+ </g>
+ </mask>
+ <clipPath id="s">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="t">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.4"/>
+ </g>
+ </mask>
+ <clipPath id="u">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="v">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.4"/>
+ </g>
+ </mask>
+ <clipPath id="w">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="x">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
+ </g>
+ </mask>
+ <clipPath id="y">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <mask id="z">
+ <g filter="url(#a)">
+ <path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
+ </g>
+ </mask>
+ <clipPath id="A">
+ <path d="m 0 0 h 1024 v 800 h -1024 z"/>
+ </clipPath>
+ <g clip-path="url(#c)" mask="url(#b)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 562.460938 212.058594 h 10.449218 c -1.183594 0.492187 -1.296875 2.460937 0 3 h -10.449218 z m 0 0" fill="#2e3436"/>
+ </g>
+ <path d="m 7.90625 1 c -3.828125 0.050781 -6.90625 3.171875 -6.90625 7 c 0 3.867188 3.132812 7 7 7 s 7 -3.132812 7 -7 s -3.132812 -7 -7 -7 c -0.03125 0 -0.0625 0 -0.09375 0 z m -0.40625 3 h 1 c 0.277344 0 0.5 0.222656 0.5 0.5 v 1 c 0 0.277344 -0.222656 0.5 -0.5 0.5 h -1 c -0.277344 0 -0.5 -0.222656 -0.5 -0.5 v -1 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m -0.5 3 h 2 v 5 h -2 z m 0 0" fill="#2e3436"/>
+ <g clip-path="url(#e)" mask="url(#d)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 16 632 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
+ </g>
+ <g clip-path="url(#g)" mask="url(#f)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 17 631 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
+ </g>
+ <g clip-path="url(#i)" mask="url(#h)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 18 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
+ </g>
+ <g clip-path="url(#k)" mask="url(#j)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 16 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
+ </g>
+ <g clip-path="url(#m)" mask="url(#l)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 17 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
+ </g>
+ <g clip-path="url(#o)" mask="url(#n)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 19 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
+ </g>
+ <g clip-path="url(#q)" mask="url(#p)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 136 660 v 7 h 7 v -7 z m 0 0" fill="#2e3436"/>
+ </g>
+ <g clip-path="url(#s)" mask="url(#r)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 199 642 h 3 v 12 h -3 z m 0 0" fill="#2e3436"/>
+ </g>
+ <g clip-path="url(#u)" mask="url(#t)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 209.5 144.160156 c 0.277344 0 0.5 0.222656 0.5 0.5 v 1 c 0 0.277344 -0.222656 0.5 -0.5 0.5 s -0.5 -0.222656 -0.5 -0.5 v -1 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m 0 0" fill="#2e3436"/>
+ </g>
+ <g clip-path="url(#w)" mask="url(#v)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 206.5 144.160156 c 0.277344 0 0.5 0.222656 0.5 0.5 v 1 c 0 0.277344 -0.222656 0.5 -0.5 0.5 s -0.5 -0.222656 -0.5 -0.5 v -1 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m 0 0" fill="#2e3436"/>
+ </g>
+ <g clip-path="url(#y)" mask="url(#x)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 229.5 143.160156 c -0.546875 0 -1 0.457032 -1 1 c 0 0.546875 0.453125 1 1 1 s 1 -0.453125 1 -1 c 0 -0.542968 -0.453125 -1 -1 -1 z m 0 0" fill="#2e3436"/>
+ </g>
+ <g clip-path="url(#A)" mask="url(#z)" transform="matrix(1 0 0 1 -660 -222)">
+ <path d="m 226.453125 143.160156 c -0.519531 0 -0.953125 0.433594 -0.953125 0.953125 v 0.09375 c 0 0.519531 0.433594 0.953125 0.953125 0.953125 h 0.09375 c 0.519531 0 0.953125 -0.433594 0.953125 -0.953125 v -0.09375 c 0 -0.519531 -0.433594 -0.953125 -0.953125 -0.953125 z m 0 0" fill="#2e3436"/>
+ </g>
+</svg>
diff --git a/panels/power/icons/meson.build b/panels/power/icons/meson.build
index 8165371ea..c56bc65b7 100644
--- a/panels/power/icons/meson.build
+++ b/panels/power/icons/meson.build
@@ -13,3 +13,8 @@ foreach icon_size: icon_sizes
install_dir: join_paths(control_center_icondir, 'hicolor', icon_size, 'apps')
)
endforeach
+
+install_data(
+ 'info-symbolic.svg',
+ install_dir: join_paths(control_center_icondir, 'hicolor', 'scalable', 'status')
+)
diff --git a/panels/power/meson.build b/panels/power/meson.build
index 625059dd2..af04b98ed 100644
--- a/panels/power/meson.build
+++ b/panels/power/meson.build
@@ -22,6 +22,7 @@ sources = files(
'cc-brightness-scale.c',
'cc-power-panel.c',
'cc-power-profile-row.c',
+ 'cc-power-profile-info-row.c'
)
sources += gnome.mkenums_simple(
diff --git a/panels/power/power.gresource.xml b/panels/power/power.gresource.xml
index 31e92b415..5a33c8e60 100644
--- a/panels/power/power.gresource.xml
+++ b/panels/power/power.gresource.xml
@@ -4,6 +4,7 @@
<file preprocess="xml-stripblanks">cc-battery-row.ui</file>
<file preprocess="xml-stripblanks">cc-power-panel.ui</file>
<file preprocess="xml-stripblanks">cc-power-profile-row.ui</file>
+ <file preprocess="xml-stripblanks">cc-power-profile-info-row.ui</file>
<file>battery-levels.css</file>
<file>power-profiles.css</file>
</gresource>
--
2.32.0
From 1a80fda8cdbd2226a5663f0fa572dd72210722a6 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 2 Apr 2021 13:10:19 +0200
Subject: [PATCH 14/33] power: Handle new power-profiles-daemon API
Handle the new PerformanceDegraded property to replace
PerformanceInhibited.
---
panels/power/cc-power-panel.c | 53 +++++++++++++++++++++++++++++++---
panels/power/cc-power-panel.ui | 11 +++++++
2 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 8acf62dee..51196a8c4 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -89,6 +89,7 @@ struct _CcPowerPanel
GtkSwitch *mobile_switch;
HdyComboRow *power_button_row;
GtkListBox *power_profile_listbox;
+ GtkListBox *power_profile_info_listbox;
HdyPreferencesGroup *power_profile_section;
GtkSizeGroup *row_sizegroup;
GtkComboBox *suspend_on_battery_delay_combo;
@@ -119,6 +120,7 @@ struct _CcPowerPanel
guint power_profiles_prop_id;
CcPowerProfileRow *power_profiles_row[NUM_CC_POWER_PROFILES];
gboolean power_profiles_in_update;
+ gboolean has_performance_degraded;
#ifdef HAVE_NETWORK_MANAGER
NMClient *nm_client;
@@ -1365,6 +1367,37 @@ performance_profile_set_inhibited (CcPowerPanel *self,
cc_power_profile_row_set_performance_inhibited (row, performance_inhibited);
}
+static void
+performance_profile_set_degraded (CcPowerPanel *self)
+{
+ g_autoptr(GVariant) variant = NULL;
+ const char *degraded, *text;
+ CcPowerProfileInfoRow *row;
+
+ empty_listbox (self->power_profile_info_listbox);
+ gtk_widget_hide (GTK_WIDGET (self->power_profile_info_listbox));
+
+ variant = g_dbus_proxy_get_cached_property (self->power_profiles_proxy, "PerformanceDegraded");
+ if (!variant)
+ return;
+ degraded = g_variant_get_string (variant, NULL);
+ if (*degraded == '\0')
+ return;
+
+ gtk_widget_show (GTK_WIDGET (self->power_profile_info_listbox));
+
+ if (g_str_equal (degraded, "high-operating-temperature"))
+ text = _("Performance mode temporarily disabled due to high operating temperature.");
+ else if (g_str_equal (degraded, "lap-detected"))
+ text = _("Lap detected: performance mode temporarily disabled. Move the device to a stable surface to restore.");
+ else
+ text = _("Performance mode temporarily disabled.");
+
+ row = cc_power_profile_info_row_new (text);
+ gtk_widget_show (GTK_WIDGET (row));
+ gtk_container_add (GTK_CONTAINER (self->power_profile_info_listbox), GTK_WIDGET (row));
+}
+
static void
power_profiles_row_activated_cb (GtkListBox *box,
GtkListBoxRow *box_row,
@@ -1420,8 +1453,13 @@ power_profiles_properties_changed_cb (CcPowerPanel *self,
{
if (g_strcmp0 (key, "PerformanceInhibited") == 0)
{
- performance_profile_set_inhibited (self,
- g_variant_get_string (value, NULL));
+ if (!self->has_performance_degraded)
+ performance_profile_set_inhibited (self,
+ g_variant_get_string (value, NULL));
+ }
+ else if (g_strcmp0 (key, "PerformanceDegraded") == 0)
+ {
+ performance_profile_set_degraded (self);
}
else if (g_strcmp0 (key, "ActiveProfile") == 0)
{
@@ -1504,7 +1542,8 @@ setup_power_profiles (CcPowerPanel *self)
g_autoptr(GVariant) props = NULL;
guint i, num_children;
g_autoptr(GError) error = NULL;
- const char *performance_inhibited;
+ const char *performance_inhibited = NULL;
+ const char *performance_degraded;
const char *active_profile;
g_autoptr(GVariant) profiles = NULL;
GtkRadioButton *last_button;
@@ -1557,7 +1596,12 @@ setup_power_profiles (CcPowerPanel *self)
gtk_widget_show (GTK_WIDGET (self->power_profile_section));
props = g_variant_get_child_value (variant, 0);
- performance_inhibited = variant_lookup_string (props, "PerformanceInhibited");
+ performance_degraded = variant_lookup_string (props, "PerformanceDegraded");
+ self->has_performance_degraded = performance_degraded != NULL;
+ if (performance_degraded == NULL)
+ performance_inhibited = variant_lookup_string (props, "PerformanceInhibited");
+ else
+ performance_profile_set_degraded (self);
active_profile = variant_lookup_string (props, "ActiveProfile");
last_button = NULL;
@@ -1715,6 +1759,7 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
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_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, row_sizegroup);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_battery_delay_combo);
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index 8e999c6d5..d8283c556 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -123,6 +123,17 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkListBox" id="power_profile_info_listbox">
+ <property name="visible">False</property>
+ <property name="selection-mode">none</property>
+ <property name="margin_top">12</property>
+ <signal name="keynav-failed" handler="keynav_failed_cb" object="CcPowerPanel" swapped="yes"/>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
<child>
--
2.32.0
From 7254da88faa5cebd43db735746eb20b2b548a462 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 16 Jul 2021 10:00:12 +0200
Subject: [PATCH 15/33] power: Prepare for adding more power profile info boxes
Rename and re-indent the code that adds the power profile info boxes to
prepare for adding more info boxes when needed.
---
panels/power/cc-power-panel.c | 46 ++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 51196a8c4..1869be065 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -1368,34 +1368,35 @@ performance_profile_set_inhibited (CcPowerPanel *self,
}
static void
-performance_profile_set_degraded (CcPowerPanel *self)
+power_profile_update_info_boxes (CcPowerPanel *self)
{
- g_autoptr(GVariant) variant = NULL;
- const char *degraded, *text;
+ g_autoptr(GVariant) degraded_variant = NULL;
+ const char *degraded = NULL;
CcPowerProfileInfoRow *row;
empty_listbox (self->power_profile_info_listbox);
gtk_widget_hide (GTK_WIDGET (self->power_profile_info_listbox));
- variant = g_dbus_proxy_get_cached_property (self->power_profiles_proxy, "PerformanceDegraded");
- if (!variant)
- return;
- degraded = g_variant_get_string (variant, NULL);
- if (*degraded == '\0')
- return;
+ degraded_variant = g_dbus_proxy_get_cached_property (self->power_profiles_proxy, "PerformanceDegraded");
+ if (degraded_variant)
+ degraded = g_variant_get_string (degraded_variant, NULL);
+ if (degraded && *degraded != '\0')
+ {
+ const char *text;
- gtk_widget_show (GTK_WIDGET (self->power_profile_info_listbox));
+ gtk_widget_show (GTK_WIDGET (self->power_profile_info_listbox));
- if (g_str_equal (degraded, "high-operating-temperature"))
- text = _("Performance mode temporarily disabled due to high operating temperature.");
- else if (g_str_equal (degraded, "lap-detected"))
- text = _("Lap detected: performance mode temporarily disabled. Move the device to a stable surface to restore.");
- else
- text = _("Performance mode temporarily disabled.");
+ if (g_str_equal (degraded, "high-operating-temperature"))
+ text = _("Performance mode temporarily disabled due to high operating temperature.");
+ else if (g_str_equal (degraded, "lap-detected"))
+ text = _("Lap detected: performance mode temporarily disabled. Move the device to a stable surface to restore.");
+ else
+ text = _("Performance mode temporarily disabled.");
- row = cc_power_profile_info_row_new (text);
- gtk_widget_show (GTK_WIDGET (row));
- gtk_container_add (GTK_CONTAINER (self->power_profile_info_listbox), GTK_WIDGET (row));
+ row = cc_power_profile_info_row_new (text);
+ gtk_widget_show (GTK_WIDGET (row));
+ gtk_container_add (GTK_CONTAINER (self->power_profile_info_listbox), GTK_WIDGET (row));
+ }
}
static void
@@ -1459,7 +1460,7 @@ power_profiles_properties_changed_cb (CcPowerPanel *self,
}
else if (g_strcmp0 (key, "PerformanceDegraded") == 0)
{
- performance_profile_set_degraded (self);
+ power_profile_update_info_boxes (self);
}
else if (g_strcmp0 (key, "ActiveProfile") == 0)
{
@@ -1600,8 +1601,6 @@ setup_power_profiles (CcPowerPanel *self)
self->has_performance_degraded = performance_degraded != NULL;
if (performance_degraded == NULL)
performance_inhibited = variant_lookup_string (props, "PerformanceInhibited");
- else
- performance_profile_set_degraded (self);
active_profile = variant_lookup_string (props, "ActiveProfile");
last_button = NULL;
@@ -1649,6 +1648,9 @@ setup_power_profiles (CcPowerPanel *self)
self->power_profiles_prop_id = g_signal_connect_object (G_OBJECT (self->power_profiles_proxy), "g-properties-changed",
G_CALLBACK (power_profiles_properties_changed_cb), self, G_CONNECT_SWAPPED);
+
+ if (self->has_performance_degraded)
+ power_profile_update_info_boxes (self);
}
static void
--
2.32.0
From 173904b7eeea145c38065939a1dd8a408745f3c9 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 16 Jul 2021 10:07:28 +0200
Subject: [PATCH 16/33] power: Move variant_lookup_string() helper function
---
panels/power/cc-power-panel.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 1869be065..4633627c2 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -1343,6 +1343,18 @@ setup_power_saving (CcPowerPanel *self)
#endif
}
+static const char *
+variant_lookup_string (GVariant *dict,
+ const char *key)
+{
+ GVariant *variant;
+
+ variant = g_variant_lookup_value (dict, key, G_VARIANT_TYPE_STRING);
+ if (!variant)
+ return NULL;
+ return g_variant_get_string (variant, NULL);
+}
+
static void
performance_profile_set_active (CcPowerPanel *self,
const char *profile_str)
@@ -1427,18 +1439,6 @@ perf_profile_list_box_sort (GtkListBoxRow *row1,
return 0;
}
-static const char *
-variant_lookup_string (GVariant *dict,
- const char *key)
-{
- GVariant *variant;
-
- variant = g_variant_lookup_value (dict, key, G_VARIANT_TYPE_STRING);
- if (!variant)
- return NULL;
- return g_variant_get_string (variant, NULL);
-}
-
static void
power_profiles_properties_changed_cb (CcPowerPanel *self,
GVariant *changed_properties,
--
2.32.0
From f49c47787de81fa39f100f3903d2d886905cd4c7 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 16 Jul 2021 11:01:52 +0200
Subject: [PATCH 17/33] power: Show power profile info boxes for profile holds
Applications can request that power-profiles-daemon "hold" a particular
power profile for the duration of a task or event, such as launching a
taxing application, or saving power because of low battery.
Show those holds in the same type of info boxes we already use to show
"degraded" performance.
See https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/merge_requests/46
---
panels/power/cc-power-panel.c | 77 ++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 1 deletion(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 4633627c2..4f1989cdf 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -24,6 +24,7 @@
#include <libupower-glib/upower.h>
#include <glib/gi18n.h>
#include <gnome-settings-daemon/gsd-enums.h>
+#include <gio/gdesktopappinfo.h>
#include <handy.h>
#ifdef HAVE_NETWORK_MANAGER
@@ -1383,12 +1384,25 @@ static void
power_profile_update_info_boxes (CcPowerPanel *self)
{
g_autoptr(GVariant) degraded_variant = NULL;
+ g_autoptr(GVariant) holds_variant = NULL;
+ g_autoptr(GVariant) profile_variant = NULL;
+ guint i, num_children;
const char *degraded = NULL;
+ const char *profile;
CcPowerProfileInfoRow *row;
+ int next_insert = 0;
empty_listbox (self->power_profile_info_listbox);
gtk_widget_hide (GTK_WIDGET (self->power_profile_info_listbox));
+ profile_variant = g_dbus_proxy_get_cached_property (self->power_profiles_proxy, "ActiveProfile");
+ if (!profile_variant)
+ {
+ g_warning ("No 'ActiveProfile' property on power-profiles-daemon service");
+ return;
+ }
+ profile = g_variant_get_string (profile_variant, NULL);
+
degraded_variant = g_dbus_proxy_get_cached_property (self->power_profiles_proxy, "PerformanceDegraded");
if (degraded_variant)
degraded = g_variant_get_string (degraded_variant, NULL);
@@ -1408,6 +1422,66 @@ power_profile_update_info_boxes (CcPowerPanel *self)
row = cc_power_profile_info_row_new (text);
gtk_widget_show (GTK_WIDGET (row));
gtk_container_add (GTK_CONTAINER (self->power_profile_info_listbox), GTK_WIDGET (row));
+ if (g_str_equal (profile, "performance"))
+ next_insert = 1;
+ }
+
+ holds_variant = g_dbus_proxy_get_cached_property (self->power_profiles_proxy, "ActiveProfileHolds");
+ if (!holds_variant)
+ {
+ g_warning ("No 'ActiveProfileHolds' property on power-profiles-daemon service");
+ return;
+ }
+
+ num_children = g_variant_n_children (holds_variant);
+ for (i = 0; i < num_children; i++)
+ {
+ g_autoptr(GDesktopAppInfo) app_info = NULL;
+ g_autoptr(GVariant) hold_variant = NULL;
+ g_autofree char *text = NULL;
+ const char *app_id, *held_profile, *reason, *name;
+
+ hold_variant = g_variant_get_child_value (holds_variant, i);
+ if (!hold_variant || !g_variant_is_of_type (hold_variant, G_VARIANT_TYPE ("a{sv}")))
+ continue;
+
+ app_id = variant_lookup_string (hold_variant, "ApplicationId");
+ if (!app_id)
+ continue;
+ app_info = g_desktop_app_info_new (app_id);
+ name = app_info ? g_app_info_get_name (G_APP_INFO (app_info)) : app_id;
+ held_profile = variant_lookup_string (hold_variant, "Profile");
+ reason = variant_lookup_string (hold_variant, "Reason");
+ g_debug ("Adding info row for %s hold by %s: %s", held_profile, app_id, reason);
+
+ if (g_strcmp0 (held_profile, "power-saver") == 0 &&
+ g_strcmp0 (app_id, "org.gnome.SettingsDaemon.Power") == 0)
+ {
+ text = g_strdup (_("Low battery: power saver enabled. Previous mode will be restored when battery is sufficiently charged."));
+ }
+ else
+ {
+ switch (cc_power_profile_from_str (held_profile))
+ {
+ case CC_POWER_PROFILE_POWER_SAVER:
+ /* translators: "%s" is an application name */
+ text = g_strdup_printf (_("Power Saver mode activated by “%s”."), name);
+ break;
+ case CC_POWER_PROFILE_PERFORMANCE:
+ /* translators: "%s" is an application name */
+ text = g_strdup_printf (_("Performance mode activated by “%s”."), name);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ row = cc_power_profile_info_row_new (text);
+ gtk_widget_show (GTK_WIDGET (row));
+ if (g_strcmp0 (held_profile, profile) != 0)
+ gtk_list_box_insert (GTK_LIST_BOX (self->power_profile_info_listbox), GTK_WIDGET (row), -1);
+ else
+ gtk_list_box_insert (GTK_LIST_BOX (self->power_profile_info_listbox), GTK_WIDGET (row), next_insert);
}
}
@@ -1458,7 +1532,8 @@ power_profiles_properties_changed_cb (CcPowerPanel *self,
performance_profile_set_inhibited (self,
g_variant_get_string (value, NULL));
}
- else if (g_strcmp0 (key, "PerformanceDegraded") == 0)
+ else if (g_strcmp0 (key, "PerformanceDegraded") == 0 ||
+ g_strcmp0 (key, "ActiveProfileHolds") == 0)
{
power_profile_update_info_boxes (self);
}
--
2.32.0
From d7cabb849c425fd84e85a981bcd56a6df1d87868 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 16 Jul 2021 11:32:37 +0200
Subject: [PATCH 18/33] power: Tweak power profile info boxes horizontal
spacing
A bit too much whitespace around the info icon.
---
panels/power/cc-power-profile-info-row.ui | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/panels/power/cc-power-profile-info-row.ui b/panels/power/cc-power-profile-info-row.ui
index d9291ff16..bc49a24ac 100644
--- a/panels/power/cc-power-profile-info-row.ui
+++ b/panels/power/cc-power-profile-info-row.ui
@@ -8,16 +8,16 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
- <property name="margin-start">12</property>
- <property name="margin-end">12</property>
+ <property name="margin-start">8</property>
+ <property name="margin-end">8</property>
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
- <property name="spacing">12</property>
+ <property name="spacing">8</property>
<child>
<object class="GtkImage" id="icon_image">
<property name="visible">True</property>
<property name="margin-start">6</property>
- <property name="margin-end">18</property>
+ <property name="margin-end">6</property>
<property name="icon-name">info-symbolic</property>
<property name="icon-size">5</property>
<style>
--
2.32.0
From 941dfe6403ae0eb68aef76754691f56b07999635 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 16 Jul 2021 11:33:38 +0200
Subject: [PATCH 19/33] power: Reword lap mode info message
Reword the lap mode info message slightly as the performance mode might
not have been what the user requested, but the warning should stay until
cleared nonetheless.
---
panels/power/cc-power-panel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 4f1989cdf..740d52c64 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -1415,7 +1415,7 @@ power_profile_update_info_boxes (CcPowerPanel *self)
if (g_str_equal (degraded, "high-operating-temperature"))
text = _("Performance mode temporarily disabled due to high operating temperature.");
else if (g_str_equal (degraded, "lap-detected"))
- text = _("Lap detected: performance mode temporarily disabled. Move the device to a stable surface to restore.");
+ text = _("Lap detected: performance mode temporarily unavailable. Move the device to a stable surface to restore.");
else
text = _("Performance mode temporarily disabled.");
--
2.32.0
From 4dff29aab988021aab3f623899271b33240c0c86 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 21 Jul 2021 12:26:39 +0200
Subject: [PATCH 20/33] power: Fix D-Bus proxy leak
---
panels/power/cc-power-panel.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 740d52c64..21183f39c 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -151,6 +151,7 @@ cc_power_panel_dispose (GObject *object)
g_clear_object (&self->bt_rfkill);
g_clear_object (&self->bt_properties);
g_clear_object (&self->iio_proxy);
+ g_clear_object (&self->power_profiles_proxy);
#ifdef HAVE_NETWORK_MANAGER
g_clear_object (&self->nm_client);
#endif
--
2.32.0
From 99140ea853c6c6ce0e4c29b3edb28a07e7aa5fb6 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 21 Jul 2021 12:29:55 +0200
Subject: [PATCH 21/33] power: Add UI for "power-saver profile when battery is
low"
See https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/merge_requests/247
---
panels/power/cc-power-panel.c | 23 +++++++++++++++++++++++
panels/power/cc-power-panel.ui | 15 +++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 21183f39c..3e1b323f4 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -92,6 +92,8 @@ struct _CcPowerPanel
GtkListBox *power_profile_listbox;
GtkListBox *power_profile_info_listbox;
HdyPreferencesGroup *power_profile_section;
+ HdyActionRow *power_saver_low_battery_row;
+ GtkSwitch *power_saver_low_battery_switch;
GtkSizeGroup *row_sizegroup;
GtkComboBox *suspend_on_battery_delay_combo;
GtkLabel *suspend_on_battery_delay_label;
@@ -257,6 +259,18 @@ empty_listbox (GtkListBox *listbox)
gtk_container_remove (GTK_CONTAINER (listbox), l->data);
}
+static void
+update_power_saver_low_battery_row_visibility (CcPowerPanel *self)
+{
+ g_autoptr(UpDevice) composite = NULL;
+ UpDeviceKind kind;
+
+ composite = up_client_get_display_device (self->up_client);
+ 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);
+}
+
static void
up_client_changed (CcPowerPanel *self)
{
@@ -427,6 +441,8 @@ up_client_changed (CcPowerPanel *self)
add_device (self, device);
}
}
+
+ update_power_saver_low_battery_row_visibility (self);
}
static void
@@ -1727,6 +1743,8 @@ setup_power_profiles (CcPowerPanel *self)
if (self->has_performance_degraded)
power_profile_update_info_boxes (self);
+
+ update_power_saver_low_battery_row_visibility (self);
}
static void
@@ -1839,6 +1857,8 @@ 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_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, 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);
@@ -1895,6 +1915,9 @@ cc_power_panel_init (CcPowerPanel *self)
setup_power_profiles (self);
setup_power_saving (self);
+ g_settings_bind (self->gsd_settings, "power-saver-profile-on-low-battery",
+ self->power_saver_low_battery_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
setup_general_section (self);
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index d8283c556..bc58e7462 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -206,6 +206,21 @@
<signal name="notify::selected-index" handler="blank_screen_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
</child>
+ <child>
+ <object class="HdyActionRow" id="power_saver_low_battery_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">Automatic Power Saver</property>
+ <property name="subtitle" translatable="yes">Enables power saver mode when battery is low.</property>
+ <property name="use_underline">True</property>
+ <property name="activatable_widget">power_saver_low_battery_switch</property>
+ <child>
+ <object class="GtkSwitch" id="power_saver_low_battery_switch">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="HdyActionRow" id="automatic_suspend_row">
<property name="visible">False</property>
--
2.32.0
From 301045260461f4ab5f6e41ebadbd94935411edb2 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Tue, 27 Jul 2021 15:49:26 +0200
Subject: [PATCH 22/33] power: Fix logic when showing profile holds
A logic error meant that the power profiles info boxes container
would not be shown if there wasn't a "degraded" performance as well.
Spotted by Allan Day
---
panels/power/cc-power-panel.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 3e1b323f4..a5c66aa9d 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -1465,6 +1465,9 @@ power_profile_update_info_boxes (CcPowerPanel *self)
app_id = variant_lookup_string (hold_variant, "ApplicationId");
if (!app_id)
continue;
+
+ gtk_widget_show (GTK_WIDGET (self->power_profile_info_listbox));
+
app_info = g_desktop_app_info_new (app_id);
name = app_info ? g_app_info_get_name (G_APP_INFO (app_info)) : app_id;
held_profile = variant_lookup_string (hold_variant, "Profile");
--
2.32.0
From ac0afc4486403ee61bd5bcc51b22cefb5bba9e8c Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 22 Jul 2021 18:29:43 +0200
Subject: [PATCH 23/33] power: Remove Wi-Fi and WWAN "power saving" toggles
It's pretty clear from their experiences on smartphones that our users
know that Wi-Fi and other wireless technologies use enough battery that
turning them off is a power saving move.
The switches and text were also pretty confusing as we would be turning
"off" the devices to turn "on" the power saving.
---
panels/power/cc-power-panel.c | 207 ---------------------------------
panels/power/cc-power-panel.ui | 34 ------
panels/power/meson.build | 4 -
3 files changed, 245 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index a5c66aa9d..97d787b95 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -27,10 +27,6 @@
#include <gio/gdesktopappinfo.h>
#include <handy.h>
-#ifdef HAVE_NETWORK_MANAGER
-#include <NetworkManager.h>
-#endif
-
#include "shell/cc-object-storage.h"
#include "list-box-helper.h"
#include "cc-battery-row.h"
@@ -86,8 +82,6 @@ struct _CcPowerPanel
GtkListBoxRow *kbd_brightness_row;
CcBrightnessScale *kbd_brightness_scale;
GtkSizeGroup *level_sizegroup;
- GtkListBoxRow *mobile_row;
- GtkSwitch *mobile_switch;
HdyComboRow *power_button_row;
GtkListBox *power_profile_listbox;
GtkListBox *power_profile_info_listbox;
@@ -102,8 +96,6 @@ struct _CcPowerPanel
GtkComboBox *suspend_on_ac_delay_combo;
GtkLabel *suspend_on_ac_label;
GtkSwitch *suspend_on_ac_switch;
- GtkListBoxRow *wifi_row;
- GtkSwitch *wifi_switch;
GSettings *gsd_settings;
GSettings *session_settings;
@@ -124,10 +116,6 @@ struct _CcPowerPanel
CcPowerProfileRow *power_profiles_row[NUM_CC_POWER_PROFILES];
gboolean power_profiles_in_update;
gboolean has_performance_degraded;
-
-#ifdef HAVE_NETWORK_MANAGER
- NMClient *nm_client;
-#endif
};
CC_PANEL_REGISTER (CcPowerPanel, cc_power_panel)
@@ -154,9 +142,6 @@ cc_power_panel_dispose (GObject *object)
g_clear_object (&self->bt_properties);
g_clear_object (&self->iio_proxy);
g_clear_object (&self->power_profiles_proxy);
-#ifdef HAVE_NETWORK_MANAGER
- g_clear_object (&self->nm_client);
-#endif
if (self->iio_proxy_watch_id != 0)
g_bus_unwatch_name (self->iio_proxy_watch_id);
self->iio_proxy_watch_id = 0;
@@ -729,184 +714,6 @@ bt_powered_state_changed (CcPowerPanel *self)
g_signal_handlers_unblock_by_func (self->bt_switch, bt_switch_changed_cb, self);
}
-#ifdef HAVE_NETWORK_MANAGER
-static gboolean
-has_wifi_devices (NMClient *client)
-{
- const GPtrArray *devices;
- NMDevice *device;
- gint i;
-
- if (!nm_client_get_nm_running (client))
- return FALSE;
-
- devices = nm_client_get_devices (client);
- if (devices == NULL)
- return FALSE;
-
- for (i = 0; i < devices->len; i++)
- {
- device = g_ptr_array_index (devices, i);
- switch (nm_device_get_device_type (device))
- {
- case NM_DEVICE_TYPE_WIFI:
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static void
-wifi_switch_changed_cb (CcPowerPanel *self)
-{
- gboolean enabled;
-
- enabled = gtk_switch_get_active (self->wifi_switch);
- g_debug ("Setting wifi %s", enabled ? "enabled" : "disabled");
- nm_client_wireless_set_enabled (self->nm_client, enabled);
-}
-
-static gboolean
-has_mobile_devices (NMClient *client)
-{
- const GPtrArray *devices;
- NMDevice *device;
- gint i;
-
- if (!nm_client_get_nm_running (client))
- return FALSE;
-
- devices = nm_client_get_devices (client);
- if (devices == NULL)
- return FALSE;
-
- for (i = 0; i < devices->len; i++)
- {
- device = g_ptr_array_index (devices, i);
- switch (nm_device_get_device_type (device))
- {
- case NM_DEVICE_TYPE_MODEM:
- return TRUE;
- default:
- break;
- }
- }
-
- return FALSE;
-}
-
-static void
-mobile_switch_changed_cb (CcPowerPanel *self)
-{
- gboolean enabled;
-
- enabled = gtk_switch_get_active (self->mobile_switch);
- g_debug ("Setting wwan %s", enabled ? "enabled" : "disabled");
- nm_client_wwan_set_enabled (self->nm_client, enabled);
-}
-
-static void
-nm_client_state_changed (CcPowerPanel *self)
-{
- gboolean visible;
- gboolean active;
- gboolean sensitive;
-
- visible = has_wifi_devices (self->nm_client);
- active = nm_client_networking_get_enabled (self->nm_client) &&
- nm_client_wireless_get_enabled (self->nm_client) &&
- nm_client_wireless_hardware_get_enabled (self->nm_client);
- sensitive = nm_client_networking_get_enabled (self->nm_client) &&
- nm_client_wireless_hardware_get_enabled (self->nm_client);
-
- g_debug ("wifi state changed to %s", active ? "enabled" : "disabled");
-
- g_signal_handlers_block_by_func (self->wifi_switch, wifi_switch_changed_cb, self);
- gtk_switch_set_active (self->wifi_switch, active);
- gtk_widget_set_sensitive (GTK_WIDGET (self->wifi_switch), sensitive);
- gtk_widget_set_visible (GTK_WIDGET (self->wifi_row), visible);
- g_signal_handlers_unblock_by_func (self->wifi_switch, wifi_switch_changed_cb, self);
-
- visible = has_mobile_devices (self->nm_client);
-
- /* Set the switch active, if wwan is enabled. */
- active = nm_client_networking_get_enabled (self->nm_client) &&
- (nm_client_wwan_get_enabled (self->nm_client) &&
- nm_client_wwan_hardware_get_enabled (self->nm_client));
- sensitive = nm_client_networking_get_enabled (self->nm_client) &&
- nm_client_wwan_hardware_get_enabled (self->nm_client);
-
- g_debug ("mobile state changed to %s", active ? "enabled" : "disabled");
-
- g_signal_handlers_block_by_func (self->mobile_switch, mobile_switch_changed_cb, self);
- gtk_switch_set_active (self->mobile_switch, active);
- gtk_widget_set_sensitive (GTK_WIDGET (self->mobile_switch), sensitive);
- gtk_widget_set_visible (GTK_WIDGET (self->mobile_row), visible);
- g_signal_handlers_unblock_by_func (self->mobile_switch, mobile_switch_changed_cb, self);
-}
-
-static void
-nm_device_changed (CcPowerPanel *self)
-{
- gtk_widget_set_visible (GTK_WIDGET (self->wifi_row), has_wifi_devices (self->nm_client));
- gtk_widget_set_visible (GTK_WIDGET (self->mobile_row), has_mobile_devices (self->nm_client));
-}
-
-static void
-setup_nm_client (CcPowerPanel *self,
- NMClient *client)
-{
- self->nm_client = client;
-
- g_signal_connect_object (self->nm_client, "notify",
- G_CALLBACK (nm_client_state_changed), self, G_CONNECT_SWAPPED);
- g_signal_connect_object (self->nm_client, "device-added",
- G_CALLBACK (nm_device_changed), self, G_CONNECT_SWAPPED);
- g_signal_connect_object (self->nm_client, "device-removed",
- G_CALLBACK (nm_device_changed), self, G_CONNECT_SWAPPED);
-
- nm_client_state_changed (self);
- nm_device_changed (self);
-}
-
-static void
-nm_client_ready_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- CcPowerPanel *self;
- NMClient *client;
- g_autoptr(GError) error = NULL;
-
- client = nm_client_new_finish (res, &error);
- if (!client)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- {
- g_warning ("Failed to create NetworkManager client: %s",
- error->message);
-
- self = user_data;
- gtk_widget_set_sensitive (GTK_WIDGET (self->wifi_row), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (self->mobile_row), FALSE);
- }
- return;
- }
-
- self = user_data;
-
- /* Setup the client */
- setup_nm_client (self, client);
-
- /* Store the object in the cache too */
- cc_object_storage_add_object (CC_OBJECT_NMCLIENT, client);
-}
-
-#endif
-
static gboolean
keynav_failed_cb (CcPowerPanel *self, GtkDirectionType direction, GtkWidget *list)
{
@@ -1326,14 +1133,6 @@ setup_power_saving (CcPowerPanel *self)
update_automatic_suspend_label (self);
}
-#ifdef HAVE_NETWORK_MANAGER
- /* Create and store a NMClient instance if it doesn't exist yet */
- if (cc_object_storage_has_object (CC_OBJECT_NMCLIENT))
- setup_nm_client (self, cc_object_storage_get_object (CC_OBJECT_NMCLIENT));
- else
- nm_client_new_async (cc_panel_get_cancellable (CC_PANEL (self)), nm_client_ready_cb, self);
-#endif
-
#ifdef HAVE_BLUETOOTH
self->bt_rfkill = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
@@ -1854,8 +1653,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, kbd_brightness_scale);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, level_sizegroup);
- 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_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_info_listbox);
@@ -1870,8 +1667,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_ac_delay_combo);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_ac_label);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, suspend_on_ac_switch);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, wifi_row);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, wifi_switch);
gtk_widget_class_bind_template_callback (widget_class, als_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, automatic_suspend_label_mnemonic_activate_cb);
@@ -1880,11 +1675,9 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, has_kbd_brightness_cb);
gtk_widget_class_bind_template_callback (widget_class, blank_screen_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
- gtk_widget_class_bind_template_callback (widget_class, mobile_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, power_button_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, power_profiles_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, automatic_suspend_row_activated_cb);
- gtk_widget_class_bind_template_callback (widget_class, wifi_switch_changed_cb);
}
static void
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index bc58e7462..0795f1b70 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -237,38 +237,6 @@
</child>
</object>
</child>
- <child>
- <object class="HdyActionRow" id="wifi_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">_Wi-Fi</property>
- <property name="subtitle" translatable="yes">Wi-Fi can be turned off to save power.</property>
- <property name="use_underline">True</property>
- <property name="activatable_widget">wifi_switch</property>
- <child>
- <object class="GtkSwitch" id="wifi_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="wifi_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="HdyActionRow" id="mobile_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">_Mobile Broadband</property>
- <property name="subtitle" translatable="yes">Mobile broadband (LTE, 4G, 3G, etc.) can be turned off to save power.</property>
- <property name="use_underline">True</property>
- <property name="activatable_widget">mobile_switch</property>
- <child>
- <object class="GtkSwitch" id="mobile_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="mobile_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="HdyActionRow" id="bt_row">
<property name="visible">False</property>
@@ -337,8 +305,6 @@
<widget name="dim_screen_row"/>
<widget name="blank_screen_row"/>
<widget name="automatic_suspend_row"/>
- <widget name="wifi_row"/>
- <widget name="mobile_row"/>
<widget name="bt_row"/>
<widget name="power_button_row"/>
<widget name="battery_percentage_row"/>
diff --git a/panels/power/meson.build b/panels/power/meson.build
index af04b98ed..b1380f4e6 100644
--- a/panels/power/meson.build
+++ b/panels/power/meson.build
@@ -47,10 +47,6 @@ deps = common_deps + [
upower_glib_dep
]
-if host_is_linux
- deps += network_manager_deps
-endif
-
if host_is_linux_not_s390
deps += gnome_bluetooth_dep
endif
--
2.32.0
From 55ab3debcc8d39a9f301dcd41a441adc568ed520 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 22 Jul 2021 18:33:41 +0200
Subject: [PATCH 24/33] power: Remove Bluetooth power switch button
See previous commit.
---
panels/power/cc-power-panel.c | 91 ----------------------------------
panels/power/cc-power-panel.ui | 17 -------
panels/power/meson.build | 4 --
3 files changed, 112 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 97d787b95..1e0a572b3 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -72,8 +72,6 @@ struct _CcPowerPanel
HdyComboRow *blank_screen_row;
GtkListBoxRow *brightness_row;
CcBrightnessScale *brightness_scale;
- GtkListBoxRow *bt_row;
- GtkSwitch *bt_switch;
GtkListBox *device_listbox;
HdyPreferencesGroup *device_section;
GtkListBoxRow *dim_screen_row;
@@ -105,9 +103,6 @@ struct _CcPowerPanel
gboolean has_batteries;
char *chassis_type;
- GDBusProxy *bt_rfkill;
- GDBusProxy *bt_properties;
-
GDBusProxy *iio_proxy;
guint iio_proxy_watch_id;
@@ -138,8 +133,6 @@ cc_power_panel_dispose (GObject *object)
g_clear_pointer ((GtkWidget **) &self->automatic_suspend_dialog, gtk_widget_destroy);
g_clear_pointer (&self->devices, g_ptr_array_unref);
g_clear_object (&self->up_client);
- g_clear_object (&self->bt_rfkill);
- g_clear_object (&self->bt_properties);
g_clear_object (&self->iio_proxy);
g_clear_object (&self->power_profiles_proxy);
if (self->iio_proxy_watch_id != 0)
@@ -659,61 +652,6 @@ set_ac_battery_ui_mode (CcPowerPanel *self)
}
}
-static void
-bt_set_powered (CcPowerPanel *self,
- gboolean powered)
-{
- g_dbus_proxy_call (self->bt_properties,
- "Set",
- g_variant_new_parsed ("('org.gnome.SettingsDaemon.Rfkill', 'BluetoothAirplaneMode', %v)",
- g_variant_new_boolean (!powered)),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- cc_panel_get_cancellable (CC_PANEL (self)),
- NULL, NULL);
-}
-
-static void
-bt_switch_changed_cb (CcPowerPanel *self)
-{
- gboolean powered;
-
- powered = gtk_switch_get_active (self->bt_switch);
-
- g_debug ("Setting bt power %s", powered ? "on" : "off");
-
- bt_set_powered (self, powered);
-}
-
-static void
-bt_powered_state_changed (CcPowerPanel *self)
-{
- gboolean powered, has_airplane_mode;
- g_autoptr(GVariant) v1 = NULL;
- g_autoptr(GVariant) v2 = NULL;
-
- v1 = g_dbus_proxy_get_cached_property (self->bt_rfkill, "BluetoothHasAirplaneMode");
- has_airplane_mode = g_variant_get_boolean (v1);
-
- if (!has_airplane_mode)
- {
- g_debug ("BluetoothHasAirplaneMode is false, hiding Bluetooth power row");
- gtk_widget_hide (GTK_WIDGET (self->bt_row));
- return;
- }
-
- v2 = g_dbus_proxy_get_cached_property (self->bt_rfkill, "BluetoothAirplaneMode");
- powered = !g_variant_get_boolean (v2);
-
- g_debug ("bt powered state changed to %s", powered ? "on" : "off");
-
- gtk_widget_show (GTK_WIDGET (self->bt_row));
-
- g_signal_handlers_block_by_func (self->bt_switch, bt_switch_changed_cb, self);
- gtk_switch_set_active (self->bt_switch, powered);
- g_signal_handlers_unblock_by_func (self->bt_switch, bt_switch_changed_cb, self);
-}
-
static gboolean
keynav_failed_cb (CcPowerPanel *self, GtkDirectionType direction, GtkWidget *list)
{
@@ -1132,32 +1070,6 @@ setup_power_saving (CcPowerPanel *self)
set_ac_battery_ui_mode (self);
update_automatic_suspend_label (self);
}
-
-#ifdef HAVE_BLUETOOTH
- self->bt_rfkill = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.SettingsDaemon.Rfkill",
- "/org/gnome/SettingsDaemon/Rfkill",
- "org.gnome.SettingsDaemon.Rfkill",
- NULL,
- NULL);
-
- if (self->bt_rfkill)
- {
- self->bt_properties = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.SettingsDaemon.Rfkill",
- "/org/gnome/SettingsDaemon/Rfkill",
- "org.freedesktop.DBus.Properties",
- NULL,
- NULL);
- }
-
- g_signal_connect_object (self->bt_rfkill, "g-properties-changed",
- G_CALLBACK (bt_powered_state_changed), self, G_CONNECT_SWAPPED);
-
- bt_powered_state_changed (self);
-#endif
}
static const char *
@@ -1643,8 +1555,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, blank_screen_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, brightness_row);
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_listbox);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, device_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, dim_screen_row);
@@ -1670,7 +1580,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, als_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, automatic_suspend_label_mnemonic_activate_cb);
- gtk_widget_class_bind_template_callback (widget_class, bt_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, has_brightness_cb);
gtk_widget_class_bind_template_callback (widget_class, has_kbd_brightness_cb);
gtk_widget_class_bind_template_callback (widget_class, blank_screen_row_changed_cb);
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index 0795f1b70..b5e12d2f5 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -237,22 +237,6 @@
</child>
</object>
</child>
- <child>
- <object class="HdyActionRow" id="bt_row">
- <property name="visible">False</property>
- <property name="title" translatable="yes">_Bluetooth</property>
- <property name="subtitle" translatable="yes">Bluetooth can be turned off to save power.</property>
- <property name="use_underline">True</property>
- <property name="activatable_widget">bt_switch</property>
- <child>
- <object class="GtkSwitch" id="bt_switch">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <signal name="notify::active" handler="bt_switch_changed_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
<child>
@@ -305,7 +289,6 @@
<widget name="dim_screen_row"/>
<widget name="blank_screen_row"/>
<widget name="automatic_suspend_row"/>
- <widget name="bt_row"/>
<widget name="power_button_row"/>
<widget name="battery_percentage_row"/>
</widgets>
diff --git a/panels/power/meson.build b/panels/power/meson.build
index b1380f4e6..9066d24bd 100644
--- a/panels/power/meson.build
+++ b/panels/power/meson.build
@@ -47,10 +47,6 @@ deps = common_deps + [
upower_glib_dep
]
-if host_is_linux_not_s390
- deps += gnome_bluetooth_dep
-endif
-
panels_libs += static_library(
cappletname,
sources: sources,
--
2.32.0
From d6e3755dbfd15f2aaf2a1850e63e7d46f6ae37c7 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 23 Jul 2021 16:09:54 +0200
Subject: [PATCH 25/33] power: Tweak labels in "Power Saving Options" section
To match the latest mockups.
The lack of subtitles for most of the items in that section made the
section look pretty bizarre.
---
panels/power/cc-power-panel.ui | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index b5e12d2f5..29503b7e4 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -139,7 +139,7 @@
<child>
<object class="HdyPreferencesGroup" id="power_saving_section">
<property name="visible">True</property>
- <property name="title" translatable="yes">Power Saving</property>
+ <property name="title" translatable="yes">Power Saving Options</property>
<child>
<object class="HdyActionRow" id="brightness_row">
<property name="visible">True</property>
@@ -188,7 +188,8 @@
<child>
<object class="HdyActionRow" id="dim_screen_row">
<property name="visible">True</property>
- <property name="title" translatable="yes">Dim Screen When Inactive</property>
+ <property name="title" translatable="yes">Dim Screen</property>
+ <property name="subtitle" translatable="yes">Reduces the screen brightness when the computer is inactive.</property>
<property name="activatable_widget">dim_screen_switch</property>
<child>
<object class="GtkSwitch" id="dim_screen_switch">
@@ -201,7 +202,8 @@
<child>
<object class="HdyComboRow" id="blank_screen_row">
<property name="visible">True</property>
- <property name="title" translatable="yes">_Blank Screen</property>
+ <property name="title" translatable="yes">Screen _Blank</property>
+ <property name="subtitle" translatable="yes">Turns the screen off after a period of inactivity.</property>
<property name="use_underline">True</property>
<signal name="notify::selected-index" handler="blank_screen_row_changed_cb" object="CcPowerPanel" swapped="yes"/>
</object>
@@ -225,6 +227,7 @@
<object class="HdyActionRow" id="automatic_suspend_row">
<property name="visible">False</property>
<property name="title" translatable="yes">_Automatic Suspend</property>
+ <property name="subtitle" translatable="yes">Pauses the computer after a period of inactivity.</property>
<property name="use_underline">True</property>
<property name="activatable">True</property>
<signal name="activated" handler="automatic_suspend_row_activated_cb" swapped="yes"/>
--
2.32.0
From e9e1fdaacc9941129beca7c15adc8b89789fcb50 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Mon, 26 Jul 2021 11:32:23 +0200
Subject: [PATCH 26/33] power: Remove Brightness scales
From https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/1020#note_1211728
"
They are out of place - fine-grained control over brightness isn't what the
power settings are for. As a result, they confuse the settings overall.
In both cases we have alternative controls, through keyboard hot keys or
through the shell's screen brightness slider.
"
---
panels/power/cc-power-panel.c | 87 +++++++++++++++++++++-------------
panels/power/cc-power-panel.ui | 36 --------------
2 files changed, 54 insertions(+), 69 deletions(-)
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 1e0a572b3..04987ff98 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -30,7 +30,6 @@
#include "shell/cc-object-storage.h"
#include "list-box-helper.h"
#include "cc-battery-row.h"
-#include "cc-brightness-scale.h"
#include "cc-power-profile-row.h"
#include "cc-power-profile-info-row.h"
#include "cc-power-panel.h"
@@ -70,15 +69,11 @@ struct _CcPowerPanel
GtkSizeGroup *battery_row_sizegroup;
HdyPreferencesGroup *battery_section;
HdyComboRow *blank_screen_row;
- GtkListBoxRow *brightness_row;
- CcBrightnessScale *brightness_scale;
GtkListBox *device_listbox;
HdyPreferencesGroup *device_section;
GtkListBoxRow *dim_screen_row;
GtkSwitch *dim_screen_switch;
HdyPreferencesGroup *general_section;
- GtkListBoxRow *kbd_brightness_row;
- CcBrightnessScale *kbd_brightness_scale;
GtkSizeGroup *level_sizegroup;
HdyComboRow *power_button_row;
GtkListBox *power_profile_listbox;
@@ -105,6 +100,7 @@ struct _CcPowerPanel
GDBusProxy *iio_proxy;
guint iio_proxy_watch_id;
+ gboolean has_brightness;
GDBusProxy *power_profiles_proxy;
guint power_profiles_prop_id;
@@ -469,11 +465,8 @@ static void
als_enabled_state_changed (CcPowerPanel *self)
{
gboolean enabled;
- gboolean has_brightness = FALSE;
gboolean visible = FALSE;
- has_brightness = cc_brightness_scale_get_has_brightness (self->brightness_scale);
-
if (self->iio_proxy != NULL)
{
g_autoptr(GVariant) v = g_dbus_proxy_get_cached_property (self->iio_proxy, "HasAmbientLight");
@@ -485,7 +478,7 @@ als_enabled_state_changed (CcPowerPanel *self)
g_debug ("ALS enabled: %s", enabled ? "on" : "off");
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 && has_brightness);
+ gtk_widget_set_visible (GTK_WIDGET (self->als_row), visible && self->has_brightness);
g_signal_handlers_unblock_by_func (self->als_switch, als_switch_changed_cb, self);
}
@@ -933,29 +926,34 @@ can_suspend_or_hibernate (CcPowerPanel *self,
}
static void
-has_brightness_cb (CcPowerPanel *self)
+got_brightness_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- gboolean has_brightness;
+ g_autoptr(GVariant) result = NULL;
+ g_autoptr(GError) error = NULL;
+ gint32 brightness = -1.0;
+ CcPowerPanel *self;
- has_brightness = cc_brightness_scale_get_has_brightness (self->brightness_scale);
+ result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object), res, &error);
+ if (!result)
+ {
+ g_debug ("Failed to get Brightness property: %s", error->message);
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ return;
+ }
+ else
+ {
+ g_autoptr(GVariant) v = NULL;
+ g_variant_get (result, "(v)", &v);
+ brightness = v ? g_variant_get_int32 (v) : -1.0;
+ }
- gtk_widget_set_visible (GTK_WIDGET (self->brightness_row), has_brightness);
- gtk_widget_set_visible (GTK_WIDGET (self->dim_screen_row), has_brightness);
+ self = user_data;
+ self->has_brightness = brightness >= 0.0;
+ gtk_widget_set_visible (GTK_WIDGET (self->dim_screen_row), self->has_brightness);
als_enabled_state_changed (self);
-
-}
-
-static void
-has_kbd_brightness_cb (CcPowerPanel *self,
- GParamSpec *pspec,
- GObject *object)
-{
- gboolean has_brightness;
-
- has_brightness = cc_brightness_scale_get_has_brightness (self->kbd_brightness_scale);
-
- gtk_widget_set_visible (GTK_WIDGET (self->kbd_brightness_row), has_brightness);
}
static void
@@ -992,6 +990,8 @@ populate_blank_screen_row (HdyComboRow *combo_row)
static void
setup_power_saving (CcPowerPanel *self)
{
+ g_autoptr(GDBusConnection) connection = NULL;
+ g_autoptr(GError) error = NULL;
int value;
/* ambient light sensor */
@@ -1005,6 +1005,33 @@ setup_power_saving (CcPowerPanel *self)
g_signal_connect_object (self->gsd_settings, "changed",
G_CALLBACK (als_enabled_setting_changed), self, G_CONNECT_SWAPPED);
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
+ cc_panel_get_cancellable (CC_PANEL (self)),
+ &error);
+ if (connection)
+ {
+ g_dbus_connection_call (connection,
+ "org.gnome.SettingsDaemon.Power",
+ "/org/gnome/SettingsDaemon/Power",
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ g_variant_new ("(ss)",
+ "org.gnome.SettingsDaemon.Power.Screen",
+ "Brightness"),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cc_panel_get_cancellable (CC_PANEL (self)),
+ got_brightness_cb,
+ self);
+ }
+ else
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("session bus not available: %s", error->message);
+ }
+
+
g_settings_bind (self->gsd_settings, "idle-dim",
self->dim_screen_switch, "active",
G_SETTINGS_BIND_DEFAULT);
@@ -1553,15 +1580,11 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_row_sizegroup);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, battery_section);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, blank_screen_row);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, brightness_row);
- gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, brightness_scale);
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_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);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, level_sizegroup);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_button_row);
gtk_widget_class_bind_template_child (widget_class, CcPowerPanel, power_profile_listbox);
@@ -1580,8 +1603,6 @@ cc_power_panel_class_init (CcPowerPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, als_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, automatic_suspend_label_mnemonic_activate_cb);
- gtk_widget_class_bind_template_callback (widget_class, has_brightness_cb);
- gtk_widget_class_bind_template_callback (widget_class, has_kbd_brightness_cb);
gtk_widget_class_bind_template_callback (widget_class, blank_screen_row_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
gtk_widget_class_bind_template_callback (widget_class, power_button_row_changed_cb);
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index 29503b7e4..a8fafba21 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -140,22 +140,6 @@
<object class="HdyPreferencesGroup" id="power_saving_section">
<property name="visible">True</property>
<property name="title" translatable="yes">Power Saving Options</property>
- <child>
- <object class="HdyActionRow" id="brightness_row">
- <property name="visible">True</property>
- <property name="title" translatable="yes">_Screen Brightness</property>
- <property name="use_underline">True</property>
- <child>
- <object class="CcBrightnessScale" id="brightness_scale">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <property name="device">screen</property>
- <signal name="notify::has-brightness" handler="has_brightness_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="HdyActionRow" id="als_row">
<property name="visible">True</property>
@@ -169,22 +153,6 @@
</child>
</object>
</child>
- <child>
- <object class="HdyActionRow" id="kbd_brightness_row">
- <property name="visible">True</property>
- <property name="title" translatable="yes">_Keyboard Brightness</property>
- <property name="use_underline">True</property>
- <child>
- <object class="CcBrightnessScale" id="kbd_brightness_scale">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="expand">True</property>
- <property name="device">kbd</property>
- <signal name="notify::has-brightness" handler="has_kbd_brightness_cb" object="CcPowerPanel" swapped="yes"/>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="HdyActionRow" id="dim_screen_row">
<property name="visible">True</property>
@@ -279,16 +247,12 @@
<object class="GtkSizeGroup" id="level_sizegroup">
<property name="mode">horizontal</property>
<widgets>
- <widget name="brightness_scale"/>
- <widget name="kbd_brightness_scale"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="row_sizegroup">
<property name="mode">vertical</property>
<widgets>
- <widget name="brightness_row"/>
<widget name="als_row"/>
- <widget name="kbd_brightness_row"/>
<widget name="dim_screen_row"/>
<widget name="blank_screen_row"/>
<widget name="automatic_suspend_row"/>
--
2.32.0
From 3167196af8133997ead275a1b0c9c3ddffe0f4ea Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Mon, 26 Jul 2021 11:34:41 +0200
Subject: [PATCH 27/33] power: Remove unused CcBrightnessScale
---
panels/power/cc-brightness-scale.c | 281 -----------------------------
panels/power/cc-brightness-scale.h | 38 ----
panels/power/meson.build | 5 -
3 files changed, 324 deletions(-)
delete mode 100644 panels/power/cc-brightness-scale.c
delete mode 100644 panels/power/cc-brightness-scale.h
diff --git a/panels/power/cc-brightness-scale.c b/panels/power/cc-brightness-scale.c
deleted file mode 100644
index 2df1ab5ed..000000000
--- a/panels/power/cc-brightness-scale.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/* cc-brightness-scale.c
- *
- * Copyright (C) 2010 Red Hat, Inc
- * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
- * Copyright (C) 2010,2015 Richard Hughes <richard@hughsie.com>
- * Copyright (C) 2020 System76, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-#include "cc-brightness-scale.h"
-#include "shell/cc-object-storage.h"
-
-struct _CcBrightnessScale {
- GtkScale parent_instance;
-
- GCancellable *cancellable;
- BrightnessDevice device;
- gboolean has_brightness;
- GDBusProxy *proxy;
- gboolean setting_brightness;
-};
-
-enum
-{
- PROP_0,
- PROP_HAS_BRIGHTNESS,
- PROP_DEVICE,
-};
-
-G_DEFINE_TYPE (CcBrightnessScale, cc_brightness_scale, GTK_TYPE_SCALE)
-
-static void
-set_brightness_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- g_autoptr(GError) error = NULL;
- g_autoptr(GVariant) result = NULL;
- GDBusProxy *proxy = G_DBUS_PROXY (source_object);
-
- result = g_dbus_proxy_call_finish (proxy, res, &error);
- if (result == NULL)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_printerr ("Error setting brightness: %s\n", error->message);
- return;
- }
-
- CcBrightnessScale *self = CC_BRIGHTNESS_SCALE (user_data);
-
- /* not setting, so pay attention to changed signals */
- self->setting_brightness = FALSE;
-}
-
-static void
-brightness_slider_value_changed_cb (CcBrightnessScale *self, GtkRange *range)
-{
- guint percentage;
- g_autoptr(GVariant) variant = NULL;
-
- percentage = (guint) gtk_range_get_value (range);
-
- /* do not loop */
- if (self->setting_brightness)
- return;
-
- self->setting_brightness = TRUE;
-
- if (self->device == BRIGHTNESS_DEVICE_KBD)
- variant = g_variant_new_parsed ("('org.gnome.SettingsDaemon.Power.Keyboard',"
- "'Brightness', %v)",
- g_variant_new_int32 (percentage));
- else
- variant = g_variant_new_parsed ("('org.gnome.SettingsDaemon.Power.Screen',"
- "'Brightness', %v)",
- g_variant_new_int32 (percentage));
-
- /* push this to g-s-d */
- g_dbus_proxy_call (self->proxy,
- "org.freedesktop.DBus.Properties.Set",
- g_variant_ref_sink (variant),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- self->cancellable,
- set_brightness_cb,
- self);
-}
-
-static void
-sync_brightness (CcBrightnessScale *self)
-{
- g_autoptr(GVariant) result = NULL;
- gint brightness;
- GtkRange *range;
-
- result = g_dbus_proxy_get_cached_property (self->proxy, "Brightness");
-
- if (result)
- {
- /* set the slider */
- brightness = g_variant_get_int32 (result);
- self->has_brightness = brightness >= 0.0;
- }
- else
- {
- self->has_brightness = FALSE;
- }
-
- g_object_notify (G_OBJECT (self), "has-brightness");
-
- if (self->has_brightness)
- {
- range = GTK_RANGE (self);
- self->setting_brightness = TRUE;
- gtk_range_set_value (range, brightness);
- self->setting_brightness = FALSE;
- }
-}
-
-static void
-got_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
- g_autoptr(GError) error = NULL;
- CcBrightnessScale *self;
- GDBusProxy *proxy;
-
- proxy = cc_object_storage_create_dbus_proxy_finish (res, &error);
- if (proxy == NULL)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_printerr ("Error creating proxy: %s\n", error->message);
- return;
- }
-
- self = CC_BRIGHTNESS_SCALE (user_data);
- self->proxy = proxy;
-
- g_signal_connect_object (proxy, "g-properties-changed",
- G_CALLBACK (sync_brightness), self, G_CONNECT_SWAPPED);
-
- sync_brightness (self);
-}
-
-static void
-cc_brightness_scale_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- CcBrightnessScale *self;
-
- self = CC_BRIGHTNESS_SCALE (object);
-
- switch (prop_id) {
- case PROP_HAS_BRIGHTNESS:
- g_value_set_boolean (value, self->has_brightness);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-cc_brightness_scale_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- CcBrightnessScale *self;
-
- self = CC_BRIGHTNESS_SCALE (object);
-
- switch (prop_id) {
- case PROP_DEVICE:
- self->device = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-cc_brightness_scale_constructed (GObject *object)
-{
- CcBrightnessScale *self;
- const gchar *interface;
-
- G_OBJECT_CLASS (cc_brightness_scale_parent_class)->constructed (object);
-
- self = CC_BRIGHTNESS_SCALE (object);
-
- self->cancellable = g_cancellable_new();
-
- g_signal_connect_object (GTK_SCALE (self), "value-changed",
- G_CALLBACK (brightness_slider_value_changed_cb), self, G_CONNECT_SWAPPED);
-
- if (self->device == BRIGHTNESS_DEVICE_KBD)
- interface = "org.gnome.SettingsDaemon.Power.Keyboard";
- else
- interface = "org.gnome.SettingsDaemon.Power.Screen";
-
- cc_object_storage_create_dbus_proxy (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.SettingsDaemon.Power",
- "/org/gnome/SettingsDaemon/Power",
- interface,
- self->cancellable,
- got_proxy_cb,
- self);
-
- gtk_range_set_range (GTK_RANGE (self), 0, 100);
- gtk_range_set_increments (GTK_RANGE (self), 1, 10);
- gtk_range_set_round_digits (GTK_RANGE (self), 0);
- gtk_scale_set_draw_value (GTK_SCALE (self), FALSE);
-}
-
-static void
-cc_brightness_scale_finalize (GObject *object)
-{
- CcBrightnessScale *self = CC_BRIGHTNESS_SCALE (object);
-
- g_cancellable_cancel (self->cancellable);
-
- G_OBJECT_CLASS (cc_brightness_scale_parent_class)->finalize (object);
-}
-
-void
-cc_brightness_scale_class_init (CcBrightnessScaleClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->get_property = cc_brightness_scale_get_property;
- object_class->set_property = cc_brightness_scale_set_property;
- object_class->constructed = cc_brightness_scale_constructed;
- object_class->finalize = cc_brightness_scale_finalize;
-
- g_object_class_install_property (object_class,
- PROP_DEVICE,
- g_param_spec_enum ("device",
- "device",
- "device",
- brightness_device_get_type(),
- BRIGHTNESS_DEVICE_SCREEN,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
-
- g_object_class_install_property (object_class,
- PROP_HAS_BRIGHTNESS,
- g_param_spec_boolean ("has-brightness",
- "has brightness",
- "has brightness",
- FALSE,
- G_PARAM_READABLE));
-}
-
-static void
-cc_brightness_scale_init (CcBrightnessScale *self)
-{
-}
-
-
-gboolean
-cc_brightness_scale_get_has_brightness (CcBrightnessScale *self)
-{
- g_return_val_if_fail (CC_IS_BRIGHTNESS_SCALE (self), FALSE);
-
- return self->has_brightness;
-}
diff --git a/panels/power/cc-brightness-scale.h b/panels/power/cc-brightness-scale.h
deleted file mode 100644
index d566dff77..000000000
--- a/panels/power/cc-brightness-scale.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* cc-brightness-scale.h
- *
- * Copyright (C) 2020 System76, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-#pragma once
-
-#include <gtk/gtk.h>
-#include "cc-brightness-scale-types.h"
-
-G_BEGIN_DECLS
-
-typedef enum {
- BRIGHTNESS_DEVICE_SCREEN,
- BRIGHTNESS_DEVICE_KBD,
-} BrightnessDevice;
-
-#define CC_TYPE_BRIGHTNESS_SCALE (cc_brightness_scale_get_type())
-G_DECLARE_FINAL_TYPE (CcBrightnessScale, cc_brightness_scale, CC, BRIGHTNESS_SCALE, GtkBox)
-
-gboolean cc_brightness_scale_get_has_brightness (CcBrightnessScale *scale);
-
-G_END_DECLS
diff --git a/panels/power/meson.build b/panels/power/meson.build
index 9066d24bd..0e3ea1d56 100644
--- a/panels/power/meson.build
+++ b/panels/power/meson.build
@@ -19,16 +19,11 @@ i18n.merge_file(
sources = files(
'cc-battery-row.c',
- 'cc-brightness-scale.c',
'cc-power-panel.c',
'cc-power-profile-row.c',
'cc-power-profile-info-row.c'
)
-sources += gnome.mkenums_simple(
- 'cc-brightness-scale-types',
- sources: ['cc-brightness-scale.h'])
-
resource_data = files(
'cc-battery-row.ui',
'cc-power-panel.ui'
--
2.32.0
From 04a299a3582eeae777052b2315bf9b2801f4865c Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Mon, 26 Jul 2021 11:38:38 +0200
Subject: [PATCH 28/33] power: Update and add subtitle to automatic brightness
row
As per:
https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/1020#note_1210702
---
panels/power/cc-power-panel.ui | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/panels/power/cc-power-panel.ui b/panels/power/cc-power-panel.ui
index a8fafba21..9880f6b7e 100644
--- a/panels/power/cc-power-panel.ui
+++ b/panels/power/cc-power-panel.ui
@@ -143,7 +143,8 @@
<child>
<object class="HdyActionRow" id="als_row">
<property name="visible">True</property>
- <property name="title" translatable="yes">Automatic Brightness</property>
+ <property name="title" translatable="yes">Automatic Screen Brightness</property>
+ <property name="subtitle" translatable="yes">Screen brightness adjusts to the surrounding light.</property>
<child>
<object class="GtkSwitch" id="als_switch">
<property name="visible">True</property>
--
2.32.0
From 52dc3f91abb83deac0b66611fd9ed6f96a78cb5f Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Tue, 3 Aug 2021 11:19:56 +0200
Subject: [PATCH 29/33] power: Dim the info box icon
This brings less focus to the icon and more to the text.
See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1421
---
panels/power/cc-power-profile-info-row.ui | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/panels/power/cc-power-profile-info-row.ui b/panels/power/cc-power-profile-info-row.ui
index bc49a24ac..6f411c688 100644
--- a/panels/power/cc-power-profile-info-row.ui
+++ b/panels/power/cc-power-profile-info-row.ui
@@ -21,7 +21,7 @@
<property name="icon-name">info-symbolic</property>
<property name="icon-size">5</property>
<style>
- <class name="power-profile"/>
+ <class name="dim-label"/>
</style>
</object>
</child>
--
2.32.0
From 254a9bfa8ac8be8403d0258742f0c3f8c8db9633 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 4 Aug 2021 11:26:33 +0200
Subject: [PATCH 30/33] power: Remove icons from power profiles
They were originally included was to educate users about what the icons
mean, for when they appeared in the top bar. However, since we no
longer plan on showing the status icon in the top bar, it's not so
important that people learn the meaning of the icons.
See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1421
---
panels/power/cc-power-profile-row.c | 13 +------------
panels/power/cc-power-profile-row.ui | 15 +--------------
2 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/panels/power/cc-power-profile-row.c b/panels/power/cc-power-profile-row.c
index ee66bdfd0..a8458c366 100644
--- a/panels/power/cc-power-profile-row.c
+++ b/panels/power/cc-power-profile-row.c
@@ -35,7 +35,6 @@ struct _CcPowerProfileRow
GtkListBoxRow parent_instance;
GtkRadioButton *button;
- GtkImage *icon_image;
GtkLabel *subtitle_label;
GtkLabel *title_label;
@@ -106,7 +105,6 @@ cc_power_profile_row_class_init (CcPowerProfileRowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/power/cc-power-profile-row.ui");
gtk_widget_class_bind_template_child (widget_class, CcPowerProfileRow, button);
- gtk_widget_class_bind_template_child (widget_class, CcPowerProfileRow, icon_image);
gtk_widget_class_bind_template_child (widget_class, CcPowerProfileRow, subtitle_label);
gtk_widget_class_bind_template_child (widget_class, CcPowerProfileRow, title_label);
@@ -175,7 +173,7 @@ CcPowerProfileRow *
cc_power_profile_row_new (CcPowerProfile power_profile)
{
CcPowerProfileRow *self;
- const char *text, *subtext, *icon_name, *class_name;
+ const char *text, *subtext;
self = g_object_new (CC_TYPE_POWER_PROFILE_ROW, NULL);
@@ -185,20 +183,14 @@ cc_power_profile_row_new (CcPowerProfile power_profile)
case CC_POWER_PROFILE_PERFORMANCE:
text = _("Performance");
subtext = _("High performance and power usage.");
- icon_name = "power-profile-performance-symbolic";
- class_name = "performance";
break;
case CC_POWER_PROFILE_BALANCED:
text = _("Balanced Power");
subtext = _("Standard performance and power usage.");
- icon_name = "power-profile-balanced-symbolic";
- class_name = NULL;
break;
case CC_POWER_PROFILE_POWER_SAVER:
text = _("Power Saver");
subtext = _("Reduced performance and power usage.");
- icon_name = "power-profile-power-saver-symbolic";
- class_name = "low-power";
break;
default:
g_assert_not_reached ();
@@ -206,9 +198,6 @@ cc_power_profile_row_new (CcPowerProfile power_profile)
gtk_label_set_markup (self->title_label, text);
gtk_label_set_markup (self->subtitle_label, subtext);
- gtk_image_set_from_icon_name (self->icon_image, icon_name, GTK_ICON_SIZE_MENU);
- if (class_name != NULL)
- gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self->icon_image)), class_name);
return self;
}
diff --git a/panels/power/cc-power-profile-row.ui b/panels/power/cc-power-profile-row.ui
index 64516edf3..1391093ba 100644
--- a/panels/power/cc-power-profile-row.ui
+++ b/panels/power/cc-power-profile-row.ui
@@ -28,19 +28,6 @@
<property name="height">2</property>
</packing>
</child>
- <child>
- <object class="GtkImage" id="icon_image">
- <property name="visible">True</property>
- <property name="margin-end">6</property>
- <style>
- <class name="power-profile"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
<child>
<object class="GtkLabel" id="title_label">
<property name="visible">True</property>
@@ -53,7 +40,7 @@
<property name="margin-end">6</property>
</object>
<packing>
- <property name="left_attach">2</property>
+ <property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
--
2.32.0
From 96efcd2835a46b8009b5f6524a2d37089f40dd44 Mon Sep 17 00:00:00 2001
From: Allan Day <allanpday@gmail.com>
Date: Wed, 4 Aug 2021 11:28:14 +0200
Subject: [PATCH 31/33] power: Align power profile info boxes with profiles
text
See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1421
---
panels/power/cc-power-profile-info-row.ui | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/panels/power/cc-power-profile-info-row.ui b/panels/power/cc-power-profile-info-row.ui
index 6f411c688..34807c38c 100644
--- a/panels/power/cc-power-profile-info-row.ui
+++ b/panels/power/cc-power-profile-info-row.ui
@@ -8,11 +8,11 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
- <property name="margin-start">8</property>
+ <property name="margin-start">4</property>
<property name="margin-end">8</property>
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
- <property name="spacing">8</property>
+ <property name="spacing">4</property>
<child>
<object class="GtkImage" id="icon_image">
<property name="visible">True</property>
--
2.32.0
From 618e269230a71ae3ac84a35daaf15ad3db38f459 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 5 Aug 2021 15:24:58 +0200
Subject: [PATCH 32/33] power: Change "Balanced" power profile label
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4530#note_1241985
---
panels/power/cc-power-profile-row.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/panels/power/cc-power-profile-row.c b/panels/power/cc-power-profile-row.c
index a8458c366..9d7f1fe6b 100644
--- a/panels/power/cc-power-profile-row.c
+++ b/panels/power/cc-power-profile-row.c
@@ -185,7 +185,7 @@ cc_power_profile_row_new (CcPowerProfile power_profile)
subtext = _("High performance and power usage.");
break;
case CC_POWER_PROFILE_BALANCED:
- text = _("Balanced Power");
+ text = _("Balanced");
subtext = _("Standard performance and power usage.");
break;
case CC_POWER_PROFILE_POWER_SAVER:
--
2.32.0
From 98ed744dcefd8c4d8398b1489d0c583a4d5787d9 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 5 Aug 2021 15:24:58 +0200
Subject: [PATCH 33/33] power: Update power profile labels
Use "Balanced" instead of "Balanced Power", and make sure to add a
context for all the profiles for translators.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4530#note_1243075
---
panels/power/cc-power-profile-row.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/panels/power/cc-power-profile-row.c b/panels/power/cc-power-profile-row.c
index 9d7f1fe6b..f290caa10 100644
--- a/panels/power/cc-power-profile-row.c
+++ b/panels/power/cc-power-profile-row.c
@@ -181,15 +181,15 @@ cc_power_profile_row_new (CcPowerProfile power_profile)
switch (self->power_profile)
{
case CC_POWER_PROFILE_PERFORMANCE:
- text = _("Performance");
+ text = C_("Power profile", "Performance");
subtext = _("High performance and power usage.");
break;
case CC_POWER_PROFILE_BALANCED:
- text = _("Balanced");
+ text = C_("Power profile", "Balanced");
subtext = _("Standard performance and power usage.");
break;
case CC_POWER_PROFILE_POWER_SAVER:
- text = _("Power Saver");
+ text = C_("Power profile", "Power Saver");
subtext = _("Reduced performance and power usage.");
break;
default:
--
2.32.0