Index: gtk/gtkentry.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkentry.c,v
retrieving revision 1.188
diff -u -p -r1.188 gtkentry.c
--- gtk/gtkentry.c	2002/02/26 23:06:34	1.188
+++ gtk/gtkentry.c	2002/02/27 19:29:24
@@ -69,6 +69,7 @@ enum {
   COPY_CLIPBOARD,
   PASTE_CLIPBOARD,
   TOGGLE_OVERWRITE,
+  SWITCH_DIRECTION,
   LAST_SIGNAL
 };
 
@@ -227,6 +228,8 @@ static void gtk_entry_cut_clipboard     
 static void gtk_entry_copy_clipboard     (GtkEntry        *entry);
 static void gtk_entry_paste_clipboard    (GtkEntry        *entry);
 static void gtk_entry_toggle_overwrite   (GtkEntry        *entry);
+static void gtk_entry_switch_direction   (GtkEntry         *entry,
+					  GtkTextDirection  text_direction);
 static void gtk_entry_select_all         (GtkEntry        *entry);
 static void gtk_entry_real_activate      (GtkEntry        *entry);
 static gboolean gtk_entry_popup_menu     (GtkWidget      *widget);
@@ -377,6 +380,36 @@ add_move_binding (GtkBindingSet  *bindin
                                 G_TYPE_BOOLEAN, TRUE);
 }
 
+static guint
+binding_signal_new (const gchar	       *signal_name,
+		    GType		itype,
+		    GSignalFlags	signal_flags,
+		    GCallback           handler,
+		    GSignalAccumulator  accumulator,
+		    gpointer		accu_data,
+		    GSignalCMarshaller  c_marshaller,
+		    GType		return_type,
+		    guint		n_params,
+		    ...)
+{
+  va_list args;
+  guint signal_id;
+
+  g_return_val_if_fail (signal_name != NULL, 0);
+  
+  va_start (args, n_params);
+
+  signal_id = g_signal_new_valist (signal_name, itype, signal_flags,
+                                   g_cclosure_new (handler, NULL, NULL),
+				   accumulator, accu_data, c_marshaller,
+                                   return_type, n_params, args);
+
+  va_end (args);
+ 
+  return signal_id;
+}
+
+
 static void
 gtk_entry_class_init (GtkEntryClass *class)
 {
@@ -600,6 +633,16 @@ gtk_entry_class_init (GtkEntryClass *cla
                     _gtk_marshal_VOID__VOID,
                     GTK_TYPE_NONE, 0);
 
+  signals[SWITCH_DIRECTION] =
+    binding_signal_new ("switch_direction",
+			G_OBJECT_CLASS_TYPE (object_class),
+			G_SIGNAL_RUN_LAST | GTK_RUN_ACTION,
+			G_CALLBACK (gtk_entry_switch_direction),
+			NULL, NULL,
+			_gtk_marshal_VOID__ENUM,
+			GTK_TYPE_NONE, 1,
+			GTK_TYPE_TEXT_DIRECTION);
+
   /*
    * Key bindings
    */
@@ -2201,6 +2244,23 @@ static void
 gtk_entry_toggle_overwrite (GtkEntry *entry)
 {
   entry->overwrite_mode = !entry->overwrite_mode;
+}
+
+static void
+gtk_entry_switch_direction (GtkEntry         *entry,
+			    GtkTextDirection  text_direction)
+{
+  GtkWidget *widget = GTK_WIDGET (entry);
+
+  if (text_direction == GTK_TEXT_DIR_NONE)
+    {
+      GtkTextDirection old = gtk_widget_get_direction (widget);
+      text_direction = (old == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
+    }
+
+  g_print ("Switching to %d\n", text_direction);
+  
+  gtk_widget_set_direction (widget, text_direction);
 }
 
 static void
