Exemple #1
0
        # name manually
        self.set_property("name", name)

    def do_change_state(self, state_change):
        if state_change == gst.STATE_CHANGE_PAUSED_TO_PLAYING:
            self._state_changed = True
        # FIXME: it seems a vmethod increases the refcount without unreffing
        # print self.__gstrefcount__
        # print self.__grefcount__

        # chain up to parent
        return gst.Bin.do_change_state(self, state_change)


# we need to register the type for PyGTK < 2.8
gobject.type_register(MyBin)

# FIXME: fix leak in vmethods before removing overriding fixture
class BinSubclassTest(TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def testStateChange(self):
        bin = MyBin("mybin")
        self.assertEquals(bin.__gstrefcount__, 1)
        self.assertEquals(sys.getrefcount(bin), pygobject_2_13 and 2 or 3)

        self.assertEquals(bin.get_name(), "mybin")
class MyAlignment(gtk.Alignment):

    def __init__(self, caption):
        self.caption = gtk.Label()
        self.caption.set_markup('<b>%s</b>' % gobject.markup_escape_text(caption))

        gtk.Alignment.__init__(self)

        self.caption.set_parent(self)

    def do_forall(self, include_internals, callback, callback_data):
        callback(self.caption, callback_data)
        gtk.Alignment.do_forall(self, include_internals, callback, callback_data)

# FIXME: Why is it needed?
gobject.type_register(MyAlignment)

class FocusContainer(gtk.HBox):

    # Just call super.
    def do_set_focus_child(self, widget):
        gtk.HBox.do_set_focus_child(self, widget)

gobject.type_register(FocusContainer)

class FocusWindow(gtk.Window):

    # Just call super.
    def do_set_focus(self, focus):
        gtk.Window.do_set_focus(self, focus)
Exemple #3
0
        # name manually
        self.set_property('name', name)

    def do_change_state(self, state_change):
        if state_change == gst.STATE_CHANGE_PAUSED_TO_PLAYING:
            self._state_changed = True
        # FIXME: it seems a vmethod increases the refcount without unreffing
        # print self.__gstrefcount__
        # print self.__grefcount__

        # chain up to parent
        return gst.Bin.do_change_state(self, state_change)


# we need to register the type for PyGTK < 2.8
gobject.type_register(MyBin)


# FIXME: fix leak in vmethods before removing overriding fixture
class BinSubclassTest(TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def testStateChange(self):
        bin = MyBin("mybin")
        self.assertEquals(bin.__gstrefcount__, 1)
        self.assertEquals(sys.getrefcount(bin), pygobject_2_13 and 2 or 3)
GUnknown = gobject.type_from_name("TestUnknown")
Unknown = GUnknown.pytype


class MyUnknown(Unknown, testhelper.Interface):
    some_property = gobject.property(type=str)

    def __init__(self):
        Unknown.__init__(self)
        self.called = False

    def do_iface_method(self):
        self.called = True
        Unknown.do_iface_method(self)
gobject.type_register(MyUnknown)


class MyObject(gobject.GObject, testhelper.Interface):
    some_property = gobject.property(type=str)

    def __init__(self):
        gobject.GObject.__init__(self)
        self.called = False

    def do_iface_method(self):
        self.called = True
gobject.type_register(MyObject)


class TestIfaceImpl(unittest.TestCase):
# -*- Mode: Python -*-

import gc
import unittest

from common import gobject

class C(gobject.GObject):
    __gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                                   (gobject.TYPE_INT,)) }
    def do_my_signal(self, arg):
        self.arg = arg
gobject.type_register(C)

class D(C):
    def do_my_signal(self, arg2):
        self.arg2 = arg2
	C.do_my_signal(self, arg2)
gobject.type_register(D)

class TestChaining(unittest.TestCase):
    def setUp(self):
        self.inst = C()
        self.inst.connect("my_signal", self.my_signal_handler_cb, 1, 2, 3)

    def my_signal_handler_cb(self, *args):
        assert len(args) == 5
        assert isinstance(args[0], C)
        assert args[0] == self.inst
        
        assert isinstance(args[1], int)