Commit graph

311 commits

Author SHA1 Message Date
Florian Müllner
dccf794897 keyboard: Add dedicated key combo type
We currently store keyval, keycode and mask that make up a particular
key combo separately. However as we want to consider multiple bindings
for a single item, it makes more sense to combine them in a dedicated
struct type.

https://bugzilla.gnome.org/show_bug.cgi?id=673078
2017-07-10 19:29:43 +02:00
Florian Müllner
bd54cd1342 keyboard: Clear additional bindings when changing a shortcut
Some shortcuts allow multiple bindings for the same actions, which
we mainly use to keep supporting old settings when changing defaults.
Multiple bindings are not exposed in the interface though, so when
changing a shortcut with multiple bindings, we previously only updated
the first one and left additional bindings untouched. This is confusing
however, precisely because additional bindings are not shown in the
UI - for instance, this makes it impossible to actually disable
such a shortcut completely. The less confusing option is to clear
any additional bindings when changing a shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=673078
2017-07-10 19:29:43 +02:00
Florian Müllner
84d527645b keyboard: Don't create shortcuts editor twice
We are accidentally creating two editors, leaking the first instance ...

https://bugzilla.gnome.org/show_bug.cgi?id=784391
2017-07-05 09:22:21 -03:00
Florian Müllner
eed74317c4 keyboard: Fix another memory leak
The memory leak fixed in commit 870fb46201 is still present in
a copy-pasted version of the function, apply the same fix there
as well ...

https://bugzilla.gnome.org/show_bug.cgi?id=784356
2017-07-04 22:52:19 -03:00
Florian Müllner
3910b4ac9d keyboard: Follow the usual search pattern for filtering
Filtering on the name currently only matches the string as a whole,
not individual words as expected, for instance "home fo" and "ho fo"
should both match "Home Folder".

https://bugzilla.gnome.org/show_bug.cgi?id=784357
2017-06-29 21:36:30 -03:00
Florian Müllner
870fb46201 keyboard: Fix a memory leak
While the actual strings returned by g_variant_get_strv() are owned
by the variant, we still need to free the container ...

https://bugzilla.gnome.org/show_bug.cgi?id=784356
2017-06-29 21:22:51 -03:00
Georges Basile Stavracas Neto
7c405d77a7 keyboard: Inform that 'backspace' is the clear key
The Keyboard shortcut editor dialog gives no clue on how
to disable a shortcut, and users were confused by this
lack of information.

Fix that by informing the user about the Backspace role
when editing a shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=777401
2017-05-10 20:45:07 -03:00
Georges Basile Stavracas Neto
f981eb58ac keyboard: Add more key aliases
To improve even more the search feature, add the
following new key aliases:

Option  → Alt
Command → Super
Apple   → Super

https://bugzilla.gnome.org/show_bug.cgi?id=772565
2017-05-04 10:42:14 +02:00
Georges Basile Stavracas Neto
1cb787e8b8 keyboard: Also search shortcut accelerators
When managing the keyboard shortcuts, the user might want
to check for keybindings based on their accelerators, not
only their names. Currently, however, the Keyboard panel
only supports searching for the keybinding description.

Fix that by also considering the normalized keybinding
accelerator when performing the search.

https://bugzilla.gnome.org/show_bug.cgi?id=772565
2017-05-04 10:41:38 +02:00
Georges Basile Stavracas Neto
dce6fe6add keyboard: Move Remove button to the header bar
According to the mockups [1], the Remove button should
be placed at the start of the header bar. Currently,
however, it is positioned below the custom shortcut edit
button.

Fix that by moving the remove button to the header bar.

[1] https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/keyboard/keyboard-wires.png

https://bugzilla.gnome.org/show_bug.cgi?id=777846
2017-05-02 07:20:29 -03:00
Mohammed Sadiq
eeddf497af keyboard: Discard the added shortcut on Escape
If the user press Escape key after the user have set some shortcut,
don't save the newly set shortcut, and close the dialog.

https://bugzilla.gnome.org/show_bug.cgi?id=778748
2017-04-27 10:20:56 -03:00
Bastien Nocera
59cbe55db9 keyboard: Add many new keywords
Based on the keyboard shortcuts offered for customisation.

