[Gtk-sharp-list] A Bold Bug ?

Daniel Kornhauser dkor@media.mit.edu
Sat, 15 Nov 2003 18:36:55 -0500


--=-goN5VcxyImDkdeGAoIqd
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Bold doesn't work for me. I get the following error :

(<unknown>:14038): GLib-GObject-CRITICAL **: file genums.c: line 394
(g_value_set_enum): assertion `G_VALUE_HOLDS_ENUM (value)' failed

Tried and failed to fix the bug, I'm allways amazed by my Gtk+ ignorance
...

Self-Contained Example attached below, compile with:
mcs -r:gtk-sharp.dll  /r:pango-sharp.dll  bold.cs

					Daniel

--=-goN5VcxyImDkdeGAoIqd
Content-Disposition: attachment; filename=bold.cs
Content-Type: text/plain; name=bold.cs; charset=
Content-Transfer-Encoding: 7bit

using Gtk;			
using GtkSharp;			

class BoldTest
{
	static Gtk.Window app;
	static TextBuffer buffer;
	static void Main(string[] args)
        {
		Application.Init ();

		app = new Gtk.Window(null);
		app.DeleteEvent += new GtkSharp.DeleteEventHandler(WindowDelete);

		app.SetDefaultSize (600,400);

		buffer = new TextBuffer (null);
		TextView view = new TextView (buffer);

		app.Add(view);
		
		TextTag italic  = new TextTag("italic");
		italic.Style = Pango.Style.Italic;
		buffer.TagTable.Add(italic);
		
		TextTag bold  = new TextTag("bold");
		bold.Weight = Pango.Weight.Bold;
		buffer.TagTable.Add(bold);

		TextIter insertIter, beginIter, endIter;
		int begin, end;

		begin = buffer.CharCount;
		buffer.GetIterAtMark(out insertIter, buffer.InsertMark);
		buffer.Insert (insertIter, "Italic works");
		end = buffer.CharCount;
		buffer.GetIterAtOffset (out endIter, end);
		buffer.GetIterAtOffset (out beginIter, begin);
		buffer.ApplyTag (italic, beginIter, endIter);


		buffer.GetIterAtMark(out insertIter, buffer.InsertMark);
		buffer.Insert (insertIter, "\n");		

		begin = buffer.CharCount;
		buffer.GetIterAtMark(out insertIter, buffer.InsertMark);
		buffer.Insert (insertIter, " but Bold doesn't");
		end = buffer.CharCount;
		buffer.GetIterAtOffset (out endIter, end);
		buffer.GetIterAtOffset (out beginIter, begin);
		buffer.ApplyTag (bold, beginIter, endIter);


		app.ShowAll ();
		Application.Run();
	}

	static void WindowDelete (object o, DeleteEventArgs args)
	{
		Application.Quit ();
	}
}

--=-goN5VcxyImDkdeGAoIqd--