changeset 3:911cb701a42e

Moved all c/objc files into a new 'src' directory; other minor refactorings.
author Atul Varma <varmaa@toolness.com>
date Sun, 24 Feb 2008 08:51:21 -0600
parents a636a7618da6
children 3f48710a9ba1
files SConstruct enso_osx/graphics/SConscript enso_osx/graphics/__init__.py enso_osx/graphics/quartz_cairo_bridge.m enso_osx/graphics/transparentwindow.py src/SConscript src/quartz_cairo_bridge.m
diffstat 7 files changed, 113 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/SConstruct	Sun Feb 24 08:40:13 2008 -0600
+++ b/SConstruct	Sun Feb 24 08:51:21 2008 -0600
@@ -21,4 +21,4 @@
     LIBPATH = sys.prefix + "/lib/python" + sys.version[:3],
     )
 
-SConscript( "enso_osx/graphics/SConscript", exports="env" )
+SConscript( "src/SConscript", exports="env" )
--- a/enso_osx/graphics/SConscript	Sun Feb 24 08:40:13 2008 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-# ----------------------------------------------------------------------------
-#
-#   enso_osx.graphics SConscript
-#
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Imports
-# ----------------------------------------------------------------------------
-
-Import( "env" )
-
-import os
-import sys
-
-
-# ----------------------------------------------------------------------------
-# Library Definitions
-# ----------------------------------------------------------------------------
-
-env = env.Copy()
-
-
-# ----------------------------------------------------------------------------
-# Build Actions
-# ----------------------------------------------------------------------------
-
-env.Append(
-    # TODO: Use pkg-config or something to get these paths.
-    CPPPATH=["/opt/local/include/cairo",
-             os.path.join( sys.prefix, "include/pycairo" )],
-    LIBPATH=["/opt/local/lib"],
-    LIBS=["python", "cairo"],
-    FRAMEWORKS=["AppKit"],
-    )
-
-osXQuartzCairoBridge = env.LoadableModule(
-    source = ["quartz_cairo_bridge.m"],
-    target = ["quartz_cairo_bridge.so"],
-    )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/enso_osx/graphics/__init__.py	Sun Feb 24 08:51:21 2008 -0600
@@ -0,0 +1,5 @@
+import AppKit
+
+def getDesktopSize():
+    size = AppKit.NSScreen.mainScreen().frame().size
+    return ( size.width, size.height )
--- a/enso_osx/graphics/quartz_cairo_bridge.m	Sun Feb 24 08:40:13 2008 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#include <Python.h>
-#include <cairo-quartz.h>
-#include "pycairo.h"
-
-#import <AppKit/NSGraphicsContext.h>
-
-typedef struct {
-	PyObject_HEAD
-	__strong id objc_object;
-	int 	    flags;
-} PyObjCObject;
-
-static Pycairo_CAPI_t *Pycairo_CAPI;
-
-static PyObject *cairo_surface_from_NSGraphicsContext( PyObject *self,
-                                                       PyObject *args )
-{
-    PyObjCObject *obj;
-    unsigned int width;
-    unsigned int height;
-
-    if ( !PyArg_ParseTuple( args, "OII", (PyObject **) &obj,
-                            &width, &height ) )
-        return NULL;
-
-    NSGraphicsContext *nsContext = (NSGraphicsContext *) obj->objc_object;
-    CGContextRef cgContext = [nsContext graphicsPort];
-
-    cairo_surface_t *surface = cairo_quartz_surface_create_for_cg_context(
-        cgContext,
-        width,
-        height
-        );
-
-    PyObject *pycairoSurface;
-
-    pycairoSurface = PycairoSurface_FromSurface( surface, NULL );
-
-    if ( pycairoSurface == NULL )
-    {
-        /* TODO: Cleanup */
-        /* PycairoSurface_FromSurface() has already set the
-           Python error state. */
-        return NULL;
-    }
-
-    return pycairoSurface;
-}
-
-static PyMethodDef OsXQuartzCairoBridgeMethods[] = {
-    { "cairo_surface_from_NSGraphicsContext",
-      cairo_surface_from_NSGraphicsContext,
-      METH_VARARGS,
-      "Convert a NSGraphicsContext object to a Cairo surface." },
-    {NULL, NULL, 0, NULL}
-};
-
-PyMODINIT_FUNC
-initOsXQuartzCairoBridge( void )
-{
-    Py_InitModule( "OsXQuartzCairoBridge",
-                   OsXQuartzCairoBridgeMethods );
-
-    Pycairo_IMPORT;
-}
--- a/enso_osx/graphics/transparentwindow.py	Sun Feb 24 08:40:13 2008 -0600
+++ b/enso_osx/graphics/transparentwindow.py	Sun Feb 24 08:51:21 2008 -0600
@@ -138,7 +138,3 @@
 
     def getMaxHeight( self ):
         return self.__maxHeight