https://bugzilla.gnome.org/show_bug.cgi?id=781245
2017-04-13 10:23:39 +02:00
Rui Matos
3ab4b33390 keyboard: Fix check for existing shortcut settings
From a Coverity scan:

panels/keyboard/cc-keyboard-manager.c:208: unreachable: Since the loop
increment "i++;" is unreachable, the loop body will never execute more
than once.

This seems like a logic thinko introduced in commit
3207fe97ec . In practice it was unlikely
to be a problem since we don't have repeated shortcut gsettings key
names in all our KeyListEntries files.
2017-03-23 17:14:29 +01:00
Jeremy Bicha
681f40ca09 keyboard: Use ellipsis for "Reset All"
https://bugzilla.gnome.org/show_bug.cgi?id=778568
2017-02-14 19:09:33 +01:00
Piotr Drąg
555e230508 Remove no longer necessary contexts from translatable strings
These strings changed recently and now their contexts don't disambiguate
anything.
2017-02-12 16:02:22 +01:00
Georges Basile Stavracas Neto
e601ae74ee keyboard: ensure the "Add" button is insensitive when adding shortcut
After successfully editing a default shortcut (and making sure the
"Set" button is sensitive), if the user clicks the '+' row to create
a new custom shortcut, the "Add" button is sensitive even with all
fields empty.

Fix that by ensuring the "Add" button is always insensitive whenever
we add a custom shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=777842
2017-02-08 14:15:16 -02:00
Georges Basile Stavracas Neto
c57cadf50b keyboard: make the "Set" and "Add" buttons blue
Per the available mockups [1], the "Set" and "Add" buttons
are the suggested action of the dialog and should be blue.

[1] https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/keyboard/keyboard-wires.png

https://bugzilla.gnome.org/show_bug.cgi?id=777842
2017-02-08 14:15:16 -02:00
Georges Basile Stavracas Neto
818024970c keyboard: add a reset all button
As described in the proposed mockups [1], the Keyboard panel
should have a Reset All button above the list of shortcuts that
allows the user to quickly reset all the shortcuts to their
default keybinding. The current implementation, however, lacks
this button.

Fix that by adding a "Reset All" button, and implementing the
reset all action. A message dialog is shown in order to confirm
the action, and custom shortcuts are not reset (unless the conflict
with the default keybinding of another standard shortcut).

[1] https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/keyboard/keyboard-wires.png

https://bugzilla.gnome.org/show_bug.cgi?id=777840
2017-01-31 09:57:59 -02:00
Georges Basile Stavracas Neto
83555219bb keyboard: make the entire panel scrollable
The current Keyboard panel allows only the shortcut list to scroll.
Since we want to add more widgets above the list, and we want them
to scroll out of sight per the latest mockups [1], making only the
shortcut list scrollable poses a problem.

Fix that by making the entire panel scrollable.

[1] https://github.com/gnome-design-team/gnome-mockups/blob/master/system-settings/keyboard/keyboard-wires.png

https://bugzilla.gnome.org/show_bug.cgi?id=777840
2017-01-31 09:57:59 -02:00
Georges Basile Stavracas Neto
1e13e97556 keyboard: manage shortcut editor state with pages
The current shortcut editor state is managed by setting and
comparing the page name directly, making the code look more
complicated than it should.

Fix this by introducing the concept of pages, and using this
to set and get the current shortcut editor dialog state.

https://bugzilla.gnome.org/show_bug.cgi?id=777845
2017-01-30 13:26:25 -02:00
Georges Basile Stavracas Neto
147a1e814d keyboard: fix editing of custom shortcuts
After introducing the reset button to match the mockups [1], the
shortcut editor dialog had some issues exposed. This is visible
e.g. when the user tries to edit a custom shortcut's name and
the shortcut is disabled.

This happens because we assume there is always a shortcut set.
When we open the dialog to edit a custom shortcut, however, nothing
is actually set, and we end up saving the disabled shortcut when
editing the shortcut's name or command.

Fix that by initializing the shortcut's accelerators when editing a
shortcut, and correcting the logic to validate the shortcut.

[1] https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/keyboard/keyboard-wires.png

