Re: Changing GtkTextTags?



> gtk-demo and testtext have a zillion g_object_set() on GtkTextTag (or
> tag_create() anyway which is just a convenience wrapper around same).
>
> So you're just triggering this bug somehow. Bug is just that
> iter_init_from_byte_offset() does not allow -1 as an arg, yet it's
> being passed in.

Yeah, it looks like setting the "scale" property in a button press event
handler after the tag had been applied was triggering it.

> Hmm, I'm sleepy, but rethinking my previous post, I think
> _gtk_text_btree_get_iter_at_last_toggle() can simply be reimplemented
> as:
> 
>  _gtk_text_btree_get_end_iter (tree, iter);
>  gtk_text_iter_backward_to_tag_toggle (iter, tag);
> 
> And similarly for _gtk_text_btree_get_iter_at_first_toggle().

The following patch does exactly that for _at_last_toggle(). I didn't
bother changing _at_first_toggle() because it works fine the way it is
now (0 is an acceptable arg) and seems more efficient, but I can change
that as well if you want.

Joe

Index: gtktextiter.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextiter.c,v
retrieving revision 1.39
diff -u -r1.39 gtktextiter.c
--- gtktextiter.c	2001/05/07 15:58:45	1.39
+++ gtktextiter.c	2001/05/22 19:45:13
@@ -4832,27 +4832,14 @@
                                          GtkTextIter    *iter,
                                          GtkTextTag     *tag)
 {
-  GtkTextLine *line;
-
   g_return_val_if_fail (iter != NULL, FALSE);
   g_return_val_if_fail (tree != NULL, FALSE);
-
-  line = _gtk_text_btree_last_could_contain_tag (tree, tag);
 
-  if (line == NULL)
-    {
-      /* Set iter to first in tree */
-      _gtk_text_btree_get_iter_at_line_char (tree, iter, 0, 0);
-      check_invariants (iter);
-      return FALSE;
-    }
-  else
-    {
-      iter_init_from_byte_offset (iter, tree, line, -1);
-      gtk_text_iter_backward_to_tag_toggle (iter, tag);
-      check_invariants (iter);
-      return TRUE;
-    }
+  _gtk_text_btree_get_end_iter (tree, iter);
+  gtk_text_iter_backward_to_tag_toggle (iter, tag);
+  check_invariants (iter);
+  
+  return TRUE;
 }
 
 gboolean


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