-
-def _getDesktopSize():
-    size = AppKit.NSScreen.mainScreen().frame().size
-    return ( size.width, size.height )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SConscript	Sun Feb 24 08:51:21 2008 -0600
@@ -0,0 +1,42 @@
+# ----------------------------------------------------------------------------
+#
+#   enso_osx.graphics SConscript
+#
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Imports
+# ----------------------------------------------------------------------------
+
+Import( "env" )
+
+import os
+import sys
+
+
+# ----------------------------------------------------------------------------
+# Library Definitions
+# ----------------------------------------------------------------------------
+
+env = env.Copy()
+
+
+# ----------------------------------------------------------------------------
+# Build Actions
+# ----------------------------------------------------------------------------
+
+env.Append(
+    # TODO: Use pkg-config or something to get these paths.
+    CPPPATH=["/opt/local/include/cairo",
+             os.path.join( sys.prefix, "include/pycairo" )],
+    LIBPATH=["/opt/local/lib"],
+    LIBS=["python", "cairo"],
+    FRAMEWORKS=["AppKit"],
+    )
+
+osXQuartzCairoBridge = env.LoadableModule(
+    source = ["quartz_cairo_bridge.m"],
+    target = ["quartz_cairo_bridge.so"],
+    )
+
+env.Install( "#enso_osx/graphics", osXQuartzCairoBridge )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/quartz_cairo_bridge.m	Sun Feb 24 08:51:21 2008 -0600
@@ -0,0 +1,65 @@
+#include <Python.h>
+#include <cairo-quartz.h>
+#include "pycairo.h"
+
+#import <AppKit/NSGraphicsContext.h>
+
+typedef struct {
+	PyObject_HEAD
+	__strong id objc_object;
+	int 	    flags;
+} PyObjCObject;
+
+static Pycairo_CAPI_t *Pycairo_CAPI;
+
+static PyObject *cairo_surface_from_NSGraphicsContext( PyObject *self,
+                                                       PyObject *args )
+{
+    PyObjCObject *obj;
+    unsigned int width;
+    unsigned int height;
+
+    if ( !PyArg_ParseTuple( args, "OII", (PyObject **) &obj,
+                            &width, &height ) )
+        return NULL;
+
+    NSGraphicsContext *nsContext = (NSGraphicsContext *) obj->objc_object;
+    CGContextRef cgContext = [nsContext graphicsPort];
+
+    cairo_surface_t *surface = cairo_quartz_surface_create_for_cg_context(
+        cgContext,
+        width,
+        height
+        );
+
+    PyObject *pycairoSurface;
+
+    pycairoSurface = PycairoSurface_FromSurface( surface, NULL );
+
+    if ( pycairoSurface == NULL )
+    {
+        /* TODO: Cleanup */
+        /* PycairoSurface_FromSurface() has already set the
+           Python error state. */
+        return NULL;
+    }
+
+    return pycairoSurface;
+}
+
+static PyMethodDef OsXQuartzCairoBridgeMethods[] = {
+    { "cairo_surface_from_NSGraphicsContext",
+      cairo_surface_from_NSGraphicsContext,
+      METH_VARARGS,
+      "Convert a NSGraphicsContext object to a Cairo surface." },
+    {NULL, NULL, 0, NULL}
+};
+
+PyMODINIT_FUNC
+initOsXQuartzCairoBridge( void )
+{
+    Py_InitModule( "OsXQuartzCairoBridge",
+                   OsXQuartzCairoBridgeMethods );
+
+    Pycairo_IMPORT;
+}