Commit graph

8503 commits

Author SHA1 Message Date
Automeris naranja
d639a95457 usage: Minor style fixes
- Sort widget and callback names alphabetically in the
C code
- Fix indentation
2024-05-18 11:04:58 +02:00
Automeris naranja
2771714a58 usage: Remove unused stuff
- Remove the "run_warning" method, as it's no longer needed
now that all AdwAlertDialogs are located in the .ui file
- Remove "clear_recent_button" object ID, as it's unused by
the C code
2024-05-18 11:04:58 +02:00
Automeris naranja
e2f68721a5 usage: Port "Delete all the temporary files" to AdwAlertDialog
Also:
- Move the dialog to the .ui file, as this dialog is UI-related
- Don't destroy/force close the dialog, as it will be closed
automatically after the responses are triggered
2024-05-18 11:04:58 +02:00
Automeris naranja
47110c25f1 usage: Port "Empty all items from Trash?" to AdwAlertDialog
Also:
- Move the dialog to the .ui file, as this dialog is UI-related
- Don't destroy/force close the dialog, as it will be closed
automatically after the responses are triggered
2024-05-18 11:04:58 +02:00
Automeris naranja
51f8742df8 usage: Port "Clear File History?" to AdwAlertDialog
Also:
- Move the dialog to the .ui file, as this dialog is UI-related
- Don't destroy/force close the dialog, as it will be closed
automatically after the responses are triggered
2024-05-18 11:04:58 +02:00
Felipe Borges
ba74864b61 cc-panel: Require explicit "subpage" widget child type for subpages
Require the use of <child type="subpage"> for when an AdwNavigationPage
is expected to be added to CcPanel.navigation.

This way we can avoid programming errors when a child widget is wrongly
packed in the navigation view.

See also https://gitlab.gnome.org/GNOME/gnome-control-center/-/wikis/shell/CcPanel#child-packing

Co-authored-by: Matthijs Velsink <mvelsink@gnome.org>
2024-05-17 09:18:00 +00:00
Felipe Borges
24a07fbef4 system: Drop mistaken <child type="child"> xml node in UI file 2024-05-17 09:18:00 +00:00
Felipe Borges
a620b9572f system: Use CcPanel.add_static_subpage
So that we can use CcPanel's mechanism to dynamically create pages on
demand.
2024-05-17 09:18:00 +00:00
Felipe Borges
3f273bee0b privacy: Use CcPanel.navigation rather than own navigation-view 2024-05-17 09:18:00 +00:00
Felipe Borges
632643f992 applications: Use CcPanel.navigation rather than own navigation 2024-05-17 09:18:00 +00:00
Felipe Borges
8eba7d6edd applications: Push navigation page by id not tag 2024-05-17 09:18:00 +00:00
Felipe Borges
8efbae3c8f display: Use CcPanel.navigation instead of own navigation view 2024-05-17 09:18:00 +00:00
Felipe Borges
170842e90a universal-access: Use CcPanel.navigation rather than own navigation 2024-05-17 09:18:00 +00:00
Felipe Borges
d721c0c7ca system: Remove CcSystem.navigation in favour of CcPanel.navigation
Makes use of the cc_panel_push_subpage method.

The changes in cc-system-panel.ui are better reviewed without identation
changes, using "git diff -w", "git show -w".
2024-05-17 09:18:00 +00:00
Felipe Borges
0656fc9f06 system, about: Force untranslated text for system info text content
Fixes #3047
2024-05-17 08:51:40 +00:00
Felipe Borges
44ad87bef7 system, about: Drop translatable strings from "Copy" content
So that users can share the content in English while copying it
into bug trackers.
2024-05-17 08:51:40 +00:00
Christopher Davis
73d60296d1 sharing-networks: Port to AdwPreferencesGroup
Also, make the list box to be a11y-labelled.

Partial rebase of https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/1239
2024-05-17 08:50:58 +00:00
Automeris naranja
2867c3e761 user-page: Re-add the notice about the "Automatic Login" option
In [1], CcListRowInfoButton was added to the "Automatic Login"
row to explain what the automatic login option does. However,
it was accidentally removed in [2], so re-add-it.

See also https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2235

[1] d586df5c87
[2] d52ec68f8d (679a0ff6735df8f5a352572f78592e3c8610ec9e_136_0)
2024-05-17 07:44:33 +00:00
Matthijs Velsink
354b6f4243 general: Use gtk_widget_dispose_template instead of unparenting
Since GTK 4.8, gtk_widget_dispose_template() is available to
automatically unparent child widgets from templated GtkWidgets. This is
only needed for GtkWidget derived classes, as most other classes will
automatically unparent their children.

