Commit ca83d0a3 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

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.
parent b506b461
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.
Fri Nov 3 08:58:38 2000 Tim Janik <timj@gtk.org>
* gtk/gtkobject.c: _g_signal_handlers_destroy() is prefixed with '_'
......
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.
Fri Nov 3 08:58:38 2000 Tim Janik <timj@gtk.org>
* gtk/gtkobject.c: _g_signal_handlers_destroy() is prefixed with '_'
......
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.
Fri Nov 3 08:58:38 2000 Tim Janik <timj@gtk.org>
* gtk/gtkobject.c: _g_signal_handlers_destroy() is prefixed with '_'
......
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.
Fri Nov 3 08:58:38 2000 Tim Janik <timj@gtk.org>
* gtk/gtkobject.c: _g_signal_handlers_destroy() is prefixed with '_'
......
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.
Fri Nov 3 08:58:38 2000 Tim Janik <timj@gtk.org>
* gtk/gtkobject.c: _g_signal_handlers_destroy() is prefixed with '_'
......
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.
Fri Nov 3 08:58:38 2000 Tim Janik <timj@gtk.org>
* gtk/gtkobject.c: _g_signal_handlers_destroy() is prefixed with '_'
......
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.
Fri Nov 3 08:58:38 2000 Tim Janik <timj@gtk.org>
* gtk/gtkobject.c: _g_signal_handlers_destroy() is prefixed with '_'
......
......@@ -56,6 +56,7 @@ VOID:INT,INT,POINTER
VOID:OBJECT
VOID:OBJECT,BOXED,BOXED
VOID:OBJECT,BOOLEAN
VOID:OBJECT,INT,INT
VOID:ENUM,INT
VOID:POINTER
VOID:POINTER,BOOLEAN
......
......@@ -56,6 +56,7 @@ VOID:INT,INT,POINTER
VOID:OBJECT
VOID:OBJECT,BOXED,BOXED
VOID:OBJECT,BOOLEAN
VOID:OBJECT,INT,INT
VOID:ENUM,INT
VOID:POINTER
VOID:POINTER,BOOLEAN
......
......@@ -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 == &gtk_text_pixbuf_type)
else if (seg->type == &gtk_text_pixbuf_type ||
seg->type == &gtk_text_child_type)
{
gboolean copy = TRUE;
......
......@@ -34,7 +34,9 @@ void gtk_text_btree_insert (GtkTextIter *iter,
void gtk_text_btree_insert_pixbuf (GtkTextIter *iter,
GdkPixbuf *pixbuf);
GtkTextChildAnchor* gtk_text_btree_create_child_anchor (GtkTextIter *iter);
void gtk_text_btree_unregister_child_anchor (GtkTextChildAnchor *anchor);
/* View stuff */
GtkTextLine *gtk_text_btree_find_line_by_y (GtkTextBTree *tree,
......@@ -129,6 +131,11 @@ gboolean gtk_text_btree_get_iter_at_last_toggle (GtkTextBTree *tree,
GtkTextIter *iter,
GtkTextTag *tag);
void gtk_text_btree_get_iter_at_child_anchor (GtkTextBTree *tree,
GtkTextIter *iter,
GtkTextChildAnchor *anchor);
/* Manipulate marks */
GtkTextMark *gtk_text_btree_set_mark (GtkTextBTree *tree,
......
......@@ -93,6 +93,7 @@ static void gtk_text_buffer_real_remove_tag (GtkTextBuffer *buffe
GtkTextTag *tag,
const GtkTextIter *start_char,
const GtkTextIter *end_char);
static void gtk_text_buffer_real_changed (GtkTextBuffer *buffer);
static GtkTextBTree* get_btree (GtkTextBuffer *buffer);
......@@ -230,6 +231,7 @@ gtk_text_buffer_class_init (GtkTextBufferClass *klass)
klass->delete_text = gtk_text_buffer_real_delete_text;
klass->apply_tag = gtk_text_buffer_real_apply_tag;
klass->remove_tag = gtk_text_buffer_real_remove_tag;
klass->changed = gtk_text_buffer_real_changed;
}
void
......@@ -401,8 +403,6 @@ gtk_text_buffer_real_insert_text (GtkTextBuffer *buffer,
gtk_text_btree_insert (iter, text, len);
gtk_signal_emit (GTK_OBJECT (buffer), signals[CHANGED]);
gtk_text_buffer_set_modified (buffer, TRUE);
}
static void
......@@ -738,8 +738,6 @@ gtk_text_buffer_real_delete_text (GtkTextBuffer *buffer,
gtk_text_buffer_update_primary_selection (buffer);
gtk_signal_emit (GTK_OBJECT (buffer), signals[CHANGED]);
gtk_text_buffer_set_modified (buffer, TRUE);
}
static void
......@@ -1021,10 +1019,31 @@ gtk_text_buffer_insert_pixbuf (GtkTextBuffer *buffer,
/* FIXME pixbuf-specific signal like insert_text */
gtk_signal_emit (GTK_OBJECT (buffer), signals[CHANGED]);
}
gtk_text_buffer_set_modified (buffer, TRUE);
/*
* Child anchor
*/
GtkTextChildAnchor*
gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer,
GtkTextIter *iter)
{
GtkTextChildAnchor *anchor;
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
g_return_val_if_fail (iter != NULL, NULL);
anchor = gtk_text_btree_create_child_anchor (iter);
/* FIXME child-anchor-specific signal */
gtk_signal_emit (GTK_OBJECT (buffer), signals[CHANGED]);
return anchor;
}
/*
* Mark manipulation
*/
......@@ -1350,41 +1369,19 @@ gtk_text_buffer_get_selection_bound (GtkTextBuffer *buffer)
return gtk_text_buffer_get_mark (buffer, "selection_bound");
}
GtkTextChildAnchor*
gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer,
const GtkTextIter *where)
{
/* FIXME: Implement? */
return NULL;
}
void
gtk_text_buffer_move_child_anchor (GtkTextBuffer *buffer,
GtkTextChildAnchor *anchor,
GtkTextIter *where)
{
}
void
gtk_text_buffer_delete_child_anchor (GtkTextBuffer *buffer,
GtkTextChildAnchor *anchor)
{
}
void
gtk_text_buffer_get_iter_at_child_anchor (GtkTextBuffer *buffer,
GtkTextIter *iter,
GtkTextChildAnchor *anchor)
{
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
g_return_if_fail (iter != NULL);
g_return_if_fail (GTK_IS_TEXT_CHILD_ANCHOR (anchor));
g_return_if_fail (!gtk_text_child_anchor_get_deleted (anchor));
gtk_text_btree_get_iter_at_child_anchor (get_btree (buffer),
iter,
anchor);
}
/**
......@@ -1473,6 +1470,11 @@ gtk_text_buffer_real_remove_tag (GtkTextBuffer *buffer,
gtk_text_btree_tag (start, end, tag, FALSE);
}
static void
gtk_text_buffer_real_changed (GtkTextBuffer *buffer)
{
gtk_text_buffer_set_modified (buffer, TRUE);
}
static void
gtk_text_buffer_emit_tag (GtkTextBuffer *buffer,
......
......@@ -78,8 +78,9 @@ struct _GtkTextBufferClass {
GtkTextIter *end,
gboolean interactive);
/* Only for text changed, marks/tags don't cause this
to be emitted */
/* Only for text/widgets/pixbuf changed, marks/tags don't cause this
* to be emitted
*/
void (* changed) (GtkTextBuffer *buffer);
......@@ -193,6 +194,10 @@ void gtk_text_buffer_insert_pixbuf (GtkTextBuffer *buffer,
GtkTextIter *iter,
GdkPixbuf *pixbuf);
/* Create a child anchor */
GtkTextChildAnchor *gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer,
GtkTextIter *iter);
/* Mark manipulation */
GtkTextMark *gtk_text_buffer_create_mark (GtkTextBuffer *buffer,
const gchar *mark_name,
......@@ -215,17 +220,6 @@ void gtk_text_buffer_delete_mark_by_name (GtkTextBuffer *buffer,
GtkTextMark* gtk_text_buffer_get_insert (GtkTextBuffer *buffer);
GtkTextMark* gtk_text_buffer_get_selection_bound (GtkTextBuffer *buffer);
/* Child widget anchors */
GtkTextChildAnchor* gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer,
const GtkTextIter *where);
void gtk_text_buffer_move_child_anchor (GtkTextBuffer *buffer,
GtkTextChildAnchor *anchor,
GtkTextIter *where);
void gtk_text_buffer_delete_child_anchor (GtkTextBuffer *buffer,
GtkTextChildAnchor *anchor);
/* efficiently move insert and selection_bound to same location */
void gtk_text_buffer_place_cursor (GtkTextBuffer *buffer,
const GtkTextIter *where);
......
......@@ -49,6 +49,7 @@
#include "gtktextchild.h"
#include "gtktextbtree.h"
#include "gtktextlayout.h"
static GtkTextLineSegment *
pixbuf_segment_cleanup_func (GtkTextLineSegment *seg,
......@@ -137,8 +138,35 @@ child_segment_delete_func (GtkTextLineSegment *seg,
GtkTextLine *line,
gboolean tree_gone)
{
_gtk_widget_segment_unref (seg);
GSList *tmp_list;
GSList *copy;
gtk_text_btree_unregister_child_anchor (seg->body.child.obj);
seg->body.child.tree = NULL;
seg->body.child.line = NULL;
/* avoid removing widgets while walking the list */
copy = g_slist_copy (seg->body.child.widgets);
tmp_list = copy;
while (tmp_list != NULL)
{
GtkWidget *child = tmp_list->data;
gtk_widget_destroy (child);
tmp_list = g_slist_next (tmp_list);
}
/* On removal from the widget's parents (GtkTextView),
* the widget should have been removed from the anchor.
*/
g_assert (seg->body.child.widgets == NULL);
g_slist_free (copy);
_gtk_widget_segment_unref (seg);
return 0;
}
......@@ -185,7 +213,8 @@ _gtk_widget_segment_new (void)
*/
seg->char_count = 1;
seg->body.child.ref_count = 1;
seg->body.child.obj = g_object_new (GTK_TYPE_TEXT_CHILD_ANCHOR, NULL);
seg->body.child.obj->segment = seg;
seg->body.child.widgets = NULL;
seg->body.child.tree = NULL;
seg->body.child.line = NULL;
......@@ -197,21 +226,23 @@ void
_gtk_widget_segment_add (GtkTextLineSegment *widget_segment,
GtkWidget *child)
{
g_assert (widget_segment->type = &gtk_text_child_type);
g_return_if_fail (widget_segment->type = &gtk_text_child_type);
g_return_if_fail (widget_segment->body.child.tree != NULL);
g_object_ref (G_OBJECT (child));
widget_segment->body.child.widgets =
g_slist_prepend (widget_segment->body.child.widgets,
child);
g_object_ref (G_OBJECT (child));
}
void
_gtk_widget_segment_remove (GtkTextLineSegment *widget_segment,
GtkWidget *child)
{
g_assert (widget_segment->type = &gtk_text_child_type);
g_return_if_fail (widget_segment->type = &gtk_text_child_type);
g_return_if_fail (widget_segment->body.child.tree != NULL);
widget_segment->body.child.widgets =
g_slist_remove (widget_segment->body.child.widgets,
child);
......@@ -224,7 +255,7 @@ _gtk_widget_segment_ref (GtkTextLineSegment *widget_segment)
{
g_assert (widget_segment->type = &gtk_text_child_type);
widget_segment->body.child.ref_count += 1;
g_object_ref (G_OBJECT (widget_segment->body.child.obj));
}
void
......@@ -232,55 +263,112 @@ _gtk_widget_segment_unref (GtkTextLineSegment *widget_segment)
{
g_assert (widget_segment->type = &gtk_text_child_type);
widget_segment->body.child.ref_count -= 1;
if (widget_segment->body.child.ref_count == 0)
{
GSList *tmp_list;
g_object_unref (G_OBJECT (widget_segment->body.child.obj));
}
if (widget_segment->body.child.tree == NULL)
g_warning ("widget segment destroyed while still in btree");
GtkTextLayout*
_gtk_anchored_child_get_layout (GtkWidget *child)
{
return gtk_object_get_data (GTK_OBJECT (child), "gtk-text-child-anchor-layout");
}
tmp_list = widget_segment->body.child.widgets;
while (tmp_list)
{
g_object_unref (G_OBJECT (tmp_list->data));
static void
_gtk_anchored_child_set_layout (GtkWidget *child,
GtkTextLayout *layout)
{
gtk_object_set_data (GTK_OBJECT (child),
"gtk-text-child-anchor-layout",
layout);
}
static void gtk_text_child_anchor_init (GtkTextChildAnchor *child_anchor);
static void gtk_text_child_anchor_class_init (GtkTextChildAnchorClass *klass);
static void gtk_text_child_anchor_finalize (GObject *obj);
tmp_list = g_slist_next (tmp_list);
}
static gpointer parent_class = NULL;
g_slist_free (widget_segment->body.child.widgets);
GType
gtk_text_child_anchor_get_type (void)
{
static GType object_type = 0;
g_free (widget_segment);
if (!object_type)
{
static const GTypeInfo object_info =
{
sizeof (GtkTextChildAnchorClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gtk_text_child_anchor_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkTextChildAnchor),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_text_child_anchor_init,
};
object_type = g_type_register_static (G_TYPE_OBJECT,
"GtkTextChildAnchor",
&object_info, 0);
}
return object_type;
}