[gtk+] Remove draw_insertion_cursor in label and entry



commit f18bbdff53322e214de14f0445c8348c241dd05f
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Nov 26 23:11:08 2011 +0100

    Remove draw_insertion_cursor in label and entry
    
    Remove the the draw_insertion_cursor wrapper which just converts from
    GtkTextDir to PangoDirection
    
    https://bugzilla.gnome.org/show_bug.cgi?id=640317

 gtk/gtkentry.c |   49 ++++++++++++++-----------------------------------
 gtk/gtklabel.c |   51 +++++++++++++++------------------------------------
 2 files changed, 29 insertions(+), 71 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 989b24a..c0d8fb2 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -5842,34 +5842,13 @@ gtk_entry_draw_text (GtkEntry *entry,
 }
 
 static void
-draw_insertion_cursor (GtkEntry      *entry,
-                       cairo_t       *cr,
-		       GdkRectangle  *cursor_location,
-		       gboolean       is_primary,
-		       PangoDirection direction,
-		       gboolean       draw_arrow)
-{
-  GtkWidget *widget = GTK_WIDGET (entry);
-  GtkTextDirection text_dir;
-
-  if (direction == PANGO_DIRECTION_LTR)
-    text_dir = GTK_TEXT_DIR_LTR;
-  else
-    text_dir = GTK_TEXT_DIR_RTL;
-
-  gtk_draw_insertion_cursor (widget, cr,
-			     cursor_location,
-			     is_primary, text_dir, draw_arrow);
-}
-
-static void
 gtk_entry_draw_cursor (GtkEntry  *entry,
                        cairo_t   *cr,
 		       CursorType type)
 {
   GtkEntryPrivate *priv = entry->priv;
   GtkWidget *widget = GTK_WIDGET (entry);
-  GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
+  GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (widget));
   PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
   GdkRectangle cursor_location;
   gboolean split_cursor;
@@ -5901,8 +5880,7 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
   if (!block)
     {
       gint strong_x, weak_x;
-      PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
-      PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
+      GtkTextDirection dir1, dir2;
       gint x1 = 0;
       gint x2 = 0;
 
@@ -5912,15 +5890,16 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
                     "gtk-split-cursor", &split_cursor,
                     NULL);
 
