diff --git a/ChangeLog b/ChangeLog index a6834a799..0177993dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2002-08-12 Rachel Hestilow + + [ Patch from Ricardo Fernandez Pascual for + libglade support (slightly modified) ] + + * configure.in: Conditionally compile glade support. + * makefile: Add glade directory. + * glade/: Added. + * sample/makefile.in: Add (conditional) glade example. + * sample/GladeViewer.cs: Added. + * glue/gladexml.c: Added. + * glue/Makefile.am: Updated. + + * parser/build.pl: Parse libglade-2.0.0. + * parser/README: Update requirements. + +2002-08-12 Rachel Hestilow + + * parser/gapi_pp.pl: Handle "typedef struct {...}" construct. + + * glue/canvaspoints.c: Added. + * glue/Makefile.am: Updated. + + * gnome/CanvasPoints.custom: Added. (Doesn't seem to work right yet, + looking into this.) + 2002-08-10 Rachel Hestilow * sample/TreeViewDemo.cs (Main, DeleteCB): Update to use correct diff --git a/configure.in b/configure.in index d9da459c9..fb67f38ba 100644 --- a/configure.in +++ b/configure.in @@ -67,15 +67,18 @@ if test "x$enable_gnome" = "xno"; then PKG_CHECK_MODULES(BASE_DEPENDENCIES, gtk+-2.0 >= $GTK_REQUIRED_VERSION gmodule-2.0 >= $GTK_REQUIRED_VERSION) fi -#GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0` -#GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0` -#GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0` -#GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0` +GLADE_REQUIRED_VERSION=2.0.0 +PKG_CHECK_MODULES(GLADE_DEPENDENCIES, libglade-2.0 >= $GLADE_REQUIRED_VERSION, enable_glade=yes, enable_glade=no) +if test "x$enable_glade" = "xyes"; then + BASE_DEPENDENCIES_CFLAGS="$BASE_DEPENDENCIES_CFLAGS $GLADE_DEPENDENCIES_CFLAGS" + BASE_DEPENDENCIES_LIBS="$BASE_DEPENDENCIES_LIBS $GLADE_DEPENDENCIES_LIBS" +fi AC_SUBST(BASE_DEPENDENCIES_CFLAGS) AC_SUBST(BASE_DEPENDENCIES_LIBS) AM_CONDITIONAL(ENABLE_GNOME, test "x$enable_gnome" = "xyes") +AM_CONDITIONAL(ENABLE_GLADE, test "x$enable_glade" = "xyes") AC_SUBST(CFLAGS) @@ -86,6 +89,7 @@ pango/Makefile atk/Makefile gdk/Makefile gtk/Makefile +glade/Makefile gnome/Makefile sample/Makefile ]) diff --git a/generator/gtkapi.xml b/generator/gtkapi.xml index 55c0db171..2d1a68632 100644 --- a/generator/gtkapi.xml +++ b/generator/gtkapi.xml @@ -1,4 +1,4 @@ - + @@ -55,12 +55,6 @@ - - - - - - @@ -160,27 +154,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -818,6 +791,17 @@ + + + + + + + + + + + @@ -960,6 +944,25 @@ + + + + + + + + + + + + + + + + + + + @@ -3577,6 +3580,19 @@ + + + + + + + + + + + + + @@ -15771,6 +15787,266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -18074,6 +18350,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/glade/Makefile.in b/glade/Makefile.in new file mode 100755 index 000000000..cef5684d5 --- /dev/null +++ b/glade/Makefile.in @@ -0,0 +1,21 @@ +MCS=mcs +DESTDIR= + +@ENABLE_GLADE_TRUE@ all: linux +@ENABLE_GLADE_FALSE@ all: + +windows: + $(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /r:../gtk/gtk-sharp.dll /out:glade-sharp.dll /recurse:*.cs + +linux: glade-sharp.dll + +glade-sharp.dll: generated/*.cs + $(MCS) --unsafe --target library -r System.Drawing -L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk -r glib-sharp.dll -r pango-sharp.dll -r atk-sharp.dll -r gdk-sharp.dll -r gtk-sharp.dll -o glade-sharp.dll --recurse '*.cs' + +clean: + rm -f *.dll + rm -f generated/* + +install: all +@ENABLE_GLADE_TRUE@ cp glade-sharp.dll $(DESTDIR)@prefix@/lib + diff --git a/glade/XML.custom b/glade/XML.custom new file mode 100644 index 000000000..671a1e947 --- /dev/null +++ b/glade/XML.custom @@ -0,0 +1,48 @@ +// XML.custom +// +// Author: Ricardo Fernández Pascual +// +// (c) 2002 Ricardo Fernández Pascual +// +// This code is inserted after the automatically generated code. + + + [DllImport("gtksharpglue")] + static extern string gtksharp_glade_xml_get_filename (IntPtr raw); + + /// Filename Property + /// Gets the filename used to create this GladeXML object + /// + public string Filename { + get { + string ret = gtksharp_glade_xml_get_filename (Handle); + return ret; + } + } + + /// Indexer of widgets + /// Acts like GetWidget + public Gtk.Widget this [string name] { + get { + return GetWidget (name); + } + } + + [DllImport("glade-2.0")] + static extern string glade_get_widget_name (IntPtr widget); + + static public string GetWidgetName (Gtk.Widget w) { + string ret = glade_get_widget_name (w.Handle); + return ret; + } + + [DllImport("glade-2.0")] + static extern IntPtr glade_get_widget_tree (IntPtr widget); + + static public Glade.XML GetWidgetTree (Gtk.Widget w) { + IntPtr ret_raw = glade_get_widget_tree (w.Handle); + Glade.XML ret = GLib.Object.GetObject (ret_raw) as Glade.XML; + return ret; + } + + diff --git a/glue/Makefile.am b/glue/Makefile.am index 16207d045..61cb5740c 100644 --- a/glue/Makefile.am +++ b/glue/Makefile.am @@ -12,19 +12,42 @@ BASESOURCES = \ paned.c \ style.c \ type.c \ - widget.c \ - canvasitem.c + widget.c +GNOMESOURCES = \ + canvasitem.c \ + canvaspoints.c \ + program.c + +# fixme: Makefile.am = THE SUCK if ENABLE_GNOME + +if ENABLE_GLADE libgtksharpglue_la_SOURCES = \ $(BASESOURCES) \ - program.c \ + $(GNOMESOURCES) \ + gladexml.c # else +libgtksharpglue_la_SOURCES = \ + $(BASESOURCES) \ + $(GNOMESOURCES) \ + # +endif + +else + +if ENABLE_GLADE +libgtksharpglue_la_SOURCES = \ + $(BASESOURCES) \ + gladexml.c +else libgtksharpglue_la_SOURCES = \ $(BASESOURCES) endif +endif + INCLUDES = @BASE_DEPENDENCIES_CFLAGS@ -I$(top_srcdir) diff --git a/glue/canvaspoints.c b/glue/canvaspoints.c new file mode 100644 index 000000000..2e71a7ac6 --- /dev/null +++ b/glue/canvaspoints.c @@ -0,0 +1,28 @@ +/* canvaspoints.c : Custom ctor for a CanvasPoints struct. + * + * Author: Rachel Hestilow + * + * 2002 Rachel Hestilow + */ + +#include +#include + +GnomeCanvasPoints* +gtksharp_gnome_canvas_points_new_from_array (guint num_points, double *coords) +{ + int i, len; + GnomeCanvasPoints *pts = gnome_canvas_points_new (num_points); + + g_print ("{"); + + len = num_points * 2; + for (i = 0; i < len; i++) { + pts->coords[i] = coords[i]; + g_print ("%f ", pts->coords[i]); + } + g_print ("}\n"); + + return pts; +} + diff --git a/glue/gladexml.c b/glue/gladexml.c new file mode 100644 index 000000000..aec748b4a --- /dev/null +++ b/glue/gladexml.c @@ -0,0 +1,18 @@ +/* gladexml.c : Glue to access GladeXML fields + * + * Author: Ricardo Fernández Pascual + * + * 2002 Ricardo Fernández Pascual + */ + +#include + +const gchar * gtksharp_glade_xml_get_filename (GladeXML *gxml); + + +const gchar * +gtksharp_glade_xml_get_filename (GladeXML *gxml) +{ + return gxml->filename; +} + diff --git a/gnome/CanvasPoints.custom b/gnome/CanvasPoints.custom new file mode 100644 index 000000000..c56d21989 --- /dev/null +++ b/gnome/CanvasPoints.custom @@ -0,0 +1,19 @@ +// +// Gnome.CanvasPoints.custom - Gnome CanvasPoints class customizations +// +// Author: Rachel Hestilow +// +// Copyright (C) 2002 Rachel Hestilow +// +// This code is inserted after the automatically generated code. +// + +[DllImport("gtksharpglue")] +static extern System.IntPtr +gtksharp_gnome_canvas_points_new_from_array (uint num_points, double[] coords); + +public static Gnome.CanvasPoints New (double[] coords) +{ + return New (gtksharp_gnome_canvas_points_new_from_array ((uint) coords.Length / 2, coords)); +} + diff --git a/makefile b/makefile index a8e7ff60b..6be9b1507 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ EXTRA_DIRS = -DIRS=generator glib pango atk gdk gtk gnome sample +DIRS=generator glib pango atk gdk gtk glade gnome sample ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT))) CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe MCS=mcs diff --git a/parser/README b/parser/README index e517381b5..c55d32c56 100644 --- a/parser/README +++ b/parser/README @@ -12,3 +12,5 @@ libgnomecanvas-2.0.1 libgnomeui-2.0.1 gtkhtml: cvs branch gnome-2-port files gtkhtml.[ch], gtkhtml-types.h, gtkhtml-enums.h, gtkhtml-stream.[ch] +libglade-2.0.0 + diff --git a/parser/build.pl b/parser/build.pl index ddd406172..a2ec7e5b2 100755 --- a/parser/build.pl +++ b/parser/build.pl @@ -11,8 +11,9 @@ unlink ($file); "gtk+-2.0.5/gtk" => "Gtk:gtk-x11-2.0", "libgnome-2.0.1/libgnome" => "Gnome:gnome-2", "libgnomecanvas-2.0.1/libgnomecanvas" => "Gnome:gnomecanvas-2", - "libgnomeui-2.0.1/libgnomeui" => "Gnome:gnomeui-2", - "gtkhtml/src" => "Gtk:gtkhtml-3.0"); + "libgnomeui-2.0.1/libgnomeui" => "Gnome:gnomeui-2", + "gtkhtml/src" => "Gtk:gtkhtml-3.0", + "libglade-2.0.0/glade" => "Glade:glade-2.0"); foreach $dir (keys %srcs) { ($ns, $lib) = split (/:/, $srcs{$dir}); diff --git a/parser/gapi_pp.pl b/parser/gapi_pp.pl index d8d938bff..0f8c5cf92 100755 --- a/parser/gapi_pp.pl +++ b/parser/gapi_pp.pl @@ -62,8 +62,26 @@ foreach $fname (@hdrs) { } } elsif ($line =~ /^#\s*ifn?\s*\!?def/) { #warn "Ignored #if:\n$line"; - } elsif ($line =~ /typedef\s+struct\s+\w*\s*\{/) { - while ($line !~ /^}\s*\w+;/) {$line = ;} + } elsif ($line =~ /typedef struct\s*\{/) { + my $first_line = $line; + my @lines = (); + $line = ; + while ($line !~ /^}\s*(\w+);/) { + push @lines, $line; + $line = ; + } + $line =~ /^}\s*(\w+);/; + my $name = $1; + print "typedef struct _$name $name;\n"; + print "struct _$name {\n"; + foreach $line (@lines) { + if ($line =~ /(\s*.+\;)/) { + $field = $1; + $field =~ s/(\w+) const/const $1/; + print "$field\n"; + } + } + print "};\n"; } elsif ($line =~ /^enum\s+\{/) { while ($line !~ /^};/) {$line = ;} } elsif ($line =~ /(\s+)union\s*{/) { diff --git a/sample/GladeViewer.cs b/sample/GladeViewer.cs new file mode 100644 index 000000000..7dcb3ce90 --- /dev/null +++ b/sample/GladeViewer.cs @@ -0,0 +1,61 @@ +// GladeViewer.cs - Silly tests for LibGlade in C# +// +// Author: Ricardo Fernández Pascual +// +// (c) 2002 Ricardo Fernández Pascual + +namespace GladeSamples { + using System; + using System.Runtime.InteropServices; + + using Gtk; + using Gnome; + using Glade; + + public class GladeDemo { + + // temporary hack until GList is wrapped + [DllImport("glib-2.0")] + static extern IntPtr g_list_nth_data (IntPtr l, int i); + [DllImport("glib-2.0")] + static extern int g_list_length (IntPtr l); + + public static void Main (string[] args) + { + if (args.Length < 2) { + Console.WriteLine ("Use: mono ./glade-viewer.exe \"fname\" \"root\""); + return; + } + + Program viewer = new Program ("GladeViewer", "0.1", Modules.UI, args); + + string fname = args [0]; + string root = args [1]; + + Glade.XML gxml = new Glade.XML (fname, root, null); + Widget wid = gxml [root]; + wid.Show (); + + Console.WriteLine ("The filename: {0}", gxml.Filename); + Console.WriteLine ("A relative filename: {0}", gxml.RelativeFile ("image.png")); + + Console.WriteLine ("The name of the root widget: {0}", Glade.XML.GetWidgetName (wid)); + Console.WriteLine ("BTW, it's {0} that it was created using from a Glade.XML object", + Glade.XML.GetWidgetTree (wid) != null); + + Console.WriteLine ("\nList of created widgets:"); + // this is a hack, until GList is wrapped + IntPtr l = gxml.GetWidgetPrefix (""); + int len = g_list_length (l); + for (int i = 0; i < len; ++i) { + Widget w = GLib.Object.GetObject (g_list_nth_data (l, i)) as Widget; + Console.WriteLine ("{0} {1}", + w.GetType (), + Glade.XML.GetWidgetName (w)); + } + + viewer.Run (); + } + + } +} diff --git a/sample/Makefile.in b/sample/Makefile.in index b242a576a..a31024c7b 100755 --- a/sample/Makefile.in +++ b/sample/Makefile.in @@ -4,8 +4,12 @@ MCS=mcs @ENABLE_GNOME_TRUE@ GNOME_ASSEMBLY=-r gnome-sharp.dll @ENABLE_GNOME_TRUE@ GNOME_TARGETS=gnome-hello-world.exe canvas-example.exe fifteen.exe -local_paths=-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk $(GNOME_PATH) -all_assemblies=-r glib-sharp.dll -r pango-sharp.dll -r atk-sharp.dll -r gdk-sharp.dll -r gtk-sharp.dll $(GNOME_ASSEMBLY) -r System.Drawing +@ENABLE_GLADE_TRUE@ GLADE_PATH=-L ../glade +@ENABLE_GLADE_TRUE@ GLADE_ASSEMBLY=-r glade-sharp.dll +@ENABLE_GLADE_TRUE@ GLADE_TARGETS=glade-viewer.exe + +local_paths=-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk $(GNOME_PATH) $(GLADE_PATH) +all_assemblies=-r glib-sharp.dll -r pango-sharp.dll -r atk-sharp.dll -r gdk-sharp.dll -r gtk-sharp.dll $(GNOME_ASSEMBLY) $(GLADE_ASSEMBLY) -r System.Drawing all: linux @@ -14,7 +18,7 @@ windows: $(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs $(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs -linux: gtk-hello-world.exe button.exe menu.exe size.exe scribble.exe treeviewdemo.exe $(GNOME_TARGETS) +linux: gtk-hello-world.exe button.exe menu.exe size.exe scribble.exe treeviewdemo.exe $(GNOME_TARGETS) $(GLADE_TARGETS) gtk-hello-world.exe: HelloWorld.cs $(MCS) --unsafe -o gtk-hello-world.exe $(local_paths) $(all_assemblies) HelloWorld.cs @@ -43,6 +47,9 @@ scribble.exe: Scribble.cs treeviewdemo.exe: TreeViewDemo.cs $(MCS) --unsafe -o treeviewdemo.exe $(local_paths) $(all_assemblies) TreeViewDemo.cs +glade-viewer.exe: GladeViewer.cs + $(MCS) --unsafe -o glade-viewer.exe $(local_paths) $(all_assemblies) GladeViewer.cs + clean: rm -f *.exe diff --git a/sources/README b/sources/README index e517381b5..c55d32c56 100644 --- a/sources/README +++ b/sources/README @@ -12,3 +12,5 @@ libgnomecanvas-2.0.1 libgnomeui-2.0.1 gtkhtml: cvs branch gnome-2-port files gtkhtml.[ch], gtkhtml-types.h, gtkhtml-enums.h, gtkhtml-stream.[ch] +libglade-2.0.0 +