You should call push_rgb_visual() and pop_rgb_visual() around the creation
of the widgets you want to use the gdk_rgb functions with.  They will call
gdk_rgb_init for you.

Note that just calling gdk_rgb_init() will probably work on your system,
but will not always work.  On multi visual X servers, the visual GdkRGB
chooses may not be the one that gtk uses as the default.  In this case,
GdkRGB will not render correctly.

James.

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


On Sat, 18 Mar 2000, Jesper Skov wrote:

> The calls were segv'ing until I added the gdk_rgb_init call. I don't
> see that anywhere in the pygtk sources - how was the gdk_rgb_ calls
> tested?  Relying on some GTK internals to call gdk_rgb_init (curious,
> not flame baiting :)
> 
> Cheers,
> Jesper
> 
> 
> 
>  2000-03-18  Jesper Skov  <[EMAIL PROTECTED]>
> 
>       * gtk.py:
>       * gtkmodule.c: 
>       Added gdk_rgb_init.
> 
> Index: gtk.py
> ===================================================================
> RCS file: /cvs/gnome/gnome-python/pygtk/gtk.py,v
> retrieving revision 1.41
> diff -u -5 -r1.41 gtk.py
> --- gtk.py    2000/03/03 08:41:57     1.41
> +++ gtk.py    2000/03/18 19:49:28
> @@ -2705,10 +2705,13 @@
>       _gtk.gdk_draw_segments(drawable, gc, segs)
>  def draw_lines(drawable, gc, points):
>       _gtk.gdk_draw_lines(drawable, gc, points)
>  
>  # these are the gdkrgb functions
> +def gdk_rgb_init():
> +     _gtk.gdk_rgb_init()
> +
>  def draw_rgb_image(drawable, gc, x, y, width, height,
>                  dither, buffer, rowstride):
>       _gtk.gdk_draw_rgb_image(drawable, gc, x, y, width, height,
>                               dither, buffer, rowstride)
>  def draw_rgb_32_image(drawable, gc, x, y, width, height,
> Index: gtkmodule.c
> ===================================================================
> RCS file: /cvs/gnome/gnome-python/pygtk/gtkmodule.c,v
> retrieving revision 1.50
> diff -u -5 -r1.50 gtkmodule.c
> --- gtkmodule.c       2000/03/13 09:14:23     1.50
> +++ gtkmodule.c       2000/03/18 19:49:43
> @@ -6257,10 +6257,18 @@
>      gtk_widget_pop_visual();
>      Py_INCREF(Py_None);
>      return Py_None;
>  }
>  
> +static PyObject *_wrap_gdk_rgb_init(PyObject *self, PyObject *args) {
> +    if (!PyArg_ParseTuple(args, ":gdk_rgb_init"))
> +     return NULL;
> +    gdk_rgb_init();
> +    Py_INCREF(Py_None);
> +    return Py_None;
> +}
> +
>  static PyObject *_wrap_gdk_draw_rgb_image(PyObject *self, PyObject *args) {
>      PyObject *drawable, *gc, *py_dith;
>      gint x, y, width, height, rowstride = -1, len;
>      GdkRgbDither dith;
>      guchar *rgb_buf;
> @@ -6519,10 +6527,11 @@
>      { "gdk_window_foreign_new", _wrap_gdk_window_foreign_new, 1 },
>      { "gdk_get_root_win", _wrap_gdk_get_root_win, 1 },
>  #endif
>      { "gtk_rgb_push_visual", _wrap_gtk_rgb_push_visual, 1 },
>      { "gtk_pop_visual", _wrap_gtk_pop_visual, 1 },
> +    { "gdk_rgb_init", _wrap_gdk_rgb_init, 1 },
>      { "gdk_draw_rgb_image", _wrap_gdk_draw_rgb_image, 1 },
>      { "gdk_draw_rgb_32_image", _wrap_gdk_draw_rgb_32_image, 1 },
>      { "gdk_draw_gray_image", _wrap_gdk_draw_gray_image, 1 },
>  #ifdef HAVE_NUMPY
>      { "gdk_draw_array", _wrap_gdk_draw_array, 1 },
> 
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to