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
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
Use a GtkListBox placeholder widget to show the
"No input source selected" message. Also, remove the
hexpand and vexpand properties from the list box, which
currently aren't doing anything.
This will be consistent with the status page from the Settings
sidebar, which shows "No Results Found" when searching for panels
(if the search term doesn't return anything).
Also, use header capitalization, as advised by HIG.
- Set the "show-arrow" and "title" properties directly in
"g_object_new"
- Remove "gtk_list_box_row_set_activatable" because
CcListRow is activatable by default
Using `g_clear_handle_id()` in combination with `g_source_remove()` can
save a lot of boiler plate code.
This removes about 110 lines of code for free.
Ditch GtkListBox and use AdwActionRow to display
the key options, adding them directly to the
preferences group.
This fixes two issues:
- Orca not reading the key options and their states
- The xkb-modifier-dialog rows looking inconsistent
with other rows with radio buttons, such as the ones
from the Multitasking and Keyboard panels
Also, remove visible=true from the AdwActionRow,
since GTK4 shows all widgets by default.
The search entry is way too big, even more than
all shortcut category rows; this makes the UI
to look unbalanced. Make the search entry smaller
to fix that.
This will be consistent with the writing style used in Settings
(e.g. "Connect to Hidden Network" and "Add Printer" instead of
"Connect to a Hidden Network" and "Add a Printer" respectively).
We add a toolbar view containing a scrolled window.
- We set the margins to 12 instead of 18
- Use AdwHeaderBar
- Set minimum size and default size
- Make resizable so it fits on small screens
See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2624
At the moment the search entry is consuming the Escape key press, so we
have to manually tell it what to do with it.
We clear the search on the first press, if there is input, and close the
window otherwise.