[pygtk] Patch for keyval functions, set_cursor, & a memory leak

John Ehresman jpe@archaeopteryx.com
Wed, 12 Jul 2000 17:21:14 -0400 (EDT)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--8323328-1576337786-963436874=:21552
Content-Type: TEXT/PLAIN; charset=US-ASCII


Attached is a patch against pygtk 0.6.5 that:
 * adds wrappers for gdk keyval functions
 * changes the gdk window's set_cursor method so it accepts None as a
   valid cursor value (& maps it to NULL when calling the C function)
 * eliminates a memory leak in PyGtk_item_factory_cb when the Python
   callback raise an exception.

I looked at pygtk 0.6.5 briefly and it looks like this patch should still
be work with it, but unfortunately I don't have the time to upgrade and
test against it right now.  I can do this in a few weeks if needed and
I can also split the patch up into 3 pieces if that will make it easier to
review.

Thanks,

John

------------------------------------------------------------------------
Archaeopteryx Software, Inc.                        Wing IDE for Python 
www.archaeopteryx.com                               Take Flight!


--8323328-1576337786-963436874=:21552
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="pygtk.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.10.10007121721140.21552@localhost.localdomain>
Content-Description: 
Content-Disposition: attachment; filename="pygtk.diff"

KioqIC9ob21lL2pwZS9kb3duL3B5Z3RrLTAuNi41L2d0ay5weQlNb24gTWFy
IDEzIDA0OjA0OjE0IDIwMDANCi0tLSAuL2d0ay5weQlXZWQgSnVsICA1IDE4
OjE4OjIxIDIwMDANCioqKioqKioqKioqKioqKg0KKioqIDI3MjksMjczNCAq
KioqDQotLS0gMjczMSwyNzQyIC0tLS0NCiAgCWRlZiBkcmF3X2FycmF5KGRy
YXdhYmxlLCBnYywgeCwgeSwgZGl0aGVyLCBhcnJheSk6DQogIAkJX2d0ay5n
ZGtfZHJhd19hcnJheShkcmF3YWJsZSwgZ2MsIHgsIHksIGRpdGhlciwgYXJy
YXkpDQogIA0KKyAjIGtleXZhbCBmdW5jdGlvbnMNCisga2V5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