diff options
author | Matthias Clasen <mclasen@redhat.com> | 2007-05-26 04:10:42 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2007-05-26 04:10:42 +0000 |
commit | 6ac30db004c4a768aaf74286bcc21ff7123e0550 (patch) | |
tree | 15e8284ee1ef0b2905bf2c0f2d1f6ce60eea9c91 /gtk/gtktextbtree.c | |
parent | a7f95266a51e905b0fea0cfe43809023038a7428 (diff) | |
download | gtk+-6ac30db004c4a768aaf74286bcc21ff7123e0550.tar.gz |
Allow to separate GtkTextMark creation from buffer insertion. (#132818,
2007-05-25 Matthias Clasen <mclasen@redhat.com>
Allow to separate GtkTextMark creation from buffer insertion.
(#132818, Gustavo Giráldez, patch by Yevgen Muntyan)
* gtk/gtktextmarkprivate.h:
* gtk/gtktextmark.[hc] (gtk_text_mark_new): New function to
create a GtkTextMark.
* gtk/gtktextbuffer.[hc] (gtk_text_buffer_add_mark): New
function to add an existing mark to a buffer.
* gtk/gtktextbtree.c: Allow adding existing marks.
* gtk/gtk.symbols: Add new functions.
* tests/testtextbuffer.c: Add some tests for new mark
functionality.
svn path=/trunk/; revision=17922
Diffstat (limited to 'gtk/gtktextbtree.c')
-rw-r--r-- | gtk/gtktextbtree.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index 7601803371..93f6b4b3d9 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -2692,7 +2692,12 @@ real_set_mark (GtkTextBTree *tree, g_return_val_if_fail (_gtk_text_iter_get_btree (where) == tree, NULL); if (existing_mark) - mark = existing_mark->segment; + { + if (gtk_text_mark_get_buffer (existing_mark) != NULL) + mark = existing_mark->segment; + else + mark = NULL; + } else if (name != NULL) mark = g_hash_table_lookup (tree->mark_table, name); @@ -2752,9 +2757,13 @@ real_set_mark (GtkTextBTree *tree, } else { - mark = _gtk_mark_segment_new (tree, - left_gravity, - name); + if (existing_mark) + g_object_ref (existing_mark); + else + existing_mark = gtk_text_mark_new (name, left_gravity); + + mark = existing_mark->segment; + _gtk_mark_segment_set_tree (mark, tree); mark->body.mark.line = _gtk_text_iter_get_text_line (&iter); @@ -2980,7 +2989,8 @@ gtk_text_mark_set_visible (GtkTextMark *mark, { seg->body.mark.visible = setting; - redisplay_mark (seg); + if (seg->body.mark.tree) + redisplay_mark (seg); } } |