On Tue, 22 Aug 2000, Frank Warmerdam wrote:

> James,
> 
> I have encountered a problem using GdkColormap.alloc() on IRIX and Sun systems, 
> and I believe it is because of your unwarranted assumption that the red, green,
> and blue components of a GdkColor are ints, when they are in fact shorts.
> 
> struct _GdkColor
> {
>   gulong  pixel;
>   gushort red;
>   gushort green;
>   gushort blue;
> };
> 
> While I actually applied my patch against pygtk-0.6.4, the code for the
> function seems identical in 0.6.6 which is the most recent release (right?).
> Anyways, here is one patch.  I would really appreciate this making it into
> the next pygtk release.  In the meantime I will need to hand build pygtk for
> distribution with OpenEV (openev.sourceforge.net). 
> 
> static PyObject *
> PyGdkColor_Alloc(PyGdkColormap_Object *self, PyObject *args) {
>   GdkColor color = {0, 0, 0, 0};
>   int   red, green, blue;
>   gchar *color_name;
>   if (!PyArg_ParseTuple(args, "iii:GdkColormap.alloc",
>                         &(red), &(green), &(blue))) {
>     PyErr_Clear();
>     if (!PyArg_ParseTuple(args, "s:GdkColormap.alloc", &color_name))
>       return NULL;
>     if (!gdk_color_parse(color_name, &color)) {
>       PyErr_SetString(PyExc_TypeError, "unable to parse color specification");
>       return NULL;
>     }
>   }
>   else
>   {
>     color.red = red;
>     color.green = green;
>     color.blue = blue;
>   }
> 
>   if (!gdk_color_alloc(self->obj, &color)) {
>     PyErr_SetString(PyExc_RuntimeError, "couldn't allocate color");
>     return NULL;
>   }
>   return PyGdkColor_New(&color);
> }
> 
> Finally, I really appreciate the excellent work you have done with pygtk.

Yes, that is a known problem and will be fixed in the next release.  You
can also fix the problem by changing the formatting characters from iii to
hhh.


> 
> Best regards,

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to