[cells-cvs] CVS cells-gtk3/gtk-ffi

phildebrandt phildebrandt at common-lisp.net
Sun Apr 13 10:59:23 UTC 2008


Update of /project/cells/cvsroot/cells-gtk3/gtk-ffi
In directory clnet:/tmp/cvs-serv5005/gtk-ffi

Added Files:
	Makefile Makefile.win32 gdk-other.lisp gtk-adds.c 
	gtk-button.lisp gtk-core.lisp gtk-ffi-impl.lisp gtk-ffi.asd 
	gtk-ffi.lisp gtk-ffi.lpr gtk-gl-ext.lisp gtk-list-tree.lisp 
	gtk-menu.lisp gtk-other.lisp gtk-threads.lisp gtk-tool.lisp 
	gtk-utilities.lisp libcellsgtk-solaris.so libcellsgtk.so 
	package.lisp specs.new 
Log Message:
cells-gtk3 initial.



--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/Makefile	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/Makefile	2008/04/13 10:59:23	1.1
# 
# Purpose: build libcellsgtk.so
#
#  NOTE THAT THERE IS A libcellsgtk.so FOR LINUX AT: 
#   ftp://common-lisp.net/pub/project/cells-gtk/libcellsgtk.so
#  If you try it, I'd be interested to know if you have problems due to 
#  version mismatch with your GTK+ installation
#
#  You don't need libCellsGtk.so to run the demo, but you will to:
#   - add an entry text widget to a dialog
#   - add menu items using populate-popup (see GTK textview).
#   - Use a TreeModel (hierarchical arrangment of items) in a ComboBox.
#   - Use GTK text iters (used for marking text in text-buffers). 
#   - Use the drawing function: setting colors, getting the window of a widget
#
#  As of this writing, those are the only situations where it is needed. 
#  But this list is getting longer with each release.
#  See FAQ.txt for more of the motivation.
#
#  In order to compile the library you will need to have on hand the C header files 
#  corresponding the libgtk.so you are using. 
#  See http://developer.gnome.org/doc/API/2.4/gtk/gtk-building.html
#  On linux, it is a matter of installing 4 or 5 .rpms and typing "make"
#  Or at least that is how it worked for me.
#
#  Once built, place the library in the directory containing libgtk.

all:
	gcc -fPIC -c gtk-adds.c `pkg-config --cflags --libs gtk+-2.0`
	gcc -shared -o libcellsgtk.so gtk-adds.o `pkg-config --cflags --libs gtk+-2.0`

solaris:
	gcc -fPIC -R/opt/csw/lib -L/opt/csw/lib -c gtk-adds.c `pkg-config --cflags --libs gtk+-2.0 glib-2.0`
	gcc -fPIC -R/opt/csw/lib -L/opt/csw/lib -shared -o libcellsgtk.so gtk-adds.o `pkg-config --cflags --libs gtk+-2.0 glib-2.0`

