Commit graph

173 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Robert Ancell
1b70273221 power: Fix device label alignment
Should be left-aligned, previously it was centered
2018-11-21 12:11:20 +13:00
João Paulo Rechi Vita
6efaf85e9a power: Label the PENDING_CHARGING state as "Not Charging"
The pending-charge state means AC power is on but the battery is not
being charged. This can happen because its charge is above a certain
threshold, to avoid short charging cycles and prolong the battery's
life, or because the PSU is not powerful enough to charge the batteries.

Instead of lying to the user about something being estimated, we should
simply tell the truth and set the label to "Not Charging".

Closes: #249.
2018-11-14 13:53:40 -08:00
Robert Ancell
e6bf2870c1 power: Make .ui filename match the .c filename 2018-11-12 16:41:01 +00:00
Benjamin Berg
b5711c59ec power: Correctly lookup or insert new items into combobox
The code to lookup or insert items into the combobox had a few issues.
It would assume that the items are sorted, causing existing items to not
be found and be inserted instead. It also would simply forget to insert
an item if it was larger than all existing items.

This code is now changed to iterate over all items, finding the best
insertion point in the process (next item has a larger value, or the
values are not increasing anymore). The item will only be inserted if it
has not been found.

Fixes #261
2018-11-08 12:38:51 +00:00
Robert Ancell
99220dad50 power: Don't use gtk_widget_show_all
It is removed in GTK+ 4
2018-10-11 22:21:34 +00:00
Jonathan Kang
4af9803f51 power: set no-show-all to TRUE on wifi and mobile rows
The Wi-Fi and mobile broadband row's visibility depends on related
device status. But calling gtk_widget_show_all on the whole list box
makes them visible even related device is not avialbe. Fix that by
setting no-show-all of these two widgets as TRUE.

https://gitlab.gnome.org/GNOME/gnome-control-center/issues/189
2018-10-11 02:07:51 +00:00
Andrea Azzarone
f34ea2bd5e power: Use g_signal_connect_object
Objects created using the object storage API are not disposed when the panel
that created them is disposed. In order to prevent segfaults we need to manually
disconnect signal handler connected to these objects or we can do it
automatically using g_signal_connect_object.

Fixes: https://launchpad.net/bugs/1797205
2018-10-10 20:12:19 +01:00
Benjamin Berg
75556d7c5a power: Handle cancelled kbd brightness proxy creation
The code must not access the passed panel if the operation to create the
keyboard proxy has been cancelled. This fixes a possible crash when
switching away from the power panel.
2018-09-25 02:46:54 +00:00
Robert Roth
f7798f5dfa power: set proper level offsets for battery levelbars
The battery power level level bars are using the default offsets for low, high and full battery level, 0.25, 0.75 and 1.0.

Based on the suggestion from #68, this commit changes the high and full offset to 0.1 and 0.8, and the low battery level offset to 0.03 for primary batteries and UPSs, and 0.05 for other batteries and devices.

https://gitlab.gnome.org/GNOME/gnome-control-center/issues/68
2018-09-10 15:15:09 +00:00
Georges Basile Stavracas Neto
c2eaafebc0 power: Minor adjustment in the mobile broadband string
Now it properly follows Nick's suggestion.

[skip ci]
2018-07-23 11:24:12 -03:00
Georges Basile Stavracas Neto
37a0b8e04f power: Reword some strings
Some of the current string related to saving power by
turning something off are ambiguous, and can mean both
"yes, turn off" or "yes, keep it on" at the same time.

This commit slightly rewords those sentences in order
to disambiguate them.

https://gitlab.gnome.org/GNOME/gnome-control-center/issues/53

[skip ci]
2018-07-23 11:07:43 -03:00
Robert Ancell
71383e8b50 power: Use GtkTemplate 2018-06-11 14:30:31 +00:00
Robert Ancell
3622c8ff14 power: Use g_auto for variables 2018-06-03 01:38:43 +00:00
Robert Ancell
d2959e4fe7 power: Simplify GPtrArray memory management 2018-05-30 23:17:08 +00:00
Robert Ancell
ed6ac15b5c power: Simplify cancellable destruction 2018-05-30 23:17:07 +00:00
Robert Ancell
f51932978f power: Replace GObject boilerplace with G_DECLARE_TYPE 2018-05-30 23:17:07 +00:00
Bastien Nocera
f26d21682a power: Automatically add values to drop-down when necessary
When a setting is set to a value that's not in the list of options, add
that custom value to the drop-down for the duration of the run, so as to
avoid the last item being selected and causing confusion.

https://bugzilla.gnome.org/show_bug.cgi?id=793448
2018-04-19 14:59:10 +02:00
Bastien Nocera
6c447dc14a power: Don't show approximate percentages
When there's a battery-level property (new in UPower 0.99.5), don't show
the percentage, as it's a rough approximation of the truth.

https://bugzilla.gnome.org/show_bug.cgi?id=780360
2018-04-19 14:39:11 +02:00
Benjamin Berg
c2f601a9d4 Move common panel code from shell/ to panel/common
This creates a new static library called libwidget which the shell links
against.
2018-04-17 15:26:59 +02:00
Georges Basile Stavracas Neto
eb62419b4b power: Cache D-Bus proxies and NMClient 2018-04-06 22:23:39 -03:00
Benjamin Berg
1d72a0b350 power: Fix crash when panel is closed quickly
Fix a use-after-free while creating the dbus proxy for
org.gnome.SettingsDaemon.Power.Keyboard. This fix is identical to the
previous fix for the screen proxy.

https://bugzilla.gnome.org/show_bug.cgi?id=794089
2018-03-05 16:47:52 +01:00
Bastien Nocera
d2f1155639 power: Fix crash when panel is closed quickly
Another use-after-free on cancellation crash.

 #0  g_type_check_instance_cast (type_instance=type_instance@entry=0x1eac3c0, iface_type=32150864) at /glib/gobject/gtype.c:4057
 #1  0x0000000000494077 in got_screen_proxy_cb (source_object=<optimized out>, res=0x1eceab0, user_data=user_data@entry=0x1eac3c0)
     at panels/power/cc-power-panel.c:1083

https://bugzilla.gnome.org/show_bug.cgi?id=789464
2018-02-20 10:59:18 +01:00