C# ~ Insert Image into Gtk.TextView

/*
 * Created by SharpDevelop.
 * User: cakirh
 * Date: 07.12.2010
 * Time: 21:36
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */


using System;
using Gtk;

namespace testgtk
{
 class  test : Window
 {
 private Pango.FontDescription font= Pango.FontDescription.FromString("Arial 32");

 private TextView txtText;
 private TextBuffer bufText;
 private ScrolledWindow scText;
 private Gdk.Pixbuf px;

 public  test()
 : base("test")
 {

 this.SetSizeRequest(300,300);
 px=new Gdk.Pixbuf("we_can_do_it.jpg");
 txtText =new TextView();
 txtText.ModifyFont(font);
 bufText=txtText.Buffer;
 TextIter insertIter = bufText.StartIter;

 bufText.InsertPixbuf(ref insertIter,px);
 bufText.Insert(ref insertIter, "hello textview");

 scText=new ScrolledWindow();
 scText.Add(txtText);
 this.Add(scText);

 this.ShowAll();
 }

 public static void Main()
 {
 Application.Init();
 new test();
 Application.Run();
 }


 }
}

OUTPUT:

Advertisement