--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/Makefile.win32	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/Makefile.win32	2008/04/13 10:59:23	1.1
# 
# Purpose: build libcellsgtk.so
#
#  NOTE THAT THERE IS A libcellsgtk.dll FOR WIN32 AT: 
#   ftp://common-lisp.net/pub/project/cells-gtk/libcellsgtk.dll
#  If you try it, I'd be interested to know if you have problems due to 
#  version mismatch with your GTK+ installation
#
#  You don't need libCellsGtk.so to run the demo, but you will to:
#   - add an entry text widget to a dialog
#   - add menu items using populate-popup (see GTK textview).
#   - Use a TreeModel (hierarchical arrangment of items) in a ComboBox.
#   - Use GTK text iters (used for marking text in text-buffers). 
#   - Use the drawing function: setting colors, getting the window of a widget
#
#  As of this writing, those are the only situations where it is needed. 
#  But this list is getting longer with each release.
#  See FAQ.txt for more of the motivation.
#
#  I build libcellsgtk.dll under cygwin. I use the win32 development directories from the site
#  ftp://ftp.gtk.org/pub/gtk/v2.8/win32 and also ftp://ftp.gtk.org/pub/gtk/v2.8/dependencies
#  I tried also the gtk-devel stuff you can get directly 
#  with cygwin setup.exe, but it doesn't seem to have everything you need. When you get it all
#  downloaded, modify the '.pc' files in   /local/win32/gtk/lib/pkgconfig so that prefix=
#  is set to wherever you placed the stuff.
#  Here is a list of the pc (package config) files....
# 
#  -rwx------  1 pdenno users  267 2005-11-13 15:02 atk.pc
#  -rwx------  1 pdenno users  267 2005-11-13 15:02 cairo.pc
#  -rwx------  1 pdenno users  336 2005-11-13 15:03 gdk-2.0.pc
#  -rwx------  1 pdenno users  287 2005-11-13 15:03 gdk-pixbuf-2.0.pc
#  -rwx------  1 pdenno users  336 2005-11-13 15:03 gdk-win32-2.0.pc
#  -rwx------  1 pdenno users  355 2005-11-13 15:03 glib-2.0.pc
#  -rwx------  1 pdenno users  260 2005-11-13 15:04 gmodule-2.0.pc
#  -rwx------  1 pdenno users  259 2005-11-13 15:04 gmodule-no-export-2.0.pc
#  -rwx------  1 pdenno users  251 2005-11-13 15:04 gobject-2.0.pc
#  -rwx------  1 pdenno users  229 2005-11-13 15:05 gthread-2.0.pc
#  -rwx------  1 pdenno users  362 2005-11-13 15:05 gtk+-2.0.pc
#  -rwx------  1 pdenno users  362 2005-11-13 15:05 gtk+-win32-2.0.pc
#  -rwx------  1 pdenno users  229 2005-11-13 15:07 libpng.pc
#  -rwx------  1 pdenno users  229 2005-11-13 14:20 libpng12.pc
#  -rwx------  1 pdenno users  229 2005-11-13 14:20 libpng13.pc
#  -rwx------  1 pdenno users  322 2005-11-13 15:07 pango.pc
#  -rwx------  1 pdenno users  315 2005-11-13 15:07 pangocairo.pc
#  -rwx------  1 pdenno users  403 2005-11-13 15:08 pangoft2.pc
#  -rwx------  1 pdenno users  276 2005-11-13 15:08 pangowin32.pc
#
#  ...and where is what the first line of one looks like on my machine: 
#  prefix=/local/win32/gtk 
#  Some like libpng have prefix=/usr ... because that is where it is (cygwin default).
#
#  Once built, place the library in the directory containing libgtk.

all:
	gcc -mno-cygwin -c gtk-adds.c `pkg-config --cflags --libs gtk+-2.0`
	dlltool -e exports.o -z cellsgtk.def -l cellsgtk.lib gtk-adds.o
	gcc -mno-cygwin -mwindows -mdll -L/usr/lib/mingw gtk-adds.o exports.o -o libcellsgtk.dll `pkg-config --cflags --libs gtk+-2.0` -specs=specs.new

--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gdk-other.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gdk-other.lisp	2008/04/13 10:59:23	1.1

(in-package :gtk-ffi)

(def-gtk-lib-functions :gdk 
  (gdk-gc-new ((drawable c-pointer))
      c-pointer)
  (gdk-draw-line ((drawable c-pointer)
		  (gc c-pointer)
		  (x1 int)
		  (y1 int)
		  (x2 int)
		  (y2 int)))
  (gdk-pixmap-new ((drawable c-pointer)
		   (width int)
		   (height int)
		   (depth int))
     c-pointer)
  (gdk-draw-drawable ((drawable c-pointer)
		      (gc c-pointer)
		      (src c-pointer)
		      (xsrc int)
		      (ysrc int)
		      (xdest int)
		      (ydest int)
		      (width int)
		      (height int)))
  (gdk-draw-rectangle ((drawable c-pointer)
		       (gc c-pointer)
		       (filled boolean)
		       (x int)
		       (y int)
		       (width int)
		       (height int)))
  (gdk-gc-set-rgb-fg-color ((gc c-pointer)
			    (color c-pointer)))
  (gdk-gc-set-rgb-bg-color ((gc c-pointer)
			    (color c-pointer)))
  (gdk-color-parse ((spec c-string)
		    (color c-pointer))
      int)
  (gdk-draw-layout ((drawable c-pointer)
		    (gc c-pointer)
		    (x int)
		    (y int)
		    (pango-layout c-pointer)))
  (gdk-gc-set-line-attributes ((gc c-pointer)
			       (line-width int)
			       (line-style int)
			       (cap-style int)
			       (join-style int))))
		   



--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-adds.c	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-adds.c	2008/04/13 10:59:23	1.1

#include <gtk/gtk.h>
#include <glib.h>

