Commit graph

240 commits

Author SHA1 Message Date
Felipe Borges
0042c11747 power: Use adw_dialog_present directly to show Auto suspend dialog 2024-04-09 11:37:37 +02:00
Automeris naranja
7b039bb279 power: Minor tweaks to strings related to automatic suspend
Rename the following strings (and use header capitalization):
- "When on battery power" to "On Battery Power"
- "When plugged in" to "When Plugged In" (in the Automatic Suspend
dialog too)

Reference 1bb482ed19
2024-04-07 21:19:28 +00:00
Automeris naranja
96d4acf1ed power: Port "Automatic Suspend" dialog to AdwDialog 2024-04-03 08:33:05 +00:00
Automeris naranja
49de7620b9 power: Update some strings
Update some strings from the power profile info row:

- Update a string to follow the latest mockups[1]
- Remove periods from phrases that are written as
a complete sentence, as recommended by HIG

[1] 1bb482ed19
[2] https://developer.gnome.org/hig/guidelines/writing-style.html#periods
2024-04-02 09:56:56 +00:00
Automeris naranja
524261c710 power: Use a single CSS file
Use a single CSS file for the entire panel.
This will make easier to set custom style
for specific widgets without having to create
a bunch of CSS files for each widget type.
2024-04-02 09:56:56 +00:00
Felipe Borges
49e35600c9 power: Load a different list for suspend-times when on mobile
Using the systemd-hostnamed chassis-type to detect when running on
"tablet", "handset", or "watch" and setting a more reasonable list
of suspend time options for them.
2024-03-21 16:01:11 +00:00
Automeris naranja
95f36e2d71 power: Remove row-activated callback for power profile rows
It isn't necessary anymore now that power profile
rows are AdwActionRows[1].

[1] f7b41b23f5
2024-02-26 15:56:41 +00:00
Automeris naranja
2b2af85ead power: Port "Automatic Suspend" row to CCListRow
This helps to clean the code a bit.
2024-02-20 10:05:15 +00:00
Automeris naranja
5785f4cc7d power: Don't use GtkSizeGroup
This isn't being used in other panels; it also
increases the height of all rows when the
window is narrow, making the UI to look odd.

Closes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1674
2024-02-20 08:51:52 +00:00
Felipe Borges
70888ea71d power: Use CcHostname to obtain the systemd-hostnamed chassis-type 2024-01-30 13:34:10 +00:00
Hari Rana
a936ac6bc9 power-panel: Port to AdwSwitchRow 2024-01-18 13:28:54 +00:00
Maximiliano Sandoval R
ae33a67be0 power-panel: Modernize suspend dialog
We make the dialog adaptive. Unfortunately for it to be trully modern a
AdwComboRow should be used instead of a GtkComboBox.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/2001>
2023-11-07 08:53:08 +00:00
Maximiliano Sandoval R
dca4e0201b power-panel: Use Header Capitalization
Part-of: <https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/2001>
2023-11-07 08:53:08 +00:00
Allan Day
a75cdb2c46 power: Adjust section titles
Use the section titles from the latest mockups. Also remove the unused
title from the .ui file.
2023-10-23 14:04:22 +00:00
Alice Mikhaylenko
1032ab01f0 power: Port the suspend dialog to AdwWindow and AdwToolbarView 2023-08-25 08:00:43 +00:00
Felipe Borges
fc9251c880 Revert "cc-power-panel: add battery health section"
This reverts commit 4a0d924afd.

There are some rough edges to be polished before this is ready for
prime time.

UPower battery health capacity reporting can often be inconsistent
across vendors, and we don't want to expose unreliable information
on the UI without proper sanitization.
2023-08-07 12:18:33 +02:00
Eric Daigle
4a0d924afd cc-power-panel: add battery health section
As described in #2554, it would be useful to be able to see battery health information
such as charge capacity in Settings. This commit implements the proposed design for
battery health information, adding this functionality to the power panel.

Closes #2554
2023-08-04 09:40:07 +00:00
Mohammed Sadiq
1e4ef1fdb0 power: Fix a memory leak 2023-07-03 01:56:24 +00:00
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