[gnome-shell] Make the search entry behave better in RTL locales



commit 1b6090fe1396df566c0b9049c79ba3521ec5e950
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Aug 26 18:24:26 2013 -0400

    Make the search entry behave better in RTL locales
    
    It is expected that the primary and secondary icons in entries
    change places in RTL locales. When doing so, the edit-clear
    icon must be replaced by an rtl variant too.
    
    http://bugzilla.gnome.org/show_bug.cgi?id=705779

 js/ui/viewSelector.js |    8 ++++++--
 src/st/st-entry.c     |   36 ++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index a78a9f7..3cfa5cd 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -85,8 +85,12 @@ const ViewSelector = new Lang.Class({
 
         this._entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
                                                    icon_name: 'edit-find-symbolic' }));
-        this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
-                                        icon_name: 'edit-clear-symbolic' });
+        if (this._entry.get_text_direction() == Clutter.TextDirection.RTL)
+            this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
+                                            icon_name: 'edit-clear-rtl-symbolic' });
+        else
+            this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
+                                            icon_name: 'edit-clear-symbolic' });
 
         this._iconClickedId = 0;
         this._capturedEventId = 0;
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index 6aa4dc3..ed5f303 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -416,6 +416,18 @@ st_entry_allocate (ClutterActor          *actor,
   ClutterActorBox content_box, child_box, icon_box;
   gfloat icon_w, icon_h;
   gfloat entry_h, min_h, pref_h, avail_h;
+  ClutterActor *left_icon, *right_icon;
+
+  if (clutter_actor_get_text_direction (actor) == CLUTTER_TEXT_DIRECTION_RTL)
+    {
+      right_icon = priv->primary_icon;
+      left_icon = priv->secondary_icon;
+    }
+  else
+    {
+      left_icon = priv->primary_icon;
+      right_icon = priv->secondary_icon;
+    }
 
   clutter_actor_set_allocation (actor, box, flags);
 
@@ -426,12 +438,10 @@ st_entry_allocate (ClutterActor          *actor,
   child_box.x1 = content_box.x1;
   child_box.x2 = content_box.x2;
 
-  if (priv->primary_icon)
+  if (left_icon)
     {
-      clutter_actor_get_preferred_width (priv->primary_icon,
-                                         -1, NULL, &icon_w);
-      clutter_actor_get_preferred_height (priv->primary_icon,
-                                          -1, NULL, &icon_h);
+      clutter_actor_get_preferred_width (left_icon, -1, NULL, &icon_w);
+      clutter_actor_get_preferred_height (left_icon, -1, NULL, &icon_h);
 
       icon_box.x1 = content_box.x1;
       icon_box.x2 = icon_box.x1 + icon_w;
@@ -439,20 +449,16 @@ st_entry_allocate (ClutterActor          *actor,
       icon_box.y1 = (int) (content_box.y1 + avail_h / 2 - icon_h / 2);
       icon_box.y2 = icon_box.y1 + icon_h;
 
-      clutter_actor_allocate (priv->primary_icon,
-                              &icon_box,
-                              flags);
+      clutter_actor_allocate (left_icon, &icon_box, flags);
 
       /* reduce the size for the entry */
       child_box.x1 += icon_w + priv->spacing;
     }
 
-  if (priv->secondary_icon)
+  if (right_icon)
     {
-      clutter_actor_get_preferred_width (priv->secondary_icon,
-                                         -1, NULL, &icon_w);
-      clutter_actor_get_preferred_height (priv->secondary_icon,
-                                          -1, NULL, &icon_h);
+      clutter_actor_get_preferred_width (right_icon, -1, NULL, &icon_w);
+      clutter_actor_get_preferred_height (right_icon, -1, NULL, &icon_h);
 
       icon_box.x2 = content_box.x2;
       icon_box.x1 = icon_box.x2 - icon_w;
@@ -460,9 +466,7 @@ st_entry_allocate (ClutterActor          *actor,
       icon_box.y1 = (int) (content_box.y1 + avail_h / 2 - icon_h / 2);
       icon_box.y2 = icon_box.y1 + icon_h;
 
-      clutter_actor_allocate (priv->secondary_icon,
-                              &icon_box,
-                              flags);
+      clutter_actor_allocate (right_icon, &icon_box, flags);
 
       /* reduce the size for the entry */
       child_box.x2 -= icon_w - priv->spacing;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]