asm (".section .drectve");
asm (".ascii \"-export:gtk_adds_text_iter_new\"");
asm (".ascii \" -export:gtk_adds_text_view_popup_menu\"");
asm (".ascii \" -export:gtk_adds_dialog_vbox\"");
asm (".ascii \" -export:gtk_adds_tree_iter_new\"");
asm (".ascii \" -export:gtk_adds_widget_mapped_p\"");
asm (".ascii \" -export:gtk_adds_widget_visible_p\"");
asm (".ascii \" -export:gtk_adds_widget_window\"");
asm (".ascii \" -export:gtk_adds_color_new\"");
asm (".ascii \" -export:gtk_adds_color_set_rgb\"");
asm (".ascii \" -export:gtk_adds_ok\"");
asm (".ascii \" -export:gtk_adds_g_thread_supported\"");

/*  Return a pointer to the vbox of a dialog. 
 *  Useful for adding widgets to dialogs. For example,
 *  if you need a dialog with text entry capability. 
 */
GtkWidget *
gtk_adds_dialog_vbox (GtkWidget *dialog)
{
  return GTK_DIALOG(dialog)->vbox;
}

/*  Return a pointer to the popup_menu of a textview. 
 *  Useful if you need to add to the default textview menu
 *  on a populate-popup event. 
 */

GtkWidget *
gtk_adds_text_view_popup_menu (GtkWidget *text_view)
{
  return GTK_TEXT_VIEW(text_view)->popup_menu;
}

/* C programmers allocate iters on the stack. We use this.
   Free it with gtk-text-iter-free */
GtkTextIter *
gtk_adds_text_iter_new ()
{
  GtkTextIter example;
  return gtk_text_iter_copy(&example);
}

/* C programmers allocate iters on the stack. We use this.
   Free it with gtk-tree-iter-free */

GtkTreeIter *
gtk_adds_tree_iter_new ()
{
  GtkTreeIter example;
  return gtk_tree_iter_copy(&example);
}

int gtk_adds_widget_mapped_p (GtkWidget *wid)
{ 
    return ((GTK_WIDGET_FLAGS (wid) & GTK_MAPPED) != 0) ? 1 : 0;
}

int gtk_adds_widget_visible_p (GtkWidget *wid)
{ 
    return ((GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE) != 0) ? 1 : 0;
}

GdkWindow * 
gtk_adds_widget_window (GtkWidget *wid)
{
    return wid->window;
}

GdkColor *
gtk_adds_color_new ()
{
    return ((GdkColor *)malloc(sizeof(GdkColor)));
}

void
gtk_adds_color_set_rgb (GdkColor* color, guint r, guint g, guint b)
{
    color->red = r;
    color->green = g;
    color->blue = b;
}

/* You can run this one without having gtk running, to be sure the library was loaded. */
int
gtk_adds_ok ()
{
  return 1;
}

/* This macro tells us whether g_thread_init has already been called from this session
   This is important to avoid double initialization, which kills the current lisp session */

int
gtk_adds_g_thread_supported ()
{
  return g_thread_supported ();
}