This makes widget implementations slightly simpler, and is also
recommended at
https://developer.gnome.org/documentation/tutorials/widget-templates.html

So, start using that function where we can.
2024-05-17 07:41:52 +00:00
Matthijs Velsink
6275e1a165 ce-8021x-security-page: Don't manually unparent child
Commit 340ee1dc fixed #1671, but the real cause of that issue was that
the widget is part of a GtkBox, which will always automatically unparent
child widgets. That caused #1671.

Also, the check for the parent is a left-over from the GTK3 days, and
its GtkContainer usage. In GTK4 there is no way a new widget will
already be inside the GtkBox to begin with.

So, don't unparent the widget at all, and stop checking for its parent.
2024-05-17 07:41:52 +00:00
Matthijs Velsink
e45ae68a5b vertical-row: Don't manually unparent child anymore
In the GTK3 days, HdyPreferencesRow (and GtkListBoxRow) did not
automatically unparent children.

In GTK4, AdwPreferencesRow (and GtkListBoxRow) do, so stop manually
unparenting child widgets.
2024-05-17 07:41:52 +00:00
Automeris naranja
80d86f9d89 add-user-dialog: Port GtkMessageDialog to AdwAlertDialog 2024-05-17 00:23:36 +00:00
Automeris naranja
d014202c3e wifi: Port "Turn Off Wi-Fi Hotspot?" to AdwAlertDialog
Also:
- Move the dialog to the .ui file, as this dialog is UI-related
- Don't destroy/force close the dialog, as it will be closed
automatically after the responses are triggered
2024-05-17 00:20:26 +00:00
Automeris naranja
9a967bc1a9 user-page: Use detailed reponse in AdwAlertDialog
Doing so, the callback doesn't need to have a string to compare.
2024-05-17 00:10:33 +00:00
Automeris naranja
231ea8ccb4 keyboard-shortcut-dialog: Port "Reset All Shortcuts?" to AdwAlertDialog
Also:
- Move the dialog to the .ui file, as this dialog is UI-related
- Don't destroy/force close the dialog, as it will be closed
automatically after the responses are triggered
2024-05-17 00:09:26 +00:00
Philip Withnall
ea014f24eb general: Fix various strict-aliasing warnings with g_clear_pointer()
This is just unfortunate. It’s an aliasing violation to cast a pointer
to a pointer (and there’s no way round that), although in practice it
will not cause a problem. People do quite often compile with
`-Werror=strict-aliasing`, though, so fixing the warnings is helpful.

Warnings are of the form:
```
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c: In function ‘cc_keyboard_shortcut_dialog_finalize’:
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:20: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
/opt/gnome/install/include/glib-2.0/glib/gmacros.h:871:47: note: in definition of macro ‘G_STATIC_ASSERT’
  871 | #define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
      |                                               ^~~~
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:3: note: in expansion of macro ‘g_clear_pointer’
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
      |   ^~~~~~~~~~~~~~~
In file included from /opt/gnome/install/include/glib-2.0/glib/gatomic.h:30,
                 from /opt/gnome/install/include/glib-2.0/glib/gthread.h:34,
                 from /opt/gnome/install/include/glib-2.0/glib/gasyncqueue.h:34,
                 from /opt/gnome/install/include/glib-2.0/glib.h:34:
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:20: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
/opt/gnome/install/include/glib-2.0/glib/glib-typeof.h:39:36: note: in definition of macro ‘glib_typeof’
   39 | #define glib_typeof(t) __typeof__ (t)
      |                                    ^
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:3: note: in expansion of macro ‘g_clear_pointer’
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
      |   ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```

I believe it’s better to fix these by expanding out the
`g_clear_pointer()` call, than by changing the types of variables — the
latter approach means everything becomes a `GtkWidget` or a `GtkWindow`,
which loses type specificity. So this approach is in contrast to that
taken in commit 1bafd46ea3, for example.

Alternative approaches would be:
 1. Add internal `cc_clear_window()` and `cc_clear_widget()` helpers
    which do this in a single line without aliasing violations.
 2. Enforce compiling with `-Wno-strict-aliasing` if strict aliasing is
    not something that g-c-c maintainers want to care about (which would
    be fine, aliasing checks probably won’t catch any bugs in this kind
    of code).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #2563
2024-05-16 14:01:02 +00:00
Philip Withnall
d2f4fe0447 wwan: Fix an uninitialised variable warning
This is another false positive, where the control flow conditions on
`modem_signal` prevent any reading of `refresh_rate` until after it’s
been initialised.

