[gtk/wip/otte/icontheme: 1/9] icontheme: Make text direction a lookup argument



commit e379dc10a03e8dd3748585ff90f76ce44651f0b2
Author: Benjamin Otte <otte redhat com>
Date:   Sun Feb 2 00:27:14 2020 +0100

    icontheme: Make text direction a lookup argument
    
    Most users were just forgetting to set the proper flags.
    And flags aren't the right way to set this anyway, it was just
    acceptable as a workaround during GTK3 to not break API.

 demos/gtk-demo/clipboard.c          |   6 +-
 demos/gtk-demo/textview.c           |   4 +-
 demos/icon-browser/iconbrowserwin.c |  11 +-
 gtk/gtkbuilder.c                    |   1 +
 gtk/gtkcalendar.c                   |   7 +-
 gtk/gtkcssimageicontheme.c          |   2 +
 gtk/gtkdragsource.c                 |   7 +-
 gtk/gtkiconhelper.c                 |  18 ++--
 gtk/gtkicontheme.c                  |  31 ++++--
 gtk/gtkicontheme.h                  |   7 +-
 gtk/gtkmountoperation.c             |   6 +-
 gtk/gtkwindow.c                     |   3 +
 tests/testclipboard2.c              |   4 +-
 tests/testdnd2.c                    |  16 ++-
 tests/testicontheme.c               |  11 +-
 testsuite/gtk/check-icon-names.c    |   2 +-
 testsuite/gtk/icontheme.c           | 204 ++++++++++++++++++++++--------------
 17 files changed, 221 insertions(+), 119 deletions(-)
---
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index 5708b888c4..2edd61c462 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -107,7 +107,11 @@ get_image_paintable (GtkImage *image)
     case GTK_IMAGE_ICON_NAME:
       icon_name = gtk_image_get_icon_name (image);
       icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
-      icon = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, 1, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+      icon = gtk_icon_theme_lookup_icon (icon_theme,
+                                         icon_name,
+                                         48, 1,
+                                         gtk_widget_get_direction (GTK_WIDGET (image)),
+                                         GTK_ICON_LOOKUP_GENERIC_FALLBACK);
       if (icon == NULL)
         return NULL;
       return GDK_PAINTABLE (icon);
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index 395bd155f0..cdc9e1b6d4 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -126,6 +126,7 @@ create_tags (GtkTextBuffer *buffer)
 static void
 insert_text (GtkTextView *view)
 {
+  GtkWidget *widget = GTK_WIDGET (view);
   GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
   GtkTextIter iter;
   GtkTextIter start, end;
@@ -133,10 +134,11 @@ insert_text (GtkTextView *view)
   GtkIconTheme *icon_theme;
   GtkIcon *icon;
 
-  icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (view)));
+  icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
   icon = gtk_icon_theme_lookup_icon (icon_theme,
                                      "gtk3-demo",
                                      32, 1,
+                                     gtk_widget_get_direction (widget),
                                      GTK_ICON_LOOKUP_GENERIC_FALLBACK);
   texture = gtk_icon_download_texture (icon, NULL);
   g_object_unref (icon);
diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c
index d40f1a8364..c133a3ee64 100644
--- a/demos/icon-browser/iconbrowserwin.c
+++ b/demos/icon-browser/iconbrowserwin.c
@@ -367,7 +367,10 @@ get_image_paintable (GtkImage *image)
       icon_name = gtk_image_get_icon_name (image);
       size = gtk_image_get_pixel_size (image);
       icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
-      icon = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size, 1,
+      icon = gtk_icon_theme_lookup_icon (icon_theme,
+                                         icon_name,
+                                         size, 1,
+                                         gtk_widget_get_direction (GTK_WIDGET (image)),
                                          GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
       if (icon == NULL)
         return NULL;
@@ -420,7 +423,11 @@ get_file (GValue   *value,
   name = gtk_image_get_icon_name (GTK_IMAGE (data));
   icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (data)));
 
-  info = gtk_icon_theme_lookup_icon (icon_theme, name, 32, 1, 0);
+  info = gtk_icon_theme_lookup_icon (icon_theme,
+                                     name,
+                                     32, 1,
+                                     gtk_widget_get_direction (GTK_WIDGET (data)),
+                                     0);
   file = g_file_new_for_path (gtk_icon_get_filename (info));
   g_value_set_object (value, file);
   g_object_unref (file);
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index c400799dfe..d6e38b92c6 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -2172,6 +2172,7 @@ gtk_builder_value_from_string_type (GtkBuilder   *builder,
               theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
 
               icon = gtk_icon_theme_lookup_icon (theme, "image-missing", 16, 1,
+                                                 GTK_TEXT_DIR_NONE,
                                                  GTK_ICON_LOOKUP_USE_BUILTIN);
               texture = gtk_icon_download_texture (icon, NULL);
               pixbuf = gdk_pixbuf_get_from_texture (texture);
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index 928a5513b5..837daad398 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -2604,7 +2604,12 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
   drag = gdk_drag_begin (surface, device, content, GDK_ACTION_COPY, start_x, start_y);
 
   theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
-  icon = gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 1, 0);
+  icon = gtk_icon_theme_lookup_icon (theme,
+                                     "text-x-generic",
+                                     32,
+                                     1,
+                                     GTK_TEXT_DIR_NONE,
+                                     0);
   gtk_drag_icon_set_from_paintable (drag, GDK_PAINTABLE (icon), 0, 0);
   g_clear_object (&icon);
 
diff --git a/gtk/gtkcssimageicontheme.c b/gtk/gtkcssimageicontheme.c
index 244324ffdb..0b92662fc7 100644
--- a/gtk/gtkcssimageicontheme.c
+++ b/gtk/gtkcssimageicontheme.c
@@ -65,11 +65,13 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
                                          icon_theme->name,
                                          size,
                                          icon_theme->scale,
