Hi Andy, >> You need to say >> >> {#import Gtk.Graphics.UI.Types#} >> >> in your import list. This will be parsed by c2hs and inform it that >> it should read the declarations in the corresponding .chi files. Then >> it will know that the Widget* type in the C header file should be >> translated into a Ptr Widget. >> >> Btw, you only need to say castPtr, you don't have to give it a full >> type signature. > Below the new version: > > <Vte.chs> > I move this file to directory gtk2hs/gtk/ and use c2hsLocal (0.13) > compile it, it pass, but when i run "ghc --make Vte.hs", i got below > error: > > gtk/Graphics/UI/Gtk/ModelView/Types.chs:64:29: > parse error on input `#'
This is weird. Looking at your import list, I don't even know how you pick up this file. > I check gtk/Graphics/UI/Gtk/ModelView/Types.chs, found below sentence > > import GHC.Exts (unsafeCoerce#) > > Looks unnecessary `#` in (). It's correct, it's a primitive. But its not a file that you should need. > And i think maybe this's wrong way that copy Vte.chs to directory > gtk2hs/gtk to test. Yes, I think this won't really work because you need to run c2hs on your file using the header file specific to VTE. The right way to go about this is to - create a directory, say 'vte' at the same level where 'gtk', 'glib', etc live - move your file in there under Graphics/UI/VTE/ or whereever you think is appropriate - rename the module VTE to Graphics.UI.VTE.VTE - edit Makefile.am to add this new module, in order to do this, you should - copy and rename another module, say 'gconf', thus there's if ENABLE_GCONF pkglib_LIBRARIES += libHSgconf.a endif so you should add if ENABLE_VTE pkglib_LIBRARIES += libHSvte.a endif then there is: # # gconf package # ######################################################################## ######## if ENABLE_GCONF gconf_PKGNAME = libHSgconf_a libHSgconf_a_NAME = gconf libHSgconf_a_CONFIG = gconf/gconf.package.conf libHSgconf_a_EXTERNALDEPS = base-$(PKG_BASE_VERSION) libHSgconf_a_INTERNALDEPS = glib libHSgconf_a_HEADER = gconf/gconf-client.h libHSgconf_a_PRECOMP = gconf/gconf.precomp libHSgconf_a_LIBS = $(GLIB_LIBS) $(GCONF_LIBS) libHSgconf_a_HCFLAGS = -fglasgow-exts .... which you copy, then do a search an replace 'gconf' with 'vte'. The header file is 'vte/vte.h' I think. The you need to generate the type for the VTE widget. This is done automatically and the result will be stored in Graphics/UI/VTE. Thus you copy and change: libHSgconf_a_GENERATEDSOURCES = \ gconf/System/Gnome/GConf/Types.chs \ gconf/System/Gnome/GConf/Signals.chs to libHSvte_a_GENERATEDSOURCES = \ gconf/System/Gnome/GConf/Types.chs I don't think you need any signals with signatures that are not already present in Gtk. Then you specify the source files, which in your case is only: libHSgconf_a_SOURCES = vte/Graphics/UI/VTE/Vte.hs The rest of the definitions remain the same (except for the renaming), however, you need to remove everything that mentions Signals.chs since your library doesn't need a signal file. Then you need to change configure.ac to allow for the new VTE module. Look for gconf and do a similar copy and paste job. Now you need to make sure that the type is generated for your module. For this, you modify hierarchy.list in tools/hierarchyGen . Specifically, you see GConfClient as GConf if gconf so we add VTE if vte Note the indentation, which implies that VTE inherits from Object and Widget. Then, under vte you need to create a vte.package.conf.in file and a vte.cabal.in file. Follow the files in gconf. Note that the *.in files are turned into * file by configure that replaces the variables between @....@. Now you need to fix your import list: I don't think you need to import Gtk at all. You will get all the types from Gtk (but probably not Pango) by importing {#import Graphics.UI.VTE.Types#} You need to import the standard signals marshallers of Gtk. You need to do this in the c2hs way: {#import Graphics.UI.Gtk.Signals#} Then you will need import System.Glib.UTFString import System.Glib.FFI and maybe some other modules. You should not import Foreign.ForeignPtr. That comes through the FFI module. Now you do a './configure --enable-vte' and a make and see what happens. Some observations about your binding: - you lack comments -- they are essential! - don't bind the signals in the deprecated way (the on... variants). We only keep these around in order not to break old code. Let me know how you get on, thanks for your patience and effort, Axel. > BTW, how do you test and add new binding in gtk2hs? Have a guideline > that teach me how to do this systematically? > > Only you and Duncan help me, i'm really frustrated. > > Thanks, > > -- Andy > > >> >> Cheers, >> Axel. >> >> >> --------------------------------------------------------------------- >> --------- >> Come build with us! The BlackBerry® Developer Conference in >> SF, CA >> is the only developer event you need to attend this year. >> Jumpstart your >> developing skills, take BlackBerry mobile applications to market >> and stay >> ahead of the curve. Join us from November 9-12, 2009. Register >> now! >> http://p.sf.net/sfu/devconf > ---------------------------------------------------------------------- > -------- > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market > and stay > ahead of the curve. Join us from November 9-12, 2009. Register > now! > http://p.sf.net/sfu/ > devconf_______________________________________________ > Gtk2hs-users mailing list > gtk2hs-us...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Gtk2hs-devel mailing list Gtk2hs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel