]> Dogcows Code - chaz/openbox/commitdiff
shit to init the module
authorDana Jansens <danakj@orodu.net>
Sat, 21 Dec 2002 12:27:05 +0000 (12:27 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 21 Dec 2002 12:27:05 +0000 (12:27 +0000)
otk_c/Makefile
otk_c/color.c
otk_c/color.h
otk_c/display.c
otk_c/display.h
otk_c/gccache.c
otk_c/gccache.h
otk_c/init.c [new file with mode: 0644]
otk_c/init.h [new file with mode: 0644]
otk_c/screeninfo.h

index b9253343e6a1f6e741a7779771351f9f17aa5874..2e0589d6ee76a9cf52a7f941a80b0cf6c85aecd0 100644 (file)
@@ -3,8 +3,8 @@ exec_prefix=$(prefix)
 libdir=$(exec_prefix)/lib
 
 targets = libotk.so libotk.a
-sources = display.c screeninfo.c rect.c gccache.c color.c
-headers = display.h screeninfo.h rect.h gccache.h color.h
+sources = init.c display.c screeninfo.c rect.c gccache.c color.c
+headers = init.h display.h screeninfo.h rect.h gccache.h color.h
 
 CFLAGS+=-g -I/usr/gwar/include/python2.2 -W -Wall
 
index d4dad53df5d9ecb071f767ab0f3cc16a286ea062..595eb08a648b59be9185687b4fed7f873365f5bf 100644 (file)
@@ -46,7 +46,7 @@ static long otkcolor_hash(OtkColor *self)
   return self->screen << 24 | self->red << 16 | self->green << 8 | self->blue;
 }
 
