[Gtk-sharp-list] gtktv binding

Joachim Jaeckel mono at coffeebreak.de
Tue Aug 9 16:52:29 EDT 2005


Hello, it's me again...

First problems occur...

I tried the following:
created a Gtk.DrawingArea in a Window, (set the background to black)
added a button to this window
do a ShowAll...

Everything comes up to the Screen and looks fine.

My clicked-Handler for the Button looks like this:

private void InitClicked (object obj, EventArgs args) {
	XVideo xv = new XVideo();
	xv.Put(tv); // tv is my DrawingArea
}

And the starting XVideo Class like this:

using System;
using System.Runtime.InteropServices;

namespace VEdit.Model {
	public class XVideo {
		const string Library = "Xv";
	
		[DllImport(Library)]
		private extern static void
			XvPutVideo(IntPtr dpy, int port, IntPtr d,
				IntPtr gc,
				int vx, int vy, int dx,	int dy,
				uint vw, uint vh, uint dw, uint dh);
		
		public XVideo() {
		}
		
		~XVideo() {
		}
		
		public int Put(Gtk.DrawingArea widget) {
			Gdk.Rectangle rc = widget.Allocation;
			Gdk.GC gc = new Gdk.GC(widget.GdkWindow);
			IntPtr a = widget.Display.Handle;
Console.WriteLine (a.ToString ());
			IntPtr b = widget.GdkWindow.Handle;
Console.WriteLine (b.ToString ());
			IntPtr c = gc.Handle;
Console.WriteLine (c.ToString ());
			XvPutVideo(widget.Display.Handle, 1,
				widget.GdkWindow.Handle, gc.Handle,
				0, 0, rc.Width, rc.Height,
				(uint) 0, (uint) 0,
				(uint) rc.Width, (uint) rc.Height);
			return 0;
		}
	
	}
}

But if I try to execute the method Put, of the XVideo-Class, the system
complains with the following error-message:

Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object
in <0x00000> <unknown method>
in (wrapper managed-to-native) VEdit.Model.XVideo:XvPutVideo
(intptr,int,intptr,intptr,int,int,int,int,uint,uint,uint,uint)
in [0x00094] (at /home/joe/Mono/event/VEdit/Model/XVideo.cs:33)
VEdit.Model.XVideo:Put (Gtk.DrawingArea widget)
in [0x0000d] (at /home/joe/Mono/event/VEdit/UI/GtkUi/MainView.cs:328)
VEdit.UI.GtkUi.MainView:PutVideo ()
in [0x00001] (at /home/joe/Mono/event/VEdit/UI/GtkUi/MainView.cs:322)
VEdit.UI.GtkUi.MainView:InitClicked (System.Object obj, System.EventArgs
args)
in (wrapper delegate-invoke)
System.MulticastDelegate:invoke_void_object_EventArgs
(object,System.EventArgs)
in <0x00096> GLib.Signal:voidObjectCallback (IntPtr handle, IntPtr gch)
in (wrapper native-to-managed) GLib.Signal:voidObjectCallback
(intptr,intptr)
in <0x00000> <unknown method>
in (wrapper managed-to-native) Gtk.Application:gtk_main ()
in <0x00007> Gtk.Application:Run ()
in <0x00007> Gnome.Program:Run ()
in [0x000b3] (at /home/joe/Mono/event/VEdit/UI/GtkUi/MainView.cs:52)
VEdit.UI.GtkUi.MainView:.ctor (System.String[] args)
in [0x00001] (at /home/joe/Mono/event/Main.cs:10) MainClass:Main
(System.String[] args)

But, which Object has a null reference? Through the WriteLine's in the
Put Methods, it seems to me, that the DrawingArea widget is correct and
also the different Handles from it.

Maybe, you have an idea?

Thanks in advance,
Joachim.



More information about the Gtk-sharp-list mailing list