Merge lp:~tigrangab/slingshot/rtl_fix into lp:~elementary-pantheon/slingshot/trunk

Proposed by Tigran Gabrielyan
Status: Rejected
Rejected by: Cody Garver
Proposed branch: lp:~tigrangab/slingshot/rtl_fix
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 239 lines (+76/-51)
1 file modified
src/SlingshotView.vala (+76/-51)
To merge this branch: bzr merge lp:~tigrangab/slingshot/rtl_fix
Reviewer Review Type Date Requested Status
David Gomes (community) Needs Fixing
Review via email: mp+184029@code.launchpad.net

Description of the change

Needs this granite branch to work correctly: https://code.launchpad.net/~tigrangab/granite/popover_fix/+merge/184027 There's a bug in arrow placement if it needs to be top right.

To post a comment you must log in.
Revision history for this message
Andrea Basso (voluntatefaber) wrote :

I'm afraid that's really not enoguh, RTL goes way deeper than that, whereas your patch could solve the positioning problem, things like page-scrolling and keyboard shortcuts are still hardcoded as in a LTR prospective.

Revision history for this message
Tigran Gabrielyan (tigrangab) wrote :

Wasn't aware there were more issues. I'll install a RTL language to actually test it.

Revision history for this message
Tigran Gabrielyan (tigrangab) wrote :

Can you check it now and make sure I didn't miss anything and it works correctly?

Revision history for this message
Andrea Basso (voluntatefaber) wrote :

I'm currently not at home, so I unfortunately cannot test it.

Just looking at the code, though, are you sure keyboard shortcuts works fine, especially in turning pages?

Revision history for this message
Tigran Gabrielyan (tigrangab) wrote :

No :) I was doing that at 2AM, I'm working on it.

Revision history for this message
Tigran Gabrielyan (tigrangab) wrote :

Shouldn't the first page in RTL still be full?

https://launchpadlibrarian.net/147514797/applications.png That's the first page but only half are full. Is that intended or another RTL bug in slingshot?

Revision history for this message
Andrea Basso (voluntatefaber) wrote :

I'd say that's definitely a bug. And also Slingshot position, I guess you
appear in top-left corner...

Revision history for this message
Tigran Gabrielyan (tigrangab) wrote :

Please test this when you get a chance. If something doesn't work as expected, please let me know how it should work. Thanks.

Revision history for this message
Andrea Basso (voluntatefaber) wrote :

I'll do that as soon as I get back :)
Il giorno 06/set/2013 08:59, "Tigran Gabrielyan" <email address hidden> ha
scritto:

> Please test this when you get a chance. If something doesn't work as
> expected, please let me know how it should work. Thanks.
> --
> https://code.launchpad.net/~tigrangab/slingshot/rtl_fix/+merge/184029
> Your team elementary Pantheon team is requested to review the proposed
> merge of lp:~tigrangab/slingshot/rtl_fix into lp:slingshot.
>

Revision history for this message
David Gomes (davidgomes) wrote :

I need someone to test this or teach me how to. Should I change my language to Hebrew or something?

Revision history for this message
Tigran Gabrielyan (tigrangab) wrote :

I left a note on the PopOver merge request about it. Add setDefaultDirection(Gtk.TextDirection.RTL); in the constructor of SlingshotView.vala. You'll still have English but it will behave RTL-ly

Revision history for this message
David Gomes (davidgomes) wrote :

Remove diff line 236, 73. Add newline after diff line 49. I tested and it worked, good job.

review: Needs Fixing
Revision history for this message
David Gomes (davidgomes) wrote :

This is DEPENDENT on a Granite bug fix which HAS NOT been released on Luna yet. So we can only merge this to stable PPA when Granite gets a push to the stable PPA with that bug fix.

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

Can we merge this now? At least as an Isis-only fix?

Unmerged revisions

381. By Tigran Gabrielyan

Fix RTL key navigation

380. By Tigran Gabrielyan

Fix keyboard and scroll navigation for RTL

379. By Tigran Gabrielyan