+                                         GTK_TEXT_DIR_NONE,
                                          GTK_ICON_LOOKUP_USE_BUILTIN);
       if (icon == NULL)
         icon = gtk_icon_theme_lookup_icon (icon_theme->icon_theme,
                                            "image-missing",
                                            size, icon_theme->scale,
+                                           GTK_TEXT_DIR_NONE,
                                            GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
 
       g_assert (icon != NULL);
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index 0df09f1b56..8799643030 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -486,7 +486,12 @@ gtk_drag_source_drag_begin (GtkDragSource *source)
       GtkIconTheme *theme;
 
       theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
-      source->paintable = GDK_PAINTABLE(gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 1, 0));
+      source->paintable = GDK_PAINTABLE(gtk_icon_theme_lookup_icon (theme,
+                                                                    "text-x-generic",
+                                                                    32,
+                                                                    1,
+                                                                    gtk_widget_get_direction (widget),
+                                                                    0));
       source->hot_x = 0;
       source->hot_y = 0;
     }
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 6b80150b74..9fc93dac30 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -55,9 +55,8 @@ struct _GtkIconHelper
 };
 
 static GtkIconLookupFlags
-get_icon_lookup_flags (GtkIconHelper    *self,
-                       GtkCssStyle      *style,
-                       GtkTextDirection  dir)
+get_icon_lookup_flags (GtkIconHelper *self,
+                       GtkCssStyle   *style)
 {
   GtkIconLookupFlags flags;
   GtkCssIconStyle icon_style;
@@ -84,11 +83,6 @@ get_icon_lookup_flags (GtkIconHelper    *self,
       return 0;
     }
 
-  if (dir == GTK_TEXT_DIR_LTR)
-    flags |= GTK_ICON_LOOKUP_DIR_LTR;
-  else if (dir == GTK_TEXT_DIR_RTL)
-    flags |= GTK_ICON_LOOKUP_DIR_RTL;
-
   return flags;
 }
 
