2002-07-31 Rachel Hestilow <hestilow@ximian.com>

* generator/StructBase.cs (GetFieldInfo): Generate strings correctly.
	Also, delegates are not marshalling correctly right now, change those
	to IntPtr.

	* generator/SymbolTable.cs: New method IsCallback.

	* sample/GnomeHelloWorld.cs: Use Gnome.App and stock menu items.
	Use the new event handlers.

svn path=/trunk/gtk-sharp/; revision=6300
This commit is contained in:
Rachel Hestilow 2002-07-31 19:18:37 +00:00
parent c73ccc6b50
commit 98d194f861
4 changed files with 46 additions and 21 deletions

View File

@ -1,3 +1,14 @@
2002-07-31 Rachel Hestilow <hestilow@ximian.com>
* generator/StructBase.cs (GetFieldInfo): Generate strings correctly.
Also, delegates are not marshalling correctly right now, change those
to IntPtr.
* generator/SymbolTable.cs: New method IsCallback.
* sample/GnomeHelloWorld.cs: Use Gnome.App and stock menu items.
Use the new event handlers.
2002-07-30 Rachel Hestilow <hestilow@ximian.com> 2002-07-30 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: Change hasDefaultConstructor to protected, * generator/ClassBase.cs: Change hasDefaultConstructor to protected,

View File