-static PyTypeObject OtkColor_Type = {
+PyTypeObject OtkColor_Type = {
   PyObject_HEAD_INIT(NULL)
   0,
   "Color",
index 6e9f421b13ef54d5b3e9ed0ceb23bde5f6e861ab..143429a0fa9a9ad4e7ad2f83402691115f0cfdda 100644 (file)
@@ -1,10 +1,12 @@
-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
 #ifndef __color_h
 #define __color_h
 
 #include <X11/Xlib.h>
 #include <Python.h>
 
+extern PyTypeObject OtkColor_Type;
+
 //!  OtkColor objects are immutable. DONT CHANGE THEM.
 typedef struct OtkColor {
   PyObject_HEAD
index 5efe71975cbee4fe91f615535fa6855456d2b12f..016aa9487fcd257dad2656a74908ea8583884cb5 100644 (file)
@@ -126,6 +126,8 @@ line argument.\n\n"));
   self->screenInfoList = PyList_New(ScreenCount(self->display));
   for (i = 0; i < ScreenCount(self->display); ++i)
     PyList_SetItem(self->screenInfoList, i, OtkScreenInfo_New(i));
+
+  Py_INCREF(OBDisplay); // make sure it stays around!!
 }
 
 void OtkDisplay_Grab(OtkDisplay *self)
index a36cd8538a5dfa2fdffbe9bf4a38362086accd3c..f13c52fbfc57ec71b6c19b8eab2521f9a8b6d3a0 100644 (file)
@@ -10,6 +10,8 @@ struct OtkDisplay;
 
 extern struct OtkDisplay *OBDisplay; // the global display XXX: move this to app.h and ob.h?
 
+extern PyTypeObject OtkDisplay_Type;
+
 typedef struct OtkDisplay {
   PyObject_HEAD
   
index 71232bf478c37c961b592411029a2ae6533377ac..f8b40f31e6d6fdfe148d2fa18de9287bbaa69e34 100644 (file)
@@ -86,7 +86,7 @@ OtkGCCacheItem *OtkGCCacheItem_New()
 }
 
 
-void OtkGCCache_Initialize(int screen_count)
+void OtkGCCache_Initialize()
 {
   unsigned int i;
 
@@ -94,7 +94,7 @@ void OtkGCCache_Initialize(int screen_count)
 
   gccache->context_count = 128;
   gccache->cache_size = 16;
-  gccache->cache_buckets = 8 * screen_count;
+  gccache->cache_buckets = 8 * ScreenCount(OBDisplay->display);
   gccache->cache_total_size = gccache->cache_size * gccache->cache_buckets;
 
   gccache->contexts = malloc(sizeof(OtkGCCacheContext*) *
@@ -108,7 +108,7 @@ void OtkGCCache_Initialize(int screen_count)
 }
 
 
-void OtkGCCache_Destroy()
+/*void OtkGCCache_Destroy()
 {
   unsigned int i;
 
@@ -122,9 +122,9 @@ void OtkGCCache_Destroy()
   free(gccache->cache);
   free(gccache);
   gccache = NULL;
-}
+}*/
 
-OtkGCCacheContext *OtkGCCache_NextContext(int screen)
+static OtkGCCacheContext *nextContext(int screen)
 {
   Window hd = OtkDisplay_ScreenInfo(OBDisplay, screen)->root_window;
   OtkGCCacheContext *c;
@@ -202,7 +202,7 @@ OtkGCCacheItem *OtkGCCache_Find(OtkColor *color, XFontStruct *font,
       gccache->cache[k-1] = c;
     }
   } else {
-    c->ctx = OtkGCCache_NextContext(screen);
+    c->ctx = nextContext(screen);
     OtkGCCacheContext_Set(c->ctx, color, font, function, subwindow, linewidth);
     c->ctx->used = True;
     c->count = 1;
index ccd9552490ba59b1a15bed52807032fe7851292e..d731826020b24e6de4753cde865530577618cb00 100644 (file)
@@ -51,8 +51,8 @@ typedef struct OtkGCCache {
   OtkGCCacheItem **cache;
 } OtkGCCache;
 
-void OtkGCCache_Initialize(int screen_count);
-void OtkGCCache_Destroy();
+void OtkGCCache_Initialize();
+//void OtkGCCache_Destroy();
 
 // cleans up the cache
 void OtkGCCache_Purge();
diff --git a/otk_c/init.c b/otk_c/init.c
new file mode 100644 (file)
index 0000000..5f576ac
--- /dev/null
@@ -0,0 +1,30 @@
+// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+#include "../config.h"
+#include "display.h"
+#include "screeninfo.h"
+#include "color.h"
+#include "gccache.h"
+
+#include <X11/Xlib.h>
+#include <Python.h>
+
+static PyMethodDef otk_methods[] = {
+//  {"new_noddy", noddy_new_noddy, METH_VARARGS,
+//   "Create a new Noddy object."},
+
+  {NULL, NULL, 0, NULL}
+};
+
+void initotk(char *display)
+{
+  OtkDisplay_Type.ob_type = &PyType_Type;
+  OtkScreenInfo_Type.ob_type = &PyType_Type;
+  OtkColor_Type.ob_type = &PyType_Type;
+
+  Py_InitModule("otk", otk_methods);
+
+  OtkDisplay_Initialize(display);
+  assert(OBDisplay);
+  OtkGCCache_Initialize();
+}
diff --git a/otk_c/init.h b/otk_c/init.h
new file mode 100644 (file)
index 0000000..ba807f2
--- /dev/null
@@ -0,0 +1,7 @@
+// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef __init_h
+#define __init_h
+
+void initotk(char *display);
+
+#endif // __init_h
index 5114a37cfb4e12aa4e0e11c08747d1ea6428f6b2..3a330f57df7c7c4e38b49ac7e81881eb8166f156 100644 (file)
@@ -5,6 +5,8 @@
 #include <X11/Xlib.h>
 #include <Python.h>
 
+extern PyTypeObject OtkScreenInfo_Type;
+
 typedef struct OtkScreenInfo {
   int screen;
   Window root_window;
This page took 0.032786 seconds and 4 git commands to generate.