Compilers aren’t good at static analysis of conditional control flow,
though, so let’s just initialise both variables to safe defaults.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-05-16 14:01:02 +00:00
Philip Withnall
b86e0e069b wacom: Fix an uninitialised variable error
This fixes an error when building with `-Werror=maybe-uninitialized`.
It’s a false positive, because the `for` loop conditions ensure that a
`default:` case in the `switch` is never needed. However, compilers are
historically quite bad at static analysis of loop iteration count, so
let’s just initialise the variable to a safe default.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-05-16 14:01:02 +00:00
Philip Withnall
63fbcbfaf9 privacy: Add subfolders to include paths
This fixes commit f00dc11f38. It’s needed
because the generated `enums.c` files refer to files in the
subdirectories by filename with no path.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-05-16 14:01:02 +00:00
Philip Withnall
3d201fabb1 general: Fix several uninitialised-autoptr variables
autoptr variables must *always* be initialised at the time of
declaration, as the compiler unconditionally inserts the free function
based on the control flow, and constantly re-checking the declarations
whenever you change the control flow in a function is tedious.

Better to just always initialise them to a safe value.

In particular, in these cases, a precondition failure in the function
would have caused the free function to be called on undefined memory,
which would have turned a potentially-graceful error recovery into a
crash.

Spotted by building with `-Werror=maybe-uninitialized`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-05-16 14:01:02 +00:00
Automeris naranja
3455e01b3f user-page: Port "Remove [user]?" to AdwAlertDialog
Also, remove the AdwAlertDialog argument in "remove_local_user_response",
as it's unused.
2024-05-15 10:46:40 +00:00
Matthijs Velsink
319bf22079 number-list: Add docstrings to props and methods
Since the new CcNumberObject and CcNumberList have a general purpose and
should hopefully exist for a long time, let's add documentation to them.
2024-05-14 21:29:02 +02:00
Matthijs Velsink
55852fa7f3 privacy,screen: Port delay lists to CcNumberList
The amount of code simplification really shows the use of CcNumberList
and how it's also useful to display dconf values that were not in the
list yet.
2024-05-14 21:29:02 +02:00
Matthijs Velsink
5043ef80c5 privacy,screen: Refactor lock delay setting
This makes the lock delay setting the same as how the screen delay is
set. A small refactor that helps make the next commit more clear.
2024-05-14 21:29:02 +02:00
Matthijs Velsink
9f79714f42 common: Add CcNumberObject and CcNumberList
GtkStringObject and GtkStringList are perfect for adding strings to
things like an AdwComboRow. However, things like delay times are harder
to set up, as the underlying GSettings take integer values directly, and
so require mapping from strings to integers if GtkStringList would be
used.

Using an AdwEnumList is an option, but is not flexible as no new values
can be added, which is required if wanting to represent values that were
set to dconf (by the user or using older Settings version) which are not
in the enum.

To solve this, we add CcNumberObject, with a similar api to
GtkStringObject. It contains an integer value, and an (optional)
representing string and (optional) custom order. These objects are
stored in a CcNumberList which wraps a GListStore and implements
GListModel. It has convenient methods for adding values directly. The
CcNumberList is always sorted, either ascending or descending, but also
takes into account any special ordering of CcNumberObjects.

Properties of CcNumberList are set up so that "values" can be added in
.ui files with a simple array notation, and one "special-value"
CcNumberObject (with string and/or custom order) can be added in .ui
files as well.

Using CcNumberObjects/CcNumberList in an AdwComboRow is very easy, it
just requires a function that takes a CcNumberObject and returns a
string. Two example functions are provided, which assume the
CcNumberObject contains a time duration value in either seconds or
minutes.
2024-05-14 21:29:02 +02:00
Felipe Borges
7c2d876b98 privacy, bolt: Port main row to AdwSwitchRow
See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2928
2024-05-14 08:45:11 +00:00
Automeris naranja
168e30a410 general: Don't set some "Copy" buttons as activatable widgets
In rows that have a "Copy" button that is set as activatable
widget, Orca doesn't the buttons a11y label/tooltip; instead,
it reads "[row title] push button".

To fix this, don't set these buttons as activatable widgets.
2024-05-13 23:13:55 -03:00
Automeris naranja
192d32926d sharing: Add DAV address row in the File Sharing dialog
Also:
- Remove the AdwPreferencesPage description, since
it's redundant with the explanatory text provided in
button from the "File Sharing" row.