https://bugzilla.gnome.org/show_bug.cgi?id=777845
2017-01-30 13:26:12 -02:00
Georges Basile Stavracas Neto
20f52da5e2 keyboard: switch to the reset button
Per the mockups [1], when editing a custom shortcut, there is
a reset button right after the current shortcut. When there
is no shortcut set, it shows a "Set Shortcut" button instead.
The current UI to edit a shortcut, however, diverges from
the proposed one since we use an "Edit" button instead.

Fix that by swapping the Edit button with a reset button, and
adapt the code to not depend on the edit button anymore.

[1] https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/keyboard/keyboard-wires.png

https://bugzilla.gnome.org/show_bug.cgi?id=777845
2017-01-30 13:24:33 -02:00
Georges Basile Stavracas Neto
8200fa860d keyboard: follow mockups for shortcut change button label
Per the mockups [1], this should be "Set Shortcut…".

[1] https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/keyboard/keyboard-wires.png

https://bugzilla.gnome.org/show_bug.cgi?id=777844
2017-01-30 08:52:37 -02:00
Georges Basile Stavracas Neto
05e03617e1 shortcut-editor: fix headerbar state when adding shortcut
When adding a custom shortcut, the header mode was set to be
only "Cancel". Per mockups, the "Add" button should also be
visible but insensitive.

Fix that by correctly setting the header mode on creation mode.

https://bugzilla.gnome.org/show_bug.cgi?id=777824
2017-01-27 14:20:47 -02:00
Georges Basile Stavracas Neto
4fac9192d8 shortcut-editor: ensure sensitive entries on creation mode
When creating a new shortcut, we currently assume the entries are
sensitive and just show the dialog. This, however, may not be, for
example after previously canceling the editing of a custom shortcut,
leading to a state where the name and command entries are insensitive.

Fix that by always making sure the entries are sensitive when
setting the dialog to creation mode.

https://bugzilla.gnome.org/show_bug.cgi?id=777824
2017-01-27 14:20:47 -02:00
Georges Basile Stavracas Neto
ecf352c1d2 shortcut-editor: untoggle Edit button on cancel
When canceling the editing of a custom shortcut, the "Edit" button
keeps pressed, causing inconsistencies when editing future custom
events.

To reproduce that:
 - Open a custom shortcut and click "Edit"
 - Start typing the new shortcut; the "Cancel" button will appear
 - *Before* completing the new shortcut, click "Cancel"; the dialog will hide
 - Open a custom shortcut again; the "Edit" button is still toggled

Fix that by properly untoggling the Edit button when cancelling
the editing.

https://bugzilla.gnome.org/show_bug.cgi?id=777824
2017-01-27 14:20:47 -02:00
Felipe Borges
696a3cc497 keyboard: Activate search-as-you-type in the scope of the panel
https://bugzilla.gnome.org/show_bug.cgi?id=772564
2016-10-12 07:29:10 +02:00
Bastien Nocera
6c598fa9d1 keyboard: Fix capture of Alt+PrintScreen shortcuts
Alt+PrintScreen gives you Alt+SysRq. Repair the key value to match user
expectations instead.

https://bugzilla.gnome.org/show_bug.cgi?id=772050
2016-10-10 18:10:57 +02:00
Piotr Drąg
9daa1633e9 Disambiguate "Set Shortcut" string with context 2016-09-25 01:59:45 +02:00
Bastien Nocera
510d980431 keyboard: Fix shortcut label in RTL languages
https://bugzilla.gnome.org/show_bug.cgi?id=771110
2016-09-09 16:51:36 +02:00
Bastien Nocera
1ef60c7f06 keyboard: Fix typo in comment
https://bugzilla.gnome.org/show_bug.cgi?id=771124
2016-09-09 16:51:36 +02:00
Yosef Or Boczko
8aae1f1973 Mark another string as translatable 2016-09-09 12:49:45 +03:00
Yosef Or Boczko
3d868c0888 Mark some strings as translatable 2016-09-09 12:36:03 +03:00
Bastien Nocera
45fb0a4feb keyboard: Normalise Shift and Tab in shortcuts
https://bugzilla.gnome.org/show_bug.cgi?id=771058
2016-09-08 17:38:04 +02:00
Florian Müllner
789639004f keyboard: Remove additional filtering of default mod mask
The mask returned by gtk_accelerator_get_default_mod_mask() should
work without additional filtering, in particular when it is overly
restrictive - a lot of shortcuts use the Super modifier nowadays,
so stop filtering it out.

