-// -*- mode: C; indent-tabs-mode: nil; -*-
+// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#include "../config.h"
#include "color.h"
static void allocate(OtkColor *self) {
XColor xcol;
- assert(!self->allocated);
-
// allocate color from rgb values
xcol.red = self->red | self->red << 8;
xcol.green = self->green | self->green << 8;
}
self->pixel = xcol.pixel;
- self->allocated = True;
if (cleancache)
doCacheCleanup();
if (!colorcache) colorcache = PyDict_New();
- self->allocated = False;
self->red = r;
self->green = g;
self->blue = b;
- self->pixel = 0;
self->screen = screen;
// does this color already exist in the cache?
// add it to the cache
PyDict_SetItem(colorcache, (PyObject*)self, (PyObject*)self);
+ allocate(self);
return (PyObject*)self;
}
if (!colorcache) colorcache = PyDict_New();
- self->allocated = False;
self->red = -1;
self->green = -1;
self->blue = -1;
- self->pixel = 0;
self->screen = screen;
parseColorName(self, name);
// add it to the cache
PyDict_SetItem(colorcache, (PyObject*)self, (PyObject*)self);
+ allocate(self);
return (PyObject*)self;
}
-unsigned long OtkColor_Pixel(OtkColor *self)
-{
- if (!self->allocated)
- allocate(self);
- return self->pixel;
-}
-
void OtkColor_CleanupColorCache()
{
cleancache = True;