开发者

Can a pixbuf inserted into a GTK+ text buffer be set as "floating"?

I'm writing an application [a Pidgin plugin, actually], which inserts an image embedded into a GtkTextBuffer. Currently, I add it using:

gtk_text_buffer_insert_pixbuf(textBuffer, &iter, pixbuf);

However, this just puts the image "inline" with the text. What I'm looking for for is something similar to HTML's "float". For example, assuming my image is about twice the size of a line of text, I current get this [where X is the image]

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam gravida

XXXX
XXXX ante in massa dignissim aliquam. Nullam tempus quam luctus eros volutpat laoreet. 

XXXX
XXXX sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Mauris semper, nunc quis gravida molestie,

leo neque imperdiet nulla, vel consectetur nisi nisl non metus. Maecenas pharetra
magna nec magna mattis faucibus convallis nibh  

Ideally, I'd like to have:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam gravida

XXXX ante in massa dignissim aliquam. Nullam tempus quam luctus eros volutpat laoreet.
XXXX

XXXX sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
XXXX Mauris semper, nunc quis gravida molestie,

leo neque imperdiet nulla, vel consectetur nisi nisl non metus. Maecenas pharetra
magna nec ma开发者_JAVA技巧gna mattis faucibus convallis nibh 

Note that there are four paragraphs, where the second and third have an image in the beginning.

Is this possible?


The short answer is no; images in TextView are just treated as a character (which may be a lot bigger than a usual character). There isn't any layout engine in the HTML sense. (Layout is limited to what PangoLayout can do.)

You could probably hack something together, using an approach such as:

  • leave a margin the size of the image on your paragraph
  • add an expose event handler to paint the image to the window (see the "border windows" examples which are I think in gtk-demo or the docs somewhere, but draw to the main window not border windows)

Some amount of work, but it would probably get the job done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