Commit graph

345 commits

Author SHA1 Message Date
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
Adrien Plazas
f06379e30c Replace HdyColumn by HdyClamp
In libhandy 1, HdyClamp replaces HdyColumn. This stops setting values
when they match HdyClamp's defaults.
2020-07-20 08:04:28 +02: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
Bastien Nocera
75ec783fc5 power: Rename "Suspend and Power Button" section
To "General" to match the latest mockups.
2020-07-06 17:27:49 +02:00
Bastien Nocera
368bb94f6c power: Make mouse a device with coarse battery level
So that this aspect is tested as well.
2020-07-06 17:27:49 +02:00
Bastien Nocera
12c01e708f power: Fix runtime warnings with test features enabled
(gnome-control-center:172393): libupower-glib-WARNING **: 15:00:10.866: Property ID 'power-supply' (6) was never set
(gnome-control-center:172393): libupower-glib-WARNING **: 15:00:10.866: Property ID 'is-present' (8) was never set
(gnome-control-center:172393): libupower-glib-WARNING **: 15:00:10.866: Property ID 'battery-level' (28) was never set
(gnome-control-center:174498): libupower-glib-WARNING **: 15:04:44.859: Property ID 'time-to-full' (24) was never set
2020-07-06 17:27:49 +02:00
Bastien Nocera
af14cda496 power: Fix compilation with test features enabled 2020-07-06 17:27:49 +02:00
D. Auer
23f8d9134e power: Add Energy keyword for desktop search 2020-04-15 06:18:29 +00:00
Robert Ancell
a6d5678dc8 power: Connect signals with g_signal_connect_object in swapped form 2020-03-30 16:18:50 +13:00
Mohammed Sadiq
be1c9ac1d6 power: Fix mobile broadband switch logic
Let the power switch be active (ie, powersave set to off) if either
of wimax or wwan device is enabled.  And set the switch sensitive
if either of them present.
2020-02-13 21:18:55 +00:00
Robert Ancell
93b14a4339 panel: Move shared GCancellable code into panel class
Make the panel class provide a cancellable that will be cancelled when the panel
is destroyed. Panel implementations can use this and not have to mangage the
cancellable themselves. Consolidate cases where panels had multiple cancellables
that were all being used for this behaviour.
2020-02-03 09:36:24 +13:00
Mohammed Sadiq
68c4023f06 power: Hide power button when chassis is handset
Just like tablets, handset power key is often handled differently
2020-01-27 21:20:29 +00:00
Georges Basile Stavracas Neto
5f640b9903 panel-list: Reorganize Devices section
Move the Power and Sound panel to there.
2020-01-06 15:15:30 +00:00
Bastien Nocera
59607bb78a power: Add a fake UPS device
When a define is set.
2019-11-20 03:49:07 +00:00
Georges Basile Stavracas Neto
255a1ab948 power: Move helper function to panels/common
It will be used by the Lock Screen panel in the future.
2019-11-07 14:19:23 +13:00
Diego Escalante Urrelo
3a1d6295cd power: Stop the brightness slider from jumping
The GtkScale widget for screen brightness has a tendency to jump around
because GtkRange defaults to NOT rounding values (round_digits = -1).

This means that the widget is constantly set with values that have
decimals (say 10.3) which it then tries to correct to fit the step size.

The solution for this particular UI quirk is to make sure to set
round-digits to 0, as that will force GtkRange to provide GtkScale with
rounded-down numbers. See gtkrange.c.

Fixes: https://gitlab.gnome.org/GNOME/gnome-settings-daemon/issues/405
2019-10-31 20:05:12 +00:00
Robert Ancell
9a2e821fe5 Initialize autoptr values to NULL.
These cases were safe, but if the code changed this risked freeing uninitialized
memory.
2019-10-03 10:58:38 +13:00
Philip Chimento
c1210c5c65 power: Use up_client_get_devices2()
The previous code would have leaked all the UpDevice objects because no
free function was set on the returned GPtrArray.

Since we already depend on upower-glib 0.99.8 which is the release in
which get_devices() was deprecated and get_devices2() was introduced, we
can simply switch to get_devices2() which does set a free function on
the returned GPtrArray, stopping the leak.
2019-09-16 14:09:40 -07:00
Robert Ancell
97985a664e Remove unused GNOMELOCALEDIR defines 2019-09-09 21:45:53 +00:00
Georges Basile Stavracas Neto
f833bb13ad power: Tweak margins and spacing
* Add another vertical size group handling only battery
   rows.

 * Add more vertical margins to the battery rows -- set
   to 16px and 14px, respectivelly, the top and bottom
   margins.

 * Increase spacing between battery level and labels to
   10px.

 * Increase spacing between titles and subtitles to 4px.

Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/553
2019-06-16 01:01:36 +00:00
Georges Basile Stavracas Neto
be5d6bfba1 power: Scale row subtitles to 0.9
This matches what the Mouse & Touchpad panel do, and
fixes a small inconsistency with the panel.

Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/553
2019-06-16 01:01:36 +00:00
Georges Basile Stavracas Neto
9b41718e4b power: Capitalize and improve labels
As spotted by Allan, these labels do not follow the
correct capitalization rules.

Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/552
2019-06-16 01:01:36 +00:00
Bastien Nocera
dff4d1f323 power: Don't treat all batteries as laptop batteries
They might be device batteries where the device type is not known or
catalogued.
2019-05-07 12:53:23 +02:00
Ethan Hsieh
83e055c9be power: correct the value of 90 minutes to 5400 2019-05-02 13:35:14 +08:00
Adrien Plazas
ef93835b31 power: Make the rows adaptive
This factorizes the row creation a bit and normalizes the margins and
spacing, reducing the required width. This also makes labels like row
titles and descriptions ellipsizable so the rows can reach narrower
widths.
2019-03-29 17:55:20 +00:00
Adrien Plazas
101ebf1bd4 power: Use a HdyColumn
This allows the window to reach narrower sizes.
2019-03-29 17:55:20 +00:00
Adrien Plazas
4e6ec3aad0 power: Don't tweak the scrollbar policy
This allows the window to reach smaller sizes.
2019-03-29 17:55:20 +00:00
Jeremy Bicha
3d686de41c power: stop using deprecated up_client_get_devices
and bump required upower version to 0.99.8 which
introduced up_client_get_devices2

This is a follow-up from
https://gitlab.gnome.org/GNOME/gnome-control-center/merge_requests/82
2018-12-07 14:55:43 +00:00