b=621962 convert -ltr/-rtl moz-icon stock names to gtk stock ids r=roc a=blocking-final+
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 03 Feb 2011 12:24:33 -0500
changeset 61855 562ae97b263612a46f215d9212d8377acf9cc378
parent 61854 29df2b0fa77bb689e9984499c5f604b8507da8b3
child 61856 602d24b981e53778e7dc5fcc0fee212f6c8af716
push id18521
push usereakhgari@mozilla.com
push dateThu, 03 Feb 2011 17:24:54 +0000
treeherdermozilla-central@562ae97b2636 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocking-final
bugs621962
milestone2.0b12pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=621962 convert -ltr/-rtl moz-icon stock names to gtk stock ids r=roc a=blocking-final+
modules/libpr0n/decoders/icon/gtk/nsIconChannel.cpp
--- a/modules/libpr0n/decoders/icon/gtk/nsIconChannel.cpp
+++ b/modules/libpr0n/decoders/icon/gtk/nsIconChannel.cpp
@@ -453,21 +453,36 @@ nsIconChannel::Init(nsIURI* aURI)
 
   nsCAutoString iconStateString;
   iconURI->GetIconState(iconStateString);
 
   GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get());
   GtkStateType state = iconStateString.EqualsLiteral("disabled") ?
     GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
 
-  // First lookup the icon by stock id.
+  // First lookup the icon by stock id and text direction.
+  GtkTextDirection direction = GTK_TEXT_DIR_NONE;
+  if (StringEndsWith(stockIcon, NS_LITERAL_CSTRING("-ltr"))) {
+    direction = GTK_TEXT_DIR_LTR;
+  } else if (StringEndsWith(stockIcon, NS_LITERAL_CSTRING("-rtl"))) {
+    direction = GTK_TEXT_DIR_RTL;
+  }
+
+  PRBool haveDirection = direction != GTK_TEXT_DIR_NONE;
+  nsCAutoString stockID;
+  if (haveDirection) {
+    stockID = Substring(stockIcon, 0, stockIcon.Length() - 4);
+  } else {
+    direction = gtk_widget_get_default_direction();
+    stockID = stockIcon;
+  }
+
   ensure_stock_image_widget();
   GtkStyle *style = gtk_widget_get_style(gStockImageWidget);
-  GtkIconSet *icon_set =
-    gtk_style_lookup_icon_set(style, stockIcon.get());
+  GtkIconSet *icon_set = gtk_style_lookup_icon_set(style, stockID.get());
 
   if (icon_set) {
     gtk_icon_set_ref(icon_set);
   } else {
     // stockIcon is not a stock id, so assume it is an icon name.
     //
     // Creating a GtkIconSet is a convenient way to allow the style to
     // render the icon, possibly with variations suitable for insensitive
@@ -476,18 +491,17 @@ nsIconChannel::Init(nsIURI* aURI)
     GtkIconSource *icon_source = gtk_icon_source_new();
     
     gtk_icon_source_set_icon_name(icon_source, stockIcon.get());
     gtk_icon_set_add_source(icon_set, icon_source);
     gtk_icon_source_free(icon_source);
   }
 
   GdkPixbuf *icon =
-    gtk_icon_set_render_icon (icon_set, style,
-                              gtk_widget_get_default_direction(), state,
+    gtk_icon_set_render_icon (icon_set, style, direction, state,
                               icon_size, gStockImageWidget, NULL);
   gtk_icon_set_unref(icon_set);
 
   // gtk_icon_set_render_icon() never returns NULL, except when we have
   // https://bugzilla.gnome.org/show_bug.cgi?id=629878#c13
   if (!icon)
     return NS_ERROR_NOT_AVAILABLE;