[PATCH] Use gtk_get_locale_direction.

David Shea dshea at redhat.com
Wed Jan 15 15:39:37 UTC 2014


Gtk now provides a function to determine the current locale's text
direction.
---
 configure.ac                                       |  2 +-
 .../ui/gui/spokes/lib/lang_locale_handler.py       |  4 ++--
 pyanaconda/ui/gui/utils.py                         | 22 +---------------------
 widgets/src/MountpointSelector.c                   | 11 +----------
 4 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0492d6e..6d689ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,7 +147,7 @@ PKG_PROG_PKG_CONFIG([0.23])
 PKG_CHECK_MODULES([X11], [x11 >= 1.3])
 PKG_CHECK_MODULES([XCOMPOSITE], [xcomposite >= 0.4.1])
 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16.1])
-PKG_CHECK_MODULES([GTK_X11], [gtk+-x11-3.0 >= 3.11.2])
+PKG_CHECK_MODULES([GTK_X11], [gtk+-x11-3.0 >= 3.11.3])
 PKG_CHECK_MODULES([GDK], [gdk-3.0])
 PKG_CHECK_MODULES([NETWORKMANAGER], [NetworkManager >= 0.7.1])
 PKG_CHECK_MODULES([LIBNM_GLIB], [libnm-glib >= 0.7.1 libnm-util >= 0.7.1])
diff --git a/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py b/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py
index de13e60..5e4d9de 100644
--- a/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py
+++ b/pyanaconda/ui/gui/spokes/lib/lang_locale_handler.py
@@ -28,7 +28,7 @@ import os
 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, get_default_widget_direction, timed_action
+from pyanaconda.ui.gui.utils import set_treeview_selection, timed_action
 
 class LangLocaleHandler(object):
     """
@@ -56,7 +56,7 @@ class LangLocaleHandler(object):
     def initialize(self):
         # Render an arrow for the chosen language
         datadir = os.environ.get("ANACONDA_WIDGETS_DATADIR", "/usr/share/anaconda")
-        if get_default_widget_direction() == Gtk.TextDirection.LTR:
+        if Gtk.get_locale_direction() == Gtk.TextDirection.LTR:
             self._arrow = Gtk.Image.new_from_file(os.path.join(datadir, "pixmaps", "right-arrow-icon.png"))
         else:
             self._arrow = Gtk.Image.new_from_file(os.path.join(datadir, "pixmaps", "left-arrow-icon.png"))
diff --git a/pyanaconda/ui/gui/utils.py b/pyanaconda/ui/gui/utils.py
index ae7eac5..1f73928 100644
--- a/pyanaconda/ui/gui/utils.py
+++ b/pyanaconda/ui/gui/utils.py
@@ -27,7 +27,6 @@ from pyanaconda.constants import NOTICEABLE_FREEZE
 from contextlib import contextmanager
 from gi.repository import Gdk, Gtk, GLib, AnacondaWidgets
 import Queue
-import gettext
 import time
 import threading
 
@@ -379,25 +378,6 @@ def set_treeview_selection(treeview, item, col=0):
 
     return itr
 
-def get_default_widget_direction():
-    """
-    Function to get default widget direction (RTL/LTR) for the current language
-    configuration.
-
-    XXX: this should be provided by the Gtk itself (#1008821)
-
-    :return: either Gtk.TextDirection.LTR or Gtk.TextDirection.RTL
-    :rtype: GtkTextDirection
-
-    """
-
-    # this is quite a hack, but it's exactly the same check Gtk uses internally
-    xlated = gettext.ldgettext("gtk30", "default:LTR")
-    if xlated == "default:LTR":
-        return Gtk.TextDirection.LTR
-    else:
-        return Gtk.TextDirection.RTL
-
 def setup_gtk_direction():
     """
     Set the right direction (RTL/LTR) of the Gtk widget's and their layout based
@@ -405,7 +385,7 @@ def setup_gtk_direction():
 
     """
 
-    Gtk.Widget.set_default_direction(get_default_widget_direction())
+    Gtk.Widget.set_default_direction(Gtk.get_locale_direction())
 
 def escape_markup(value):
     """
diff --git a/widgets/src/MountpointSelector.c b/widgets/src/MountpointSelector.c
index 24a0855..ea7ce17 100644
--- a/widgets/src/MountpointSelector.c
+++ b/widgets/src/MountpointSelector.c
@@ -167,15 +167,6 @@ 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) {
     gchar *file;
 
@@ -202,7 +193,7 @@ 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.
      */
-    if (get_default_widget_direction() == GTK_TEXT_DIR_LTR)
+    if (gtk_get_locale_direction() == GTK_TEXT_DIR_LTR)
         file = g_strdup_printf("%s/pixmaps/right-arrow-icon.png", get_widgets_datadir());
     else
         file = g_strdup_printf("%s/pixmaps/left-arrow-icon.png", get_widgets_datadir());
-- 
1.8.5.2



More information about the anaconda-patches mailing list