Commit graph

215 commits

Author SHA1 Message Date
Bastien Nocera
bd4c27e7ab power: Remove support for power-profiles-daemon < 0.9.0 2022-01-14 13:46:50 +00:00
Georges Basile Stavracas Neto
a0d49cb3a8 power: Port to GTK4
Extra care was needed for the combo boxes, and the way we currently
use GtkStringList is kind of hacky, but overall things seem to be
working fine.
2021-12-14 22:34:21 -03:00
Frédéric Péters
667af4f521 power: Use translated strings for power button action behaviors
Fixes: #1476
2021-09-29 17:58:46 +00:00
Bastien Nocera
bb30b04ed6 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.
"
2021-07-28 11:55:34 +00:00
Bastien Nocera
f03cf178dd power: Remove Bluetooth power switch button
See previous commit.
2021-07-28 11:55:34 +00:00
Bastien Nocera
2f2ea3aed6 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.
2021-07-28 11:55:34 +00:00
Bastien Nocera
93cf2405ee 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
2021-07-27 15:49:26 +02:00
Bastien Nocera
1144db552e power: Add UI for "power-saver profile when battery is low"
See https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/merge_requests/247
2021-07-26 18:53:20 +02:00
Bastien Nocera
738c15be66 power: Fix D-Bus proxy leak 2021-07-21 13:53:59 +00:00
Bastien Nocera
98b921b46f 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.
2021-07-20 00:51:48 +02:00
Bastien Nocera
c0ce1e53ab 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
2021-07-20 00:51:48 +02:00
Bastien Nocera
05997b424c power: Move variant_lookup_string() helper function 2021-07-20 00:51:48 +02:00
Bastien Nocera
eda473f0d6 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.
2021-07-20 00:51:48 +02:00
Bastien Nocera
9724d3ef59 power: Handle new power-profiles-daemon API
Handle the new PerformanceDegraded property to replace
PerformanceInhibited.
2021-07-15 22:14:06 +02:00
Bastien Nocera
e5bbe4d7c6 power: Add new power profile info row widget 2021-07-15 22:14:06 +02:00
Bastien Nocera
0f86d4d754 power: Simplify emptying listbox
We do that in a few places.
2021-07-15 14:57:49 +02:00
Bastien Nocera
d35c816508 power: Fix keynav not working
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;
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
2021-07-15 13:12:36 +02:00
Adrien Plazas
a5c0934b4d power: Use HdyPreferencesGroup 2021-05-07 02:50:40 +00:00
Adrien Plazas
6c8307faf4 power: Use HdyActionRow to simplify the code 2021-05-07 02:50:40 +00:00
Adrien Plazas
4cc4b91b4e power: Use HdyComboRow for the Power Button Behavior row
This simplifies the code a bit and modernizes the UI.
2021-05-07 02:50:40 +00:00
Adrien Plazas
3069dc84c8 power: Use HdyComboRow for the Blank Screen row
This simplifies the code a bit and modernizes the UI.
2021-05-07 02:50:40 +00:00
Adrien Plazas
f986fedf49 power: Don't set the vadjustment
This is useless as GtkScrolledwindow already does it on the viewport it
creates.
2021-05-07 02:50:40 +00:00
Adrien Plazas
5168e924cf 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.
2021-05-07 02:50:40 +00:00
Bastien Nocera
9acaa10567 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	}
2021-03-31 11:12:17 +02:00
Robert Ancell
2dbab9d4fa power: Use GtkBuilder for CcPowerProfileRow 2021-01-06 20:02:46 +00:00
Robert Ancell
edec4b6575 power: Use self variable naming style 2021-01-06 20:02:46 +00:00
Robert Ancell
fd33f80558 power: Move general UI into GtkBuilder file 2020-12-13 20:57:04 +00:00
Robert Ancell
2cd571f2f7 power: Move power saving UI into GtkBuilder file 2020-12-13 20:57:04 +00:00
Robert Ancell
b539a2d94f power: Move power profile UI into GtkBuilder file 2020-12-13 20:57:04 +00:00
Robert Ancell
1d11ba552d power: Move device UI into GtkBuilder file 2020-12-13 20:57:04 +00:00
Robert Ancell
3bd01516e3 power: Move battery UI into GtkBuilder file 2020-12-13 20:57:04 +00:00
Robert Ancell
cd24fddcf8 power: Move GtkSizeGroups into GtkBuilder file 2020-12-13 20:57:04 +00:00
Robert Ancell
d06375fc82 power: Use GTK widget types 2020-12-13 20:57:04 +00:00
Robert Ancell
4b0c908e1f power: Fix battery percentage control not showing on mobile devices.
If you can't suspend/hibernate or on a mobile device or VM then the battery
percentage is control is supposed to be shown.
The parent widgets are hidden though, so this doesn't work.
Always show the parents, as all branches show something here.

