Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial upload to google

git-svn-id: https://gtknode.googlecode.com/svn/trunk@3 9999ab98-4a1b-0410-ba6a-d90168ca9a37
  • Loading branch information...
commit 558d6b14fba1ac04d17f400178180d649a8707a9 1 parent 224f3f2
@massemanet authored
Showing with 7,614 additions and 0 deletions.
  1. +4 −0 AUTHORS
  2. +20 −0 COPYING
  3. +426 −0 ChangeLog
  4. +236 −0 INSTALL
  5. +4 −0 Makefile.am
  6. 0  NEWS
  7. +11 −0 c_src/Makefile.am
  8. +43 −0 c_src/gtknode.c
  9. +78 −0 c_src/gtknode.h
  10. +152 −0 c_src/gtknode_cnode.c
  11. +4 −0 c_src/gtknode_gen.c
  12. +39 −0 c_src/gtknode_glade.c
  13. +228 −0 c_src/gtknode_internal.c
  14. +590 −0 c_src/gtknode_marshal.c
  15. +22 −0 c_src/gtknode_structs.c
  16. +142 −0 compile
  17. +50 −0 configure.ac
  18. +530 −0 depcomp
  19. +4 −0 doc/Makefile.am
  20. +55 −0 doc/announce
  21. +1 −0  doc/short-desc
  22. +323 −0 install-sh
  23. +360 −0 missing
  24. +1 −0  priv/Makefile.am
  25. +6 −0 priv/examples/Makefile.am
  26. +12 −0 priv/examples/README
  27. +14 −0 priv/examples/points/Makefile.am
  28. +82 −0 priv/examples/points/points.erl
  29. +114 −0 priv/examples/points/points.glade
  30. +8 −0 priv/examples/points/points.gladep
  31. +16 −0 priv/examples/sherk/Makefile.am
  32. +158 −0 priv/examples/sherk/sherk.erl
  33. +298 −0 priv/examples/sherk/sherk.glade
  34. +298 −0 priv/examples/sherk/sherk.glade.bak
  35. +8 −0 priv/examples/sherk/sherk.gladep
  36. +8 −0 priv/examples/sherk/sherk.gladep.bak
  37. +32 −0 priv/examples/sherk/sherk_list.erl
  38. +217 −0 priv/examples/sherk/sherk_prof.erl
  39. +319 −0 priv/examples/sherk/sherk_scan.erl
  40. +37 −0 priv/examples/sherk/sherk_tab.erl
  41. +17 −0 priv/examples/sherk/sherk_tree.erl
  42. +14 −0 priv/examples/top/Makefile.am
  43. +147 −0 priv/examples/top/top.erl
  44. +218 −0 priv/examples/top/top.glade
  45. +8 −0 priv/examples/top/top.gladep
  46. +77 −0 priv/examples/top/top_top.erl
  47. +84 −0 priv/generator/Makefile.am
  48. +57 −0 priv/generator/bio.erl
  49. 0  priv/generator/g_black.txt
  50. 0  priv/generator/g_predefined.defs
  51. +1 −0  priv/generator/g_white.txt
  52. 0  priv/generator/gdk_black.txt
  53. +12 −0 priv/generator/gdk_predefined.defs
  54. +5 −0 priv/generator/gdk_white.txt
  55. +413 −0 priv/generator/generator.erl
  56. +746 −0 priv/generator/gtk_black.txt
  57. +6 −0 priv/generator/gtk_predefined.defs
  58. +147 −0 priv/generator/gtk_white.txt
  59. +513 −0 priv/generator/h2def.py
  60. +11 −0 src/Makefile.am
  61. +188 −0 src/gtknode.erl
