Patch for Automated RTL widgets



I am resending this because apparently my first mail didn't get through
(possible due to the gnome.org DNS issues)

Anyway, attached is a patch for gtk_init that checks wether your locale
(LC_ALL or LANG) is Arabic or Hebrew, if it is then it will automatically set
the widget direction to RTL.

I think this is needed because LTR widgets with Arabic characters is not a
very nice thing to look at. You can still run apps the traditional way by
unsetting the locale for just that specific app.

This beats the alternative of having to manually set the text direction (by
calling gtk_widget_set_default_direction in each and every app that wants to
have an RTL direction.

Regards,
Ali
Index: gtkmain.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmain.c,v
retrieving revision 1.138
diff -u -r1.138 gtkmain.c
--- gtkmain.c	2000/09/14 16:41:19	1.138
+++ gtkmain.c	2000/09/25 20:23:34
@@ -245,6 +245,25 @@
       env_string = NULL;
     }
 
+  env_string = getenv ("LANG");
+  if (env_string != NULL)
+    {
+      if (strstr (env_string, "iw") || strstr (env_string, "ar"))
+	gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+      env_string = NULL;
+    }
+  else
+    {
+      env_string = getenv ("LC_ALL");
+      if (env_string != NULL)
+        {
+          if (strstr (env_string, "iw") || strstr (env_string, "ar"))
+	    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+          env_string = NULL;
+	}
+    } 
+
+
   if (argc && argv)
     {
       gint i, j, k;


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