This was added in 6a65dcf693.
2020-12-13 20:57:04 +00:00
Bastien Nocera
1619d30780 power: Fix battery gauge colours
Calling gtk_css_provider_load_from_resource() twice will remove any
already loaded resource instead of adding the new CSS with the old. Load
each CSS individually instead.

Fixes: f1bcaf1fbc
2020-12-11 17:16:55 +00:00
Bastien Nocera
f1bcaf1fbc power: Add "Power Mode" section
Use power-profiles-daemon[1] to implement switchable power profiles.
The performance profile will only be available on systems which provide
this functionality.

[1]: https://gitlab.freedesktop.org/hadess/power-profiles-daemon
2020-10-29 16:58:24 +01:00
Robert Ancell
35790b5430 power: Replace g_object_new with gtk widget methods
This improves compile time type checking.
2020-10-19 04:07:53 +00:00
Ian Douglas Scott
f40d4865fa power: Use CcBatteryRow for devices section as well
This had another slightly different version of the same code.
2020-10-14 22:56:16 +00:00
Ian Douglas Scott
dc9a3c993a power: Remove unused status code in add_device
It seems this was added in ee36b0df91, but the `status` variable has
been unused since a9683772d9 (committed in 2012).

Seems safe to remove if it's been unused since 2012.
2020-10-14 22:56:16 +00:00
Ian Douglas Scott
af8c3247b4 power: Remove get_battery_level()
This was added in 6c447dc14a to deal with
both older and newer UPower versions.

It should be safe now to assume a UPower version with this property.
2020-10-14 22:56:16 +00:00
Ian Douglas Scott
f297f544f1 power: Refactor battery row code into a CcBatteryRow type
`set_primary()` and `add_primary()` had a lot of redundant code. This
unifies them, and moves them to a custom widget called `CcBatteryRow`.
This also decreases the somewhat excessive size of `cc-power-panel.c`,
and makes it easier to see the layout of widgets, now that it's
specified in xml.

Before this, `warning-battery-offset` was set to `0.03` for a "primary"
battery, and `0.05` otherwise. I expect this is a bug, so I've changed
both to `0.03`.

No other style or behavior change is intended.
2020-10-14 22:56:16 +00:00
Bastien Nocera
12e2475e72 power: Remove WiMax handling
It's been deprecated and unsupported by NetworkManager since version 1.2
(current is 1.26).
2020-09-25 02:04:00 +00:00
Felipe Borges
04211dd548 power: Hide "Suspend & Power Button" section when empty
Fixes #1075
2020-09-14 21:39:34 +00:00
Ian Douglas Scott
3893a1da77 power: Refactor brightness scale code into a CcBrightnessScale class
This reduces some redundancy between the screen brightness and keyboard
brightness code.

Such refactoring is a prerequisite for including a keyboard backlight
control in the Keyboard panel, as has been [proposed][1]. But hopefully
this makes the code a bit neater and more managable even without that.

[1]: https://gitlab.gnome.org/Teams/Design/settings-mockups/-/blob/master/keyboard/Keyboard-with-dialogs.png
2020-08-18 03:01:02 +00:00
Georges Basile Stavracas Neto
8d48630910 power: Remove unused variable 2020-07-07 15:59:34 -03:00
Georges Basile Stavracas Neto
82cb025b69 power: Fix battery row
Add it to the actual listbox.
2020-07-07 15:59:16 -03:00
Bastien Nocera
2397d0c082 power: Use correct colour for battery level bars
Use 3 symbolic colours to paint the levels in the battery bars, with a
red "error" colour used for the lowest level of battery, an orange
"warning" colour for the pre-error level, and a green "success" colour
used for levels above that.

There's no yellow intermediate colour as this is usually too anxiety
inducing and there's no real need to press users into a "warning"
behaviour when the level will still be comfortable for a long enough
time.

Closes: #725
2020-07-06 17:27:49 +02:00
Bastien Nocera
2bf373ef9a power: Move "Automatic Suspend" row 2020-07-06 17:27:49 +02:00
Bastien Nocera
06db069048 power: Move helper functions
To prepare for moving the "Automatic Suspend" row to the
"Power Saving" section.
2020-07-06 17:27:49 +02:00
Bastien Nocera
6a65dcf693 power: Add Battery percentage preference
This matches the preferences available in a lot of other OSes, whether
desktop or mobile, and can help with identifying the state of the
battery quicker for some people, as a number might be parsed quicker
than an icon/colour combination.

Closes: #481
2020-07-06 17:27:49 +02:00