@@ -106,18 +100,20 @@ ensure_paintable_for_gicon (GtkIconHelper    *self,
   GtkIconLookupFlags flags;
 
   icon_theme = gtk_css_icon_theme_value_get_icon_theme (style->core->icon_theme);
-  flags = get_icon_lookup_flags (self, style, dir);
+  flags = get_icon_lookup_flags (self, style);
 
   width = height = gtk_icon_helper_get_size (self);
 
   icon = gtk_icon_theme_lookup_by_gicon (icon_theme,
                                          gicon,
                                          MIN (width, height),
+                                         dir,
                                          scale, flags);
   if (icon == NULL)
     icon = gtk_icon_theme_lookup_icon (icon_theme,
                                        "image-missing",
                                        width, scale,
+                                       dir,
                                        flags | GTK_ICON_LOOKUP_USE_BUILTIN | 
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
 
   *symbolic = gtk_icon_is_symbolic (icon);
@@ -146,8 +142,8 @@ gtk_icon_helper_load_paintable (GtkIconHelper   *self,
         gicon = g_themed_icon_new (gtk_image_definition_get_icon_name (self->def));
       paintable = ensure_paintable_for_gicon (self,
                                               gtk_css_node_get_style (self->node),
-                                              gtk_widget_get_direction (self->owner),
                                               gtk_widget_get_scale_factor (self->owner),
+                                              gtk_widget_get_direction (self->owner),
                                               gicon,
                                               &symbolic);
       g_object_unref (gicon);
@@ -156,8 +152,8 @@ gtk_icon_helper_load_paintable (GtkIconHelper   *self,
     case GTK_IMAGE_GICON:
       paintable = ensure_paintable_for_gicon (self, 
                                               gtk_css_node_get_style (self->node),
-                                              gtk_widget_get_direction (self->owner),
                                               gtk_widget_get_scale_factor (self->owner),
+                                              gtk_widget_get_direction (self->owner),
                                               gtk_image_definition_get_gicon (self->def),
                                               &symbolic);
       break;
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 7d28d3b02c..91c26b4c1b 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2056,6 +2056,7 @@ choose_icon (GtkIconTheme      *self,
              const gchar       *icon_names[],
              gint               size,
              gint               scale,
+             GtkTextDirection   direction,
              GtkIconLookupFlags flags,
              gboolean           non_blocking,
              gboolean           *would_block)
@@ -2066,12 +2067,22 @@ choose_icon (GtkIconTheme      *self,
   const gchar *dir_suffix;
   guint i;
 
-  if (flags & GTK_ICON_LOOKUP_DIR_LTR)
+  switch (direction)
+  {
+  case GTK_TEXT_DIR_NONE:
+    dir_suffix = NULL;
+    break;
+  case GTK_TEXT_DIR_LTR:
     dir_suffix = "-ltr";
-  else if (flags & GTK_ICON_LOOKUP_DIR_RTL)
+    break;
+  case GTK_TEXT_DIR_RTL:
     dir_suffix = "-rtl";
-  else
+    break;
+  default:
+    g_assert_not_reached();
     dir_suffix = NULL;
+    break;
+  }
 
   for (i = 0; icon_names[i]; i++)
     {
@@ -2170,6 +2181,7 @@ choose_icon (GtkIconTheme      *self,
  * @icon_name: the name of the icon to lookup
  * @size: desired icon size.  The resulting icon may not be exactly this size.
  * @scale: the window scale this will be displayed on
+ * @direction: text direction the icon will be displayed in
  * @flags: flags modifying the behavior of the icon lookup
  *
  * Looks up a named icon for a desired size and window scale, returning a
@@ -2202,6 +2214,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *self,
                             const gchar        *icon_name,
                             gint                size,
                             gint                scale,
+                            GtkTextDirection    direction,
                             GtkIconLookupFlags  flags)
 {
   GtkIcon *icon;
@@ -2264,7 +2277,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *self,
           names = nonsymbolic_names;
         }
 
-      icon = choose_icon (self, (const gchar **) names, size, scale, flags, FALSE, NULL);
+      icon = choose_icon (self, (const gchar **) names, size, scale, direction, flags, FALSE, NULL);
 
       g_strfreev (names);
     }
@@ -2275,7 +2288,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *self,
       names[0] = icon_name;
       names[1] = NULL;
 
-      icon = choose_icon (self, names, size, scale, flags, FALSE, NULL);
+      icon = choose_icon (self, names, size, scale, direction, flags, FALSE, NULL);
     }
 
   gtk_icon_theme_unlock (self);
@@ -2290,6 +2303,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *self,
  *     array of icon names to lookup
  * @size: desired icon size. The resulting icon may not be exactly this size.
  * @scale: the window scale this will be displayed on
+ * @direction: text direction the icon will be displayed in
  * @flags: flags modifying the behavior of the icon lookup
  *
  * Looks up a named icon for a desired size and window scale, returning a
@@ -2327,6 +2341,7 @@ gtk_icon_theme_choose_icon (GtkIconTheme       *self,
                             const gchar        *icon_names[],
                             gint                size,
                             gint                scale,
+                            GtkTextDirection    direction,
                             GtkIconLookupFlags  flags)
 {
   GtkIcon *icon;
@@ -2340,7 +2355,7 @@ gtk_icon_theme_choose_icon (GtkIconTheme       *self,
 
   gtk_icon_theme_lock (self);
 
-  icon = choose_icon (self, icon_names, size, scale, flags, FALSE, NULL);
+  icon = choose_icon (self, icon_names, size, scale, direction, flags, FALSE, NULL);
 
   gtk_icon_theme_unlock (self);
 
@@ -4022,6 +4037,7 @@ gtk_icon_new_for_pixbuf (GtkIconTheme *icon_theme,
  * @icon: the #GIcon to look up
  * @size: desired icon size
  * @scale: the desired scale
+ * @direction: text direction the icon will be displayed in
  * @flags: flags modifying the behavior of the icon lookup
  *
  * Looks up a icon for a desired size and window scale, returning a
@@ -4037,6 +4053,7 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme       *self,
                                 GIcon              *gicon,
                                 gint                size,
                                 gint                scale,
+                                GtkTextDirection    direction,
                                 GtkIconLookupFlags  flags)
 {
   GtkIcon *icon;
@@ -4109,7 +4126,7 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme       *self,
       const gchar **names;
 
       names = (const gchar **)g_themed_icon_get_names (G_THEMED_ICON (gicon));
-      icon = gtk_icon_theme_choose_icon (self, names, size, scale, flags);
+      icon = gtk_icon_theme_choose_icon (self, names, size, scale, direction, flags);
 
       return icon;
     }
diff --git a/gtk/gtkicontheme.h b/gtk/gtkicontheme.h
index 193595cbb5..8d73006f8e 100644
--- a/gtk/gtkicontheme.h
+++ b/gtk/gtkicontheme.h
@@ -76,9 +76,7 @@ typedef enum
   GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3,
   GTK_ICON_LOOKUP_FORCE_SIZE       = 1 << 4,
   GTK_ICON_LOOKUP_FORCE_REGULAR    = 1 << 5,
-  GTK_ICON_LOOKUP_FORCE_SYMBOLIC   = 1 << 6,
-  GTK_ICON_LOOKUP_DIR_LTR          = 1 << 7,
-  GTK_ICON_LOOKUP_DIR_RTL          = 1 << 8
+  GTK_ICON_LOOKUP_FORCE_SYMBOLIC   = 1 << 6
 } GtkIconLookupFlags;
 
 /**
@@ -148,18 +146,21 @@ GtkIcon *    gtk_icon_theme_lookup_icon            (GtkIconTheme
                                                     const gchar                 *icon_name,
                                                     gint                         size,
                                                     gint                         scale,
+                                                    GtkTextDirection             direction,
                                                     GtkIconLookupFlags           flags);
 GDK_AVAILABLE_IN_ALL
 GtkIcon *    gtk_icon_theme_choose_icon            (GtkIconTheme                *self,
                                                     const gchar                 *icon_names[],
                                                     gint                         size,
                                                     gint                         scale,
+                                                    GtkTextDirection             direction,
                                                     GtkIconLookupFlags           flags);
 GDK_AVAILABLE_IN_ALL
 GtkIcon *   gtk_icon_theme_lookup_by_gicon         (GtkIconTheme                *self,
                                                     GIcon                       *icon,
                                                     gint                         size,
                                                     gint                         scale,
+                                                    GtkTextDirection             direction,
                                                     GtkIconLookupFlags           flags);
 GDK_AVAILABLE_IN_ALL
 GList *       gtk_icon_theme_list_icons            (GtkIconTheme                *self,
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index 20e61d0831..417ba0a7c1 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -1174,7 +1174,11 @@ add_pid_to_process_list_store (GtkMountOperation              *mount_operation,
       theme = gtk_css_icon_theme_value_get_icon_theme
         (_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET 
(mount_operation->priv->dialog)),
                                            GTK_CSS_PROPERTY_ICON_THEME));
-      icon = gtk_icon_theme_lookup_icon (theme, "application-x-executable", 24, 1, 0);
+      icon = gtk_icon_theme_lookup_icon (theme,
+                                         "application-x-executable",
+                                         24, 1,
+                                         gtk_widget_get_direction (GTK_WIDGET 
(mount_operation->priv->dialog)),
+                                         0);
       texture = gtk_icon_download_texture (icon, NULL);
       g_object_unref (icon);
     }
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c9e274a110..2730181c79 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4029,10 +4029,12 @@ icon_list_from_theme (GtkWindow   *window,
       if (sizes[i] == -1)
         info = gtk_icon_theme_lookup_icon (icon_theme, name,
                                            48, priv->scale,
+                                           gtk_widget_get_direction (GTK_WIDGET (window)),
                                            0);
       else
         info = gtk_icon_theme_lookup_icon (icon_theme, name,
                                            sizes[i], priv->scale,
+                                           gtk_widget_get_direction (GTK_WIDGET (window)),
                                            0);
       if (info)
         {
@@ -4113,6 +4115,7 @@ gtk_window_get_icon_for_size (GtkWindow *window,
 
   info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET 
(window))),
                                      name, size, priv->scale,
+                                     gtk_widget_get_direction (GTK_WIDGET (window)),
                                      GTK_ICON_LOOKUP_FORCE_SIZE);
   if (info == NULL)
     return NULL;
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index 9e5d37bcf4..e3fb9422e8 100644
--- a/tests/testclipboard2.c
+++ b/tests/testclipboard2.c
@@ -288,7 +288,9 @@ get_button_list (GdkClipboard *clipboard,
   g_value_init (&value, GDK_TYPE_PIXBUF);
   icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (gdk_clipboard_get_display (clipboard)),
                                      "utilities-terminal",
-                                     48, 1, 0);
+                                     48, 1,
+                                     gtk_widget_get_direction (box),
+                                     0);
   texture = gtk_icon_download_texture (icon, NULL);
   g_value_take_object (&value, gdk_pixbuf_get_from_texture (texture));
   g_object_unref (texture);
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 7204ff7e9c..9fd2d02ea7 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -25,7 +25,11 @@ get_image_texture (GtkImage *image,
       icon_name = gtk_image_get_icon_name (image);
       icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
       *out_size = width;
-      icon = gtk_icon_theme_lookup_icon (icon_theme, icon_name, width, 1, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+      icon = gtk_icon_theme_lookup_icon (icon_theme,
+                                         icon_name,
+                                         width, 1,
+                                         gtk_widget_get_direction (GTK_WIDGET (image)),
+                                         GTK_ICON_LOOKUP_GENERIC_FALLBACK);
       if (icon)
         texture = gtk_icon_download_texture (icon, NULL);
       g_object_unref (icon);
@@ -223,14 +227,16 @@ update_source_icon (GtkDragSource *source,
                     const char *icon_name,
                     int hotspot)
 {
+  GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
   GtkIcon *icon;
   int hot_x, hot_y;
   int size = 48;
 
-  icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (
-                                         gtk_widget_get_display (
-                                             gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER 
(source)))),
-                                     icon_name, size, 1, 0);
+  icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (gtk_widget_get_display (widget)),
+                                     icon_name,
+                                     size, 1,
+                                     gtk_widget_get_direction (widget),
+                                     0);
   switch (hotspot)
     {
     default:
diff --git a/tests/testicontheme.c b/tests/testicontheme.c
index 2d64de49d9..fe7c28f771 100644
--- a/tests/testicontheme.c
+++ b/tests/testicontheme.c
@@ -43,6 +43,7 @@ main (int argc, char *argv[])
   int size = 48;
   int scale = 1;
   GtkIconLookupFlags flags;
+  GtkTextDirection direction;
   
   gtk_init ();
 
@@ -55,9 +56,11 @@ main (int argc, char *argv[])
   flags = GTK_ICON_LOOKUP_USE_BUILTIN;
 
   if (g_getenv ("RTL"))
-    flags |= GTK_ICON_LOOKUP_DIR_RTL;
+    direction = GTK_TEXT_DIR_RTL;
+  else if (g_getenv ("LTR"))
+    direction = GTK_TEXT_DIR_LTR;
   else
-    flags |= GTK_ICON_LOOKUP_DIR_LTR;
+    direction = GTK_TEXT_DIR_NONE;
 
   themename = argv[2];
   
@@ -83,7 +86,7 @@ main (int argc, char *argv[])
       if (argc >= 6)
        scale = atoi (argv[5]);
 
-      icon = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size, scale, flags);
+      icon = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size, scale, direction, flags);
       if (!icon)
         {
           g_print ("Icon '%s' not found\n", argv[3]);
@@ -131,7 +134,7 @@ main (int argc, char *argv[])
       if (argc >= 6)
        scale = atoi (argv[5]);
 
-      icon = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size, scale, flags);
+      icon = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size, scale, direction, flags);
       g_print ("icon for %s at %dx%d@%dx is %s\n", argv[3], size, size, scale,
                icon ? gtk_icon_get_filename (icon) : "<none>");
 
diff --git a/testsuite/gtk/check-icon-names.c b/testsuite/gtk/check-icon-names.c
index a5bc6756d1..d608f76be1 100644
--- a/testsuite/gtk/check-icon-names.c
+++ b/testsuite/gtk/check-icon-names.c
@@ -80,7 +80,7 @@ test_icon_existence (gconstpointer icon_name)
    * icon theme.
    * The icon size is randomly chosen.
    */
-  info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 16, 1, GTK_ICON_LOOKUP_DIR_LTR);
+  info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 16, 1, GTK_TEXT_DIR_LTR, 0);
   if (info == NULL)
     {
       g_test_message ("Failed to look up icon for \"%s\"", (char *) icon_name);
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c
index e65396a0c6..f0dbae4544 100644
--- a/testsuite/gtk/icontheme.c
+++ b/testsuite/gtk/icontheme.c
@@ -51,13 +51,14 @@ lookup_flags_to_string (GtkIconLookupFlags flags)
 static void
 assert_icon_lookup_size (const char         *icon_name,
                          gint                size,
+                         GtkTextDirection    direction,
                          GtkIconLookupFlags  flags,
                          const char         *filename,
                          gint                pixbuf_size)
 {
   GtkIcon *info;
 
-  info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, size, 1, flags);
+  info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, size, 1, direction, flags);
   if (info == NULL)
     {
       g_error ("Could not look up an icon for \"%s\" with flags %s at size %d",
@@ -97,20 +98,22 @@ assert_icon_lookup_size (const char         *icon_name,
 static void
 assert_icon_lookup (const char         *icon_name,
                     gint                size,
+                    GtkTextDirection    direction,
                     GtkIconLookupFlags  flags,
                     const char         *filename)
 {
-  assert_icon_lookup_size (icon_name, size, flags, filename, -1);
+  assert_icon_lookup_size (icon_name, size, direction, flags, filename, -1);
 }
 
 static void
 assert_icon_lookup_fails (const char         *icon_name,
                           gint                size,
+                          GtkTextDirection    direction,
                           GtkIconLookupFlags  flags)
 {
   GtkIcon *info;
 
-  info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, size, 1, flags);
+  info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, size, 1, direction, flags);
 
   if (info != NULL)
     {
@@ -157,6 +160,7 @@ log_writer (GLogLevelFlags   log_level,
 static void
 assert_lookup_order (const char         *icon_name,
                      gint                size,
+                     GtkTextDirection    direction,
                      GtkIconLookupFlags  flags,
                      const char         *first,
                      ...)
@@ -173,7 +177,7 @@ assert_lookup_order (const char         *icon_name,
 
   g_assert (lookups == NULL);
 
-  info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, size, 1, flags);
+  info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, size, 1, direction, flags);
   if (info)
     g_object_unref (info);
   
@@ -201,18 +205,18 @@ static void
 test_basics (void)
 {
   /* just a basic boring lookup so we know everything works */
-  assert_icon_lookup ("simple", 16, 0, "/icons/16x16/simple.png");
+  assert_icon_lookup ("simple", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16x16/simple.png");
 }
 
 static void
 test_lookup_order (void)
 {
-  assert_lookup_order ("foo-bar-baz", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+  assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                        "foo-bar-baz",
                        "foo-bar",
                        "foo",
                        NULL);
-  assert_lookup_order ("foo-bar-baz", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_RTL,
+  assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                        "foo-bar-baz-rtl",
                        "foo-bar-baz",
                        "foo-bar-rtl",
@@ -220,11 +224,11 @@ test_lookup_order (void)
                        "foo-rtl",
                        "foo",
                        NULL);
-  assert_lookup_order ("foo-bar-baz", 16, GTK_ICON_LOOKUP_DIR_RTL,
+  assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0,
                        "foo-bar-baz-rtl",
                        "foo-bar-baz",
                        NULL);
-  assert_lookup_order ("foo-bar-baz-symbolic", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+  assert_lookup_order ("foo-bar-baz-symbolic", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                        "foo-bar-baz-symbolic",
                        "foo-bar-symbolic",
                        "foo-symbolic",
@@ -233,13 +237,13 @@ test_lookup_order (void)
                        "foo",
                        NULL);
 
-  assert_lookup_order ("bla-bla", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
+  assert_lookup_order ("bla-bla", 16, GTK_TEXT_DIR_NONE, 
GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                        "bla-bla-symbolic",
                        "bla-symbolic",
                        "bla-bla",
                        "bla",
                        NULL);
-  assert_lookup_order ("bla-bla-symbolic", 16, 
GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
+  assert_lookup_order ("bla-bla-symbolic", 16, GTK_TEXT_DIR_NONE, 
GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                        "bla-bla-symbolic",
                        "bla-symbolic",
                        "bla-bla-symbolic", /* awkward */
@@ -248,7 +252,7 @@ test_lookup_order (void)
                        "bla",
                        NULL);
 
-  assert_lookup_order ("bar-baz", 16, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_RTL,
+  assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_RTL, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                        "bar-baz-symbolic-rtl",
                        "bar-baz-symbolic",
                        "bar-symbolic-rtl",
@@ -258,7 +262,7 @@ test_lookup_order (void)
                        "bar-rtl",
                        "bar",
                        NULL);
-  assert_lookup_order ("bar-baz-symbolic", 16, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_RTL,
+  assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_RTL, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                        "bar-baz-symbolic-rtl",
                        "bar-baz-symbolic",
                        "bar-symbolic-rtl",
@@ -273,7 +277,7 @@ test_lookup_order (void)
                        "bar",
                        NULL);
 
-  assert_lookup_order ("bar-baz", 16, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_LTR,
+  assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_LTR, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                        "bar-baz-symbolic-ltr",
                        "bar-baz-symbolic",
                        "bar-symbolic-ltr",
@@ -283,7 +287,7 @@ test_lookup_order (void)
                        "bar-ltr",
                        "bar",
                        NULL);
-  assert_lookup_order ("bar-baz-symbolic", 16, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_LTR,
+  assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_LTR, 
GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                        "bar-baz-symbolic-ltr",
                        "bar-baz-symbolic",
                        "bar-symbolic-ltr",
@@ -305,12 +309,14 @@ test_generic_fallback (void)
   /* simple test for generic fallback */
   assert_icon_lookup ("simple-foo-bar",
                       16,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/16x16/simple.png");
 
   /* Check generic fallback also works for symbolics falling back to regular items */
   assert_icon_lookup ("simple-foo-bar-symbolic",
                       16,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/16x16/simple.png");
 
@@ -318,6 +324,7 @@ test_generic_fallback (void)
    * non-symbolics */
   assert_icon_lookup ("everything-justregular-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/scalable/everything-symbolic.svg");
 }
@@ -328,46 +335,56 @@ test_force_symbolic (void)
   /* check forcing symbolic works */
   assert_icon_lookup ("everything",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-symbolic.svg");
   /* check forcing symbolic also works for symbolic icons (d'oh) */
   assert_icon_lookup ("everything-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-symbolic.svg");
 
   /* check all the combos for fallbacks on an icon that only exists as symbolic */
   assert_icon_lookup ("everything-justsymbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-justsymbolic-symbolic.svg");
   assert_icon_lookup ("everything-justsymbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-justsymbolic-symbolic.svg");
   assert_icon_lookup ("everything-justsymbolic-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-justsymbolic-symbolic.svg");
   assert_icon_lookup ("everything-justsymbolic-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-justsymbolic-symbolic.svg");
 
   /* check all the combos for fallbacks, this time for an icon that only exists as regular */
   assert_icon_lookup ("everything-justregular",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-justregular.svg");
   assert_icon_lookup ("everything-justregular",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-symbolic.svg");
   assert_icon_lookup_fails ("everything-justregular-symbolic",
                             SCALABLE_IMAGE_SIZE,
+                            GTK_TEXT_DIR_NONE,
                             GTK_ICON_LOOKUP_FORCE_SYMBOLIC);
   assert_icon_lookup ("everything-justregular-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
                       "/icons/scalable/everything-symbolic.svg");
 }
@@ -378,46 +395,56 @@ test_force_regular (void)
   /* check forcing regular works (d'oh) */
   assert_icon_lookup ("everything",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything.svg");
   /* check forcing regular also works for symbolic icons ) */
   assert_icon_lookup ("everything-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything.svg");
 
   /* check all the combos for fallbacks on an icon that only exists as regular */
   assert_icon_lookup ("everything-justregular",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything-justregular.svg");
   assert_icon_lookup ("everything-justregular",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything-justregular.svg");
   assert_icon_lookup ("everything-justregular-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything-justregular.svg");
   assert_icon_lookup ("everything-justregular-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything-justregular.svg");
 
   /* check all the combos for fallbacks, this time for an icon that only exists as symbolic */
   assert_icon_lookup_fails ("everything-justsymbolic",
                             SCALABLE_IMAGE_SIZE,
+                            GTK_TEXT_DIR_NONE,
                             GTK_ICON_LOOKUP_FORCE_REGULAR);
   assert_icon_lookup ("everything-justsymbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything.svg");
   assert_icon_lookup ("everything-justsymbolic-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything-justsymbolic-symbolic.svg");
   assert_icon_lookup ("everything-justsymbolic-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_REGULAR,
                       "/icons/scalable/everything.svg");
 }
@@ -427,35 +454,43 @@ test_rtl (void)
 {
   assert_icon_lookup ("everything",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_DIR_RTL,
+                      GTK_TEXT_DIR_RTL,
+                      0,
                       "/icons/scalable/everything-rtl.svg");
   assert_icon_lookup ("everything-symbolic",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_DIR_RTL,
+                      GTK_TEXT_DIR_RTL,
+                      0,
                       "/icons/scalable/everything-symbolic-rtl.svg");
 
   assert_icon_lookup_fails ("everything-justrtl",
                             SCALABLE_IMAGE_SIZE,
+                            GTK_TEXT_DIR_NONE,
                             0);
   assert_icon_lookup_fails ("everything-justrtl",
                             SCALABLE_IMAGE_SIZE,
-                            GTK_ICON_LOOKUP_DIR_LTR);
+                            GTK_TEXT_DIR_LTR,
+                            0);
   assert_icon_lookup ("everything-justrtl",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_DIR_RTL,
+                      GTK_TEXT_DIR_RTL,
+                      0,
                       "/icons/scalable/everything-justrtl-rtl.svg");
 
   assert_icon_lookup ("everything-justrtl",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/scalable/everything.svg");
   assert_icon_lookup ("everything-justrtl",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_DIR_LTR,
+                      GTK_TEXT_DIR_LTR,
+                      GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/scalable/everything.svg");
   assert_icon_lookup ("everything-justrtl",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_DIR_RTL,
+                      GTK_TEXT_DIR_RTL,
+                      GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/scalable/everything-justrtl-rtl.svg");
 }
 
@@ -465,15 +500,18 @@ test_symbolic_single_size (void)
   /* Check we properly load a symbolic icon from a sized directory */
   assert_icon_lookup ("only32-symbolic",
                       32,
+                      GTK_TEXT_DIR_NONE,
                       0,
                       "/icons/32x32/only32-symbolic.svg");
   /* Check that we still properly load it even if a different size is requested */
   assert_icon_lookup ("only32-symbolic",
                       16,
+                      GTK_TEXT_DIR_NONE,
                       0,
                       "/icons/32x32/only32-symbolic.svg");
   assert_icon_lookup ("only32-symbolic",
                       128,
+                      GTK_TEXT_DIR_NONE,
                       0,
                       "/icons/32x32/only32-symbolic.svg");
 }
@@ -486,69 +524,69 @@ test_svg_size (void)
    * account for choosing).
    */
   /* Check we properly load a svg icon from a sized directory */
-  assert_icon_lookup_size ("twosize-fixed", 48, 0, "/icons/32x32/twosize-fixed.svg", 32);
-  assert_icon_lookup_size ("twosize-fixed", 32, 0, "/icons/32x32/twosize-fixed.svg", 32);
-  assert_icon_lookup_size ("twosize-fixed", 20, 0, "/icons/32x32/twosize-fixed.svg", 32);
-  assert_icon_lookup_size ("twosize-fixed", 16, 0, "/icons/16x16/twosize-fixed.svg", 16);
+  assert_icon_lookup_size ("twosize-fixed", 48, GTK_TEXT_DIR_NONE, 0, "/icons/32x32/twosize-fixed.svg", 32);
+  assert_icon_lookup_size ("twosize-fixed", 32, GTK_TEXT_DIR_NONE, 0, "/icons/32x32/twosize-fixed.svg", 32);
+  assert_icon_lookup_size ("twosize-fixed", 20, GTK_TEXT_DIR_NONE, 0, "/icons/32x32/twosize-fixed.svg", 32);
+  assert_icon_lookup_size ("twosize-fixed", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16x16/twosize-fixed.svg", 16);
 
   /* Check that we still properly load it even if a different size is requested */
-  assert_icon_lookup_size ("twosize", 64, 0, "/icons/32x32s/twosize.svg", 48);
-  assert_icon_lookup_size ("twosize", 48, 0, "/icons/32x32s/twosize.svg", 48);
-  assert_icon_lookup_size ("twosize", 32, 0, "/icons/32x32s/twosize.svg", 32);
-  assert_icon_lookup_size ("twosize", 24, 0, "/icons/32x32s/twosize.svg", 24);
-  assert_icon_lookup_size ("twosize", 16, 0, "/icons/16x16s/twosize.svg", 16);
-  assert_icon_lookup_size ("twosize", 12, 0, "/icons/16x16s/twosize.svg", 12);
-  assert_icon_lookup_size ("twosize",  8, 0, "/icons/16x16s/twosize.svg", 12);
+  assert_icon_lookup_size ("twosize", 64, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 48);
+  assert_icon_lookup_size ("twosize", 48, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 48);
+  assert_icon_lookup_size ("twosize", 32, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 32);
+  assert_icon_lookup_size ("twosize", 24, GTK_TEXT_DIR_NONE, 0, "/icons/32x32s/twosize.svg", 24);
+  assert_icon_lookup_size ("twosize", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16x16s/twosize.svg", 16);
+  assert_icon_lookup_size ("twosize", 12, GTK_TEXT_DIR_NONE, 0, "/icons/16x16s/twosize.svg", 12);
+  assert_icon_lookup_size ("twosize",  8, GTK_TEXT_DIR_NONE, 0, "/icons/16x16s/twosize.svg", 12);
 }
 
 static void
 test_size (void)
 {
-  assert_icon_lookup_size ("size-test", 12, 0, "/icons/15/size-test.png", 15);
-  assert_icon_lookup_size ("size-test", 13, 0, "/icons/15/size-test.png", 15);
-  assert_icon_lookup_size ("size-test", 14, 0, "/icons/15/size-test.png", 15);
-  assert_icon_lookup_size ("size-test", 15, 0, "/icons/15/size-test.png", 15);
-  assert_icon_lookup_size ("size-test", 16, 0, "/icons/16-22/size-test.png", 19);
-  assert_icon_lookup_size ("size-test", 17, 0, "/icons/16-22/size-test.png", 19);
-  assert_icon_lookup_size ("size-test", 18, 0, "/icons/16-22/size-test.png", 19);
-  assert_icon_lookup_size ("size-test", 19, 0, "/icons/16-22/size-test.png", 19);
+  assert_icon_lookup_size ("size-test", 12, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
+  assert_icon_lookup_size ("size-test", 13, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
+  assert_icon_lookup_size ("size-test", 14, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
+  assert_icon_lookup_size ("size-test", 15, GTK_TEXT_DIR_NONE, 0, "/icons/15/size-test.png", 15);
+  assert_icon_lookup_size ("size-test", 16, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
+  assert_icon_lookup_size ("size-test", 17, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
+  assert_icon_lookup_size ("size-test", 18, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
+  assert_icon_lookup_size ("size-test", 19, GTK_TEXT_DIR_NONE, 0, "/icons/16-22/size-test.png", 19);
   /* the next 3 are because we never scale up */
-  assert_icon_lookup_size ("size-test", 20, 0, "/icons/25+/size-test.svg", 25);
-  assert_icon_lookup_size ("size-test", 21, 0, "/icons/25+/size-test.svg", 25);
-  assert_icon_lookup_size ("size-test", 22, 0, "/icons/25+/size-test.svg", 25);
-
-  assert_icon_lookup_size ("size-test", 23, 0, "/icons/25+/size-test.svg", 25);
-  assert_icon_lookup_size ("size-test", 23, 0, "/icons/25+/size-test.svg", 25);
-  assert_icon_lookup_size ("size-test", 25, 0, "/icons/25+/size-test.svg", 25);
-  assert_icon_lookup_size ("size-test", 28, 0, "/icons/25+/size-test.svg", 28);
+  assert_icon_lookup_size ("size-test", 20, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
+  assert_icon_lookup_size ("size-test", 21, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
+  assert_icon_lookup_size ("size-test", 22, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
+
+  assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
+  assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
+  assert_icon_lookup_size ("size-test", 25, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 25);
+  assert_icon_lookup_size ("size-test", 28, GTK_TEXT_DIR_NONE, 0, "/icons/25+/size-test.svg", 28);
   /* the next 2 are because we never scale up */
-  assert_icon_lookup_size ("size-test", 31, 0, "/icons/35+/size-test.svg", 35);
-  assert_icon_lookup_size ("size-test", 34, 0, "/icons/35+/size-test.svg", 35);
-
-  assert_icon_lookup_size ("size-test", 37, 0, "/icons/35+/size-test.svg", 37);
-  assert_icon_lookup_size ("size-test", 40, 0, "/icons/35+/size-test.svg", 40);
-  assert_icon_lookup_size ("size-test", 45, 0, "/icons/35+/size-test.svg", 45);
-
-  assert_icon_lookup_size ("size-test", 12, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 12);
-  assert_icon_lookup_size ("size-test", 13, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 13);
-  assert_icon_lookup_size ("size-test", 14, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 14);
-  assert_icon_lookup_size ("size-test", 15, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/15/size-test.png", 15);
-  assert_icon_lookup_size ("size-test", 16, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 16);
-  assert_icon_lookup_size ("size-test", 17, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 17);
-  assert_icon_lookup_size ("size-test", 18, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 18);
-  assert_icon_lookup_size ("size-test", 19, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 19);
-  //assert_icon_lookup_size ("size-test", 20, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 20);
-  //assert_icon_lookup_size ("size-test", 21, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 21);
-  //assert_icon_lookup_size ("size-test", 22, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/16-22/size-test.png", 22);
-  assert_icon_lookup_size ("size-test", 23, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 23);
-  assert_icon_lookup_size ("size-test", 24, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 24);
-  assert_icon_lookup_size ("size-test", 25, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 25);
-  assert_icon_lookup_size ("size-test", 28, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 28);
-  //assert_icon_lookup_size ("size-test", 31, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 31);
-  //assert_icon_lookup_size ("size-test", 34, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/25+/size-test.svg", 34);
-  assert_icon_lookup_size ("size-test", 37, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/35+/size-test.svg", 37);
-  assert_icon_lookup_size ("size-test", 40, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/35+/size-test.svg", 40);
-  assert_icon_lookup_size ("size-test", 45, GTK_ICON_LOOKUP_FORCE_SIZE, "/icons/35+/size-test.svg", 45);
+  assert_icon_lookup_size ("size-test", 31, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 35);
+  assert_icon_lookup_size ("size-test", 34, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 35);
+
+  assert_icon_lookup_size ("size-test", 37, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 37);
+  assert_icon_lookup_size ("size-test", 40, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 40);
+  assert_icon_lookup_size ("size-test", 45, GTK_TEXT_DIR_NONE, 0, "/icons/35+/size-test.svg", 45);
+
+  assert_icon_lookup_size ("size-test", 12, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/15/size-test.png", 12);
+  assert_icon_lookup_size ("size-test", 13, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/15/size-test.png", 13);
+  assert_icon_lookup_size ("size-test", 14, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/15/size-test.png", 14);
+  assert_icon_lookup_size ("size-test", 15, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/15/size-test.png", 15);
+  assert_icon_lookup_size ("size-test", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/16-22/size-test.png", 16);
+  assert_icon_lookup_size ("size-test", 17, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/16-22/size-test.png", 17);
+  assert_icon_lookup_size ("size-test", 18, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/16-22/size-test.png", 18);
+  assert_icon_lookup_size ("size-test", 19, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/16-22/size-test.png", 19);
+  //assert_icon_lookup_size ("size-test", 20, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/16-22/size-test.png", 20);
+  //assert_icon_lookup_size ("size-test", 21, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/16-22/size-test.png", 21);
+  //assert_icon_lookup_size ("size-test", 22, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/16-22/size-test.png", 22);
+  assert_icon_lookup_size ("size-test", 23, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/25+/size-test.svg", 23);
+  assert_icon_lookup_size ("size-test", 24, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/25+/size-test.svg", 24);
+  assert_icon_lookup_size ("size-test", 25, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/25+/size-test.svg", 25);
+  assert_icon_lookup_size ("size-test", 28, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/25+/size-test.svg", 28);
+  //assert_icon_lookup_size ("size-test", 31, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/25+/size-test.svg", 31);
+  //assert_icon_lookup_size ("size-test", 34, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/25+/size-test.svg", 34);
+  assert_icon_lookup_size ("size-test", 37, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/35+/size-test.svg", 37);
+  assert_icon_lookup_size ("size-test", 40, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/35+/size-test.svg", 40);
+  assert_icon_lookup_size ("size-test", 45, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SIZE, 
"/icons/35+/size-test.svg", 45);
 }
 
 static void
@@ -594,27 +632,33 @@ test_inherit (void)
 {
   assert_icon_lookup ("one-two-three",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/scalable/one-two.svg");
   assert_icon_lookup ("one-two-three",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_DIR_RTL,
+                      GTK_TEXT_DIR_RTL,
+                      GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons/scalable/one-two-rtl.svg");
   assert_icon_lookup ("one-two-three-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons2/scalable/one-two-three-symbolic.svg");
   assert_icon_lookup ("one-two-three-symbolic",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_DIR_RTL,
+                      GTK_TEXT_DIR_RTL,
+                      GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons2/scalable/one-two-three-symbolic.svg");
   assert_icon_lookup ("one-two-symbolic",
                       SCALABLE_IMAGE_SIZE,
+                      GTK_TEXT_DIR_NONE,
                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons2/scalable/one-two-symbolic.svg");
   assert_icon_lookup ("one-two-symbolic",
                       SCALABLE_IMAGE_SIZE,
-                      GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_DIR_RTL,
+                      GTK_TEXT_DIR_RTL,
+                      GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                       "/icons2/scalable/one-two-symbolic-rtl.svg");
 }
 
@@ -649,7 +693,7 @@ test_nonsquare_symbolic (void)
   file = g_file_new_for_path (path);
   icon = g_file_icon_new (file);
   info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon,
-                                         height, 1, 0);
+                                         height, 1, GTK_TEXT_DIR_NONE, 0);
   g_assert_nonnull (info);
 
   g_object_unref (pixbuf);
@@ -694,7 +738,7 @@ main (int argc, char *argv[])
   /* Ignore the one-time warning that the fallback icon theme can’t be found
    * (because we’ve changed the search paths). */
   g_log_set_writer_func (log_writer_drop_warnings, &ignore_warnings, NULL);
-  assert_icon_lookup_fails ("this-icon-totally-does-not-exist", 16, 0);
+  assert_icon_lookup_fails ("this-icon-totally-does-not-exist", 16, GTK_TEXT_DIR_NONE, 0);
   ignore_warnings = FALSE;
 
   g_test_add_func ("/icontheme/basics", test_basics);


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