Commit fda8a069 authored by Jose Rostagno's avatar Jose Rostagno Committed by Martin Pitt
Browse files

pygtkcompat: Add gdk.pixbuf_get_formats compat code

https://bugzilla.gnome.org/show_bug.cgi?id=675489

Signed-off-by: default avatarMartin Pitt <martinpitt@gnome.org>
parent 2b49c5f5
......@@ -135,6 +135,26 @@ def enable_gtk(version='2.0'):
Gdk.pixbuf_new_from_file = GdkPixbuf.Pixbuf.new_from_file
Gdk.PixbufLoader = GdkPixbuf.PixbufLoader.new_with_type
orig_get_formats = GdkPixbuf.Pixbuf.get_formats
def get_formats():
formats = orig_get_formats()
result = []
def make_dict(format_):
result = {}
result['description'] = format_.get_description()
result['name'] = format_.get_name()
result['mime_types'] = format_.get_mime_types()
result['extensions'] = format_.get_extensions()
return result
for format_ in formats:
result.append(make_dict(format_))
return result
Gdk.pixbuf_get_formats = get_formats
orig_get_frame_extents = Gdk.Window.get_frame_extents
def get_frame_extents(window):
......
......@@ -117,6 +117,14 @@ class TestGTKCompat(unittest.TestCase):
loader = gtk.gdk.PixbufLoader('png')
loader.close()
def testPixbufFormats(self):
formats = gtk.gdk.pixbuf_get_formats()
self.assertEqual(type(formats[0]), dict)
self.assertTrue('name' in formats[0])
self.assertTrue('description' in formats[0])
self.assertTrue('mime_types' in formats[0])
self.assertEqual(type(formats[0]['extensions']), list)
def testGdkWindow(self):
w = gtk.Window()
w.realize()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment