forked from AuroraMiddleware/gtk
textview: Replace pixbufs by textures
This affects a few apis, such as gtk_text_iter_get_pixbuf, gtk_text_buffer_insert_pixbuf and GtkTextBuffer::insert-pixbuf, which have all been replaced by texture equivalents. Update all callers.
This commit is contained in:
parent
3d4743ee62
commit
0b39631464
@ -129,6 +129,7 @@ insert_text (GtkTextBuffer *buffer)
|
||||
GtkTextIter iter;
|
||||
GtkTextIter start, end;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
GtkIconTheme *icon_theme;
|
||||
|
||||
icon_theme = gtk_icon_theme_get_default ();
|
||||
@ -138,6 +139,7 @@ insert_text (GtkTextBuffer *buffer)
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
|
||||
NULL);
|
||||
g_assert (pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
|
||||
/* get start of buffer; each insertion will revalidate the
|
||||
* iterator to point to just after the inserted text.
|
||||
@ -232,9 +234,9 @@ insert_text (GtkTextBuffer *buffer)
|
||||
"heading", NULL);
|
||||
|
||||
gtk_text_buffer_insert (buffer, &iter, "The buffer can have images in it: ", -1);
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
gtk_text_buffer_insert (buffer, &iter, " for example.\n\n", -1);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Spacing. ", -1,
|
||||
@ -378,6 +380,7 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_apply_tag_by_name (buffer, "word_wrap", &start, &end);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1258,8 +1258,8 @@ _gtk_text_btree_insert (GtkTextIter *iter,
|
||||
}
|
||||
|
||||
static void
|
||||
insert_pixbuf_or_widget_segment (GtkTextIter *iter,
|
||||
GtkTextLineSegment *seg)
|
||||
insert_texture_or_widget_segment (GtkTextIter *iter,
|
||||
GtkTextLineSegment *seg)
|
||||
|
||||
{
|
||||
GtkTextIter start;
|
||||
@ -1296,19 +1296,19 @@ insert_pixbuf_or_widget_segment (GtkTextIter *iter,
|
||||
*iter = start;
|
||||
gtk_text_iter_forward_char (iter); /* skip forward past the segment */
|
||||
|
||||
DV (g_print ("invalidating due to inserting pixbuf/widget (%s)\n", G_STRLOC));
|
||||
DV (g_print ("invalidating due to inserting texture/widget (%s)\n", G_STRLOC));
|
||||
_gtk_text_btree_invalidate_region (tree, &start, iter, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_text_btree_insert_pixbuf (GtkTextIter *iter,
|
||||
GdkPixbuf *pixbuf)
|
||||
_gtk_text_btree_insert_texture (GtkTextIter *iter,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GtkTextLineSegment *seg;
|
||||
|
||||
seg = _gtk_pixbuf_segment_new (pixbuf);
|
||||
seg = _gtk_texture_segment_new (texture);
|
||||
|
||||
insert_pixbuf_or_widget_segment (iter, seg);
|
||||
insert_texture_or_widget_segment (iter, seg);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1329,7 +1329,7 @@ _gtk_text_btree_insert_child_anchor (GtkTextIter *iter,
|
||||
tree = seg->body.child.tree = _gtk_text_iter_get_btree (iter);
|
||||
seg->body.child.line = _gtk_text_iter_get_text_line (iter);
|
||||
|
||||
insert_pixbuf_or_widget_segment (iter, seg);
|
||||
insert_texture_or_widget_segment (iter, seg);
|
||||
|
||||
if (tree->child_anchor_table == NULL)
|
||||
tree->child_anchor_table = g_hash_table_new (NULL, NULL);
|
||||
@ -2379,7 +2379,7 @@ copy_segment (GString *string,
|
||||
|
||||
/* printf (" :%s\n", string->str); */
|
||||
}
|
||||
else if (seg->type == >k_text_pixbuf_type ||
|
||||
else if (seg->type == >k_text_texture_type ||
|
||||
seg->type == >k_text_child_type)
|
||||
{
|
||||
gboolean copy = TRUE;
|
||||
|
@ -68,8 +68,8 @@ void _gtk_text_btree_delete (GtkTextIter *start,
|
||||
void _gtk_text_btree_insert (GtkTextIter *iter,
|
||||
const gchar *text,
|
||||
gint len);
|
||||
void _gtk_text_btree_insert_pixbuf (GtkTextIter *iter,
|
||||
GdkPixbuf *pixbuf);
|
||||
void _gtk_text_btree_insert_texture (GtkTextIter *iter,
|
||||
GdkTexture *texture);
|
||||
|
||||
void _gtk_text_btree_insert_child_anchor (GtkTextIter *iter,
|
||||
GtkTextChildAnchor *anchor);
|
||||
|
@ -85,7 +85,7 @@ struct _ClipboardRequest
|
||||
|
||||
enum {
|
||||
INSERT_TEXT,
|
||||
INSERT_PIXBUF,
|
||||
INSERT_TEXTURE,
|
||||
INSERT_CHILD_ANCHOR,
|
||||
DELETE_RANGE,
|
||||
CHANGED,
|
||||
@ -121,9 +121,9 @@ static void gtk_text_buffer_real_insert_text (GtkTextBuffer *buffe
|
||||
GtkTextIter *iter,
|
||||
const gchar *text,
|
||||
gint len);
|
||||
static void gtk_text_buffer_real_insert_pixbuf (GtkTextBuffer *buffer,
|
||||
static void gtk_text_buffer_real_insert_texture (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GdkPixbuf *pixbuf);
|
||||
GdkTexture *texture);
|
||||
static void gtk_text_buffer_real_insert_anchor (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GtkTextChildAnchor *anchor);
|
||||
@ -180,7 +180,7 @@ gtk_text_buffer_class_init (GtkTextBufferClass *klass)
|
||||
object_class->notify = gtk_text_buffer_notify;
|
||||
|
||||
klass->insert_text = gtk_text_buffer_real_insert_text;
|
||||
klass->insert_pixbuf = gtk_text_buffer_real_insert_pixbuf;
|
||||
klass->insert_texture = gtk_text_buffer_real_insert_texture;
|
||||
klass->insert_child_anchor = gtk_text_buffer_real_insert_anchor;
|
||||
klass->delete_range = gtk_text_buffer_real_delete_range;
|
||||
klass->apply_tag = gtk_text_buffer_real_apply_tag;
|
||||
@ -311,33 +311,33 @@ gtk_text_buffer_class_init (GtkTextBufferClass *klass)
|
||||
_gtk_marshal_VOID__BOXED_STRING_INTv);
|
||||
|
||||
/**
|
||||
* GtkTextBuffer::insert-pixbuf:
|
||||
* GtkTextBuffer::insert-texture:
|
||||
* @textbuffer: the object which received the signal
|
||||
* @location: position to insert @pixbuf in @textbuffer
|
||||
* @pixbuf: the #GdkPixbuf to be inserted
|
||||
*
|
||||
* The ::insert-pixbuf signal is emitted to insert a #GdkPixbuf
|
||||
* @location: position to insert @texture in @textbuffer
|
||||
* @texture: the #GdkTexture to be inserted
|
||||
*
|
||||
* The ::insert-texture signal is emitted to insert a #GdkTexture
|
||||
* in a #GtkTextBuffer. Insertion actually occurs in the default handler.
|
||||
*
|
||||
* Note that if your handler runs before the default handler it must not
|
||||
* invalidate the @location iter (or has to revalidate it).
|
||||
* The default signal handler revalidates it to be placed after the
|
||||
* inserted @pixbuf.
|
||||
*
|
||||
* See also: gtk_text_buffer_insert_pixbuf().
|
||||
*
|
||||
* Note that if your handler runs before the default handler it must not
|
||||
* invalidate the @location iter (or has to revalidate it).
|
||||
* The default signal handler revalidates it to be placed after the
|
||||
* inserted @texture.
|
||||
*
|
||||
* See also: gtk_text_buffer_insert_texture().
|
||||
*/
|
||||
signals[INSERT_PIXBUF] =
|
||||
g_signal_new (I_("insert-pixbuf"),
|
||||
signals[INSERT_TEXTURE] =
|
||||
g_signal_new (I_("insert-texture"),
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkTextBufferClass, insert_pixbuf),
|
||||
G_STRUCT_OFFSET (GtkTextBufferClass, insert_texture),
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__BOXED_OBJECT,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
GDK_TYPE_PIXBUF);
|
||||
g_signal_set_va_marshaller (signals[INSERT_PIXBUF],
|
||||
GDK_TYPE_TEXTURE);
|
||||
g_signal_set_va_marshaller (signals[INSERT_TEXTURE],
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_VOID__BOXED_OBJECTv);
|
||||
|
||||
@ -1198,26 +1198,25 @@ insert_range_untagged (GtkTextBuffer *buffer,
|
||||
}
|
||||
else if (gtk_text_iter_get_char (&range_end) == GTK_TEXT_UNKNOWN_CHAR)
|
||||
{
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GtkTextChildAnchor *anchor = NULL;
|
||||
pixbuf = gtk_text_iter_get_pixbuf (&range_end);
|
||||
GdkTexture *texture;
|
||||
GtkTextChildAnchor *anchor;
|
||||
|
||||
texture = gtk_text_iter_get_texture (&range_end);
|
||||
anchor = gtk_text_iter_get_child_anchor (&range_end);
|
||||
|
||||
if (pixbuf)
|
||||
if (texture)
|
||||
{
|
||||
r = save_range (&range_start,
|
||||
&range_end,
|
||||
&end);
|
||||
|
||||
gtk_text_buffer_insert_pixbuf (buffer,
|
||||
iter,
|
||||
pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, iter, texture);
|
||||
|
||||
restore_range (r);
|
||||
r = NULL;
|
||||
|
||||
|
||||
gtk_text_iter_forward_char (&range_end);
|
||||
|
||||
|
||||
range_start = range_end;
|
||||
}
|
||||
else if (anchor)
|
||||
@ -1413,7 +1412,7 @@ gtk_text_buffer_real_insert_range (GtkTextBuffer *buffer,
|
||||
* @start: a position in a #GtkTextBuffer
|
||||
* @end: another position in the same buffer as @start
|
||||
*
|
||||
* Copies text, tags, and pixbufs between @start and @end (the order
|
||||
* Copies text, tags, and texture between @start and @end (the order
|
||||
* of @start and @end doesn’t matter) and inserts the copy at @iter.
|
||||
* Used instead of simply getting/inserting text because it preserves
|
||||
* images and tags. If @start and @end are in a different buffer from
|
||||
@ -1873,7 +1872,7 @@ gtk_text_buffer_get_text (GtkTextBuffer *buffer,
|
||||
* the returned string do correspond to byte
|
||||
* and character indexes into the buffer. Contrast with
|
||||
* gtk_text_buffer_get_text(). Note that 0xFFFC can occur in normal
|
||||
* text as well, so it is not a reliable indicator that a pixbuf or
|
||||
* text as well, so it is not a reliable indicator that a texture or
|
||||
* widget is in the buffer.
|
||||
*
|
||||
* Returns: (transfer full): an allocated UTF-8 string
|
||||
@ -1901,42 +1900,41 @@ gtk_text_buffer_get_slice (GtkTextBuffer *buffer,
|
||||
*/
|
||||
|
||||
static void
|
||||
gtk_text_buffer_real_insert_pixbuf (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GdkPixbuf *pixbuf)
|
||||
gtk_text_buffer_real_insert_texture (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
_gtk_text_btree_insert_pixbuf (iter, pixbuf);
|
||||
_gtk_text_btree_insert_texture (iter, texture);
|
||||
|
||||
g_signal_emit (buffer, signals[CHANGED], 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_buffer_insert_pixbuf:
|
||||
* gtk_text_buffer_insert_texture:
|
||||
* @buffer: a #GtkTextBuffer
|
||||
* @iter: location to insert the pixbuf
|
||||
* @pixbuf: a #GdkPixbuf
|
||||
* @iter: location to insert the texture
|
||||
* @texture: a #GdkTexture
|
||||
*
|
||||
* Inserts an image into the text buffer at @iter. The image will be
|
||||
* counted as one character in character counts, and when obtaining
|
||||
* the buffer contents as a string, will be represented by the Unicode
|
||||
* “object replacement character” 0xFFFC. Note that the “slice”
|
||||
* variants for obtaining portions of the buffer as a string include
|
||||
* this character for pixbufs, but the “text” variants do
|
||||
* this character for texture, but the “text” variants do
|
||||
* not. e.g. see gtk_text_buffer_get_slice() and
|
||||
* gtk_text_buffer_get_text().
|
||||
**/
|
||||
void
|
||||
gtk_text_buffer_insert_pixbuf (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GdkPixbuf *pixbuf)
|
||||
gtk_text_buffer_insert_texture (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
|
||||
g_return_if_fail (iter != NULL);
|
||||
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
|
||||
g_return_if_fail (GDK_IS_TEXTURE (texture));
|
||||
g_return_if_fail (gtk_text_iter_get_buffer (iter) == buffer);
|
||||
|
||||
g_signal_emit (buffer, signals[INSERT_PIXBUF], 0,
|
||||
iter, pixbuf);
|
||||
|
||||
g_signal_emit (buffer, signals[INSERT_TEXTURE], 0, iter, texture);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -86,22 +86,17 @@ struct _GtkTextBuffer
|
||||
* GtkTextBufferClass:
|
||||
* @parent_class: The object class structure needs to be the first.
|
||||
* @insert_text: The class handler for the #GtkTextBuffer::insert-text signal.
|
||||
* @insert_pixbuf: The class handler for the #GtkTextBuffer::insert-pixbuf
|
||||
* signal.
|
||||
* @insert_child_anchor: The class handler for the
|
||||
* #GtkTextBuffer::insert-child-anchor signal.
|
||||
* @insert_texture: The class handler for the #GtkTextBuffer::insert-texture signal.
|
||||
* @insert_child_anchor: The class handler for the #GtkTextBuffer::insert-child-anchor signal.
|
||||
* @delete_range: The class handler for the #GtkTextBuffer::delete-range signal.
|
||||
* @changed: The class handler for the #GtkTextBuffer::changed signal.
|
||||
* @modified_changed: The class handler for the #GtkTextBuffer::modified-changed
|
||||
* signal.
|
||||
* @modified_changed: The class handler for the #GtkTextBuffer::modified-changed signal.
|
||||
* @mark_set: The class handler for the #GtkTextBuffer::mark-set signal.
|
||||
* @mark_deleted: The class handler for the #GtkTextBuffer::mark-deleted signal.
|
||||
* @apply_tag: The class handler for the #GtkTextBuffer::apply-tag signal.
|
||||
* @remove_tag: The class handler for the #GtkTextBuffer::remove-tag signal.
|
||||
* @begin_user_action: The class handler for the
|
||||
* #GtkTextBuffer::begin-user-action signal.
|
||||
* @end_user_action: The class handler for the #GtkTextBuffer::end-user-action
|
||||
* signal.
|
||||
* @begin_user_action: The class handler for the #GtkTextBuffer::begin-user-action signal.
|
||||
* @end_user_action: The class handler for the #GtkTextBuffer::end-user-action signal.
|
||||
* @paste_done: The class handler for the #GtkTextBuffer::paste-done signal.
|
||||
*/
|
||||
struct _GtkTextBufferClass
|
||||
@ -113,9 +108,9 @@ struct _GtkTextBufferClass
|
||||
const gchar *new_text,
|
||||
gint new_text_length);
|
||||
|
||||
void (* insert_pixbuf) (GtkTextBuffer *buffer,
|
||||
void (* insert_texture) (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GdkPixbuf *pixbuf);
|
||||
GdkTexture *texture);
|
||||
|
||||
void (* insert_child_anchor) (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
@ -271,11 +266,11 @@ gchar *gtk_text_buffer_get_slice (GtkTextBuffer *buffer,
|
||||
const GtkTextIter *end,
|
||||
gboolean include_hidden_chars);
|
||||
|
||||
/* Insert a pixbuf */
|
||||
/* Insert a texture */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_text_buffer_insert_pixbuf (GtkTextBuffer *buffer,
|
||||
void gtk_text_buffer_insert_texture (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GdkPixbuf *pixbuf);
|
||||
GdkTexture *texture);
|
||||
|
||||
/* Insert a child anchor */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -72,67 +72,67 @@
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#define PIXBUF_SEG_SIZE ((unsigned) (G_STRUCT_OFFSET (GtkTextLineSegment, body) \
|
||||
+ sizeof (GtkTextPixbuf)))
|
||||
#define TEXTURE_SEG_SIZE ((unsigned) (G_STRUCT_OFFSET (GtkTextLineSegment, body) \
|
||||
+ sizeof (GtkTextTexture)))
|
||||
|
||||
#define WIDGET_SEG_SIZE ((unsigned) (G_STRUCT_OFFSET (GtkTextLineSegment, body) \
|
||||
+ sizeof (GtkTextChildBody)))
|
||||
|
||||
static GtkTextLineSegment *
|
||||
pixbuf_segment_cleanup_func (GtkTextLineSegment *seg,
|
||||
GtkTextLine *line)
|
||||
texture_segment_cleanup_func (GtkTextLineSegment *seg,
|
||||
GtkTextLine *line)
|
||||
{
|
||||
/* nothing */
|
||||
return seg;
|
||||
}
|
||||
|
||||
static int
|
||||
pixbuf_segment_delete_func (GtkTextLineSegment *seg,
|
||||
GtkTextLine *line,
|
||||
gboolean tree_gone)
|
||||
texture_segment_delete_func (GtkTextLineSegment *seg,
|
||||
GtkTextLine *line,
|
||||
gboolean tree_gone)
|
||||
{
|
||||
if (seg->body.pixbuf.pixbuf)
|
||||
g_object_unref (seg->body.pixbuf.pixbuf);
|
||||
if (seg->body.texture.texture)
|
||||
g_object_unref (seg->body.texture.texture);
|
||||
|
||||
g_slice_free1 (PIXBUF_SEG_SIZE, seg);
|
||||
g_slice_free1 (TEXTURE_SEG_SIZE, seg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_segment_check_func (GtkTextLineSegment *seg,
|
||||
GtkTextLine *line)
|
||||
texture_segment_check_func (GtkTextLineSegment *seg,
|
||||
GtkTextLine *line)
|
||||
{
|
||||
if (seg->next == NULL)
|
||||
g_error ("pixbuf segment is the last segment in a line");
|
||||
g_error ("texture segment is the last segment in a line");
|
||||
|
||||
if (seg->byte_count != GTK_TEXT_UNKNOWN_CHAR_UTF8_LEN)
|
||||
g_error ("pixbuf segment has byte count of %d", seg->byte_count);
|
||||
g_error ("texture segment has byte count of %d", seg->byte_count);
|
||||
|
||||
if (seg->char_count != 1)
|
||||
g_error ("pixbuf segment has char count of %d", seg->char_count);
|
||||
g_error ("texture segment has char count of %d", seg->char_count);
|
||||
}
|
||||
|
||||
|
||||
const GtkTextLineSegmentClass gtk_text_pixbuf_type = {
|
||||
"pixbuf", /* name */
|
||||
const GtkTextLineSegmentClass gtk_text_texture_type = {
|
||||
"texture", /* name */
|
||||
FALSE, /* leftGravity */
|
||||
NULL, /* splitFunc */
|
||||
pixbuf_segment_delete_func, /* deleteFunc */
|
||||
pixbuf_segment_cleanup_func, /* cleanupFunc */
|
||||
texture_segment_delete_func, /* deleteFunc */
|
||||
texture_segment_cleanup_func, /* cleanupFunc */
|
||||
NULL, /* lineChangeFunc */
|
||||
pixbuf_segment_check_func /* checkFunc */
|
||||
texture_segment_check_func /* checkFunc */
|
||||
|
||||
};
|
||||
|
||||
GtkTextLineSegment *
|
||||
_gtk_pixbuf_segment_new (GdkPixbuf *pixbuf)
|
||||
_gtk_texture_segment_new (GdkTexture *texture)
|
||||
{
|
||||
GtkTextLineSegment *seg;
|
||||
|
||||
seg = g_slice_alloc (PIXBUF_SEG_SIZE);
|
||||
seg = g_slice_alloc (TEXTURE_SEG_SIZE);
|
||||
|
||||
seg->type = >k_text_pixbuf_type;
|
||||
seg->type = >k_text_texture_type;
|
||||
|
||||
seg->next = NULL;
|
||||
|
||||
@ -142,9 +142,9 @@ _gtk_pixbuf_segment_new (GdkPixbuf *pixbuf)
|
||||
seg->byte_count = GTK_TEXT_UNKNOWN_CHAR_UTF8_LEN;
|
||||
seg->char_count = 1;
|
||||
|
||||
seg->body.pixbuf.pixbuf = pixbuf;
|
||||
seg->body.texture.texture = texture;
|
||||
|
||||
g_object_ref (pixbuf);
|
||||
g_object_ref (texture);
|
||||
|
||||
return seg;
|
||||
}
|
||||
|
@ -54,14 +54,14 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkTextPixbuf GtkTextPixbuf;
|
||||
typedef struct _GtkTextTexture GtkTextTexture;
|
||||
|
||||
struct _GtkTextPixbuf
|
||||
struct _GtkTextTexture
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
};
|
||||
|
||||
GtkTextLineSegment *_gtk_pixbuf_segment_new (GdkPixbuf *pixbuf);
|
||||
GtkTextLineSegment *_gtk_texture_segment_new (GdkTexture *texture);
|
||||
|
||||
typedef struct _GtkTextChildBody GtkTextChildBody;
|
||||
|
||||
|
@ -79,6 +79,7 @@
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
|
||||
/* DO NOT go putting private headers in here. This file should only
|
||||
* use the semi-public headers, as with gtktextview.c.
|
||||
@ -414,19 +415,24 @@ gtk_text_renderer_draw_shape (PangoRenderer *renderer,
|
||||
|
||||
unset_color (text_renderer);
|
||||
}
|
||||
else if (GDK_IS_PIXBUF (attr->data))
|
||||
else if (GDK_IS_TEXTURE (attr->data))
|
||||
{
|
||||
cairo_t *cr = text_renderer->cr;
|
||||
GdkPixbuf *pixbuf = GDK_PIXBUF (attr->data);
|
||||
|
||||
GdkTexture *texture = GDK_TEXTURE (attr->data);
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = gdk_texture_download_surface (texture);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
gdk_cairo_set_source_pixbuf (cr, pixbuf,
|
||||
PANGO_PIXELS (x),
|
||||
PANGO_PIXELS (y) - gdk_pixbuf_get_height (pixbuf));
|
||||
cairo_set_source_surface (cr, surface,
|
||||
PANGO_PIXELS (x),
|
||||
PANGO_PIXELS (y) - gdk_texture_get_height (texture));
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
else if (GTK_IS_WIDGET (attr->data))
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ gtk_text_iter_make_surreal (const GtkTextIter *_iter)
|
||||
_gtk_text_btree_get_chars_changed_stamp (iter->tree))
|
||||
{
|
||||
g_warning ("Invalid text buffer iterator: either the iterator "
|
||||
"is uninitialized, or the characters/pixbufs/widgets "
|
||||
"is uninitialized, or the characters/textures/widgets "
|
||||
"in the buffer have been modified since the iterator "
|
||||
"was created.\nYou must use marks, character numbers, "
|
||||
"or line numbers to preserve a position across buffer "
|
||||
@ -896,7 +896,7 @@ gtk_text_iter_get_char (const GtkTextIter *iter)
|
||||
* such as images. Because images are encoded in the slice, byte and
|
||||
* character offsets in the returned array will correspond to byte
|
||||
* offsets in the text buffer. Note that 0xFFFC can occur in normal
|
||||
* text as well, so it is not a reliable indicator that a pixbuf or
|
||||
* text as well, so it is not a reliable indicator that a texture or
|
||||
* widget is in the buffer.
|
||||
*
|
||||
* Returns: (transfer full): slice of text from the buffer
|
||||
@ -990,17 +990,16 @@ gtk_text_iter_get_visible_text (const GtkTextIter *start,
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_iter_get_pixbuf:
|
||||
* gtk_text_iter_get_texture:
|
||||
* @iter: an iterator
|
||||
*
|
||||
* If the element at @iter is a pixbuf, the pixbuf is returned
|
||||
* (with no new reference count added). Otherwise,
|
||||
* %NULL is returned.
|
||||
* If the element at @iter is a texture, the texture is returned
|
||||
* (with no new reference count added). Otherwise, %NULL is returned.
|
||||
*
|
||||
* Returns: (transfer none): the pixbuf at @iter
|
||||
* Returns: (transfer none): the texture at @iter
|
||||
**/
|
||||
GdkPixbuf*
|
||||
gtk_text_iter_get_pixbuf (const GtkTextIter *iter)
|
||||
GdkTexture *
|
||||
gtk_text_iter_get_texture (const GtkTextIter *iter)
|
||||
{
|
||||
GtkTextRealIter *real;
|
||||
|
||||
@ -1013,10 +1012,10 @@ gtk_text_iter_get_pixbuf (const GtkTextIter *iter)
|
||||
|
||||
check_invariants (iter);
|
||||
|
||||
if (real->segment->type != >k_text_pixbuf_type)
|
||||
if (real->segment->type != >k_text_texture_type)
|
||||
return NULL;
|
||||
else
|
||||
return real->segment->body.pixbuf.pixbuf;
|
||||
return real->segment->body.texture.texture;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2446,7 +2445,7 @@ gtk_text_iter_backward_chars (GtkTextIter *iter, gint count)
|
||||
* @iter: a #GtkTextIter
|
||||
* @count: number of chars to move
|
||||
*
|
||||
* Moves forward by @count text characters (pixbufs, widgets,
|
||||
* Moves forward by @count text characters (textures, widgets,
|
||||
* etc. do not count as characters for this). Equivalent to moving
|
||||
* through the results of gtk_text_iter_get_text(), rather than
|
||||
* gtk_text_iter_get_slice().
|
||||
@ -2467,7 +2466,7 @@ gtk_text_iter_forward_text_chars (GtkTextIter *iter,
|
||||
* @iter: a #GtkTextIter
|
||||
* @count: number of chars to move
|
||||
*
|
||||
* Moves backward by @count text characters (pixbufs, widgets,
|
||||
* Moves backward by @count text characters (textures, widgets,
|
||||
* etc. do not count as characters for this). Equivalent to moving
|
||||
* through the results of gtk_text_iter_get_text(), rather than
|
||||
* gtk_text_iter_get_slice().
|
||||
|
@ -38,7 +38,7 @@ G_BEGIN_DECLS
|
||||
* GtkTextSearchFlags:
|
||||
* @GTK_TEXT_SEARCH_VISIBLE_ONLY: Search only visible data. A search match may
|
||||
* have invisible text interspersed.
|
||||
* @GTK_TEXT_SEARCH_TEXT_ONLY: Search only text. A match may have pixbufs or
|
||||
* @GTK_TEXT_SEARCH_TEXT_ONLY: Search only text. A match may have textures or
|
||||
* child widgets mixed inside the matched range.
|
||||
* @GTK_TEXT_SEARCH_CASE_INSENSITIVE: The text will be matched regardless of
|
||||
* what case it is in.
|
||||
@ -47,7 +47,7 @@ G_BEGIN_DECLS
|
||||
*
|
||||
* If neither #GTK_TEXT_SEARCH_VISIBLE_ONLY nor #GTK_TEXT_SEARCH_TEXT_ONLY are
|
||||
* enabled, the match must be exact; the special 0xFFFC character will match
|
||||
* embedded pixbufs or child widgets.
|
||||
* embedded textures or child widgets.
|
||||
*/
|
||||
typedef enum {
|
||||
GTK_TEXT_SEARCH_VISIBLE_ONLY = 1 << 0,
|
||||
@ -155,7 +155,7 @@ gchar *gtk_text_iter_get_visible_text (const GtkTextIter *start,
|
||||
const GtkTextIter *end);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkPixbuf* gtk_text_iter_get_pixbuf (const GtkTextIter *iter);
|
||||
GdkTexture * gtk_text_iter_get_texture (const GtkTextIter *iter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GSList * gtk_text_iter_get_marks (const GtkTextIter *iter);
|
||||
|
||||
|
@ -1686,20 +1686,20 @@ add_text_attrs (GtkTextLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
add_pixbuf_attrs (GtkTextLayout *layout,
|
||||
GtkTextLineDisplay *display,
|
||||
GtkTextAttributes *style,
|
||||
GtkTextLineSegment *seg,
|
||||
PangoAttrList *attrs,
|
||||
gint start)
|
||||
add_texture_attrs (GtkTextLayout *layout,
|
||||
GtkTextLineDisplay *display,
|
||||
GtkTextAttributes *style,
|
||||
GtkTextLineSegment *seg,
|
||||
PangoAttrList *attrs,
|
||||
gint start)
|
||||
{
|
||||
PangoAttribute *attr;
|
||||
PangoRectangle logical_rect;
|
||||
GtkTextPixbuf *pixbuf = &seg->body.pixbuf;
|
||||
GtkTextTexture *texture = &seg->body.texture;
|
||||
gint width, height;
|
||||
|
||||
width = gdk_pixbuf_get_width (pixbuf->pixbuf);
|
||||
height = gdk_pixbuf_get_height (pixbuf->pixbuf);
|
||||
width = gdk_texture_get_width (texture->texture);
|
||||
height = gdk_texture_get_height (texture->texture);
|
||||
|
||||
logical_rect.x = 0;
|
||||
logical_rect.y = -height * PANGO_SCALE;
|
||||
@ -1707,7 +1707,7 @@ add_pixbuf_attrs (GtkTextLayout *layout,
|
||||
logical_rect.height = height * PANGO_SCALE;
|
||||
|
||||
attr = pango_attr_shape_new_with_data (&logical_rect, &logical_rect,
|
||||
pixbuf->pixbuf, NULL, NULL);
|
||||
texture->texture, NULL, NULL);
|
||||
attr->start_index = start;
|
||||
attr->end_index = start + seg->byte_count;
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
@ -2120,7 +2120,7 @@ update_text_display_cursors (GtkTextLayout *layout,
|
||||
{
|
||||
/* Displayable segments */
|
||||
if (seg->type == >k_text_char_type ||
|
||||
seg->type == >k_text_pixbuf_type ||
|
||||
seg->type == >k_text_texture_type ||
|
||||
seg->type == >k_text_child_type)
|
||||
{
|
||||
gtk_text_layout_get_iter_at_line (layout, &iter, line,
|
||||
@ -2336,14 +2336,14 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
|
||||
{
|
||||
/* Displayable segments */
|
||||
if (seg->type == >k_text_char_type ||
|
||||
seg->type == >k_text_pixbuf_type ||
|
||||
seg->type == >k_text_texture_type ||
|
||||
seg->type == >k_text_child_type)
|
||||
{
|
||||
style = get_style (layout, tags);
|
||||
initial_toggle_segments = FALSE;
|
||||
|
||||
/* We have to delay setting the paragraph values until we
|
||||
* hit the first pixbuf or text segment because toggles at
|
||||
* hit the first texture or text segment because toggles at
|
||||
* the beginning of the paragraph should affect the
|
||||
* paragraph-global values
|
||||
*/
|
||||
@ -2417,15 +2417,15 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
|
||||
add_text_attrs (layout, style, bytes, attrs,
|
||||
layout_byte_offset - bytes, size_only);
|
||||
}
|
||||
else if (seg->type == >k_text_pixbuf_type)
|
||||
else if (seg->type == >k_text_texture_type)
|
||||
{
|
||||
add_generic_attrs (layout,
|
||||
&style->appearance,
|
||||
seg->byte_count,
|
||||
attrs, layout_byte_offset,
|
||||
size_only, FALSE);
|
||||
add_pixbuf_attrs (layout, display, style,
|
||||
seg, attrs, layout_byte_offset);
|
||||
add_texture_attrs (layout, display, style,
|
||||
seg, attrs, layout_byte_offset);
|
||||
memcpy (text + layout_byte_offset, _gtk_text_unknown_char_utf8,
|
||||
seg->byte_count);
|
||||
layout_byte_offset += seg->byte_count;
|
||||
|
@ -144,7 +144,7 @@ struct _GtkTextLineSegment {
|
||||
* hold as many characters as needed.*/
|
||||
GtkTextToggleBody toggle; /* Information about tag toggle. */
|
||||
GtkTextMarkBody mark; /* Information about mark. */
|
||||
GtkTextPixbuf pixbuf; /* Child pixbuf */
|
||||
GtkTextTexture texture; /* Child texture */
|
||||
GtkTextChildBody child; /* Child widget */
|
||||
} body;
|
||||
};
|
||||
|
@ -50,7 +50,7 @@ extern G_GNUC_INTERNAL const GtkTextLineSegmentClass gtk_text_left_mark_type;
|
||||
extern G_GNUC_INTERNAL const GtkTextLineSegmentClass gtk_text_right_mark_type;
|
||||
|
||||
/* In gtktextchild.c */
|
||||
extern G_GNUC_INTERNAL const GtkTextLineSegmentClass gtk_text_pixbuf_type;
|
||||
extern G_GNUC_INTERNAL const GtkTextLineSegmentClass gtk_text_texture_type;
|
||||
extern G_GNUC_INTERNAL const GtkTextLineSegmentClass gtk_text_child_type;
|
||||
|
||||
/*
|
||||
|
@ -638,6 +638,7 @@ fill_buffer (GtkTextBuffer *buffer)
|
||||
GtkTextIter iter;
|
||||
GtkTextIter iter2;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
int i;
|
||||
|
||||
color.red = 0.0;
|
||||
@ -675,8 +676,9 @@ fill_buffer (GtkTextBuffer *buffer)
|
||||
NULL);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
|
||||
g_assert (pixbuf != NULL);
|
||||
g_assert (texture != NULL);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
@ -684,11 +686,11 @@ fill_buffer (GtkTextBuffer *buffer)
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
|
||||
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 1);
|
||||
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
|
||||
str = g_strdup_printf ("%d Hello World!\nwoo woo woo woo woo woo woo woo\n",
|
||||
i);
|
||||
@ -704,20 +706,20 @@ fill_buffer (GtkTextBuffer *buffer)
|
||||
"Spanish (Espa\303\261ol) \302\241Hola! / French (Fran\303\247ais) Bonjour, Salut / German (Deutsch S\303\274d) Gr\303\274\303\237 Gott (testing Latin-1 chars encoded in UTF8)\nThai (we can't display this, just making sure we don't crash) (\340\270\240\340\270\262\340\270\251\340\270\262\340\271\204\340\270\227\340\270\242) \340\270\252\340\270\247\340\270\261\340\270\252\340\270\224\340\270\265\340\270\204\340\270\243\340\270\261\340\270\232, \340\270\252\340\270\247\340\270\261\340\270\252\340\270\224\340\270\265\340\270\204\340\271\210\340\270\260\n",
|
||||
-1);
|
||||
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 4);
|
||||
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 7);
|
||||
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 8);
|
||||
|
||||
gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
|
||||
gtk_text_buffer_insert_texture (buffer, &iter, texture);
|
||||
|
||||
gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, 0, 8);
|
||||
iter2 = iter;
|
||||
@ -787,6 +789,7 @@ fill_buffer (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_apply_tag (buffer, tag, &iter, &iter2);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user