Commit graph

222 commits

Author SHA1 Message Date
Eric Daigle
598e71fdd2 cc-power-panel: hide automatic suspend row in vm
As described in #2521, the automatic suspend row is currently shown
when Settings is running in a VM, in which case it has no effect.

This commit checks whether Settings is running in a VM and disables
showing the automatic suspend row in this case, as is done for the
Suspend/Hibernate rows. This prevents the user from being shown a
useless row in the power panel.

Closes #2521
2023-06-13 04:17:35 +00:00
Robert Ancell
868dd6cf7e power: Use self for object variable name 2023-06-06 07:54:38 +00:00
Bastien Nocera
5755f0eec7 power: Label the main "battery" as UPS if that's what it is
Change the label from "Battery" to "UPS" if the upower DisplayDevice is
a UPS. This avoids confusions like:
https://www.reddit.com/r/gnome/comments/11aws0q/battery_indicator_for_desktop_computer_seems/
https://askubuntu.com/questions/1344733/why-does-ubuntu-show-battery-and-charge-info-when-it-is-a-desktop-with-no-batter

"
Why does GNOME display a battery percentage ("Fully Charged") when I'm
running a desktop computer without any battery?
"
followed by:
"
Ha! I figured it out[...]. I have my desktop plugged into a UPS
"
2023-03-14 19:19:51 +00:00
Marco Melorio
088edd6c35 power: Remove deprecated gtk_widget_show/hide usage 2023-01-02 22:10:39 +00:00
Bastien Nocera
da7b4db162 power: Don't assert if we can't find the widget for a profile
In some cases, it was possible for a profile to be set (directly, or
through a hold) even though it wasn't supported. Don't assert in those
cases.

Closes: #1504
2022-09-16 11:07:09 +00:00
Pablo Correa Gómez
ddfacc6b81 power: Only update ALS state if it has changed
Ambient light sensors can be quite sensitive and the LightLevel
property might be changing very often. That has two undesired
consequences:
* The `als_enabled_state_changed` callback gets constantly called
  due to a change in a property which it does not care about, as
  only `HasAmbientLight` is relevant. Therefore, limit the code
  execution to when something needs to be changed.
* During debugging, the terminal gets spammed with "ALS enabled: on/off"
  messages.
2022-05-10 04:32:12 +00:00
Bastien Nocera
595f04ea12 power: Remove ad-hoc UI debugging ifdef's
Remove the static UI debugging tools in the power panel code, and use
the scenario tester instead.
2022-01-18 16:06:15 +01:00
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