Show slingshot on right side of screen if language is RTL

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/SlingshotView.vala'
--- src/SlingshotView.vala 2013-09-04 19:08:08 +0000
+++ src/SlingshotView.vala 2013-09-06 06:54:15 +0000
@@ -61,6 +61,9 @@
61 private int search_view_position = 0;61 private int search_view_position = 0;
62 private Modality modality;62 private Modality modality;
6363
64 // Used for RTL support
65 private int direction = 1;
66
64 // Sizes67 // Sizes
65 public int columns {68 public int columns {
66 get {69 get {
@@ -111,6 +114,10 @@
111 setup_ui ();114 setup_ui ();
112 connect_signals ();115 connect_signals ();
113116
117 if (get_default_direction () == Gtk.TextDirection.RTL) {
118 direction = -1;
119 }
120
114 debug ("Apps loaded");121 debug ("Apps loaded");
115122
116 }123 }
@@ -281,17 +288,19 @@
281288
282 }289 }
283290
284 private void reposition (bool show=true) {291 private void reposition (bool show = true) {
285
286 debug("Repositioning");292 debug("Repositioning");
287 293
294 var direction = get_default_direction ();
288 Gdk.Rectangle monitor_dimensions, app_launcher_pos;295 Gdk.Rectangle monitor_dimensions, app_launcher_pos;
289 screen.get_monitor_geometry (this.screen.get_primary_monitor(), out monitor_dimensions);296 screen.get_monitor_geometry (this.screen.get_primary_monitor(), out monitor_dimensions);
290 app_launcher_pos = Gdk.Rectangle () { x = monitor_dimensions.x,297
291 y = monitor_dimensions.y,298 app_launcher_pos = Gdk.Rectangle () {
292 width = 100,299 x = (direction == Gtk.TextDirection.RTL) ? monitor_dimensions.width : monitor_dimensions.x,
293 height = 30300 y = monitor_dimensions.y,
294 };301 width = 100,
302 height = 30
303 };
295 move_to_rect (app_launcher_pos, show);304 move_to_rect (app_launcher_pos, show);
296 }305 }
297306
@@ -391,15 +400,17 @@
391 case "Left":400 case "Left":
392 if (modality == Modality.NORMAL_VIEW) {401 if (modality == Modality.NORMAL_VIEW) {
393 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Left402 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Left
394 page_switcher.set_active (page_switcher.active - 1);403 page_switcher.set_active (page_switcher.active - direction);
395 else404 else
396 normal_move_focus (-1, 0);405 normal_move_focus (-direction, 0);
397 } else if (modality == Modality.CATEGORY_VIEW) {406 } else if (modality == Modality.CATEGORY_VIEW) {
398 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Left407 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Left
399 category_view.switcher.set_active (category_view.switcher.active - 1);408 category_view.switcher.set_active (category_view.switcher.active - direction);
400 else if (!searchbar.has_focus) {//the user has already selected an AppEntry409 else if (searchbar.has_focus && direction == -1) // there's no AppEntry selected, the user is switching category
401 category_move_focus (-1, 0);410 top_left_focus ();
402 }411 else
412 category_move_focus (-direction, 0);
413
403 } else414 } else
404 return base.key_press_event (event);415 return base.key_press_event (event);
405 break;416 break;
@@ -407,16 +418,16 @@
407 case "Right":418 case "Right":
408 if (modality == Modality.NORMAL_VIEW) {419 if (modality == Modality.NORMAL_VIEW) {
409 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Right420 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Right
410 page_switcher.set_active (page_switcher.active + 1);421 page_switcher.set_active (page_switcher.active + direction);
411 else422 else
412 normal_move_focus (+1, 0);423 normal_move_focus (direction, 0);
413 } else if (modality == Modality.CATEGORY_VIEW) {424 } else if (modality == Modality.CATEGORY_VIEW) {
414 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Right425 if (event.state == Gdk.ModifierType.SHIFT_MASK) // Shift + Right
415 category_view.switcher.set_active (category_view.switcher.active + 1);426 category_view.switcher.set_active (category_view.switcher.active + direction);
416 else if (searchbar.has_focus) // there's no AppEntry selected, the user is switching category427 else if (searchbar.has_focus && direction == 1) // there's no AppEntry selected, the user is switching category
417 top_left_focus ();428 top_left_focus ();
418 else //the user has already selected an AppEntry429 else //the user has already selected an AppEntry
419 category_move_focus (+1, 0);430 category_move_focus (direction, 0);
420 } else {431 } else {
421 return base.key_press_event (event);432 return base.key_press_event (event);
422 }433 }
@@ -463,7 +474,7 @@
463474
464 case "Page_Up":475 case "Page_Up":
465 if (modality == Modality.NORMAL_VIEW) {476 if (modality == Modality.NORMAL_VIEW) {
466 page_switcher.set_active (page_switcher.active - 1);477 page_switcher.set_active (page_switcher.active - direction);
467 if (page_switcher.active != 0) // we don't wanna lose focus if we don't actually change page478 if (page_switcher.active != 0) // we don't wanna lose focus if we don't actually change page
468 searchbar.grab_focus (); // this is because otherwise focus isn't the current page479 searchbar.grab_focus (); // this is because otherwise focus isn't the current page
469 } else if (modality == Modality.CATEGORY_VIEW) {480 } else if (modality == Modality.CATEGORY_VIEW) {
@@ -474,7 +485,7 @@
474485
475 case "Page_Down":486 case "Page_Down":
476 if (modality == Modality.NORMAL_VIEW) {487 if (modality == Modality.NORMAL_VIEW) {
477 page_switcher.set_active (page_switcher.active + 1);488 page_switcher.set_active (page_switcher.active + direction);
478 if (page_switcher.active != grid_view.get_n_pages () - 1) // we don't wanna lose focus if we don't actually change page489 if (page_switcher.active != grid_view.get_n_pages () - 1) // we don't wanna lose focus if we don't actually change page
479 searchbar.grab_focus (); //this is because otherwise focus isn't the current page490 searchbar.grab_focus (); //this is because otherwise focus isn't the current page
480 } else if (modality == Modality.CATEGORY_VIEW) {491 } else if (modality == Modality.CATEGORY_VIEW) {
@@ -542,32 +553,33 @@
542553
543 }554 }
544555
556 private void scroll_page (int direction) {
557 if (modality == Modality.NORMAL_VIEW) {
558 page_switcher.set_active (page_switcher.active + direction);
559 } else if (modality == Modality.SEARCH_VIEW) {
560 if (direction == this.direction) {
561 search_view_up ();
562 } else {
563 search_view_down ();
564 }
565 } else {
566 category_view.switcher.set_active (category_view.switcher.active + direction);
567 }
568 }
569
545 public override bool scroll_event (EventScroll event) {570 public override bool scroll_event (EventScroll event) {
546
547 switch (event.direction.to_string ()) {571 switch (event.direction.to_string ()) {
548 case "GDK_SCROLL_UP":572 case "GDK_SCROLL_UP":
549 case "GDK_SCROLL_LEFT":573 case "GDK_SCROLL_LEFT":
550 if (modality == Modality.NORMAL_VIEW)574 scroll_page (-direction);
551 page_switcher.set_active (page_switcher.active - 1);
552 else if (modality == Modality.SEARCH_VIEW)
553 search_view_up ();
554 else
555 category_view.switcher.set_active (category_view.switcher.active - 1);
556 break;575 break;
557 case "GDK_SCROLL_DOWN":576 case "GDK_SCROLL_DOWN":
558 case "GDK_SCROLL_RIGHT":577 case "GDK_SCROLL_RIGHT":
559 if (modality == Modality.NORMAL_VIEW)578 scroll_page (direction);
560 page_switcher.set_active (page_switcher.active + 1);
561 else if (modality == Modality.SEARCH_VIEW)
562 search_view_down ();
563 else
564 category_view.switcher.set_active (category_view.switcher.active + 1);
565 break;579 break;
566
567 }580 }
568581
569 return false;582 return false;
570
571 }583 }
572584
573 public void show_slingshot () {585 public void show_slingshot () {
@@ -590,34 +602,40 @@
590 Wnck.Screen.get_default ().force_update ();602 Wnck.Screen.get_default ().force_update ();
591 if (w != null)603 if (w != null)
592 w.activate (Gdk.x11_get_server_time (this.get_window ()));604 w.activate (Gdk.x11_get_server_time (this.get_window ()));
593 }605 }
594606
595 private void move_page (int step) {607 private void move_page (int step) {
596
597 debug ("Moving: step = " + step.to_string ());608 debug ("Moving: step = " + step.to_string ());
598 609
599 if (step == 0)610 if (step == 0)
600 return;611 return;
601 if (step < 0 && current_position >= 0) //Left border612
602 return;613 int max_position = (grid_view.get_n_pages () - 1) * grid_view.get_page_columns () * 130;
603 if (step > 0 && (-current_position) >= ((grid_view.get_n_pages () - 1) * grid_view.get_page_columns () * 130)) //Right border614
604 return;615 if (step < 0) {
605 616 if ((direction == 1 && current_position >= 0) || (direction == -1 && current_position <= -max_position)) {
617 return;
618 }
619 } else {
620 if ((direction == 1 && current_position <= -max_position) || (direction == -1 && current_position >= 0)) {
621 return;
622 }
623 }
624
606 int count = 0;625 int count = 0;
607 int increment = -step*130*columns/10;626 int increment = -step * 130 * columns / 10 * direction;
608 Timeout.add (30/columns, () => {
609627
628 Timeout.add (30 / columns, () => {
610 if (count >= 10) {629 if (count >= 10) {
611 current_position += -step*130*columns - 10*increment; //We adjust to end of the page630 current_position += -step * 130 * columns - 10 * increment * direction; //We adjust to end of the page
612 view_manager.move (grid_view, current_position, 0);631 view_manager.move (grid_view, current_position, 0);
613 return false;632 return false;
614 }633 }
615 634
616 current_position += increment;635 current_position += increment;
617 view_manager.move (grid_view, current_position, 0);636 view_manager.move (grid_view, current_position, 0);
618 count++;637 count++;
619 return true;638 return true;
620
621 }, Priority.DEFAULT_IDLE);639 }, Priority.DEFAULT_IDLE);
622 }640 }
623641
@@ -744,10 +762,17 @@
744 grid_view.append (app_entry);762 grid_view.append (app_entry);
745 app_entry.show_all ();763 app_entry.show_all ();
746 }764 }
747 765
748 view_manager.move (grid_view, 0, 0);
749 current_position = 0;766 current_position = 0;
750767
768 if (get_default_direction () == Gtk.TextDirection.RTL) {
769 int width;
770 view_manager.get_size_request (out width, null);
771 current_position = (grid_view.get_n_pages () - 1) * width * -1;
772 }
773
774 view_manager.move (grid_view, current_position, 0);
775
751 }776 }
752777
753 private void read_settings (bool first_start = false, bool check_columns = true, bool check_rows = true) {778 private void read_settings (bool first_start = false, bool check_columns = true, bool check_rows = true) {

Subscribers

People subscribed via source and target branches