https://bugzilla.gnome.org/show_bug.cgi?id=771058
2016-09-08 17:38:04 +02:00
Florian Müllner
4beb7cefd4 keyboard: Allow Tab in accels
gtk_accelerator_valid() doesn't accept Tab as keyval, so using it to
check whether a shortcut is valid breaks commonly used shortcuts like
Alt+Tab. Unbreak those by adding a small wrapper that special-cases
Tab-with-modifiers.

https://bugzilla.gnome.org/show_bug.cgi?id=771058
2016-09-08 17:38:04 +02:00
Bastien Nocera
784d8f89de keyboard: Don't apply "Backspace" straight away
Before, when pressing "Backspace" in the editing dialogue, the
keybinding would be changed straight away, *behind* the dialogue, and
the dialogue would still be expecting a new shortcut.

Instead, we should make it behave like other shortcuts, which means
special handling empty shortcuts as valid ones.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Bastien Nocera
69258a91a6 keyboard: Add helper to detect empty keybindings
We'll use this shortly.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Bastien Nocera
58b175f351 keyboard: Fix grabs not working when showing the dialog
We couldn't override gnome-shell's keybindings without having a working
grab, but the grab was only started when clicking the "edit" button when
editing a custom shortcut, or *after* receiving the first key press event.

To fix that problem, we need to grab the keyboard once we've shown the
dialog itself, but not in the ->map vfunc, otherwise it will block the
dialog from showing up. We set up a short timeout instead. Hopefully
this isn't too fragile.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Bastien Nocera
141441eb71 keyboard: Don't regrab the keyboard after an event
It was already grabbed if we received the event, so no need to grab it
again.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Bastien Nocera
6c7746abb3 keyboard: Don't rely on events to grab keyboard
Rather than relying on us being in the middle of processing an event to
grab the keyboard, get the keyboard for the first seat of the display.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Bastien Nocera
b10a1ac935 keyboard: Don't grab the mouse pointer
In a0a15588, we starting using a separate shortcut editor window, which
was doing its own capture instead of using the GtkCellRendererAccel. But
this started grabbing both keyboard and pointer, making it impossible to
cancel captures using the pointer.

We now only grab keyboard keys, making the pointer usable again.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Bastien Nocera
b32f58ed00 keyboard: Remove unused variable
grab_device was added in a0a15588 but unused there or since.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
778395f61b shortcut-editor: show custom page while waiting for input
While waiting for keyboard input, as per the new proposed mockup,
the shortcut editor dialog should show a custom page with an icon
that indicates the required action. The current code, however, does
not expose this new customized page.

Fix that by adding this new page and controlling the time when it
shows and hides.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
9c4b27309d shortcut-editor: move widgets into a stack
The stack will be used by the next patches to show
an call for action page.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
cbff1e7b0a shortcut-editor: update reset button position and style
The Reset button, according to the mockups, should be placed
at the right side (left on rtl) of the shortcut label. Also,
rather than a plain string, the button should use a symbolic
icon for 'edit-clear' action.

This patch moves and updates the Reset button to match the
mockups.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
c5cd32f797 shortcut-editor: use a different page to edit custom shortcuts
When adding a new keyboard shortcut, in accordance to the mockups,
the dialog should present a new page calling for an action from the
user.

This patch adds this page, and adapts the code to show it whenever
the user wants to change the shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
a0001b14b5 keyboard: add enter-new-shortcut asset
This is a stub icon shown whenever we want to tell
the user to start typing the new shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
faef0353f3 shortcuts: remove bottom label
https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
4db1337664 shortcut-editor: hide editing dialog on Escape
When editing a standard shortcut, the current code only
cancels the editing on Escape, but doesn't hide the
dialog.

Fix that by properly handling the canceling of shortcut
editing and making sure we always hide the dialog on
cancel.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00