Skip to content

Correct RTL accelerator arrow keys#2797

Open
stan-janssen wants to merge 4 commits into
elementary:mainfrom
stan-janssen:correct-rtl-accelerator-arrow-keys
Open

Correct RTL accelerator arrow keys#2797
stan-janssen wants to merge 4 commits into
elementary:mainfrom
stan-janssen:correct-rtl-accelerator-arrow-keys

Conversation

@stan-janssen
Copy link
Copy Markdown

@stan-janssen stan-janssen commented May 24, 2026

This corrects accelerators that include a Left or Right arrow key when using a Right-to-Left (RTL) language, where UI elements are draw from right to left.

This includes:

  • switching focus between the sidebar and the main tab view (the sidebar is on the right side in an RTL situation);
  • the 'drill down' and 'drill up' keys when navigating in list or Miller views;
  • the arrow keys for selecting the previous and next icon in icon view (the icons are also drawn right to left, with the 'next' icon being on the left of the 'previous' icon in an RTL situation;
  • the 'back' and 'forward' actions that map to the buttons in the navigation bar (including the tooltips for these buttons)

(This PR includes the commits from PR #2796 )

@stan-janssen stan-janssen marked this pull request as draft May 24, 2026 14:54
@stan-janssen stan-janssen force-pushed the correct-rtl-accelerator-arrow-keys branch 2 times, most recently from 4ebfe09 to 3730615 Compare May 24, 2026 15:07
@stan-janssen stan-janssen marked this pull request as ready for review May 24, 2026 15:11
Comment thread src/View/IconView.vala Outdated

uint prev_key;
uint next_key;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace

Comment thread src/View/IconView.vala Outdated
@@ -244,10 +244,22 @@ public class Files.IconView : Files.AbstractDirectoryView {
/* Override native Gtk.IconView cursor handling */
protected override bool move_cursor (uint keyval, bool only_shift_pressed, bool control_pressed) {
Gtk.TreePath? path = get_path_at_cursor ();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this next to the clause that uses it

Comment thread src/View/IconView.vala Outdated
/* Override native Gtk.IconView cursor handling */
protected override bool move_cursor (uint keyval, bool only_shift_pressed, bool control_pressed) {
Gtk.TreePath? path = get_path_at_cursor ();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace

Comment thread src/View/ListView.vala Outdated
protected override bool on_view_key_press_event (uint keyval, uint keycode, Gdk.ModifierType state) {
uint up_key;
uint down_key;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace

Copy link
Copy Markdown
Contributor

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some whitespace I would consider superfluous. I try not to leave space between a variable declaration and where it used. Not all existing code may comply!

I have not tested this yet but looks like it does not fully cope with a change in LTR/RTL state "on the fly" as the shortcuts are set up on construction. May be better to have fixed shortcuts (e.g. for action-focus-left and action-focus-right) and deal with the state in the handlers. Not sure how important this is in practice though.

@stan-janssen
Copy link
Copy Markdown
Author

Thanks for the review. I'll remove the superfluous whitespace (I'm not completely "fluent" yet in the code style of the project, so thanks for pointing these things out).

it does not fully cope with a change in LTR/RTL state "on the fly" as the shortcuts are set up on construction

The left/right arrow keys for ascending and descending through the hierarchy and for navigating through Icon view do change "on the fly", but the ones for focusing different areas and the ones for Forward / Back do not.

I'm not aware of a use case for changing these things on the fly (I think it can only be done using the interactive debugger?) so I don't think it's a big issue myself.

This corrects accelerators that include a Left or Right arrow key when
using a Right-to-Left (RTL) language, where UI elements are draw from
right to left.

This includes switching focus to the sidebar, which is on the right side
in an RTL situation, as well as the 'drill down' and 'drill up' keys
when navigating in list or Miller views, and the arrow keys for
selecting the previous and next icon in icon view (the icons are also
drawn right to left, with the 'next' icon being on the left of the
'previous' icon in an RTL situation.

This also matches the directions of the arrow buttons in the tool bar.
@stan-janssen stan-janssen force-pushed the correct-rtl-accelerator-arrow-keys branch from 3730615 to 8be84dd Compare May 24, 2026 18:52
@jeremypw
Copy link
Copy Markdown
Contributor

Yes, you are probably right that its not a problem in practice. I tried switching to an RTL language and although some widgets (e.g. TextView) start typing RTL, the layout of widgets does not change. I guess you either need to use the interactive debugger or change the system locale in settings (needing a new session). I'll test tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants