[Gtk-sharp-list] LibGlade

Ricardo Fernández Pascual rfp1@ono.com
12 Aug 2002 18:25:04 +0200


--=-f0fv5dse46iYbjYKmN4q
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable


    I have wrapped Libglade using the Gtk# generator. I'm sending the
patch here because maybe you can use it.

    Doing this I have found the following problem:
    - The changes to the configure.in file are broken. You can't enable
    gnome support without enabling libglade support. I tried to do this,
    but I don't understand why autoconf didn't let me do it. It must be
    something trivial, but I couldn't get it to work.
    - glade_xml_get_widget_prefix returns a GList. GList is not wrapped.
    I wanted to write a wrapper for it, but that's for another patch[1].
    - I've left some funtions out:
        glade_xml_construct: This is useless, AFAIKS
       =20
        glade_set_custom_handle
        glade_xml_signal_connect
        glade_xml_signal_connect_full
        glade_xml_signal_connect_data: Don't know how to wrap these.
        Ideas?
       =20
        glade_xml_signal_autoconnect
        glade_xml_signal_autoconnect_full: I don't think that wrapping
        these is useful. Instead, something should be written using
        reflection.
       =20
        glade_require
        glade_provide: is it ok if i put these ones in the GladeXML
        class, as static members? They are in a separate header in the C
        api.
       =20

[1] I looked at GLib.SList and I can't understand why it inherits from
ArrayList. IMHO, it should just implement the IList interface (which
implies ICollection and IEnumerable) and maybe have some extra methods
wrapping the glib functions, and another to create an ArrayList. I can
write a patch doing this if you want.

--=20
Ricardo Fern=E1ndez Pascual
ric@users.sourceforge.net
Murcia. Espa=F1a.

--=-f0fv5dse46iYbjYKmN4q
Content-Description: the patch
Content-Disposition: attachment; filename=glade-sharp.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-15

? glade
? glue/gladexml.c
? sample/GladeViewer.cs
Index: configure.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/gtk-sharp/configure.in,v
retrieving revision 1.11
diff -u -r1.11 configure.in
--- configure.in	4 Aug 2002 19:03:21 -0000	1.11
+++ configure.in	12 Aug 2002 15:54:12 -0000
@@ -57,14 +57,18 @@
 	fi
 )
=20
+## fixme...
=20
 ## Versions of dependencies
 GNOME_REQUIRED_VERSION=3D2.0.0
 GTK_REQUIRED_VERSION=3D2.0.0
-PKG_CHECK_MODULES(BASE_DEPENDENCIES, libgnomeui-2.0 >=3D $GNOME_REQUIRED_V=
ERSION gtk+-2.0 >=3D $GTK_REQUIRED_VERSION gmodule-2.0 >=3D $GTK_REQUIRED_V=
ERSION, enable_gnome=3Dyes, enable_gnome=3Dno)
+GLADE_REQUIRED_VERSION=3D2.0.0
+PKG_CHECK_MODULES(BASE_DEPENDENCIES, libgnomeui-2.0 >=3D $GNOME_REQUIRED_V=
ERSION gtk+-2.0 >=3D $GTK_REQUIRED_VERSION gmodule-2.0 >=3D $GTK_REQUIRED_V=
ERSION libglade-2.0 >=3D $GLADE_REQUIRED_VERSION, enable_gnome=3Dyes, enabl=
e_gnome=3Dno)
=20
 if test "x$enable_gnome" =3D "xno"; then
 	PKG_CHECK_MODULES(BASE_DEPENDENCIES, gtk+-2.0 >=3D $GTK_REQUIRED_VERSION =
gmodule-2.0 >=3D $GTK_REQUIRED_VERSION)
+else
+	enable_glade=3Dyes
 fi
=20
 #GTK_CFLAGS=3D`$PKG_CONFIG --cflags gtk+-2.0`
@@ -76,6 +80,7 @@
 AC_SUBST(BASE_DEPENDENCIES_LIBS)
=20
 AM_CONDITIONAL(ENABLE_GNOME, test "x$enable_gnome" =3D "xyes")
+AM_CONDITIONAL(ENABLE_GLADE, test "x$enable_glade" =3D "xyes")
=20
 AC_SUBST(CFLAGS)
=20
@@ -87,6 +92,7 @@
 gdk/Makefile
 gtk/Makefile
 gnome/Makefile
+glade/Makefile
 sample/Makefile
 ])
=20
Index: makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/gtk-sharp/makefile,v
retrieving revision 1.19
diff -u -r1.19 makefile
--- makefile	6 Aug 2002 02:07:09 -0000	1.19
+++ makefile	12 Aug 2002 15:54:13 -0000
@@ -1,6 +1,6 @@
 EXTRA_DIRS =3D
=20
-DIRS=3Dgenerator glib pango atk gdk gtk gnome sample
+DIRS=3Dgenerator glib pango atk gdk gtk gnome glade sample
 ROOT=3D/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
 CSC=3D$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe
 MCS=3Dmcs
Index: generator/SymbolTable.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/gtk-sharp/generator/SymbolTable.cs,v
retrieving revision 1.36
diff -u -r1.36 SymbolTable.cs
--- generator/SymbolTable.cs	9 Aug 2002 04:54:39 -0000	1.36
+++ generator/SymbolTable.cs	12 Aug 2002 15:54:14 -0000
@@ -85,6 +85,7 @@
 			dlls.Add("Gdk", "gdk-x11-2.0");=0D
 			dlls.Add("Gdk.Imaging", "gdk_pixbuf-2.0");=0D
 			dlls.Add("Gtk", "gtk-x11-2.0");=0D
+			dlls.Add("Glade", "glade-2.0");=0D
 		}=0D
 	=09=0D
 		public static void AddAlias (string name, string type)=0D
Index: generator/gtkapi.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/gtk-sharp/generator/gtkapi.xml,v
retrieving revision 1.37
diff -u -r1.37 gtkapi.xml
--- generator/gtkapi.xml	10 Aug 2002 19:15:57 -0000	1.37
+++ generator/gtkapi.xml	12 Aug 2002 15:54:52 -0000
@@ -21893,4 +21893,47 @@
     </struct>
     <alias name=3D"XSubfont" cname=3D"PangoXSubfont" type=3D"guint16 "/>
   </namespace>
+  <namespace name=3D"Glade" library=3D"glade-2.0">
+    <object name=3D"GladeXML" cname=3D"GladeXML" parent=3D"GObject">
+      <method name=3D"GetType" cname=3D"glade_xml_get_type" shared=3D"true=
">
+        <return-type type=3D"GType"/>
+      </method>
+      <constructor cname=3D"glade_xml_new">
+        <parameters>
+          <parameter type=3D"const-gchar*" name=3D"fname"/>
+          <parameter type=3D"const-gchar*" name=3D"root"/>
+          <parameter type=3D"const-gchar*" name=3D"domain"/>
+        </parameters>
+      </constructor>
+      <constructor cname=3D"glade_xml_new_from_buffer">
+        <parameters>
+          <parameter type=3D"const-gchar*" name=3D"buffer"/>
+          <parameter type=3D"int" name=3D"size"/>
+          <parameter type=3D"const-gchar*" name=3D"root"/>
+          <parameter type=3D"const-gchar*" name=3D"domain"/>
+        </parameters>
+      </constructor>
+      <method name=3D"GetWidget" cname=3D"glade_xml_get_widget">
+        <return-type type=3D"GtkWidget*"/>
+        <parameters>
+          <parameter type=3D"const-gchar*" name=3D"name"/>
+        </parameters>
+      </method>
+
+      <method name=3D"GetWidgetPrefix" cname=3D"glade_xml_get_widget_prefi=
x">
+        <return-type type=3D"GList*"/>
+        <parameters>
+          <parameter type=3D"const-gchar*" name=3D"name"/>
+        </parameters>
+      </method>
+
+      <method name=3D"RelativeFile" cname=3D"glade_xml_relative_file">
+        <return-type type=3D"gchar*"/>
+        <parameters>
+          <parameter type=3D"const-gchar*" name=3D"filename"/>
+        </parameters>
+      </method>
+
+    </object>
+  </namespace>
 </api>
Index: glue/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/gtk-sharp/glue/Makefile.am,v
retrieving revision 1.15
diff -u -r1.15 Makefile.am
--- glue/Makefile.am	11 Aug 2002 22:48:00 -0000	1.15
+++ glue/Makefile.am	12 Aug 2002 15:54:52 -0000
@@ -16,10 +16,18 @@
 	canvasitem.c
=20
 if ENABLE_GNOME
+if ENABLE_GLADE
 libgtksharpglue_la_SOURCES =3D 	\
 	$(BASESOURCES) \
 	program.c \
+	gladexml.c \
 	#
+else
+libgtksharpglue_la_SOURCES =3D 	\
+	$(BASESOURCES) \
+	program.c \
+	#
+endif
 else
 libgtksharpglue_la_SOURCES =3D 	\
 	$(BASESOURCES)=20
Index: sample/Makefile.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/gtk-sharp/sample/Makefile.in,v
retrieving revision 1.14
diff -u -r1.14 Makefile.in
--- sample/Makefile.in	10 Aug 2002 19:15:58 -0000	1.14
+++ sample/Makefile.in	12 Aug 2002 15:54:53 -0000
@@ -4,8 +4,12 @@
 @ENABLE_GNOME_TRUE@ GNOME_ASSEMBLY=3D-r gnome-sharp.dll
 @ENABLE_GNOME_TRUE@ GNOME_TARGETS=3Dgnome-hello-world.exe canvas-example.e=
xe fifteen.exe=20
=20
-local_paths=3D-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk $(GNOME=
_PATH)=20
-all_assemblies=3D-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=3D-L ../glade
+@ENABLE_GLADE_TRUE@ GLADE_ASSEMBLY=3D-r glade-sharp.dll
+@ENABLE_GLADE_TRUE@ GLADE_TARGETS=3Dglade-viewer.exe
+
+local_paths=3D-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk $(GNOME=
_PATH) $(GLADE_PATH)
+all_assemblies=3D-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 Syste=
m.Drawing
=20
=20
 all: linux
@@ -14,7 +18,7 @@
 	$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../g=
tk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs
 	$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sh=
arp.dll ButtonApp.cs
=20
-linux: gtk-hello-world.exe button.exe menu.exe size.exe scribble.exe treev=
iewdemo.exe $(GNOME_TARGETS)=20
+linux: gtk-hello-world.exe button.exe menu.exe size.exe scribble.exe treev=
iewdemo.exe $(GNOME_TARGETS) $(GLADE_TARGETS)
=20
 gtk-hello-world.exe: HelloWorld.cs
 	$(MCS) --unsafe -o gtk-hello-world.exe $(local_paths) $(all_assemblies) H=
elloWorld.cs
@@ -42,6 +46,9 @@
=20
 treeviewdemo.exe: TreeViewDemo.cs
 	$(MCS) --unsafe -o treeviewdemo.exe $(local_paths) $(all_assemblies) Tree=
ViewDemo.cs
+
+glade-viewer.exe: GladeViewer.cs
+	$(MCS) --unsafe -o glade-viewer.exe $(local_paths) $(all_assemblies) Glad=
eViewer.cs
=20
 clean:
 	rm -f *.exe

--=-f0fv5dse46iYbjYKmN4q
Content-Description: glue functions
Content-Disposition: attachment; filename=gladexml.c
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-c; charset=ISO-8859-15

/* gladexml.c : Glue to access GladeXML fields
 *
 * Author: Ricardo Fern=E1ndez Pascual <ric@users.sourceforge.net>
 *
 * <c> 2002 Ricardo Fern=E1ndez Pascual
 */

#include <glade/glade.h>

const gchar *	gtksharp_glade_xml_get_filename		(GladeXML *gxml);


const gchar *
gtksharp_glade_xml_get_filename (GladeXML *gxml)
{
	return gxml->filename;
}


--=-f0fv5dse46iYbjYKmN4q
Content-Description: sample and test
Content-Disposition: attachment; filename=GladeViewer.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-15

// GladeViewer.cs - Silly tests for LibGlade in C#
//
// Author: Ricardo Fern=E1ndez Pascual <ric@users.sourceforge.net>
//
// (c) 2002 Ricardo Fern=E1ndez 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 =3D new Program ("GladeViewer", "0.1", Modules.UI, args);

			string fname =3D args [0];
			string root =3D args [1];
		=09
			GladeXML gxml =3D new GladeXML (fname, root, null);
			Widget wid =3D gxml [root];
			wid.Show ();
		=09
			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}", GladeXML.GetWidge=
tName (wid));
			Console.WriteLine ("BTW, it's {0} that it was created using from a Glade=
XML object",
					   GladeXML.GetWidgetTree (wid) !=3D null);

			Console.WriteLine ("\nList of created widgets:");
			// this is a hack, until GList is wrapped
			IntPtr l =3D gxml.GetWidgetPrefix ("");
			int len =3D g_list_length (l);
			for (int i =3D 0; i < len; ++i) {
				Widget w =3D GLib.Object.GetObject (g_list_nth_data (l, i)) as Widget;
				Console.WriteLine ("{0} {1}",=20
						   w.GetType (),
						   GladeXML.GetWidgetName (w));
			}
		=09
			viewer.Run ();
		}
	=09
	}
}

--=-f0fv5dse46iYbjYKmN4q
Content-Description: tarball with files in the glade/ dir
Content-Type: application/x-gzip
Content-Disposition: attachment; filename=glade.tar.gz
Content-Transfer-Encoding: base64

H4sIAGPgVz0AA+1Ze2/iOBDnX/wprL2VFiqRB0lA4tqqvdL2KtFt1fZ0J61WyE0MzZHEnONs6Z32
w+43ubHzKAFaulJh1buMIA/P+PH7jT0ezDggHtVrGxXDsI1u14G7YXQ75XsmNaPrtJ2u021bZs0w
24bZrWFns8NKJYkF4RjXuO8S7rEn7dbp36iMlf9vLvoXm+vDMA2j07Gf9L9l2YX/bceS/nfMdg0b
mxvSo1T+9+hwFgZDl0Wx4Ikr0GNZ7I8jolQRfUYx9Iggy1qSCLa26igJgmerzlvEVAxd8BgLh3ck
8gKalXP6V+Lz/G3K2Rffo+hHc/sWJF3/YxpRTgT1NrITfH/8t7qOU8X/bUjq/3MyoSM/oJofbaAP
Gf+f8b9pSZ8r/1uObUK5aRudKv5vRc6PrvdCN0b94+ub/tnVHkIHxx8PfxkcD08Hh/3j4c3Vb8cH
mARBDwd+lMwW1CeHg+tcj9C9H3nsPu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