[PATCH 2/2] Render the right arrow based on the widget direction (#1008397)

Vratislav Podzimek vpodzime at redhat.com
Tue Sep 17 07:47:55 UTC 2013


LTR langauges should have a right arrow, RTL languages should have a left arrow.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 data/pixmaps/left-arrow-icon.png                    | Bin 0 -> 286 bytes
 pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py |   9 ++++++---
 widgets/src/MountpointSelector.c                    |  15 ++++++++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 data/pixmaps/left-arrow-icon.png

diff --git a/data/pixmaps/left-arrow-icon.png b/data/pixmaps/left-arrow-icon.png
new file mode 100644
index 0000000..fc25a91
Binary files /dev/null and b/data/pixmaps/left-arrow-icon.png differ

diff --git a/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py b/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py
index dea6bef..86c2cd0 100644
--- a/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py
+++ b/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py
@@ -27,7 +27,7 @@ screens handling languages or locales configuration.
 from gi.repository import Gtk, Pango
 from pyanaconda import localization
 from pyanaconda.iutil import strip_accents
-from pyanaconda.ui.gui.utils import set_treeview_selection
+from pyanaconda.ui.gui.utils import set_treeview_selection, get_default_widget_direction
 
 class LangLocaleHandler(object):
     """
@@ -51,8 +51,11 @@ class LangLocaleHandler(object):
         self._localeSelection = None
 
     def initialize(self):
-        # Render a right arrow for the chosen language
-        self._right_arrow = Gtk.Image.new_from_file("/usr/share/anaconda/pixmaps/right-arrow-icon.png")
+        # Render an arrow for the chosen language
+        if get_default_widget_direction() == Gtk.TextDirection.LTR:
+            self._right_arrow = Gtk.Image.new_from_file("/usr/share/anaconda/pixmaps/right-arrow-icon.png")
+        else:
+            self._right_arrow = Gtk.Image.new_from_file("/usr/share/anaconda/pixmaps/left-arrow-icon.png")
         self._langSelectedColumn.set_cell_data_func(self._langSelectedRenderer,
                                                     self._render_lang_selected)
 
diff --git a/widgets/src/MountpointSelector.c b/widgets/src/MountpointSelector.c
index 726b42e..9c8e61c 100644
--- a/widgets/src/MountpointSelector.c
+++ b/widgets/src/MountpointSelector.c
@@ -21,6 +21,7 @@
 #include <gdk/gdk.h>
 #include <glib.h>
 #include <glib/gstdio.h>
+#include <gettext.h>
 
 #include "MountpointSelector.h"
 #include "intl.h"
@@ -166,6 +167,15 @@ static void format_name_label(AnacondaMountpointSelector *widget, const char *va
     g_free(markup);
 }
 
+/* XXX: this should be provided by the Gtk itself (#1008821) */
+static GtkTextDirection get_default_widget_direction() {
+    const char *xlated = g_dgettext("gtk30", "default:LTR");
+    if (strcmp (xlated, "default:RTL") == 0)
+        return GTK_TEXT_DIR_RTL;
+    else
+        return GTK_TEXT_DIR_LTR;
+}
+
 static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountpoint) {
     mountpoint->priv = G_TYPE_INSTANCE_GET_PRIVATE(mountpoint,
                                                    ANACONDA_TYPE_MOUNTPOINT_SELECTOR,
@@ -192,7 +202,10 @@ static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountp
      * gtk_image_new_from_file will just display a broken image icon in that
      * case.  That's good enough error notification.
      */
-    mountpoint->priv->arrow = gtk_image_new_from_file("/usr/share/anaconda/pixmaps/right-arrow-icon.png");
+    if (get_default_widget_direction() == GTK_TEXT_DIR_LTR)
+        mountpoint->priv->arrow = gtk_image_new_from_file("/usr/share/anaconda/pixmaps/right-arrow-icon.png");
+    else
+        mountpoint->priv->arrow = gtk_image_new_from_file("/usr/share/anaconda/pixmaps/left-arrow-icon.png");
     gtk_widget_set_no_show_all(GTK_WIDGET(mountpoint->priv->arrow), TRUE);
 
     /* Set some properties. */
-- 
1.7.11.7



More information about the anaconda-patches mailing list