Commit graph

349 commits

Author SHA1 Message Date
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
Georges Basile Stavracas Neto
40ee225385 shortcut-editor: use states to handle headerbar mode
Instead of manually handling every button in the headerbar
individually, using states to switch between modes. It's clearer
and easier to maintain.

This patch adds the headerbar mode handling code, and updates
the current code to use it rather than by updating each individual
button manually.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
472959657b shortcut-editor: add 'Set' button
The Set button will be used to update a standard
shortcut.

This patch adds it to the headerbar.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
5637d573a6 shortcut-editor: update header title message
Instead of showing the shortcut description, show an
action-oriented title, according to the mockups. Precisely,
"Set Shortcut" for standard shortcuts and "Set Custom
Shortcut" for custom shortcuts.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
199ba17258 keyboard: use a better icon to represent "Reset Shortcut"
The current button to reset shortcuts is represented by the
'x' icon, which induces the user to think this is a remove
button rather then a reset button.

Fix that by using edit-clear-symbolic icon to represent the
reset action.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
d8d85bae12 keyboard: make Add button insensitive after editing
When creating a new keyboard shortcut, the Add button gets
sensitive when all the fields are valid. If the user tries
to create a new shortcut right after closing the shortcut
editor dialog, the Add button is still sensitive even with
invalid custom fields.

Fix that by making the Add button sensitive whenever we
finish editing the new custom shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
cf3ff886ca keyboard: change standard shortcut top label
Per feedback, the current call-to-action label isn't very clear
and is too long.

Fix that by rewording the label.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-08 17:12:17 +02:00
Georges Basile Stavracas Neto
b39bc93600 keyboard: fix list sizes with latest Gtk+
Gtk+ changed again the behavior of the scrolled window,
fixing the weird height issue but introducing a new issue
where the keyboard shortcut list doesn't expand horizontally
nor allocates the correct size vertically.

Fortunately, this is easily solvable with the newly introduced
GtkScrolledWindow:propagate-natural-width and -height
properties.

Fix the misbehavior by setting the new properties to sane
values.

https://bugzilla.gnome.org/show_bug.cgi?id=769314
2016-09-07 14:26:29 +02:00
Georges Basile Stavracas Neto
00f1b53abb keyboard: make sure to retrieve the correct type from variants
When comparing the keyboard shortcut's default and current
values, we double-check what kind of variant the default
value is, but don't check that for the user value.

This ends up throwing lots of variant-related warnings, as
the user value may not be a plain string.

Fix that by checking the variant types both for the user and
the default value of the shortcut's settings.

https://bugzilla.gnome.org/show_bug.cgi?id=769310
2016-07-29 19:32:51 +02:00
Georges Basile Stavracas Neto
ab8721fc04 keyboard: add search support
Based on the latest mockups, the Keyboard panel would
benefit from a search functionality.

This patch add all the necessary UI and functions to
make the search work. Worth noticing that the current
implementation still doesn't work with search-as-you-type,
which'll be addressed on a future fix.

https://bugzilla.gnome.org/show_bug.cgi?id=769063
2016-07-29 13:48:31 -03:00
Georges Basile Stavracas Neto
7b877bc33f keyboard: bring back reverse item management
In order to simplify the porting to the new UI, the
reverse item functionality was removed. Now that all
the necessary code landed, it is time to bring it back.

This patch adds back the ability to manage reverse items.

https://bugzilla.gnome.org/show_bug.cgi?id=769063
2016-07-29 13:48:31 -03:00
Georges Basile Stavracas Neto
d0c32c38a3 keyboard: remove unused code
CcKeyboardItem overrides GObject:constructor with an
empty function that only hooks up with the parent
constructor.

https://bugzilla.gnome.org/show_bug.cgi?id=769063
2016-07-29 13:48:31 -03:00
Georges Basile Stavracas Neto
1c85479742 keyboard: add support to reset shortcuts to their default values
Following the proposed mockups, the shortcut list must
have the ability to reset modified to non-default shortcuts
right from the listbox.

After adding the necessary API in CcKeyboardItem, adding
the user-visible elements to enable that is easy.

To make that happen, add a button that resets the
keyboard shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=769063
2016-07-29 13:48:31 -03:00