#include "gtktextiterprivate.h"
#include "gtktextutil.h"
#include "gtkintl.h"
-#include "gtkalias.h"
#include <stdlib.h>
#include <string.h>
static void gtk_text_layout_update_cursor_line (GtkTextLayout *layout);
+static void line_display_index_to_iter (GtkTextLayout *layout,
+ GtkTextLineDisplay *display,
+ GtkTextIter *iter,
+ gint index,
+ gint trailing);
+
+static gint line_display_iter_to_index (GtkTextLayout *layout,
+ GtkTextLineDisplay *display,
+ const GtkTextIter *iter);
+
enum {
INVALIDATED,
CHANGED,
_gtk_marshal_VOID__OBJECT_INT_INT,
G_TYPE_NONE,
3,
- GTK_TYPE_OBJECT,
+ G_TYPE_OBJECT,
G_TYPE_INT,
G_TYPE_INT);
G_OBJECT_CLASS (gtk_text_layout_parent_class)->finalize (object);
}
+/**
+ * gtk_text_layout_set_buffer:
+ * @buffer: (allow-none):
+ */
void
gtk_text_layout_set_buffer (GtkTextLayout *layout,
GtkTextBuffer *buffer)
return GTK_TEXT_LAYOUT_GET_CLASS (layout)->wrap (layout, line, line_data);
}
+
+/**
+ * gtk_text_layout_get_lines:
+ *
+ * Return value: (element-type GtkTextLine) (transfer container):
+ */
GSList*
gtk_text_layout_get_lines (GtkTextLayout *layout,
/* [top_y, bottom_y) */
{
GtkTextAttrAppearance *appearance_attr = (GtkTextAttrAppearance *)attr;
- if (appearance_attr->appearance.bg_stipple)
- g_object_unref (appearance_attr->appearance.bg_stipple);
- if (appearance_attr->appearance.fg_stipple)
- g_object_unref (appearance_attr->appearance.fg_stipple);
-
g_slice_free (GtkTextAttrAppearance, appearance_attr);
}
return (gdk_color_equal (&appearance1->fg_color, &appearance2->fg_color) &&
gdk_color_equal (&appearance1->bg_color, &appearance2->bg_color) &&
- appearance1->fg_stipple == appearance2->fg_stipple &&
- appearance1->bg_stipple == appearance2->bg_stipple &&
appearance1->underline == appearance2->underline &&
appearance1->strikethrough == appearance2->strikethrough &&
appearance1->draw_bg == appearance2->draw_bg);
result->appearance = *appearance;
- if (appearance->bg_stipple)
- g_object_ref (appearance->bg_stipple);
- if (appearance->fg_stipple)
- g_object_ref (appearance->fg_stipple);
-
return (PangoAttribute *)result;
}
/* Found it */
GtkRequisition req;
- gtk_widget_get_child_requisition (child, &req);
-
+ gtk_widget_get_preferred_size (child, &req, NULL);
+
width = req.width;
height = req.height;
allocate_child_widgets (GtkTextLayout *text_layout,
GtkTextLineDisplay *display)
{
- GSList *shaped = display->shaped_objects;
PangoLayout *layout = display->layout;
- PangoLayoutIter *iter;
-
- iter = pango_layout_get_iter (layout);
-
+ PangoLayoutIter *run_iter;
+
+ run_iter = pango_layout_get_iter (layout);
do
{
- PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter);
+ PangoLayoutRun *run = pango_layout_iter_get_run_readonly (run_iter);
if (run && is_shape (run))
{
- GObject *shaped_object = shaped->data;
- shaped = shaped->next;
-
- /* shaped_object is NULL for child anchors with no
- * widgets stored at them
+ gint byte_index;
+ GtkTextIter text_iter;
+ GtkTextChildAnchor *anchor = NULL;
+ GList *widgets = NULL;
+ GList *l;
+
+ /* The pango iterator iterates in visual order.
+ * We use the byte index to find the child widget.
*/
- if (GTK_IS_WIDGET (shaped_object))
+ byte_index = pango_layout_iter_get_index (run_iter);
+ line_display_index_to_iter (text_layout, display, &text_iter, byte_index, 0);
+ anchor = gtk_text_iter_get_child_anchor (&text_iter);
+ if (anchor)
+ widgets = gtk_text_child_anchor_get_widgets (anchor);
+
+ for (l = widgets; l; l = l->next)
{
PangoRectangle extents;
+ GtkWidget *child = l->data;
- /* We emit "allocate_child" with the x,y of
- * the widget with respect to the top of the line
- * and the left side of the buffer
- */
-
- pango_layout_iter_get_run_extents (iter,
- NULL,
- &extents);
-
- g_signal_emit (text_layout,
- signals[ALLOCATE_CHILD],
- 0,
- shaped_object,
- PANGO_PIXELS (extents.x) + display->x_offset,
- PANGO_PIXELS (extents.y) + display->top_margin);
+ if (_gtk_anchored_child_get_layout (child) == text_layout)
+ {
+
+ /* We emit "allocate_child" with the x,y of
+ * the widget with respect to the top of the line
+ * and the left side of the buffer
+ */
+ pango_layout_iter_get_run_extents (run_iter,
+ NULL,
+ &extents);
+
+ g_signal_emit (text_layout,
+ signals[ALLOCATE_CHILD],
+ 0,
+ child,
+ PANGO_PIXELS (extents.x) + display->x_offset,
+ PANGO_PIXELS (extents.y) + display->top_margin);
+ }
}
+
+ g_list_free (widgets);
}
}
- while (pango_layout_iter_next_run (iter));
-
- pango_layout_iter_free (iter);
+ while (pango_layout_iter_next_run (run_iter));
+
+ pango_layout_iter_free (run_iter);
}
static void
size_only, FALSE);
add_pixbuf_attrs (layout, display, style,
seg, attrs, layout_byte_offset);
- memcpy (text + layout_byte_offset, gtk_text_unknown_char_utf8,
+ memcpy (text + layout_byte_offset, _gtk_text_unknown_char_utf8,
seg->byte_count);
layout_byte_offset += seg->byte_count;
buffer_byte_offset += seg->byte_count;
size_only, FALSE);
add_child_attrs (layout, display, style,
seg, attrs, layout_byte_offset);
- memcpy (text + layout_byte_offset, gtk_text_unknown_char_utf8,
+ memcpy (text + layout_byte_offset, _gtk_text_unknown_char_utf8,
seg->byte_count);
layout_byte_offset += seg->byte_count;
buffer_byte_offset += seg->byte_count;
* gtk_text_layout_get_cursor_locations:
* @layout: a #GtkTextLayout
* @iter: a #GtkTextIter
- * @strong_pos: location to store the strong cursor position (may be %NULL)
- * @weak_pos: location to store the weak cursor position (may be %NULL)
+ * @strong_pos: (allow-none): location to store the strong cursor position (may be %NULL)
+ * @weak_pos: (allow-none): location to store the weak cursor position (may be %NULL)
*
* Given an iterator within a text layout, determine the positions of the
* strong and weak cursors if the insertion point is at that
gtk_text_layout_update_cursor_line (layout);
}
-
-#define __GTK_TEXT_LAYOUT_C__
-#include "gtkaliasdef.c"