View
4 AUTHORS
@@ -0,0 +1,4 @@
+mats cronqvist (mats.cronqvist@ericsson.com)
+ basic design and most of the hacking
+Romain Lenglet (rlenglet@users.forge.objectweb.org)
+ the build system + various fixes
View
20 COPYING
@@ -0,0 +1,20 @@
+Copyright (c) 2006 mats cronqvist
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
View
426 ChangeLog
@@ -0,0 +1,426 @@
+2006-01-26 Romain Lenglet <rlenglet@users.forge.objectweb.org>
+
+ * src/get_inc_path priv/generator/src/get_inc_path: reimplemented in
+ bash instead of tcsh, so that all scripts only depend on bash
+
+ * src/check_otp: redevelopped using Erlang's code:root_dir/0 and
+ code:lib_dir/1; now works all the time, including when the "erl"
+ command in the PATH is not in the Erlang installation hierarchy (e.g.
+ on Debian, erl is in /usr/bin, whereas the Erlang root is
+ /usr/lib/erlang)
+
+ * priv/gen/gdk_generated-2.8.10.h priv/gen/g_generated-2.8.10.h
+ priv/gen/gtk_generated-2.8.10.h: added generated files for GTK 2.8.10
+
+2006-01-16 Mats Cronqvist <locmacr@mwlx084>
+
+ * src/check (Module): removed the dummy *_generated.h files from CVS
+
+ * src/gtkNode_cnode.c (Module): newbie argv-bug :<
+
+2006-01-06 Mats Cronqvist <locmacr@mwlx084>
+
+ * src/gtkNode_glade.c (Module): since it seems there can be
+ signals witout events, gtkNode can now pass the event type 'NONE'
+ to the erlang side.
+
+ * src/gtkNode.erl (Module): added a debug server. start
+ gtkNode:debug() on the erlang side, then start the c-node in the
+ debugger. args like this;
+ <erlnode name> <host> gtkNodeDBG <cookie> <cnode name> <erts version>
+ e.g. erl snode gtkNodeDBG snookie gtkNodeCDBG 10
+
+ * src/gtkNode_glade.c (Module): handle the case where the signal
+ handler gets called but there is no event. have no idea why this
+ can happen...
+
+ but wait... in glade we coupled the "clicked" signal to
+ gn_sighandler. but "clicked" isn't necessarily connected to a GDK
+ event? e.g. if you click a button many times by holding the space
+ bar down. that's just one GDK_PRESS (or whatever it's called).
+
+ * src/gtkNode.c (Module): cosmetic
+
+2005-12-01 Mats Cronqvist <locmacr@mwlx084>
+
+ * src/gtkNode.c (Module):
+ * src/gtkNode.erl (Module):
+ * src/gtkNode_cnode.c (Module): erlang node passes its
+ distribution version number to cnode. cnode set the correct
+ compatibility mode. should work for erls back to R7.
+
+ * src/Makefile (Module): always building against R10
+
+ * src/check_otp (Message): script used by makefile to ensure
+ correct OTP. we want R10 or later, and assert the we can find erlc
+ and ei.h.
+
+2005-11-15 Mats Cronqvist <locmacr@mwlx084>
+
+ * src/Makefile (Module): added -lpthread to the linker flags (crux)
+
+2005-11-05 Mats Cronqvist <locmacr@mwlx084>
+
+ * README (Module): typo
+
+ * examples/simple/Makefile (Module): added +debug_info
+
+ * src/gtkNode_internal.c (Module): gn_*() must return boolean in
+ order to get error handling to work with bulking
+
+2005-09-02 Mats Cronqvist <locmacr@mwlx084>
+
+ * src/check (Module): smarter. compares version of GTK with
+ versions of wrappers, copies the best wrappers to priv/gen/*.h
+
+2005-08-31 Mats Cronqvist <locmacr@mwlx084>
+
+ * examples/points/Makefile (Module): +debug_info
+
+ * src/gtkNode.erl (make_cmd/1): changed call error/1 to fault1/
+
+2005-08-30 Mats Cronqvist <locmacr@mwlx084>
+
+ * :> Committed
+
+ * src/gtkNode_marshal.c (Module): added get_arg_struct
+
+ * src/gtkNode_cnode.c (Module): error handling didnt work with
+ bulking. cnode number of args changed.
+
+ * src/gtkNode.erl (Module): error termination fixed. cnode number
+ of args changed.
+
+ * src/gtkNode.c (Module): the cnode needed its own node name as
+ argument
+
+ * priv/generator/src/generator.erl (Module): wrappers must return
+ boolean in order to get error handling to work with bulking
+
+2005-08-26 Mats Cronqvist <locmacr@mwlx084>
+
+ * src/gtkNode_structs.c: added struct constructors
+ gn_construct_PangoLayout and gn_construct_PangoContext. we must
+ also be able to return struct handles to erlang (with
+ gn_put_struct)
+
+ * src/gtkNode_internal.c (Module): added GN_widget_get_attr.
+ removed old crap, i.e. everything except GN_glade_init and
+ GN_new_gvalue
+
+ * src/check (Module): intended to check that the generated gtkNode
+ headers are compatible with the installed gtk (tjena uffe)
+
+ * src/Makefile (Module): os name in name of binary
+
+ * priv/generator/src/generator.erl (Module): in order to get pango
+ to work, we need to be able to return structs to erlang. also
+ changed the filenames of generated names to include the gtk
+ version number.
+
+ * priv/generator/src/bio.erl (Module): unused_vars warnings in R10
+
+ * priv/generator/src/Makefile (Module): cleaned up deps
+
+ * include/gtkNode.h (Module): pango stuff added
+
+ * examples/Makefile (clean): -rm
+
+ * Makefile (Module): new targets; generate, clean, realclean, tarfile
+
+2005-08-18 Mats Cronqvist <locmacr@mwlx084>
+
+ * priv/gen/gtk_generated.h (Module): GTK 2.4
+
+ * priv/gen/gdk_generated.h (Module): GTK 2.4
+
+ * Makefile (generate): target to re-generate gtk wrappers
+
+2005-08-12 Mats Cronqvist <mats.cronqvist@ericsson.com>
+
+ * everything: moved into jungerl. not in CVS yet though. code
+ generating stuff is not yet migrated, and broken becuse of changed
+ paths.
+
+ * src/gtkNode_internal.c (GN_widget_get_attr): should be fixed to
+ return list of tagged tuples. good thing it's still alpha :>
+
+ * examples/simple/*: created
+
+ * README: created
+
+ * src/gtkNode_cnode.c: changed the message formats :> for
+ consistency and to support bulking
+
+ * allOverThePlace: fixed and rearranged
+
+2005-01-18 Mats Cronqvist <mats.cronqvist@ericsson.com>
+
+ * src/gtkNodeTest.erl (Repository): cosmetic
+
+ * src/gtkNode.erl (Repository): cosmetic
+
+2005-01-06 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNodeTest.erl (Repository): cosmetic
+
+2005-01-05 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gdk.defs (Repository): drawable stuff
+
+ * inc/gtkNode.h (Repository): added get_arg_int
+
+ * src/gtkNode_structs.c (Repository): drawable stuff
+
+ * src/gtkNode_marshal.c (Repository): added get_arg_int
+
+ * src/gtkNode_internal.c (Repository): drawable stuff.
+ GN_drawingarea_get_window is necessary
+
+ * src/gtkNodeTest.erl (Repository): drawable stuff
+
+ * src/gtkNode.erl (Repository): drawable stuff
+
+ * src/gdk_white.txt (Repository): drawable stuff
+
+ * src/Makefile (Repository): better dependencies (still sucky though)
+
+2005-01-03 Mats Cronqvist <mats.cronqvist@ericsson.com>
+
+ * src/gtkNode_cnode.c (Repository): passing regname of erlang node
+ process to cnode as command line parameter
+
+ * src/gtkNode.erl (Repository): passing regname of erlang node process
+ to cnode as command line parameter
+
+ * src/gtkNode.c (Repository): passing regname of erlang node process
+ to cnode as command line parameter
+
+ * src/Makefile (Repository): linux generalizations
+
+2004-12-10 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNodeTest.erl (Module): branch on selection test... loop is
+ external call
+
+2004-12-09 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_structs.c (Module): GtkTreePath
+
+ * src/gtkNodeTest.erl (Module): selections
+
+ * src/gtkNode_structs.c (Module): using g_new0 instead of g_new (zero-
+ fills).
+
+ * src/gtkNode_marshal.c (Module): GType stuff. tries to init the type
+ if getting the GType by name doesn't work. gint64 support.
+ get_arg_list (only for GType*). better(?) error codes.
+
+ * src/gtkNode_internal.c (Module): the GN_new_gvalue function.
+
+ * src/gtkNode_glade.c (Module): GType stuff
+
+ * src/gtkNodeTest.erl (Module): the treeview/list stuff
+
+ * src/gtkNode.erl (Module): handshaking at startup. the new_gvalue
+ function.
+
+ * src/generate.erl (Module): lists (onlt for GType*).get structs by
+ grepping in gtkNode_structs.c :<
+
+ * src/Makefile (Module): added boatloads of stuff. still doesn't work
+ properly after make clean
+
+ * inc/gtkNode.h (Module): added gn_get_arg_gint64 and gn_get_arg_list.
+ more GType stuff
+
+2004-11-25 Mats Cronqvist <qthmacr@mwux005>
+
+ * : release gtkNode-0_11
+
+ * src/gtkNode_glade.c (Module): gn_sighandler can now deal with a
+ non-glade widget (i.e. a GObject) sending a signal
+
+ * src/gtkNodeTest.erl (Module): works now
+
+ * src/gtkNode.erl (Module): improved prrocess handling a bit
+
+2004-11-24 Mats Cronqvist <qthmacr@mwux005>
+
+ * first working version!! released gtkNode-0_1
+
+ * src/gtkNode_marshal.c (Module): changed pid handling. wraps all
+ messages in {OwnPid,...}
+
+ * src/gtkNode_internal.c (Module): rewrite
+
+ * src/gtkNode_glade.c (Module): fixed error handling
+
+ * src/gtkNode_cnode.c (Module): refactored... objects are no longer
+ special. removed printf's. changed pid handling, link erl process to
+ gtkNode. handle exit from erlang by exiting gtkNode
+
+ * src/gtkNode.erl (Module): working version.
+
+ * src/gtkNode.c (Module): details in pid handling. removed printf's
+
+ * src/generate.erl (Module): refactored... objects are no longer special
+ removed hardcoded qthmacr stuff
+
+ * inc/gtkNode.h (Module): removed some crap. added a forgotten prototype
+
+2004-11-22 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/generate.erl (Module): gtk_generated.hrl added
+
+ * src/Makefile (Module): gtk_generated.hrl added
+
+2004-11-19 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_marshal.c (Module): implemented hash table storage of
+ references to structs and non-named objects. the erlang node sees these
+ as atoms, the hash table maps atoms to pointers.
+
+ * src/gtkNode_cnode.c (Module): GModule stuff external
+
+ * src/gtkNode.c (Module): global definetions of hash table and GModule
+
+ * src/generate.erl (Module): forgotten some unstar's. some new structs
+ included. also added code to generate gtk.erl.
+
+ * inc/gtkNode.h (Module): cosmetic
+
+2004-11-16 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_marshal.c (Module): refactored again...
+ coded a prototype of the struct handling. the real one should use
+ malloc and a hash table. there's no need to free, since on the erlang
+ side the structs are id'd with atoms.
+ maybe we should send an extra arg, a label (i.e. atom), to every
+ function that returns a pointer?
+
+ * src/gtkNode_internal.c (Module): effects of latest refactoring
+
+ * src/gtkNode_cnode.c (Module): separate atom and string decode
+
+ * src/generate.erl (Module): unstarred some types
+
+ * inc/gtkNode.h (Module): refactored prototypes
+
+2004-11-12 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_marshal.c (Module): refactoring for struct handling
+
+ * src/gtkNode_internal.c (Module): affected by refactoring
+
+ * src/gtkNode_glade.c (Module): fixed misplaced functionality
+
+ * src/gtkNode_cnode.c (Module): refactoring for struct handling
+
+ * src/generate.erl (Module): refactoring for struct handling
+
+ * src/Makefile (Module): fixed defs dependencies
+
+ * inc/gtkNode.h (Module): refactoring...
+
+2004-11-10 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtk_black.txt (Module): added many deprecated functions
+
+ * src/gtkNode_marshal.c (Module): fixed the gn_put_* functions
+
+ * src/gtkNode_internal.c (Module): all ints are longlong
+
+ * src/generate.erl (Module): casting bugs
+
+2004-11-09 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_marshal.c (Module): doc. there's a bunch of stuff
+ missing in this version...
+
+ * src/gtkNode_glade.c (Module): pointer bug
+
+ * src/generate.erl (Module): uses src/*.txt files to generate .defs
+
+ * src/Makefile (Module): .defs handling. we generate ../defs/*.defs
+
+2004-11-05 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_gtk.c (Module): cosmetic
+
+ * src/gtkNode_cnode.c (Module): doc
+
+ * src/generate.erl (Module): rewrite
+
+2004-11-04 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/generate.erl (Module): modified to use .defs files from pygtk
+
+ * src/gtkNode_log.c (Module): removed
+
+ * src/gtknode.glade (Module): button signal handler fixed
+
+ * src/gtkNode_marshal.c (Module): final(?) refactoring + bugs galore
+
+ * src/gtkNode_internal.c (Module): final(?) refactoring
+
+ * src/gtkNode_glade.c (Module): final(?) refactoring + signals
+
+ * src/gtkNode_cnode.c (Module): final(?) refactoring
+
+ * src/gtkNode.c (Module): final(?) refactoring
+
+ * src/Makefile (Module): TAGS file
+
+ * inc/gtkNode.h (Module): final(?) refactoring
+
+2004-10-27 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_log.c (Module): Glib'd. it's not used anymore...
+
+ * src/gtkNode_internal.c (Module): prettified
+
+ * src/gtkNode_gtk.c (Module): stuff -> gtkNode_marshal
+
+ * src/gtkNode_glade.c (Module): GLib'd error handling
+
+ * src/gtkNode_cnode.c (Module): GLib'd error handling
+
+ * inc/gtkNode.h (Module): marshalling
+
+2004-10-26 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_cnode.c (Module): passing widgets back and forth,
+ by name or by reference, seemingly works
+
+ * src/gtkNode.c (Module): scoping error
+
+ * inc/gtkNode.h (Module): scoping error
+
+2004-10-18 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtkNode_glade.c (Module): signals work...
+
+ * src/gtkNode_cnode.c (Module): signals work...
+
+ * src/gtkNode.c (Module): drudgery
+
+ * inc/gtkNode.h (Module): drudgery
+
+2004-10-11 Mats Cronqvist <qthmacr@mwux005>
+
+ * src/gtknode.glade (Module): drudgery
+
+ * src/gtkNode_log.c (Module): refactoring
+
+ * src/gtkNode_glade.c (Module): drudgery
+
+ * src/gtkNode_cnode.c (Module): drudgery
+
+ * src/gtkNode.c (Module): drudgery
+
+ * src/Makefile (Module): drudgery
+
+ * inc/gtkNode.h (Module): drudgery
+
+2004-10-01 Mats Cronqvist <qthmacr@mwux005>
View
236 INSTALL
@@ -0,0 +1,236 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
+Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about. Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory. After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script). Here is a another example:
+
+ /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
+configuration-related scripts to be executed by `/bin/bash'.
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+ Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
View
4 Makefile.am
@@ -0,0 +1,4 @@
+SUBDIRS = doc priv c_src src
+
+clean-local:
+ -find . -name "*~" -exec rm {} \;
View
0  NEWS
No changes.
View
11 c_src/Makefile.am
@@ -0,0 +1,11 @@
+bindir = $(ERLANG_INSTALL_LIB_DIR_gtknode)/priv/bin
+bin_PROGRAMS = gtknode
+gtknode_SOURCES = gtknode.c gtknode_cnode.c gtknode_gen.c gtknode_glade.c \
+ gtknode_internal.c gtknode_marshal.c gtknode_structs.c gtknode.h
+gtknode_CFLAGS = $(GTK_CFLAGS) -I$(ERLANG_LIB_DIR_erl_interface)/include
+gtknode_LDADD = $(GTK_LIBS) -lpthread \
+ -L$(ERLANG_LIB_DIR_erl_interface)/lib -lei
+
+gtknodedir = $(ERLANG_INSTALL_LIB_DIR_gtknode)/priv/src
+gtknode_DATA = $(gtknode_SOURCES) $(gtknode_INCLUDES)
+
View
43 c_src/gtknode.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include "gtknode.h"
+
+GHashTable* ghash = NULL; /* the hash table */
+GModule *gmod = NULL; /* the available functions */
+GladeXML *xml = NULL; /* the Glade design */
+ei_cnode ec; /* our cnode struct */
+
+
+static void start_gtk(int argc, char **argv, int ErlFd){
+ GIOChannel *channel;
+ GIOCondition condition = G_IO_IN;
+ GIOFunc func = gn_handle_read;
+ gpointer user_data = NULL;
+
+ /* exit on g_critical */
+ g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
+
+
+ /* initialise libraries */
+ gtk_init(&argc, &argv);
+
+ /* watch the erlang distribution file descriptor */
+ channel = g_io_channel_unix_new(ErlFd);
+ g_io_add_watch(channel, condition, func, user_data);
+
+ gtk_main(); /* start the event loop */
+}
+
+int main(int argc, char **argv){
+ int fd;
+
+ if ( argc != 7 ){
+ g_print("Usage: %s node host regname cookie node_name erl_dist_vsn\n",
+ argv[0]);
+ return 1;
+ }
+
+ fd = gn_start_cnode(argv);
+ start_gtk(argc, argv, fd);
+
+ return 0;
+}
View
78 c_src/gtknode.h
@@ -0,0 +1,78 @@
+#include "ei.h"
+#include <gtk/gtk.h>
+#include <gmodule.h>
+#include <glade/glade.h>
+#include <pango/pango.h>
+
+/* starts the cnode, returns file descriptor*/
+int gn_start_cnode(char **argv);
+
+/* called when there's data on the erlang node socket */
+gboolean gn_handle_read(GIOChannel *source,GIOCondition cond,gpointer data);
+
+/* called by all signals */
+void gn_sighandler(GtkWidget *widget);/* , gpointer user_data); */
+
+/* inits libglade */
+gboolean gn_glade_init(char *filename);
+
+/* marshalling functions (gtknode_marshal.c) */
+void gn_wrap_ans(char* tag, ei_x_buff* xbuf);
+void gn_enc_1_error(ei_x_buff *xbuf, char *err);
+void gn_enc_2_error(ei_x_buff *xbuf, char *err);
+
+void gn_put_tuple(ei_x_buff *xbuf, int N);
+void gn_put_void(ei_x_buff *xbuf);
+void gn_put_pid(ei_x_buff *xbuf, erlang_pid *p);
+void gn_put_boolean(ei_x_buff *xbuf, int i);
+void gn_put_double(ei_x_buff *xbuf, double d);
+void gn_put_longlong(ei_x_buff *xbuf, long long l);
+void gn_put_ulonglong(ei_x_buff *xbuf, unsigned long long l);
+void gn_put_string(ei_x_buff *xbuf, char *p);
+void gn_put_object(ei_x_buff *xbuf, GObject *w);
+void gn_put_enum(ei_x_buff *xbuf, char* type_name, gint enum_val);
+void gn_put_flags(ei_x_buff *xbuf, char* type_name, guint flags);
+
+gboolean gn_get_arg_pid(ei_x_buff *xbuf, char *buff, int *index, erlang_pid *p);
+gboolean gn_get_arg_gboolean(ei_x_buff *xbuf, char *B, int *I, gboolean *a);
+gboolean gn_get_arg_char(ei_x_buff *xbuf, char *B, int *I, char **a);
+gboolean gn_get_arg_gchar(ei_x_buff *xbuf, char *B, int *I, gchar **a);
+gboolean gn_get_arg_gchar_fix(ei_x_buff *xbuf, char *B, int *I, gchar *a);
+gboolean gn_get_arg_gint(ei_x_buff *xbuf, char *buff, int *index, gint *a);
+gboolean gn_get_arg_int(ei_x_buff *xbuf, char *buff, int *index, int *a);
+gboolean gn_get_arg_gint64(ei_x_buff *xbuf, char *B, int *I, gint64 *a);
+gboolean gn_get_arg_glong(ei_x_buff *xbuf, char *B, int *I, glong *a);
+gboolean gn_get_arg_guint16(ei_x_buff *xbuf, char *B, int *I, guint16 *a);
+gboolean gn_get_arg_guint32(ei_x_buff *xbuf, char *B, int *I, guint32 *a);
+gboolean gn_get_arg_guint(ei_x_buff *xbuf, char *B, int *I, guint *a);
+gboolean gn_get_arg_gfloat(ei_x_buff *xbuf, char *B, int *I, gfloat *a);
+gboolean gn_get_arg_gdouble(ei_x_buff *xbuf, char *B, int *I, gdouble *a);
+gboolean gn_get_arg_enum(ei_x_buff *xbuf, char *B, int *I, gchar* ec, gint *i);
+gboolean gn_get_arg_flags(ei_x_buff *xbuf, char *B, int *I,
+ gchar* type_name, gint *flags);
+gboolean gn_get_arg_list(ei_x_buff *xbuf, char *B, int *I,
+ char* type, void** go);
+gboolean gn_get_arg_object(ei_x_buff *xbuf, char *B, int *I,
+ GType type, GObject** go);
+gboolean gn_get_arg_struct(ei_x_buff *xbuf, char *B, int *I,
+ char* type, void** go);
+
+gboolean gn_check_object(ei_x_buff *xbuf, gchar* object_name,
+ GType type, GObject** object);
+gboolean gn_check_struct(ei_x_buff *xbuf,
+ gchar* struct_name, gchar* struct_type, void** pp);
+gboolean gn_check_arity(ei_x_buff *xbuf, int a1, int a2);
+
+gint gn_get_list(ei_x_buff *xbuf, char *buff, int *index);
+gint gn_get_tuple(ei_x_buff *xbuf, char *buff, int *index);
+
+gboolean gn_get_enum_name(const gchar *type_name, gint i, gchar *enum_name);
+gboolean gn_get_enum_val(ei_x_buff *xbuf,
+ const gchar *type_name, gchar *enum_name, gint *i);
+
+GType gn_GType_from_name(const gchar* name);
+
+void gn_send(ei_x_buff *xbuf);
+void gn_send_signal(const char *widgetname, char *evtyp);
+
+GtkWidget* gn_check_widget_name(char* widget_name);
View
152 c_src/gtknode_cnode.c
@@ -0,0 +1,152 @@
+#include <string.h>
+#include "gtknode.h"
+
+#define CREATION 1
+#define REMNODE argv[1]
+#define REMHOST argv[2]
+#define REMREG argv[3]
+#define COOKIE argv[4]
+#define NODE_NAME argv[5]
+#define ERL_DIST_VSN atoi(argv[6])
+
+static int fd; /* fd to remote Erlang node */
+static gchar* rem_regname; /* process name on remote Erlang node */
+
+int gn_start_cnode(char **argv) {
+ extern ei_cnode ec;
+ char rem_node_name[MAXATOMLEN] = ""; /* other node name */
+ ei_x_buff xbuf;
+ erlang_pid *self = ei_self(&ec);
+
+ strcat(rem_node_name,REMNODE);
+ strcat(rem_node_name,"@");
+ strcat(rem_node_name,REMHOST);
+ rem_regname = g_strdup(REMREG);
+ g_print("I am %s, you are %s\n", NODE_NAME, rem_node_name);
+
+ ei_set_compat_rel(ERL_DIST_VSN); /* erlnode version of dist. protocol */
+
+ if ( ei_connect_init(&ec, NODE_NAME, COOKIE, CREATION) < 0 )
+ g_critical("ei_connect_init");
+
+ if ( (fd = ei_connect(&ec, rem_node_name)) < 0 )
+ g_critical("ei_connect failed.\nwrong cookie? erl-dist version mismatch?");
+
+ self->num = fd; /* bug?? in ei_reg_send_tmo */
+
+ ei_x_new_with_version(&xbuf);
+ gn_wrap_ans("handshake", &xbuf);
+ ei_x_encode_empty_list(&xbuf);
+ gn_send(&xbuf);
+ ei_x_free(&xbuf);
+
+ return fd;
+}
+
+void gn_send(ei_x_buff *xbuf) {
+ extern ei_cnode ec;
+
+ if ( ei_reg_send(&ec, fd, rem_regname, xbuf->buff, xbuf->index) )
+ g_critical("bad send");
+}
+
+static gboolean get_fpointer(char *cmd, ei_x_buff *xbuf, gpointer* poi) {
+ extern GModule* gmod;
+
+ if ( ! g_module_supported() ) g_critical("gtkNode requires working gmodule");
+
+ if ( ! gmod ) gmod = g_module_open(NULL,0); /* "gtknode_gtk.so" */
+
+ if ( g_module_symbol(gmod, cmd, poi) ) return TRUE;
+
+ g_warning("could not find '%s'.", cmd);
+ gn_enc_2_error(xbuf, "no_such_function");
+ ei_x_encode_atom(xbuf, cmd);
+ return FALSE;
+}
+
+static gboolean make_reply(ei_x_buff *xbuf, char *buff, int *index) {
+ int k;
+ gint arity;
+ gchar cmd[MAXATOMLEN+1];
+ gboolean (*funcp)(int, ei_x_buff *, char *, int *);
+
+ if ( ! ((arity = gn_get_tuple(xbuf, buff, index)) > -1) ||
+ ! gn_check_arity(xbuf,2,arity) ||
+ ! gn_get_arg_gchar_fix(xbuf, buff, index, cmd) ||
+ ! ((arity = gn_get_list(xbuf, buff, index)) > -1) )
+ return FALSE;
+
+ if ( get_fpointer(cmd, xbuf, (gpointer *)&funcp) &&
+ (*funcp)(arity, xbuf, buff, index) ) {
+ g_assert( ei_decode_list_header(buff,index,&k) == 0 );
+ g_assert( k == 0 );
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void make_reply_list(ei_x_buff *xbuf, char *buff, int *index) {
+
+ gint arity, i;
+
+ if ( ! ((arity = gn_get_list(xbuf, buff, index)) > -1) )
+ return;
+
+ gn_wrap_ans("reply",xbuf);
+ for (i = 0; i < arity; i++) {
+ ei_x_encode_list_header(xbuf, 1);
+ if ( ! make_reply(xbuf, buff, index) )
+ break;
+ }
+ ei_x_encode_empty_list(xbuf);
+}
+
+
+static void reply(erlang_msg *msg, ei_x_buff *recv_x_buf) {
+ int i = 0;
+ int version;
+ ei_x_buff xbuf;
+
+ ei_decode_version(recv_x_buf->buff, &i, &version);
+ ei_x_new_with_version(&xbuf);
+ make_reply_list(&xbuf, recv_x_buf->buff, &i);
+ gn_send(&xbuf);
+ ei_x_free(&xbuf);
+}
+
+/* called from gtk main loop when there's data on the cnode socket */
+gboolean gn_handle_read(GIOChannel *source,GIOCondition cond,gpointer data){
+ erlang_msg msg;
+ ei_x_buff xbuf;
+
+ /* fd = g_io_channel_unix_get_fd(source); */
+ ei_x_new_with_version(&xbuf);
+ switch ( ei_xreceive_msg(fd, &msg, &xbuf) ){
+ case ERL_TICK:
+ break; /* ignore */
+ case ERL_MSG:
+ switch (msg.msgtype) {
+ case ERL_SEND:
+ case ERL_REG_SEND:
+ reply(&msg, &xbuf);
+ break;
+ case ERL_LINK:
+ case ERL_UNLINK:
+ case ERL_GROUP_LEADER:
+ break; /* ignore */
+ case ERL_EXIT:
+ case ERL_EXIT2:
+ case ERL_NODE_LINK:
+ gtk_main_quit(); /* crash and burn */
+ return FALSE;
+ }
+ break;
+ case ERL_ERROR:
+ gtk_main_quit(); /* crash and burn */
+ return FALSE;
+ }
+ ei_x_free(&xbuf);
+ return TRUE;
+}
View
4 c_src/gtknode_gen.c
@@ -0,0 +1,4 @@
+#include "gtknode.h"
+#include "../priv/generator/gtk_generated.h"
+#include "../priv/generator/gdk_generated.h"
+#include "../priv/generator/g_generated.h"
View
39 c_src/gtknode_glade.c
@@ -0,0 +1,39 @@
+#include "gtknode.h"
+
+gboolean gn_glade_init(char *filename) {
+ const char *rootnode = NULL;
+ extern GladeXML *xml;
+
+ if ( ! (xml = glade_xml_new(filename, rootnode, NULL)) )
+ return FALSE;
+ glade_xml_signal_autoconnect(xml);
+ return TRUE;
+}
+
+void gn_sighandler(GtkWidget *widget){
+ GdkEvent *gdk_event;
+ GtkWidget *wid;
+ GType gtyp;
+ char evtype[100];
+ const char *widgetname;
+
+ /* instantiate the GdkEventType */
+ g_assert( gn_GType_from_name("GdkEventType") );
+
+ if ( ! (widgetname = glade_get_widget_name(widget)) )
+ widgetname = "UNKNOWN";
+
+ if ( ! (gdk_event = gtk_get_current_event()) ){
+ g_strlcpy(evtype,"NONE",sizeof(evtype));
+ }else{
+ /*wid = gtk_get_event_widget(gdk_event);*/
+ g_assert( gn_get_enum_name("GdkEventType", gdk_event->type, evtype));
+ gdk_event_free(gdk_event);
+ }
+ gn_send_signal(widgetname, evtype);
+}
+
+GtkWidget* gn_check_widget_name(char* widget_name) {
+ extern GladeXML *xml;
+ return glade_xml_get_widget(xml, widget_name);
+}
View
228 c_src/gtknode_internal.c
@@ -0,0 +1,228 @@
+#include "gtknode.h"
+#include <string.h>
+
+gboolean GN_glade_init(int arity, ei_x_buff *XBUF, char *B, int *I){
+ char *xml_filename;
+
+ if ( ! gn_check_arity(XBUF, 1, arity) )
+ return FALSE;
+ if ( ! gn_get_arg_gchar(XBUF, B, I, &xml_filename) )
+ return FALSE; /* free */
+
+ if ( gn_glade_init(xml_filename) ) {
+ gn_put_void(XBUF);
+ free(xml_filename);
+ return TRUE;
+ }else{
+ gn_enc_1_error(XBUF, "glade_init_failed");
+ free(xml_filename);
+ return FALSE;
+ }
+}
+
+gboolean GN_value_get(int ARI, ei_x_buff *XBUF, char *B, int *I){
+
+ GValue* object;
+
+ gboolean v_boolean;
+ gchar* v_string;
+ long long ll;
+ gdouble v_double;
+
+ if ( ! gn_check_arity(XBUF, 1, ARI) ) return FALSE;
+ if ( ! gn_get_arg_struct(XBUF, B, I, "GValue", (void**)&object) ) return FALSE;
+
+ if ( ! G_IS_VALUE(object) ) {
+ gn_put_atom(XBUF,"NULL");
+ return TRUE;
+ }
+
+ switch (G_VALUE_TYPE(object)) {
+ case G_TYPE_BOOLEAN:
+ v_boolean = g_value_get_boolean(object);
+ gn_put_boolean(XBUF,v_boolean);
+ break;
+ case G_TYPE_INT:
+ ll = (long long) g_value_get_int(object);
+ gn_put_longlong(XBUF, ll);
+ break;
+ case G_TYPE_UINT:
+ ll = (long long) g_value_get_uint(object);
+ gn_put_longlong(XBUF, ll);
+ break;
+ case G_TYPE_LONG:
+ ll = (long long) g_value_get_long(object);
+ gn_put_longlong(XBUF, ll);
+ break;
+ case G_TYPE_ULONG:
+ ll = (long long) g_value_get_ulong(object);
+ gn_put_longlong(XBUF, ll);
+ break;
+ case G_TYPE_INT64:
+ ll = (long long) g_value_get_int64(object);
+ gn_put_longlong(XBUF, ll);
+ break;
+ case G_TYPE_UINT64:
+ ll = (long long) g_value_get_uint64(object);
+ gn_put_longlong(XBUF, ll);
+ break;
+ case G_TYPE_FLOAT:
+ v_double = (double) g_value_get_float(object);
+ gn_put_double(XBUF, v_double);
+ case G_TYPE_DOUBLE:
+ v_double = g_value_get_double(object);
+ gn_put_double(XBUF,v_double);
+ break;
+ case G_TYPE_STRING:
+ v_string = (gchar*) g_value_get_string(object);
+ gn_put_string(XBUF, v_string);
+ break;
+ default:
+ gn_put_atom(XBUF,"NULL");
+ }
+ return TRUE;
+}
+
+gboolean GN_value_set(int ARI, ei_x_buff *XBUF, char *B, int *I){
+
+ GValue* object;
+ int type, len;
+
+ gboolean v_boolean;
+ gchar v_atom[MAXATOMLEN+1];
+ gchar* v_gchar;
+ gint64 v_gint64;
+ gdouble v_double;
+
+ /* no return value */
+
+ if ( ! gn_check_arity(XBUF, 2, ARI) ) return FALSE;
+ if ( ! gn_get_arg_struct(XBUF, B, I, "GValue", (void**)&object) ) return FALSE;
+
+ if ( G_IS_VALUE(object) ) g_value_unset(object);
+
+ ei_get_type(B,I,&type,&len); /* can't fail */
+ switch (type) {
+ case ERL_ATOM_EXT:
+ if ( ! ei_decode_boolean(B, I, (int*)&v_boolean) ){
+ g_value_init(object,G_TYPE_BOOLEAN);
+ g_value_set_boolean(object, v_boolean);
+ } else if ( gn_get_arg_gchar_fix(XBUF, B, I, v_atom) ){
+ g_value_init(object,G_TYPE_STRING);
+ g_value_set_string(object,v_atom);
+ } else {
+ return FALSE;
+ }
+ break;
+ case ERL_SMALL_INTEGER_EXT:
+ case ERL_INTEGER_EXT:
+ case ERL_SMALL_BIG_EXT:
+ case ERL_LARGE_BIG_EXT:
+ if ( ! gn_get_arg_gint64(XBUF, B, I, &v_gint64) ) return FALSE;
+ g_value_init(object,G_TYPE_INT64);
+ g_value_set_int64(object, v_gint64);
+ break;
+ case ERL_FLOAT_EXT:
+ if ( ! gn_get_arg_gdouble(XBUF, B, I, &v_double) ) return FALSE;
+ g_value_init(object,G_TYPE_DOUBLE);
+ g_value_set_double(object, v_double);
+ break;
+ case ERL_NIL_EXT:
+ case ERL_STRING_EXT:
+ if ( ! gn_get_arg_gchar(XBUF, B, I, &v_gchar) ) return FALSE;
+ g_value_init(object,G_TYPE_STRING);
+ g_value_set_string(object,v_gchar);
+ free(v_gchar);
+ break;
+ default:
+ gn_enc_1_error(XBUF, "bad_erl_type");
+ return FALSE;
+ break;
+ }
+ gn_put_void(XBUF);
+ return TRUE;
+}
+
+gboolean GN_value_unset(int ARI, ei_x_buff *XBUF, char *B, int *I){
+
+ GValue* object;
+
+ /* no return value */
+
+ if ( ! gn_check_arity(XBUF, 1, ARI) ) return FALSE;
+ if ( ! gn_get_arg_struct(XBUF, B, I, "GValue", (void**)&object) ) return FALSE;
+ if ( G_IS_VALUE(object) ) g_value_unset(object);
+ gn_put_void(XBUF);
+ return TRUE;
+}
+
+gboolean GN_tree_selection_get_selected(int ARI, ei_x_buff *XBUF, char *B, int *I){
+ GtkTreeSelection* object;
+ GtkTreeIter* iter;
+
+ gboolean R; /* return value */
+
+ if ( ! gn_check_arity(XBUF, 2, ARI) ) return FALSE;
+ if ( ! gn_get_arg_object(XBUF, B, I, GTK_TYPE_TREE_SELECTION, (GObject**)&object) ) return FALSE;
+ if ( ! gn_get_arg_struct(XBUF, B, I, "GtkTreeIter", (void**)&iter) ) return FALSE;
+ R = gtk_tree_selection_get_selected(object, NULL, iter);
+ gn_put_boolean(XBUF,(int)R);
+ return TRUE;
+}
+
+gboolean GN_pango_layout_set_text(int ARI, ei_x_buff *XBUF, char *B, int *I){
+ char* text;
+ char* descr_str;
+ PangoLayout* layout;
+ PangoFontDescription* descr;
+
+ /* no return value */
+
+ if ( ! gn_check_arity(XBUF, 3, ARI) )
+ return FALSE;
+ if ( ! gn_get_arg_struct(XBUF, B, I, "PangoLayout", (void**)&layout) )
+ return FALSE;
+ if ( ! gn_get_arg_gchar(XBUF, B, I, &text) ) /* free */
+ return FALSE;
+ if ( ! gn_get_arg_gchar(XBUF, B, I, &descr_str) ) { /* free */
+ free(text);
+ return FALSE;
+ }
+
+ descr = pango_font_description_from_string(descr_str);
+ pango_layout_set_font_description(layout, descr);
+ pango_layout_set_text(layout,text,(int)strlen(text));
+ pango_font_description_free(descr);
+
+ gn_put_void(XBUF);
+ free(text);
+ free(descr_str);
+ return TRUE;
+}
+
+gboolean GN_widget_get_attr(int ARI, ei_x_buff *XBUF, char *B, int *I) {
+ gchar attr[MAXATOMLEN+1];
+ GtkWidget* widget;
+
+ if ( ! gn_check_arity(XBUF, 2, ARI) ) return FALSE;
+ if ( ! gn_get_arg_object(XBUF, B, I, GTK_TYPE_WIDGET, (GObject**)&widget) )
+ return FALSE;
+ if ( ! gn_get_arg_gchar_fix(XBUF, B, I, attr) ) return FALSE;
+
+ if ( strcmp("window",attr) == 0 ){
+ gn_put_object(XBUF,(GObject*) widget->window);
+ }else if ( strcmp("x",attr) == 0 ) {
+ gn_put_longlong(XBUF,(long long)widget->allocation.x);
+ }else if ( strcmp("y",attr) == 0 ) {
+ gn_put_longlong(XBUF,(long long)widget->allocation.y);
+ }else if ( strcmp("width",attr) == 0 ) {
+ gn_put_longlong(XBUF,(long long)widget->allocation.width);
+ }else if ( strcmp("height",attr) == 0 ) {
+ gn_put_longlong(XBUF,(long long)widget->allocation.height);
+ }else{
+ gn_enc_2_error(XBUF, "no_such_attr");
+ ei_x_encode_atom(XBUF, attr);
+ return FALSE;
+ }
+ return TRUE;
+}
View
590 c_src/gtknode_marshal.c
@@ -0,0 +1,590 @@
+#include "gtknode.h"
+#include <string.h>
+#include <stdlib.h>
+
+static void hash_init() {
+ extern GHashTable* ghash;
+ if ( ! ghash ) ghash = g_hash_table_new(g_str_hash, g_str_equal);
+}
+
+void hash_insert(gchar* key, void* value) {
+ extern GHashTable* ghash;
+ hash_init();
+ g_hash_table_insert(ghash, (gpointer) g_strdup(key), (gpointer) value);
+}
+
+void* hash_lookup(gchar* key) {
+ extern GHashTable* ghash;
+ hash_init();
+ return (void*) g_hash_table_lookup(ghash, (gconstpointer) key);
+}
+static void ghFunc(gpointer key,gpointer value,gpointer user_data){
+ g_message("hash_foreach %s %d", (gchar*) key, value);
+}
+static void hash_printall() {
+ extern GHashTable* ghash;
+ hash_init();
+ g_hash_table_foreach(ghash, ghFunc, NULL);
+}
+
+/***************************************************************************/
+static char* get_type_name(const gchar* name) {
+ char c;
+ static char str[100];
+ int i = 1;
+ int ii = 1;
+
+ str[0] = tolower(name[0]);
+ while ( c = name[i++] ){
+ if ( isupper(c) ) {
+ str[ii++] = '_';
+ str[ii++] = tolower(c);
+ }else{
+ str[ii++] = c;
+ }
+ }
+ str[ii] = 0;
+ return strcat(str,"_get_type");
+}
+
+GType gn_GType_from_name(const gchar* name) {
+ extern GModule *gmod;
+ GType (*func)(void);
+ GType gtp;
+ char* tname;
+
+ /* is this type registered? */
+ if ( (gtp = g_type_from_name(name) ) )
+ return gtp;
+ /* try to instantiate the type */
+ tname = get_type_name(name);
+ g_message("tname :%s:\n", tname);
+ if ( g_module_symbol(gmod, tname, (gpointer *)&func ) )
+ if ( (gtp = (*func)() ) )
+ return gtp;
+ /* no dice... */
+ return (GType)NULL;
+}
+/***************************************************************************/
+/* wrap all answers in this */
+/* {{self(),reply|signal|error|handshake},...} */
+/***************************************************************************/
+
+void gn_wrap_ans(char* tag, ei_x_buff* xbuf) {
+ extern ei_cnode ec;
+ ei_x_encode_tuple_header(xbuf,2);
+ ei_x_encode_tuple_header(xbuf,2);
+ ei_x_encode_pid(xbuf, ei_self(&ec));
+ ei_x_encode_atom(xbuf, tag);
+}
+
+void gn_wrap_reply(char* tag, ei_x_buff* xbuf) {
+ ei_x_encode_tuple_header(xbuf,2);
+ ei_x_encode_atom(xbuf, tag);
+}
+/***************************************************************************/
+/* error tuple builders */
+/***************************************************************************/
+/* {{Node,error}, {Err,...}} */
+void gn_enc_2_error(ei_x_buff *xbuf, char *err) {
+ gn_wrap_reply("error", xbuf);
+ ei_x_encode_tuple_header(xbuf,2);
+ ei_x_encode_atom(xbuf, err);
+}
+
+/* {{Node,error}, Err} */
+void gn_enc_1_error(ei_x_buff *xbuf, char *err) {
+ gn_wrap_reply("error", xbuf);
+ ei_x_encode_atom(xbuf, err);
+}
+
+/***************************************************************************/
+/* marshal return values from gtk calls */
+/* {{Node,reply}, ...} */
+/***************************************************************************/
+void gn_put_tuple(ei_x_buff *xbuf, int N) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_tuple_header(xbuf,N));
+}
+
+void gn_put_void(ei_x_buff *xbuf) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_atom(xbuf, "void") );
+}
+
+void gn_put_pid(ei_x_buff *xbuf, erlang_pid *p) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_pid(xbuf, p) );
+}
+
+void gn_put_boolean(ei_x_buff *xbuf, int i) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_boolean(xbuf, i) );
+}
+
+void gn_put_double(ei_x_buff *xbuf, double d) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_double(xbuf, d) );
+}
+
+void gn_put_longlong(ei_x_buff *xbuf, long long l) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_longlong(xbuf, l) );
+}
+
+void gn_put_ulonglong(ei_x_buff *xbuf, unsigned long long l) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_ulonglong(xbuf, l) );
+}
+
+void gn_put_atom(ei_x_buff *xbuf, char *p) {
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_atom(xbuf, p) );
+}
+
+void gn_put_string(ei_x_buff *xbuf, char *p) {
+ gn_wrap_reply("ok", xbuf);
+ if ( p == NULL ) {
+ ei_x_encode_string(xbuf, "");
+ }else{
+ ei_x_encode_string(xbuf, p);
+ }
+}
+
+void gn_put_object(ei_x_buff *xbuf, GObject *w) {
+ gchar bf[24];
+
+ if ( G_IS_OBJECT(w) ){
+ /* ref all objs that are returned to erl to avoid garbing */
+ g_object_ref(w);
+ g_assert( (sprintf(bf,"%d", (long)w) < sizeof(bf)) );
+ hash_insert(bf, (void*)w);
+ } else if ( w == 0 ) {
+ memcpy(bf,"NULL",5);
+ } else {
+ g_critical("put_object called with non-object");
+ }
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_atom(xbuf, bf));
+}
+
+
+/* if GLib decides to free a struct we're hosed */
+/* i think one could rig up some freeing callback and */
+/*remove the pointer from the hash, but i'm not sure how */
+void gn_put_struct(ei_x_buff *xbuf, char *type, void *struct_p) {
+ gchar key[200];
+ gchar name[24];
+
+ g_assert( (sprintf(name,"%d", (long)struct_p) < sizeof(name)) );
+ g_assert( (strlen(type)+sizeof(name)+4) < sizeof(key) );
+ memcpy(key, type, strlen(type)+1);
+ strcat(key, "-");
+ strcat(key, name);
+
+ g_assert( hash_lookup(key) == NULL );
+ hash_insert(key, struct_p);
+
+ gn_wrap_reply("ok", xbuf);
+ g_assert( ! ei_x_encode_atom(xbuf, name));
+}
+
+
+void gn_put_enum(ei_x_buff *xbuf, char* type_name, gint enum_val) {
+ char buf[100];
+ gn_wrap_reply("ok", xbuf);
+ g_assert( gn_get_enum_name(type_name, enum_val, buf) );
+ g_assert( ! ei_x_encode_atom(xbuf, buf));
+}
+
+void gn_put_flags(ei_x_buff *xbuf, char* type_name, guint flags) {
+ GType gtyp;
+ GFlagsClass* fclass;
+ GFlagsValue* fval;
+
+ gn_wrap_reply("ok", xbuf);
+ g_assert( (gtyp = gn_GType_from_name(type_name)));
+ g_assert(G_TYPE_IS_FLAGS(gtyp));
+ fclass = g_type_class_ref(gtyp);
+ while (flags) {
+ fval = g_flags_get_first_value(fclass,flags);
+ flags = flags & ~fval->value;
+ g_assert( ! ei_x_encode_list_header(xbuf, 1) );
+ g_assert( ! ei_x_encode_atom(xbuf, fval->value_name) );
+ }
+ g_assert( ! ei_x_encode_empty_list(xbuf));
+ g_type_class_unref(fclass);
+}
+
+
+/***************************************************************************/
+/* marshalling erlang -> gtk */
+/***************************************************************************/
+/*****************************************************************************/
+gboolean gn_get_arg_pid(ei_x_buff *xbuf, char *B, int *I, erlang_pid *pid){
+ if ( ! ei_decode_pid(B ,I, pid) ) return TRUE;
+ gn_enc_1_error(xbuf, "bad_pid");
+ return FALSE;
+}
+
+gboolean gn_get_arg_gboolean(ei_x_buff *xbuf, char *B, int *I, gboolean *a) {
+ if ( ! ei_decode_boolean(B, I, a) ) return TRUE;
+ gn_enc_1_error(xbuf, "bad_boolean");
+ return FALSE;
+}
+
+gboolean gn_get_arg_gchar_fix(ei_x_buff *xbuf, char *B, int *I, char *a){
+ if ( ! ei_decode_atom(B, I, a) ) return TRUE;
+ gn_enc_1_error(xbuf, "bad_atom");
+ return FALSE;
+}
+
+/* if gn_get_arg_(g)char returns TRUE, *a must be freed */
+gboolean gn_get_arg_char(ei_x_buff *xbuf, char *B, int *I, char **a){
+ gn_get_arg_gchar(xbuf,B,I,a);
+}
+gboolean gn_get_arg_gchar(ei_x_buff *xbuf, char *B, int *I, gchar **a) {
+ int type, size, dummy;
+
+ if ( ei_get_type(B, I, &type, &size) ) {
+ gn_enc_1_error(xbuf, "bad_type");
+ return FALSE;
+ }
+
+ *a = (gchar *)malloc(size+1);
+
+ if ( ! ei_decode_string(B, I, *a) ) return TRUE;
+
+ free(*a);
+ gn_enc_1_error(xbuf, "bad_string");
+ return FALSE;
+}
+
+gboolean gn_get_arg_int(ei_x_buff *xbuf, char *B, int *I, int *a) {
+ gint64 ll;
+
+ if ( ! gn_get_arg_gint64(xbuf, B, I, &ll) ) return FALSE;
+ *a = ll;
+ return TRUE;
+}
+gboolean gn_get_arg_gint(ei_x_buff *xbuf, char *B, int *I, gint *a) {
+ gint64 ll;
+
+ if ( ! gn_get_arg_gint64(xbuf, B, I, &ll) ) return FALSE;
+ *a = ll;
+ return TRUE;
+}
+gboolean gn_get_arg_glong(ei_x_buff *xbuf, char *B, int *I, glong *a) {
+ gint64 ll;
+
+ if ( ! gn_get_arg_gint64(xbuf, B, I, &ll) ) return FALSE;
+ *a = ll;
+ return TRUE;
+}
+gboolean gn_get_arg_gint64(ei_x_buff *xbuf, char *B, int *I, gint64 *a) {
+ long long ll;
+ if ( ! ei_decode_longlong(B ,I, &ll) ) {
+ *a = ll;
+ return TRUE;
+ }
+ gn_enc_1_error(xbuf, "bad_longlong");
+ return FALSE;
+}
+
+gboolean gn_get_arg_guint16(ei_x_buff *xbuf, char *B, int *I, guint16 *a) {
+ guint gui;
+ if ( ! gn_get_arg_guint(xbuf,B,I,&gui) ) return FALSE;
+ *a = gui;
+ return TRUE;
+}
+gboolean gn_get_arg_guint32(ei_x_buff *xbuf, char *B, int *I, guint32 *a) {
+ guint gui;
+ if ( ! gn_get_arg_guint(xbuf,B,I,&gui) ) return FALSE;
+ *a = gui;
+ return TRUE;
+}
+gboolean gn_get_arg_guint(ei_x_buff *xbuf, char *B, int *I, guint *a) {
+ unsigned long long ull;
+ if ( ! ei_decode_ulonglong(B, I, &ull) ) {
+ *a = ull;
+ return TRUE;
+ }
+ gn_enc_1_error(xbuf, "bad_uint");
+ return FALSE;
+}
+
+gboolean gn_get_arg_gfloat(ei_x_buff *xbuf, char *B, int *I, gfloat *a) {
+ gdouble dbl;
+ if ( ! gn_get_arg_gdouble(xbuf, B, I, &dbl) ) return FALSE;
+ *a = dbl;
+ return TRUE;
+}
+gboolean gn_get_arg_gdouble(ei_x_buff *xbuf, char *B, int *I, gdouble *a) {
+ if ( ! ei_decode_double(B, I, a) ) return TRUE;
+ gn_enc_1_error(xbuf, "bad_double");
+ return FALSE;
+}
+
+gboolean gn_get_arg_enum(ei_x_buff *xbuf, char *B, int *I, gchar* ec, gint *i) {
+ gchar enum_name[MAXATOMLEN+1];
+ if ( ! gn_get_arg_gchar_fix(xbuf, B, I, enum_name) ) return FALSE;
+ if ( ! gn_get_enum_val(xbuf, ec, enum_name, i) ) return FALSE;
+ return TRUE;
+}
+
+gboolean gn_get_arg_flags(ei_x_buff *xbuf, char *B, int *I,
+ gchar* type_name, gint *flags) {
+ GType gtyp;
+ GFlagsClass* fclass;
+ GFlagsValue* fval;
+ char flag_name[MAXATOMLEN+1];
+ int list_len;
+
+ *flags = 0;
+ if ( (list_len = gn_get_list(xbuf,B,I)) < 0 ) return FALSE;
+ if ( ! (gtyp = gn_GType_from_name(type_name))) {
+ gn_enc_2_error(xbuf, "bad_flag_type");
+ ei_x_encode_atom(xbuf, type_name);
+ return FALSE;
+ }
+ if ( ! G_TYPE_IS_FLAGS(gtyp)) {
+ gn_enc_2_error(xbuf, "bad_type_flag");
+ ei_x_encode_atom(xbuf, type_name);
+ return FALSE;
+ }
+ fclass = g_type_class_ref(gtyp);
+ while ( list_len-- ) {
+ if ( ei_decode_atom(B, I, flag_name) ) {
+ gn_enc_2_error(xbuf, "bad_flag_atom");
+ ei_x_encode_atom(xbuf, type_name);
+ g_type_class_unref(fclass);
+ return FALSE;
+ }
+ fval = g_flags_get_value_by_name(fclass, flag_name);
+ *flags = *flags | fval->value;
+ }
+ g_type_class_unref(fclass);
+ return TRUE;
+}
+
+/* if get_arg_list returns TRUE, *list must be freed */
+gboolean gn_get_arg_list(ei_x_buff *XBUF, char *B, int *I,
+ gchar* type_name, void** list) {
+ GType gtyp;
+ GType* tlist;
+ char tname[MAXATOMLEN+1];
+ int list_len, i;
+
+ if ( strcmp(type_name,"GType") != 0 ) { /* only GType* yet */
+ gn_enc_1_error(XBUF, "bad_list_type");
+ return FALSE;
+ }
+
+ if ( (list_len = gn_get_list(XBUF,B,I)) < 0 ) return FALSE;
+
+ tlist = g_new(GType, list_len);
+
+ for (i = 0; i < list_len; i++) {
+ if ( ! gn_get_arg_gtype(XBUF, B, I, &gtyp )) {
+ g_free(tlist);
+ return FALSE;
+ }
+ tlist[i] = gtyp;
+ }
+ *list = (void*)tlist;
+ return TRUE;
+}
+
+gboolean gn_get_arg_gtype(ei_x_buff *XBUF, char *B, int *I, GType *gt){
+ gchar type_str[MAXATOMLEN+1];
+
+ if ( ! gn_get_arg_gchar_fix(XBUF, B, I, type_str) ) return FALSE;
+ if ( strcmp(type_str,"string") == 0 ){
+ *gt = G_TYPE_STRING;
+ } else if(strcmp(type_str,"integer") == 0) {
+ *gt = G_TYPE_INT64;
+ } else if(strcmp(type_str,"float") == 0) {
+ *gt = G_TYPE_DOUBLE;
+ } else {
+ gn_enc_2_error(XBUF, "not_value_type");
+ ei_x_encode_atom(XBUF, type_str);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean gn_get_arg_object(ei_x_buff *xbuf, char *B, int *I,
+ GType type, GObject** go) {
+
+ char object_name[MAXATOMLEN+1];
+
+ if ( ei_decode_atom(B, I, object_name) ) {
+ gn_enc_1_error(xbuf, "bad_object_atom");
+ return FALSE;
+ }
+ if ( strcmp(object_name,"NULL") == 0 ) {
+ *go = NULL;
+ }else if ( ! gn_check_object(xbuf, object_name, type, go) ) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+gboolean gn_get_arg_struct(ei_x_buff *xbuf, char *B, int *I,
+ char* type, void** pp) {
+
+ char str_name[MAXATOMLEN+1];
+
+ if ( ei_decode_atom(B, I, str_name) ) {
+ gn_enc_1_error(xbuf, "bad_struct_atom");
+ return FALSE;
+ }
+ if ( strcmp(str_name,"NULL") == 0 ) {
+ *pp = NULL;
+ }else if ( ! gn_check_struct(xbuf, str_name, type, pp) ) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean gn_check_object(ei_x_buff *xbuf, gchar* object_name,
+ GType type, GObject** object) {
+ void* vp;
+ GType GT;
+
+ if ( (vp = hash_lookup(object_name)) ) {
+ /* dynamic object */
+ }else if ( (vp = gn_check_widget_name(object_name))) {
+ /* named widget */
+ }else{
+ gn_enc_2_error(xbuf, "bad_object");
+ ei_x_encode_atom(xbuf, object_name);
+ return FALSE;
+ }
+
+ *object = G_OBJECT(vp);
+ if ( G_TYPE_CHECK_INSTANCE_TYPE ((*object), type) ) return TRUE;
+
+ GT = G_TYPE_FROM_INSTANCE(*object);
+ gn_enc_2_error(xbuf, "bad_type");
+ ei_x_encode_atom(xbuf, g_type_name(GT));
+ return FALSE;
+}
+
+gboolean gn_check_struct(ei_x_buff *xbuf,
+ char* struct_name, char* struct_type,void** pp) {
+ extern GModule *gmod;
+ gchar con_str[200] = "gn_construct_";
+ gchar key[200];
+ void* (*constr)(void);
+
+ memcpy(key,struct_type,strlen(struct_type)+1);
+ strcat(key,"-");
+ strcat(key,struct_name);
+ if ( (*pp = hash_lookup(key)) ) {
+ return TRUE;
+ }else{
+ strcat(con_str,struct_type);
+ g_module_symbol(gmod, con_str, (gpointer *)&constr);
+ if ( ! constr ) {
+ gn_enc_2_error(xbuf, "bad_constructor");
+ ei_x_encode_atom(xbuf, con_str);
+ return FALSE;
+ }
+ *pp = (*constr)();
+ hash_insert(key,*pp);
+ return TRUE;
+ }
+}
+
+gboolean gn_check_arity(ei_x_buff *xbuf, int a1, int a2) {
+ if ( a1 == a2 ) return TRUE;
+
+ gn_enc_2_error(xbuf, "bad_arity");
+ ei_x_encode_long(xbuf, (long) a2);
+ return FALSE;
+}
+
+/***************************************************************************/
+gint gn_get_list(ei_x_buff *xbuf, char *B, int *I) {
+ int ari;
+ if ( ! ei_decode_list_header(B, I, &ari) ) return ari;
+ gn_enc_1_error(xbuf, "bad_list");
+ return -1;
+}
+
+gint gn_get_tuple(ei_x_buff *xbuf, char *B, int *I) {
+ int ari;
+ if ( ! ei_decode_tuple_header(B, I, &ari) ) return ari;
+ gn_enc_1_error(xbuf, "bad_tuple");
+ return -1;
+}
+
+/***************************************************************************/
+
+static GEnumClass* get_enum_class(const gchar *type_name) {
+ GType gtyp;
+
+ if ( ! (gtyp = gn_GType_from_name(type_name)))
+ return NULL;
+ if ( ! G_TYPE_IS_ENUM(gtyp))
+ return NULL;
+
+ return g_type_class_ref(gtyp);
+}
+
+gboolean gn_get_enum_val(ei_x_buff *xbuf,
+ const gchar *type_name, gchar *enum_name, gint *i) {
+ GEnumClass* eclass;
+ GEnumValue* eval;
+
+ if ( ! (eclass = get_enum_class(type_name)) ) {
+ gn_enc_2_error(xbuf, "bad_enum_type");
+ ei_x_encode_atom(xbuf, type_name);
+ return FALSE;
+ }
+
+ eval = g_enum_get_value_by_name(eclass, enum_name);
+ g_type_class_unref(eclass);
+ if ( ! eval ) {
+ gn_enc_2_error(xbuf, "bad_enum_name");
+ ei_x_encode_atom(xbuf, enum_name);
+ return FALSE;
+ }
+ *i = eval->value;
+ return TRUE;
+}
+
+gboolean gn_get_enum_name(const gchar *type_name, gint i, gchar *enum_name) {
+ GEnumClass* eclass;
+ GEnumValue *eval;
+
+ if ( ! (eclass = get_enum_class(type_name)) )
+ return FALSE;
+
+ eval = g_enum_get_value(eclass, i);
+ g_type_class_unref(eclass);
+
+ if ( ! eval )
+ return FALSE;
+
+ memcpy(enum_name, eval->value_name, strlen(eval->value_name)+1);
+ return TRUE;
+}
+
+/***************************************************************************/
+/* {{Pid,signal},{Widget,EvType}} */
+/***************************************************************************/
+void gn_send_signal(const char *widgetname, char *evtyp) {
+ ei_x_buff xbuf;
+
+ ei_x_new_with_version(&xbuf);
+ gn_wrap_ans("signal", &xbuf);
+ ei_x_encode_tuple_header(&xbuf,2);
+ ei_x_encode_atom(&xbuf, widgetname);
+ ei_x_encode_atom(&xbuf, evtyp);
+ gn_send(&xbuf);
+ ei_x_free(&xbuf);
+}
+/***************************************************************************/
View
22 c_src/gtknode_structs.c
@@ -0,0 +1,22 @@
+#include "gtknode.h"
+
+void* gn_construct_GtkTextIter() {
+ return (void*) g_new0(GtkTextIter,1);}
+void* gn_construct_GtkTreeIter() {
+ return (void*) g_new0(GtkTreeIter,1);}
+void* gn_construct_GtkTreeModelIface() {
+ return (void*) g_new0(GtkTreeModelIface,1);}
+void* gn_construct_GValue() {
+ return (void*) g_new0(GValue,1);}
+void* gn_construct_GtkTreePath() {
+ return (void*) gtk_tree_path_new();}
+void* gn_construct_GdkPoint() {
+ return (void*) g_new0(GdkPoint,1);}
+void* gn_construct_GdkRectangle() {
+ return (void*) g_new0(GdkRectangle,1);}
+void* gn_construct_GdkColor() {
+ return (void*) g_new0(GdkColor,1);}
+void* gn_construct_PangoLayout() {
+ return (void*) pango_layout_new((PangoContext*) pango_context_new());}
+void* gn_construct_PangoContext() {
+ return (void*) pango_context_new();}
View
142 compile
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "compile $scriptversion"
+ exit $?
+ ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as `compile cc -o foo foo.c'.
+ # So we strip `-o arg' only if arg is an object.
+ eat=1
+ case $2 in
+ *.o | *.obj)
+ ofile=$2
+ ;;
+ *)
+ set x "$@" -o "$2"
+ shift
+ ;;
+ esac
+ ;;
+ *.c)
+ cfile=$1
+ set x "$@" "$1"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+ # If no `-o' option was seen then we might have been invoked from a
+ # pattern rule where we don't need one. That is ok -- this is a
+ # normal compilation that the losing compiler can handle. If no
+ # `.c' file was seen then we are probably linking. That is also
+ # ok.
+ exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use `[/.-]' here to ensure that we don't use the same name
+# that we are using for the .o file. Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+while true; do
+ if mkdir "$lockdir" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+ mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+ mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
View
50 configure.ac
@@ -0,0 +1,50 @@
+AC_INIT(GTK+ 2 wrapper library for Erlang, 0.15, rlenglet@users.forge.objectweb.org, gtknode)
+dnl Require autoconf version >=2.57.
+AC_PREREQ(2.57)
+AC_COPYRIGHT(Copyright (C) 2005 Romain Lenglet)
+dnl AC_REVISION($Id$)
+
+dnl Require automake version >=1.9.5.
+AM_INIT_AUTOMAKE(1.9.5)
+
+dnl C-related configuration.
+AC_PROG_CC
+AC_STDC_HEADERS
+
+dnl Erlang-related configuration.
+AC_ERLANG_SUBST_ROOT_DIR
+AC_ERLANG_SUBST_LIB_DIR
+AC_ERLANG_CHECK_LIB(erl_interface)
+AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR(gtknode, 0.15)
+erlcflags="+debug_info"
+AC_SUBST([ERLCFLAGS], [$erlcflags])
+
+dnl Python-related configuration (for the generator).
+AM_PATH_PYTHON
+
+dnl Information about GTK+2.
+PKG_CHECK_MODULES(GTK, [gmodule-2.0 libglade-2.0 gtk+-2.0])
+dnl Get the directory that contains the GTK+ include files.
+gtk_include_dir=`echo "$GTK_CFLAGS" | sed -n -e 's/^.*-I\([[^ ]]*include\/gtk-2.0\).*$/\1/p'`
+AC_SUBST([GTKINC], [$gtk_include_dir])
+glib_include_dir=`echo "$GTK_CFLAGS" | sed -n -e 's/^.*-I\([[^ ]]*include\/glib-2.0\).*$/\1/p'`
+AC_SUBST([GINC], [$glib_include_dir])
+gtk_version="`$PKG_CONFIG --modversion gtk+-2.0`"
+AC_SUBST([GTKVSN], [$gtk_version])
+
+dnl Specify the files to instantiate.
+AC_CONFIG_FILES([ \
+ Makefile \
+ src/Makefile \
+ c_src/Makefile \
+ priv/Makefile \
+ priv/generator/Makefile \
+ priv/examples/Makefile \
+ priv/examples/points/Makefile \
+ priv/examples/sherk/Makefile \
+ priv/examples/top/Makefile \
+ doc/Makefile \
+ ])
+
+AC_OUTPUT
+
View
530 depcomp
@@ -0,0 +1,530 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2005-07-09.11
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+ depmode Dependency tracking mode.
+ source Source file read by `PROGRAMS ARGS'.
+ object Object file output by `PROGRAMS ARGS'.
+ DEPDIR directory where to store dependencies.
+ depfile Dependency file to output.
+ tmpdepfile Temporary file to use when outputing dependencies.
+ libtool Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "depcomp $scriptversion"
+ exit $?
+ ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+ sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+ "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+ tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'. On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like `#:fec' to the end of the
+ # dependency line.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+ tr '
+' ' ' >> $depfile
+ echo >> $depfile
+
+ # The second pass generates a dummy entry for each header file.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+ >> $depfile
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts `$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
+ tmpdepfile="$stripped.u"
+ if test "$libtool" = yes; then
+ "$@" -Wc,-M
+ else
+ "$@" -M
+ fi
+ stat=$?
+
+ if test -f "$tmpdepfile"; then :
+ else
+ stripped=`echo "$stripped" | sed 's,^.*/,,'`
+ tmpdepfile="$stripped.u"
+ fi
+
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+
+ if test -f "$tmpdepfile"; then
+ outname="$stripped.o"
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+ sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+icc)
+ # Intel's C compiler understands `-MD -MF file'. However on
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # ICC 7.0 will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+ # ICC 7.1 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using \ :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+ sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+tru64)
+ # The Tru64 compiler uses -MD to generate dependencies as a side
+ # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in `foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+ if test "$libtool" = yes; then
+ # With Tru64 cc, shared objects can also be used to make a
+ # static library. This mecanism is used in libtool 1.4 series to
+ # handle both shared and static libraries in a single compilation.
+ # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+ #
+ # With libtool 1.5 this exception was removed, and libtool now
+ # generates 2 separate objects for the 2 libraries. These two
+ # compilations output dependencies in in $dir.libs/$base.o.d and
+ # in $dir$base.o.d. We have to check for both files, because
+ # one of the two compilations can be disabled. We should prefer
+ # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+ # automatically cleaned when .libs/ is deleted, while ignoring
+ # the former would cause a distcleancheck panic.
+ tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
+ tmpdepfile2=$dir$base.o.d # libtool 1.5
+ tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
+ tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
+ "$@" -Wc,-MD
+ else
+ tmpdepfile1=$dir$base.o.d
+ tmpdepfile2=$dir$base.d
+ tmpdepfile3=$dir$base.d
+ tmpdepfile4=$dir$base.d
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+