gtk+ r21581 - in branches/gtk-2-14: . gtk



Author: matthiasc
Date: Fri Oct  3 01:42:41 2008
New Revision: 21581
URL: http://svn.gnome.org/viewvc/gtk+?rev=21581&view=rev

Log:
2008-10-02  Matthias Clasen <mclasen redhat com>

        Merged from trunk:

        530575 â GtkEntry with invisible chars has a confused cursor in
        overwrite mode
        Bug 371908 â Password Entry broken

        * gtk/gtkentry.c (gtk_entry_draw_cursor): Use the visible text
        in the layout when positioning the cursor, not the actual text
        content of the entry. This makes a different when using overwrite
        mode in an invisible entry.
        Problem noticed by Jonathan Blandford

        * gtk/gtkentry.c (gtk_entry_backspace): Make backspace behave
        properly when invisible.



Modified:
   branches/gtk-2-14/ChangeLog
   branches/gtk-2-14/gtk/gtkentry.c

Modified: branches/gtk-2-14/gtk/gtkentry.c
==============================================================================
--- branches/gtk-2-14/gtk/gtkentry.c	(original)
+++ branches/gtk-2-14/gtk/gtkentry.c	Fri Oct  3 01:42:41 2008
@@ -2940,7 +2940,7 @@
       return;
     }
 
-  prev_pos = gtk_entry_move_logically(entry, entry->current_pos, -1);
+  prev_pos = gtk_entry_move_logically (entry, entry->current_pos, -1);
 
   if (prev_pos < entry->current_pos)
     {
@@ -2950,7 +2950,8 @@
 
       pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
 
-      if (log_attrs[entry->current_pos].backspace_deletes_character)
+      if (entry->visible &&
+          log_attrs[entry->current_pos].backspace_deletes_character)
 	{
 	  gchar *cluster_text;
 	  gchar *normalized_text;
@@ -3679,6 +3680,8 @@
       gint cursor_index;
       gboolean block;
       gboolean block_at_line_end;
+      PangoLayout *layout;
+      const char *text;
 
       _gtk_entry_effective_inner_border (entry, &inner_border);
 
@@ -3686,11 +3689,13 @@
 
       gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
 
-      cursor_index = g_utf8_offset_to_pointer (entry->text, entry->current_pos + entry->preedit_cursor) - entry->text;
+      layout = gtk_entry_ensure_layout (entry, TRUE);
+      text = pango_layout_get_text (layout);
+      cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text;
       if (!entry->overwrite_mode)
         block = FALSE;
       else
-        block = _gtk_text_util_get_block_cursor_location (gtk_entry_ensure_layout (entry, TRUE),
+        block = _gtk_text_util_get_block_cursor_location (layout,
                                                           cursor_index, &cursor_rect, &block_at_line_end);
 
       if (!block)
@@ -3746,7 +3751,6 @@
         }
       else /* overwrite_mode */
         {
-          PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
           GdkColor cursor_color;
           GdkRectangle rect;
           cairo_t *cr;



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