-      dir1 = priv->resolved_dir;
-  
+      dir1 = (priv->resolved_dir == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
+      dir2 = GTK_TEXT_DIR_NONE;
+
       if (split_cursor)
         {
           x1 = strong_x;
 
           if (weak_x != strong_x)
             {
-              dir2 = (priv->resolved_dir == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+              dir2 = (priv->resolved_dir == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
               x2 = weak_x;
             }
         }
@@ -5937,16 +5916,16 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
       cursor_location.width = 0;
       cursor_location.height = text_area_height - inner_border.top - inner_border.bottom;
 
-      draw_insertion_cursor (entry, cr,
-                             &cursor_location, TRUE, dir1,
-                             dir2 != PANGO_DIRECTION_NEUTRAL);
-  
-      if (dir2 != PANGO_DIRECTION_NEUTRAL)
+      gtk_draw_insertion_cursor (widget, cr,
+                                 &cursor_location, TRUE, dir1,
+                                 dir2 != GTK_TEXT_DIR_NONE);
+
+      if (dir2 != GTK_TEXT_DIR_NONE)
         {
           cursor_location.x = xoffset + x2;
-          draw_insertion_cursor (entry, cr,
-                                 &cursor_location, FALSE, dir2,
-                                 TRUE);
+          gtk_draw_insertion_cursor (widget, cr,
+                                     &cursor_location, FALSE, dir2,
+                                     TRUE);
         }
     }
   else /* overwrite_mode */
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index f763521..aa55e74 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3950,26 +3950,6 @@ get_layout_location (GtkLabel  *label,
     *yp = y;
 }
 
-static void
-draw_insertion_cursor (GtkLabel      *label,
-                       cairo_t       *cr,
-		       GdkRectangle  *cursor_location,
-		       gboolean       is_primary,
-		       PangoDirection direction,
-		       gboolean       draw_arrow)
-{
-  GtkWidget *widget = GTK_WIDGET (label);
-  GtkTextDirection text_dir;
-
-  if (direction == PANGO_DIRECTION_LTR)
-    text_dir = GTK_TEXT_DIR_LTR;
-  else
-    text_dir = GTK_TEXT_DIR_RTL;
-
-  gtk_draw_insertion_cursor (widget, cr, cursor_location,
-			     is_primary, text_dir, draw_arrow);
-}
-
 static PangoDirection
 get_cursor_direction (GtkLabel *label)
 {
@@ -4014,12 +3994,11 @@ gtk_label_draw_cursor (GtkLabel  *label, cairo_t *cr, gint xoffset, gint yoffset
       PangoDirection keymap_direction;
       PangoDirection cursor_direction;
       PangoRectangle strong_pos, weak_pos;
+      GtkTextDirection dir1, dir2;
       gboolean split_cursor;
       PangoRectangle *cursor1 = NULL;
       PangoRectangle *cursor2 = NULL;
       GdkRectangle cursor_location;
-      PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
-      PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
 
       keymap_direction = gdk_keymap_get_direction (gdk_keymap_get_for_display (gtk_widget_get_display (widget)));
       cursor_direction = get_cursor_direction (label);
@@ -4033,16 +4012,16 @@ gtk_label_draw_cursor (GtkLabel  *label, cairo_t *cr, gint xoffset, gint yoffset
 		    "gtk-split-cursor", &split_cursor,
 		    NULL);
 
-      dir1 = cursor_direction;
-      
+      dir1 = (cursor_direction == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
+      dir2 = GTK_TEXT_DIR_NONE;
+
       if (split_cursor)
 	{
 	  cursor1 = &strong_pos;
 
-	  if (strong_pos.x != weak_pos.x ||
-	      strong_pos.y != weak_pos.y)
+	  if (strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y)
 	    {
-	      dir2 = (cursor_direction == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+              dir2 = (cursor_direction == PANGO_DIRECTION_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
 	      cursor2 = &weak_pos;
 	    }
 	}
@@ -4053,26 +4032,26 @@ gtk_label_draw_cursor (GtkLabel  *label, cairo_t *cr, gint xoffset, gint yoffset
 	  else
 	    cursor1 = &weak_pos;
 	}
-      
+
       cursor_location.x = xoffset + PANGO_PIXELS (cursor1->x);
       cursor_location.y = yoffset + PANGO_PIXELS (cursor1->y);
       cursor_location.width = 0;
       cursor_location.height = PANGO_PIXELS (cursor1->height);
 
-      draw_insertion_cursor (label, cr,
-			     &cursor_location, TRUE, dir1,
-			     dir2 != PANGO_DIRECTION_NEUTRAL);
-      
-      if (dir2 != PANGO_DIRECTION_NEUTRAL)
+      gtk_draw_insertion_cursor (widget, cr,
+                                 &cursor_location, TRUE, dir1,
+                                 dir2 != GTK_TEXT_DIR_NONE);
+
+      if (dir2 != GTK_TEXT_DIR_NONE)
 	{
 	  cursor_location.x = xoffset + PANGO_PIXELS (cursor2->x);
 	  cursor_location.y = yoffset + PANGO_PIXELS (cursor2->y);
 	  cursor_location.width = 0;
 	  cursor_location.height = PANGO_PIXELS (cursor2->height);
 
-	  draw_insertion_cursor (label, cr,
-				 &cursor_location, FALSE, dir2,
-				 TRUE);
+          gtk_draw_insertion_cursor (widget, cr,
+                                     &cursor_location, FALSE, dir2,
+                                     TRUE);
 	}
     }
 }



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