diff options
author | Havoc Pennington <hp@redhat.com> | 2000-11-03 20:40:57 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-11-03 20:40:57 +0000 |
commit | ca83d0a3dcb6660cff67f61fca108b1b02c31859 (patch) | |
tree | e3fc8cfe149cdfaac5adb2750c24c200c38e276a /gtk/gtktextbtree.c | |
parent | b506b461cb03d4b3aac16f82298a5427f1baf759 (diff) | |
download | gtk+-ca83d0a3dcb6660cff67f61fca108b1b02c31859.tar.gz |
Get widgets working on the btree/buffer side. Display of them still
2000-11-03 Havoc Pennington <hp@redhat.com>
Get widgets working on the btree/buffer side. Display of them
still doesn't work.
* gtk/gtktextview.c: start implementing child widget stuff
* gtk/gtktextiter.c (gtk_text_iter_get_child_anchor): new function
* gtk/gtktextlayout.c: handle embedded widgets
* gtk/gtktextdisplay.c: handle embedded widgets
* gtk/gtktextchild.c: Implement all the child anchor goo
* gtk/gtktextbuffer.c (gtk_text_buffer_create_child_anchor): New
function
* gtk/gtktextbtree.c: Add child anchor table to the btree struct
(insert_pixbuf_or_widget_segment): abstract out common portions of
creating a child anchor or a pixbuf segment.
(gtk_text_btree_create_child_anchor): new function
(gtk_text_btree_unregister_child_anchor): new function
* gtk/gtkmarshal.list: added VOID:OBJECT,INT,INT for the
allocate_child signal on GtkTextLayout
* gtk/gtktextiter.c (gtk_text_iter_get_pixbuf): fix bogus return
values
(gtk_text_iter_get_child_anchor): new function
* gtk/gtktextbuffer.c (gtk_text_buffer_real_changed): Add a
default handler for the changed signal, which calls
gtk_text_buffer_set_modified(), instead of just always emitting
changed then calling set_modified() manually. I guess this is
maybe more flexible. It seems logical.
Diffstat (limited to 'gtk/gtktextbtree.c')
-rw-r--r-- | gtk/gtktextbtree.c | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index 3f0f7c2c2e..b73ba456c6 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -195,6 +195,8 @@ struct _GtkTextBTree { GtkTextLine *end_iter_line; guint end_iter_line_stamp; + + GHashTable *child_anchor_table; }; @@ -417,7 +419,8 @@ gtk_text_btree_new (GtkTextTagTable *table, tree); tree->mark_table = g_hash_table_new (g_str_hash, g_str_equal); - + tree->child_anchor_table = NULL; + /* We don't ref the buffer, since the buffer owns us; * we'd have some circularity issues. The buffer always * lasts longer than the BTree @@ -1053,11 +1056,11 @@ gtk_text_btree_insert (GtkTextIter *iter, } } -void -gtk_text_btree_insert_pixbuf (GtkTextIter *iter, - GdkPixbuf *pixbuf) +static void +insert_pixbuf_or_widget_segment (GtkTextIter *iter, + GtkTextLineSegment *seg) + { - GtkTextLineSegment *seg; GtkTextIter start; GtkTextLineSegment *prevPtr; GtkTextLine *line; @@ -1068,8 +1071,6 @@ gtk_text_btree_insert_pixbuf (GtkTextIter *iter, tree = gtk_text_iter_get_btree (iter); start_byte_offset = gtk_text_iter_get_line_index (iter); - seg = _gtk_pixbuf_segment_new (pixbuf); - prevPtr = gtk_text_line_segment_split (iter); if (prevPtr == NULL) { @@ -1092,11 +1093,54 @@ gtk_text_btree_insert_pixbuf (GtkTextIter *iter, gtk_text_btree_get_iter_at_line (tree, &start, line, start_byte_offset); *iter = start; - gtk_text_iter_next_char (iter); /* skip forward past the pixmap */ + gtk_text_iter_next_char (iter); /* skip forward past the segment */ gtk_text_btree_invalidate_region (tree, &start, iter); } + +void +gtk_text_btree_insert_pixbuf (GtkTextIter *iter, + GdkPixbuf *pixbuf) +{ + GtkTextLineSegment *seg; + + seg = _gtk_pixbuf_segment_new (pixbuf); + + insert_pixbuf_or_widget_segment (iter, seg); +} + +GtkTextChildAnchor* +gtk_text_btree_create_child_anchor (GtkTextIter *iter) +{ + GtkTextLineSegment *seg; + GtkTextBTree *tree; + + seg = _gtk_widget_segment_new (); + + insert_pixbuf_or_widget_segment (iter, seg); + + tree = seg->body.child.tree; + + if (tree->child_anchor_table == NULL) + tree->child_anchor_table = g_hash_table_new (NULL, NULL); + + g_hash_table_insert (tree->child_anchor_table, + seg->body.child.obj, + seg->body.child.obj); + + return seg->body.child.obj; +} + +void +gtk_text_btree_unregister_child_anchor (GtkTextChildAnchor *anchor) +{ + GtkTextLineSegment *seg; + seg = anchor->segment; + + g_hash_table_remove (seg->body.child.tree->child_anchor_table, + anchor); +} /* * View stuff @@ -2069,7 +2113,8 @@ copy_segment (GString *string, /* printf (" :%s\n", string->str); */ } - else if (seg->type == >k_text_pixbuf_type) + else if (seg->type == >k_text_pixbuf_type || + seg->type == >k_text_child_type) { gboolean copy = TRUE; |