Reference:
cfb7cae4a9
2024-05-14 01:07:22 +02:00
Automeris naranja
188b2d6769 sharing: Add explanatory text describing how sharing features work
In the File/Media Sharing dialogs, add a explanatory
text to the "File Sharing" and "Media Sharing" rows
explaining how these sharing features work.

Also, remove the AdwPreferencesPage description in
the "Media Sharing" dialog, since it's redundant
with the explanatory text provided in button from
the "Media Sharing" row.

Reference:
cfb7cae4a9
2024-05-14 01:07:22 +02:00
Automeris naranja
d0f520985c network: Don't use two AdwToolbarView widgets
Set the AdwViewStack as the content widget of a single
AdwToolbarView instead of using an AdwToolbarView in
each AdwViewStackPage, as this is redundant.
2024-05-12 17:02:12 +02:00
Matthijs Velsink
e7252dba4c display: Remove unsupported action from .ui file
Actions can be set in .ui files, but not callback actions. That's done
in the .c file anyways, but it was also put in the .ui file.

That used to be ignored, but since gtk!7121 that will generate a
warning.

So, remove that line.

Closes #3050
2024-05-08 18:04:41 +02:00
Automeris naranja
cc92084193 apps: Remove CcInfoRow and replace it with CcListRow
CcListRow is very similar to CcInfoRow:

- The "show-arrow" property is the equivalent of the "is-link"
property from CcInfoRow[1]
- The "secondary-label" is the equivalent of the "info" property
from CcInfoRow
- Setting the "activatable" property of CcListRow to "false" makes
the row to not be activatable just like CcInfoRow

Unlike CcListRow, CcInfoRow has the `expanded` property. However,
none of the CcInfoRows from the Apps panel are currently using it.
Also, CcInfoRow is specific to the Apps panel, while CcListRow is
used in many different panels

All of these things makes CcInfoRow redundant, so remove it and replace
all CcInfoRows with CcListRows.

[1] used together with the "has-expander" property
2024-05-08 14:50:11 +00:00
Monster
ec01b9d629 cc-applications-panel: Widen the search bar
Increase the maximum-size of the AdwClamp so the search bar isn't
awkward on small screen sizes.
2024-05-08 10:23:18 +00:00
Felipe Borges
3ab1dcdc61 network: Fix row removal when Bluetooth device is removed
When the user clicks in an existing Bluetooth connection and in the
Connection Editor chooses to "Remove Connection", we should delete the
row from the Bluetooth list.

Currently the row doesn't get deleted because the code that is shared
among all network device types assumes every list to be a GtkBox, while
the Bluetooth device list is a GtkListBox.

Let's check what's the connection being removed and remove the device
from the Bluetooth listbox correctly.
2024-05-06 23:00:44 +00:00
Matthijs Velsink
67be010833 datetime: Remove unused self variable
Commit 1c081549 fixed a crash in the datetime page, but forgot to remove
a `self` variable that is unused now.
2024-05-07 00:41:14 +02:00
Matthijs Velsink
d87135be0e net-vpn: Set GtkListBoxRow to changed on changes
The VPN list is sorted, but this sorting does not get updated when
changing any VPN name.

Make sure sorting gets retriggered by calling `gtk_list_box_row_changed()`
when updating the row contents.
2024-05-06 22:31:40 +00:00
Matthijs Velsink
8a7f2b233e network: Sort VPNs in the list
GNOME Shell sorts VPNs in the quick settings, but GNOME Settings does
not. This can be particularly annoying with many saved VPNs.

Fix this by adding a sort function to the VPN GtkListBox.

Closes #510
2024-05-06 22:31:40 +00:00
Automeris naranja
aaa08b8194 datetime-page: Set a content width in the "Date & Time" dialog
The GtkListBox from the "Date & Time" dialog is
currently what gives the dialog width, but this
is an unusual approach that other dialogs from
Settings don't use.

To fix this, use the content-width property from
AdwDialog. The dialog width is now almost the same
as before this change.
2024-05-06 12:15:12 +00:00
Automeris naranja
e66d4adb01 date-time: Use AdwActionRow in the Month row from the "Date & Time" dialog
The Month row is a CcListRow which displays the selected month
using the secondary-label property from CcListRow. However, the
month appears dimmed (because secondary-label uses the .dim-label
style class) and the Month row is supposed to mimick AdwComboRow,
which doesn't dim the selected item. To fix this, use an
AdwActionRow instead.
2024-05-06 12:15:12 +00:00
Automeris naranja
cf81656e55 datetime-page: Use AdwPreferencesPage/Group in the "Date & Time" dialog
This simplifies the .ui code a bit and keep consistency
with other dialogs.
2024-05-06 12:15:12 +00:00