[Gtk-sharp-list] Error derive from class gtk.window
Pieter Greyling
pieter.greyling@bluewin.ch
Fri, 23 May 2003 00:56:41 +0200
Hi Peter,
Your class CMyWin is not invoking the base class (Gtk.Window) constructor
upon its own construction.
I duplicated (some of) your problem(s) and "fixed" CMyWin as follows:
//--------------------------------------------------------------------------
---------------------------
public class CMyWin : Gtk.Window {
//public CMyWin(string str) {
public CMyWin(string str) : base(str) { // [-pg-] 2003.05.22-23:35
// invoke base class constructor to alloc properly using "base(str)"
}
} // ends: class CMyWin
//--------------------------------------------------------------------------
---------------------------
This happily creates both windows plus the dialog on my system (Win2K Pro
SP3).
In the code I also implemented some changes to CStart as below since the Gtk
application was not unloading
when you destroy the windows. It also sizes the CMyWin instance so that I
could read the caption/title.
This in principle also confirms calling inherited methods properly from an
instance of CMyWin.
//--------------------------------------------------------------------------
---------------------------
class CStart {
static public void Main() {
Application.Init();
//Works
Gtk.Window aWin = new Window("Gtk.Window");
aWin.Show();
//Do not work - (Should work now [-pg-]) /////////
CMyWin AppWin = new CMyWin("CMyWin : Gtk.Window");
AppWin.DefaultSize = new System.Drawing.Size(400, 150); // startup main
window dimensions
// bind destroy event/signal inherited from Gtk.Window
AppWin.DeleteEvent += new DeleteEventHandler(Window_OnDestroy);
AppWin.Show();
//Works
CMyDialog dlg = new CMyDialog();
dlg.Show();
Application.Run();
} // ends: Main
static void Window_OnDestroy(object obj, DeleteEventArgs args) {
Console.WriteLine(">> Goodbye, Cruel World...");
Gtk.Application.Quit();
} // ends: Window_OnDestroy
} // ends: class CStart
//--------------------------------------------------------------------------
---------------------------
I used the following make command:
REM ------------------------------------------------------------------------
---------------------------
mcs -unsafe+ listmain.cs -r
C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Drawing -lib:c:\mono\lib\
-r System.Data.dll -r ByteFX.Data.dll -r gtk-sharp.dll -r glib-sharp.dll -r
glade-sharp.dll
REM ------------------------------------------------------------------------
---------------------------
It forces use of the Microsoft System.Drawing implementation since I have
found the one that ships with Mono
does not work for me.
Hope this helps.
Pieter Greyling [-pg-]
-----Original Message-----
From: gtk-sharp-list-admin@lists.ximian.com
[mailto:gtk-sharp-list-admin@lists.ximian.com]On Behalf Of Peter Börding
Sent: Thursday, May 22, 2003 14:20
To: gtk-sharp-list@lists.ximian.com
Subject: [Gtk-sharp-list] Error derive from class gtk.window
Hi,
i can't derive a my own class from the class gtk.window. Compiles but do not
run.
Deriving from gtk.dialog works (code below).
Can somebody help ?
System WinXP, gtk0.9, mono0.24
Thank you very much.
Peter
==================================================================
Compileline:
C:\sharp\oop\OOP>mcs -unsafe+ Main.cs -r System.Data.dll -r
ByteFX.Data.dll -r gtk-sharp.dll -r
glib-sharp.dll -lib:C:\mono-0.23\lib\ -r System.Drawing -r glade-sharp.dll
Compilation succeeded
Mono-Run + Output (the Warnings came always ( problem ? )):
C:\sharp\oop\OOP>mono Main.exe
** (<unknown>:2692): WARNING **: Failed to load library
libgobject-2.0.so.dll (libgobject-2.0.so): Das angegebene Modul wurde nicht
gefunden.
** (<unknown>:2692): WARNING **: Failed to load library
libgobject-2.0.so.dll (libgobject-2.0.so): Das angegebene Modul wurde nicht
gefunden.
** (<unknown>:2692): WARNING **: Failed to load library
libgtksharpglue.so.dll (libgtksharpglue.so): Das angegebene Modul wurde
nicht gefunden.
** (<unknown>:2692): WARNING **: Failed to load library
libgtksharpglue.so.dll (libgtksharpglue.so): Das angegebene Modul wurde
nicht gefunden.
font is 0x0
(<unknown>:2692): Gtk-CRITICAL **: file gtkwidget.c: line 1630
(gtk_widget_show): assertion `GTK_IS_WIDGET (widget)' failed
font is 0x0
font is 0x0
The code:
using Gtk;
using GtkSharp;
using GLib;
using System;
using System.Drawing;
public class CMyWin:Gtk.Window {
public CMyWin(string str) {}
}
public class CMyDialog:Gtk.Dialog {
public CMyDialog() {
this.Title = "MyDlg";
}
}
class CStart{
static public void Main(){
Application.Init();
//Works
Gtk.Window aWin;
aWin = new Window("aWindow");
aWin.Show();
//Do not work
CMyWin AppWin;
AppWin = new CMyWin("AppWindow");
AppWin.Show();
//Works
CMyDialog dlg;
dlg = new CMyDialog();
dlg.Show();
Application.Run();
}
}