--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-button.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-button.lisp	2008/04/13 10:59:23	1.1
#|

 Gtk ffi

 Copyright (c) 2004 by Vasilis Margioulas <vasilism at sch.gr>

 You have the right to distribute and use this software as governed by 
 the terms of the Lisp Lesser GNU Public License (LLGPL):

    (http://opensource.franz.com/preamble.html)
 
 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
 Lisp Lesser GNU Public License for more details.
 
|#

(in-package :gtk-ffi)




(def-gtk-lib-functions :gtk
  (gtk-button-new :pointer ())
  (gtk-button-set-label
   :void
   ((button :pointer) (label :gtk-string)))
  (gtk-button-set-relief
   :void
   ((button :pointer) (style :int)))
  (gtk-button-set-use-stock
   :void
   ((button :pointer) (use-stock :gtk-boolean)))
  (gtk-toggle-button-new :pointer ())
  (gtk-toggle-button-set-mode
   :void
   ((button :pointer)
    (draw-indicator :gtk-boolean)))
  (gtk-toggle-button-set-active
   :void
   ((button :pointer) (active :gtk-boolean)))
  (gtk-toggle-button-get-active
   :gtk-boolean
   ((button :pointer)))
  (gtk-check-button-new :pointer ())
  (gtk-radio-button-new
   :pointer
   ((gslist :pointer)))
  (gtk-radio-button-new-from-widget
   :pointer
   ((radio-group :pointer)))
  (gtk-spin-button-new
   :pointer
   ((adjustment :pointer)
    (climb-rate :double)
    (digits :unsigned-int)))
  (gtk-spin-button-new-with-range
   :pointer
   ((minval :double)
    (maxval :double)
    (step :double)))
  (gtk-spin-button-set-value :void
    ((spin-button :pointer) (value :double)))
  (gtk-spin-button-get-value
   :double
   ((spin-button :pointer)))
  (gtk-spin-button-get-value-as-int
   :int
   ((spin-button :pointer)))
  (gtk-spin-button-set-wrap
   :void
   ((spin-button :pointer) (wrap :gtk-boolean))))


#+debugthis
(gtk-toggle-button-get-active ((button c-pointer))
     boolean)

#+not
(DEF-GTK-FUNCTION :GTK GTK-TOGGLE-BUTTON-GET-ACTIVE
                  :ARGUMENTS ((BUTTON C-POINTER))
                  :RETURN-TYPE BOOLEAN
                  :CALL-DIRECT T)
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-core.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-core.lisp	2008/04/13 10:59:23	1.1
#|

 Gtk ffi

 Copyright (c) 2004 by Vasilis Margioulas <vasilism at sch.gr>

 You have the right to distribute and use this software as governed by 
 the terms of the Lisp Lesser GNU Public License (LLGPL):

    (http://opensource.franz.com/preamble.html)
 
 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
 Lisp Lesser GNU Public License for more details.
 
|#

(in-package :gtk-ffi)


(def-gtk-lib-functions :glib
  (g-free :void ((data :pointer)))
  (g-slist-free :void ((lst :pointer)))
  (g-timeout-add :unsigned-int
		 ((milliseconds :unsigned-int)
		  (func :pointer)
		  (data :pointer)))
  (g-locale-from-utf8 :gtk-string
		      ((utf8-string :pointer)
		       (len :int)
		       (bytes-read :pointer)
		       (bytes-written :pointer)
		       (gerror :pointer)))
  (g-locale-to-utf8 :pointer
		    ((local-string :gtk-string)
		     (len :int)
		     (bytes-read :pointer)
		     (bytes-written :pointer)
		     (gerror :pointer))))

(def-gtk-lib-functions :gthread (g-thread-init :void ((vtable :pointer))))

(def-gtk-lib-functions :gdk
  (gdk-threads-init :void ())
  (gdk-threads-enter :void ())
  (gdk-threads-leave :void ())
  (gdk-flush :void ()))

(uffi:def-union g-value-data
  (v-int :int)
  (v-uint :unsigned-int)
  (v-long :long)
  (v-ulong :unsigned-long)
  (v-int64-lo :int)
  (v-int64-hi :int)
  (v-uint64-lo :unsigned-int)
  (v-uint64-hi :unsigned-int)
  (v-float :float)
  (v-double :double)
  (v-pointer :pointer-void))

(uffi:def-struct g-value
    (g-type (:array :int 16)))

(defmacro with-g-value ((var) &body body)

[61 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi-impl.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi-impl.lisp	2008/04/13 10:59:23	1.1

[97 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi.asd	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi.asd	2008/04/13 10:59:23	1.1

[131 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi.lisp	2008/04/13 10:59:23	1.1

[578 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi.lpr	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-ffi.lpr	2008/04/13 10:59:23	1.1

[618 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-gl-ext.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-gl-ext.lisp	2008/04/13 10:59:23	1.1

[725 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-list-tree.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-list-tree.lisp	2008/04/13 10:59:23	1.1

[946 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-menu.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-menu.lisp	2008/04/13 10:59:23	1.1

[1052 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-other.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-other.lisp	2008/04/13 10:59:23	1.1

[1971 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-threads.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-threads.lisp	2008/04/13 10:59:23	1.1

[2022 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-tool.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-tool.lisp	2008/04/13 10:59:23	1.1

[2131 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-utilities.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/gtk-utilities.lisp	2008/04/13 10:59:23	1.1

[2388 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/libcellsgtk-solaris.so	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/libcellsgtk-solaris.so	2008/04/13 10:59:23	1.1

[2441 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/libcellsgtk.so	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/libcellsgtk.so	2008/04/13 10:59:23	1.1

[2486 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/package.lisp	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/package.lisp	2008/04/13 10:59:23	1.1

[2567 lines skipped]
--- /project/cells/cvsroot/cells-gtk3/gtk-ffi/specs.new	2008/04/13 10:59:23	NONE
+++ /project/cells/cvsroot/cells-gtk3/gtk-ffi/specs.new	2008/04/13 10:59:23	1.1

[2654 lines skipped]



More information about the Cells-cvs mailing list