[mutter] util: Move the text direction stuff out of MetaUI



commit f42258327b77f6e74c9b5153a133d5033c7034d4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Aug 17 22:57:51 2014 -0400

    util: Move the text direction stuff out of MetaUI
    
    GTK+ doesn't need to be initialized to get locale direction,
    which means we can do this without bringing up MetaUI at all.

 src/core/keybindings.c |    2 +-
 src/core/prefs.c       |    2 +-
 src/core/util.c        |   14 ++++++++++++++
 src/core/workspace.c   |    4 ++--
 src/meta/util.h        |    8 ++++++++
 src/ui/ui.c            |   10 ----------
 src/ui/ui.h            |    8 --------
 7 files changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 09b389f..f14bcd0 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2900,7 +2900,7 @@ handle_activate_window_menu (MetaDisplay     *display,
       meta_window_get_client_area_rect (display->focus_window, &child_rect);
 
       x = frame_rect.x + child_rect.x;
-      if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
+      if (meta_get_locale_direction () == META_LOCALE_DIRECTION_RTL)
         x += child_rect.width;
 
       y = frame_rect.y + child_rect.y;
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 6fc1162..09d2791 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -1697,7 +1697,7 @@ button_layout_handler (GVariant *value,
   g_strfreev (sides);
 
   /* Invert the button layout for RTL languages */
-  if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
+  if (meta_get_locale_direction() == META_LOCALE_DIRECTION_RTL)
   {
     MetaButtonLayout rtl_layout;
     int j;
diff --git a/src/core/util.c b/src/core/util.c
index ccc1d15..71ff68d 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -946,5 +946,19 @@ meta_later_remove (guint later_id)
     }
 }
 
+MetaLocaleDirection
+meta_get_locale_direction (void)
+{
+  switch (gtk_get_locale_direction ())
+    {
+    case GTK_TEXT_DIR_LTR:
+      return META_LOCALE_DIRECTION_LTR;
+    case GTK_TEXT_DIR_RTL:
+      return META_LOCALE_DIRECTION_RTL;
+    default:
+      g_assert_not_reached ();
+    }
+}
+
 /* eof util.c */
 
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 3447f26..af84eed 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -524,7 +524,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
    meta_screen_calc_workspace_layout (workspace->screen, num_workspaces,
                                       new_space, &layout2);
 
-   if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
+   if (meta_get_locale_direction () == META_LOCALE_DIRECTION_RTL)
      {
        if (layout1.current_col > layout2.current_col)
          direction = META_MOTION_RIGHT;
@@ -1087,7 +1087,7 @@ meta_workspace_get_neighbor (MetaWorkspace      *workspace,
   meta_verbose ("Getting neighbor of %d in direction %s\n",
                 current_space, meta_motion_direction_to_string (direction));
 
-  ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR;
+  ltr = (meta_get_locale_direction () == META_LOCALE_DIRECTION_LTR);
 
   switch (direction)
     {
diff --git a/src/meta/util.h b/src/meta/util.h
index eaa7dd4..8de831b 100644
--- a/src/meta/util.h
+++ b/src/meta/util.h
@@ -181,6 +181,14 @@ guint meta_later_add    (MetaLaterType  when,
                          GDestroyNotify notify);
 void  meta_later_remove (guint          later_id);
 
+typedef enum
+{
+  META_LOCALE_DIRECTION_LTR,
+  META_LOCALE_DIRECTION_RTL,
+} MetaLocaleDirection;
+
+MetaLocaleDirection meta_get_locale_direction (void);
+
 #endif /* META_UTIL_H */
 
 
diff --git a/src/ui/ui.c b/src/ui/ui.c
index d6fbb80..963be7c 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -653,13 +653,3 @@ meta_ui_window_is_widget (MetaUI *ui,
   else
     return FALSE;
 }
-
-MetaUIDirection
-meta_ui_get_direction (void)
-{
-  if (gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL)
-    return META_UI_DIRECTION_RTL;
-
-  return META_UI_DIRECTION_LTR;
-}
-
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 7190295..2dfeead 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -34,12 +34,6 @@ typedef struct _MetaUI MetaUI;
 
 typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data);
 
-typedef enum
-{
-  META_UI_DIRECTION_LTR,
-  META_UI_DIRECTION_RTL
-} MetaUIDirection;
-
 void meta_ui_init (void);
 
 Display* meta_ui_get_display (void);
@@ -123,6 +117,4 @@ gboolean meta_ui_have_a_theme      (void);
 gboolean meta_ui_window_is_widget (MetaUI *ui,
                                    Window  xwindow);
 
-MetaUIDirection meta_ui_get_direction (void);
-
 #endif


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