@ -111,14 +111,16 @@ namespace GtkSharp.Generation {
protected bool GetFieldInfo (XmlElement field, out string type, out string name) protected bool GetFieldInfo (XmlElement field, out string type, out string name)
{ {
name = ""; name = "";
if (IsBit (field)) string c_type = field.GetAttribute ("type");
type = SymbolTable.GetCSType (c_type);
if (IsBit (field)) {
type = "uint"; type = "uint";
else if (IsPointer (field)) { } else if (IsPointer (field) && type != "string") {
type = "IntPtr"; type = "IntPtr";
name = "_"; name = "_";
} else if (SymbolTable.IsCallback (c_type)) {
type = "IntPtr";
} else { } else {
string c_type = field.GetAttribute ("type");
type = SymbolTable.GetCSType (c_type);
if (type == "") { if (type == "") {
Console.WriteLine ("Field has unknown Type {0}", c_type); Console.WriteLine ("Field has unknown Type {0}", c_type);
Statistics.ThrottledCount++; Statistics.ThrottledCount++;

View File

@ -330,6 +330,19 @@ namespace GtkSharp.Generation {
return false; return false;
} }
public static bool IsCallback(string c_type)
{
c_type = Trim(c_type);
c_type = DeAlias(c_type);
if (complex_types.ContainsKey(c_type)) {
IGeneratable gen = (IGeneratable) complex_types[c_type];
if (gen is CallbackGen) {
return true;
}
}
return false;
}
public static bool IsManuallyWrapped(string c_type) public static bool IsManuallyWrapped(string c_type)
{ {
c_type = Trim(c_type); c_type = Trim(c_type);

View File

@ -57,58 +57,59 @@ namespace GtkSamples {
entry.desc); entry.desc);
} }
icons.IconSelected += new EventHandler (icon_selected_cb); icons.IconSelected += new IconSelectedHandler (icon_selected_cb);
return icons; return icons;
} }
Gtk.Widget CreateMenus () Gtk.MenuBar CreateMenus ()
{ {
AccelGroup group = new AccelGroup ();
MenuBar bar = new MenuBar (); MenuBar bar = new MenuBar ();
Menu file_menu = new Menu (); Menu file_menu = new Menu ();
MenuItem file_menu_item = new MenuItem ("_File"); MenuItem file_menu_item = new MenuItem ("_File");
file_menu_item.Submenu = file_menu; file_menu_item.Submenu = file_menu;
MenuItem file_exit = new MenuItem ("E_xit"); ImageMenuItem file_exit = new ImageMenuItem (Gtk.Stock.Quit, group);
file_exit.Activated += new EventHandler (exit_cb); file_exit.Activated += new EventHandler (exit_cb);
file_menu.Append (file_exit); file_menu.Append (file_exit);
bar.Append (file_menu_item); bar.Append (file_menu_item);
Menu help_menu = new Menu (); Menu help_menu = new Menu ();
MenuItem help_menu_item = new MenuItem ("_Help"); ImageMenuItem help_menu_item = new ImageMenuItem (Gtk.Stock.Help, group);
help_menu_item.Submenu = help_menu; help_menu_item.Submenu = help_menu;
MenuItem file_help = new MenuItem ("_About"); ImageMenuItem file_help = new ImageMenuItem (Gnome.Stock.About, group);
file_help.Activated += new EventHandler (about_cb); file_help.Activated += new EventHandler (about_cb);
help_menu.Append (file_help); help_menu.Append (file_help);
bar.Append (help_menu_item); bar.Append (help_menu_item);
bar.ShowAll ();
return bar; return bar;
} }
public Gtk.Window CreateWindow () public Gtk.Window CreateWindow ()
{ {
Gtk.Window win = new Gtk.Window ("Gnome# Hello World"); Gnome.App win = new Gnome.App ("gnome-hello-world", "Gnome# Hello World");
win.DeleteEvent += new EventHandler (Window_Delete); win.DeleteEvent += new EventHandler (Window_Delete);
win.Menus = CreateMenus ();
VBox vbox = new VBox (false, 0); VBox vbox = new VBox (false, 0);
vbox.PackStart (CreateMenus (), false, false, 0);
vbox.PackStart (new Label ("The following demos are available.\nTo run a demo, double click on its icon."), false, false, 4); vbox.PackStart (new Label ("The following demos are available.\nTo run a demo, double click on its icon."), false, false, 4);
vbox.PackStart (CreateList (), true, true, 4); vbox.PackStart (CreateList (), true, true, 4);
win.Contents = vbox;
win.DefaultSize = new Size (250, 130); win.DefaultSize = new Size (250, 200);
win.Add (vbox);
return win; return win;
} }
public static int Main (string[] args) public static int Main (string[] args)
{ {
/* FIXME: Broken params support in mcs, should be fixed soonish */
object[] props = new object[0];
Program kit = new Program ("gnome-hello-world", "0.0.1", Modules.UI, Program kit = new Program ("gnome-hello-world", "0.0.1", Modules.UI,
args, props); args);
GnomeHelloWorld hello = new GnomeHelloWorld (); GnomeHelloWorld hello = new GnomeHelloWorld ();
Window win = hello.CreateWindow (); Window win = hello.CreateWindow ();
@ -126,7 +127,6 @@ namespace GtkSamples {
static void exit_cb (object o, EventArgs args) static void exit_cb (object o, EventArgs args)
{ {
Console.WriteLine ("hi {0}", Gnome.Program.Get ().AppId);
Application.Quit (); Application.Quit ();
} }
@ -150,11 +150,10 @@ namespace GtkSamples {
[DllImport("glib-2.0")] [DllImport("glib-2.0")]
static extern bool g_spawn_command_line_async (string command, IntPtr err); static extern bool g_spawn_command_line_async (string command, IntPtr err);
void icon_selected_cb (object obj, EventArgs args) void icon_selected_cb (object obj, IconSelectedArgs args)
{ {
SignalArgs sa = (SignalArgs) args; int idx = args.Num;
int idx = (int) sa.Args[0]; Event ev = args.Event;
Event ev = (Event) sa.Args[1];
if (ev.IsValid && ev.Type == EventType.TwoButtonPress) { if (ev.IsValid && ev.Type == EventType.TwoButtonPress) {
g_spawn_command_line_async ("mono " + entries[idx].program, IntPtr.Zero); g_spawn_command_line_async ("mono " + entries[idx].program, IntPtr.Zero);