Beispiel #1
0
    def test_item_removed_signal(self):
        remove_events = []
        item_removed_events = []

        def on_remove(self, widget):
            remove_events.append(widget)

        def on_item_removed(dockpaned, child):
            item_removed_events.append(child)

        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('remove', on_remove)
        dockpaned.connect('item-removed', on_item_removed)
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.remove(dockgroup1)
        dockpaned.remove_item(0)

        self.assertTrue(dockgroup1 in item_removed_events)
        self.assertTrue(dockgroup1 in remove_events)
        self.assertTrue(dockgroup2 in item_removed_events)
        self.assertFalse(dockgroup2 in remove_events)

        dockgroup1.destroy()
        dockgroup2.destroy()
        dockpaned.destroy()
Beispiel #2
0
    def test_item_added_signal(self):
        add_events = []
        item_added_events = []

        def on_add(self, widget):
            add_events.append(widget)

        def on_item_added(dockpaned, child):
            item_added_events.append(child)

        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('add', on_add)
        dockpaned.connect('item-added', on_item_added)
        dockpaned.add(dockgroup1)
        dockpaned.insert_item(dockgroup2)

        self.assertTrue(dockgroup1 in item_added_events)
        self.assertTrue(dockgroup1 in add_events)
        self.assertTrue(dockgroup2 in item_added_events)
        self.assertFalse(dockgroup2 in add_events)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #3
0
    def test_item_removed_signal(self):
        remove_events = []
        item_removed_events = []

        def on_remove(self, widget):
            remove_events.append(widget)

        def on_item_removed(dockpaned, child):
            item_removed_events.append(child)

        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('remove', on_remove)
        dockpaned.connect('item-removed', on_item_removed)
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.remove(dockgroup1)
        dockpaned.remove_item(0)

        self.assertTrue(dockgroup1 in item_removed_events)
        self.assertTrue(dockgroup1 in remove_events)
        self.assertTrue(dockgroup2 in item_removed_events)
        self.assertFalse(dockgroup2 in remove_events)

        dockgroup1.destroy()
        dockgroup2.destroy()
        dockpaned.destroy()
Beispiel #4
0
    def test_construction(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        layout = DockLayout()

        layout.add(frame)

        assert frame in layout.frames
        print(layout._signal_handlers)
        self.assertEquals(4, len(layout._signal_handlers))
        self.assertEquals(9, len(layout._signal_handlers[frame]))

        layout.remove(frame)

        assert not layout._signal_handlers, layout._signal_handlers
        assert frame not in layout.frames
Beispiel #5
0
    def test_construction_after_setting_layout(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        layout = DockLayout()

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        assert frame in layout.frames
        self.assertEquals(4, len(layout._signal_handlers))
        self.assertEquals(9, len(layout._signal_handlers[frame]))

        paned.remove(group)

        self.assertEquals(2, len(layout._signal_handlers), layout._signal_handlers)
        assert frame in list(layout._signal_handlers.keys()), layout._signal_handlers
        assert paned in list(layout._signal_handlers.keys()), layout._signal_handlers
        assert group not in list(layout._signal_handlers.keys()), layout._signal_handlers
        assert item not in list(layout._signal_handlers.keys()), layout._signal_handlers
        assert frame in layout.frames
Beispiel #6
0
    def test_get_widgets(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()
        label = gtk.Label()

        layout = DockLayout()

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)
        item.add(label)

        group2 = DockGroup()
        paned.add(group2)

        paned.set_name('foo')

        widgets = list(layout.get_widgets('foo'))
        assert len(widgets) == 1
        assert widgets[0] is paned

        widgets = list(layout.get_widgets('EtkDockGroup'))
        assert len(widgets) == 2
        assert widgets[0] is group
        assert widgets[1] is group2
Beispiel #7
0
    def test_drag_drop_on_group(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        layout = self.layout

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        win.set_default_size(200, 200)
        win.show_all()

        while gtk.events_pending():
            gtk.main_iteration()


        context = StubContext(group, [group.items[0]])

        group.do_drag_begin(context)
        x, y = 30, 30
        layout.on_widget_drag_motion(group, context, x, y, 0)

        assert layout._drag_data
        assert layout._drag_data.drop_widget is group

        layout.on_widget_drag_drop(group, context, x, y, 0)
Beispiel #8
0
    def test_drag_drop_on_group(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        layout = self.layout

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        win.set_default_size(200, 200)
        win.show_all()

        while gtk.events_pending():
            gtk.main_iteration()

        context = StubContext(group, [group.items[0]])

        group.do_drag_begin(context)
        x, y = 30, 30
        layout.on_widget_drag_motion(group, context, x, y, 0)

        assert layout._drag_data
        assert layout._drag_data.drop_widget is group

        layout.on_widget_drag_drop(group, context, x, y, 0)
Beispiel #9
0
    def test_construction(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        layout = DockLayout()

        layout.add(frame)

        assert frame in layout.frames
        print(layout._signal_handlers)
        self.assertEquals(4, len(layout._signal_handlers))
        self.assertEquals(9, len(layout._signal_handlers[frame]))

        layout.remove(frame)

        assert not layout._signal_handlers, layout._signal_handlers
        assert frame not in layout.frames
Beispiel #10
0
    def test_item_added_signal(self):
        add_events = []
        item_added_events = []

        def on_add(self, widget):
            add_events.append(widget)

        def on_item_added(dockpaned, child):
            item_added_events.append(child)

        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('add', on_add)
        dockpaned.connect('item-added', on_item_added)
        dockpaned.add(dockgroup1)
        dockpaned.insert_item(dockgroup2)

        self.assertTrue(dockgroup1 in item_added_events)
        self.assertTrue(dockgroup1 in add_events)
        self.assertTrue(dockgroup2 in item_added_events)
        self.assertFalse(dockgroup2 in add_events)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #11
0
    def test_construction_after_setting_layout(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        layout = DockLayout()

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        assert frame in layout.frames
        self.assertEquals(4, len(layout._signal_handlers))
        self.assertEquals(9, len(layout._signal_handlers[frame]))

        paned.remove(group)

        self.assertEquals(2, len(layout._signal_handlers),
                          layout._signal_handlers)
        assert frame in list(
            layout._signal_handlers.keys()), layout._signal_handlers
        assert paned in list(
            layout._signal_handlers.keys()), layout._signal_handlers
        assert group not in list(
            layout._signal_handlers.keys()), layout._signal_handlers
        assert item not in list(
            layout._signal_handlers.keys()), layout._signal_handlers
        assert frame in layout.frames
Beispiel #12
0
    def test_get_widgets(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()
        label = gtk.Label()

        layout = DockLayout()

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)
        item.add(label)

        group2 = DockGroup()
        paned.add(group2)

        paned.set_name('foo')

        widgets = list(layout.get_widgets('foo'))
        assert len(widgets) == 1
        assert widgets[0] is paned

        widgets = list(layout.get_widgets('EtkDockGroup'))
        assert len(widgets) == 2
        assert widgets[0] is group
        assert widgets[1] is group2
Beispiel #13
0
    def test_add(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)

        self.assertTrue(dockgroup in dockpaned)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #14
0
    def test_add(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)

        self.assertTrue(dockgroup in dockpaned)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #15
0
    def test_remove(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)
        dockpaned.remove(dockgroup)

        self.assertTrue(dockgroup not in dockpaned)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #16
0
    def test_remove(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)
        dockpaned.remove(dockgroup)

        self.assertTrue(dockgroup not in dockpaned)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #17
0
    def test_get_n_handles(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned._get_n_handles() == 1)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #18
0
    def test_len(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(len(dockpaned) == 2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #19
0
    def test_len(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(len(dockpaned) == 2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #20
0
    def test_get_n_handles(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned._get_n_handles() == 1)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #21
0
    def test_child_destroy(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)

        self.assertTrue(len(dockpaned) == len(dockpaned._items) == 1)

        dockgroup.destroy()

        self.assertTrue(len(dockpaned) == len(dockpaned._items) == 0)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #22
0
    def test_get_nth_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned.get_nth_item(0) == dockgroup1)
        self.assertTrue(dockpaned.get_nth_item(1) == dockgroup2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #23
0
    def test_get_nth_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned.get_nth_item(0) == dockgroup1)
        self.assertTrue(dockpaned.get_nth_item(1) == dockgroup2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #24
0
    def test_item_num(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned.item_num(dockgroup1) == 0)
        self.assertTrue(dockpaned.item_num(dockgroup2) == 1)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #25
0
    def test_item_num(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned.item_num(dockgroup1) == 0)
        self.assertTrue(dockpaned.item_num(dockgroup2) == 1)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #26
0
    def test_child_destroy(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)

        self.assertTrue(len(dockpaned) == len(dockpaned._items) == 1)

        dockgroup.destroy()

        self.assertTrue(len(dockpaned) == len(dockpaned._items) == 0)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #27
0
    def test_add_signal(self):
        add_events = []

        def on_add(self, widget):
            add_events.append(widget)

        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('add', on_add)
        dockpaned.add(dockgroup)

        self.assertTrue(dockgroup in add_events)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #28
0
    def test_add_signal(self):
        add_events = []

        def on_add(self, widget):
            add_events.append(widget)

        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('add', on_add)
        dockpaned.add(dockgroup)

        self.assertTrue(dockgroup in add_events)

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #29
0
    def test_remove_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockgroup3 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.add(dockgroup3)
        dockpaned.remove_item(None)
        dockpaned.remove_item(0)
        dockpaned.remove_item(-1)

        self.assertTrue(dockgroup1 not in dockpaned)
        self.assertTrue(dockgroup2 not in dockpaned)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #30
0
    def test_remove_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockgroup3 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.add(dockgroup3)
        dockpaned.remove_item(None)
        dockpaned.remove_item(0)
        dockpaned.remove_item(-1)

        self.assertTrue(dockgroup1 not in dockpaned)
        self.assertTrue(dockgroup2 not in dockpaned)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #31
0
    def test_reorder_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockgroup3 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.add(dockgroup3)
        dockpaned.reorder_item(dockgroup3, 0)
        dockpaned.reorder_item(dockgroup1, 2)

        self.assertTrue(dockpaned.item_num(dockgroup1) == 2)
        self.assertTrue(dockpaned.item_num(dockgroup2) == 1)
        self.assertTrue(dockpaned.item_num(dockgroup3) == 0)

        dockgroup3.destroy()
        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #32
0
    def test_child_prop_weight(self):
        global child_notify_called

        def _on_child_notify(gobject, pspec):
            global child_notify_called
            child_notify_called = True

        dockpaned = DockPaned()
        dockgroup = DockGroup()
        dockgroup.connect('child-notify::weight', _on_child_notify)
        dockpaned.add(dockgroup)

        child_notify_called = False
        dockpaned.child_set_property(dockgroup, 'weight', 0.3)
        self.assertTrue(child_notify_called,
                        msg='weight child property change notification failed')

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #33
0
    def test_child_prop_weight(self):
        global child_notify_called

        def _on_child_notify(gobject, pspec):
            global child_notify_called
            child_notify_called = True

        dockpaned = DockPaned()
        dockgroup = DockGroup()
        dockgroup.connect('child-notify::weight', _on_child_notify)
        dockpaned.add(dockgroup)

        child_notify_called = False
        dockpaned.child_set_property(dockgroup, 'weight', 0.3)
        self.assertTrue(child_notify_called,
                        msg='weight child property change notification failed')

        dockgroup.destroy()
        dockpaned.destroy()
Beispiel #34
0
    def test_reorder_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockgroup3 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.add(dockgroup3)
        dockpaned.reorder_item(dockgroup3, 0)
        dockpaned.reorder_item(dockgroup1, 2)

        self.assertTrue(dockpaned.item_num(dockgroup1) == 2)
        self.assertTrue(dockpaned.item_num(dockgroup2) == 1)
        self.assertTrue(dockpaned.item_num(dockgroup3) == 0)

        dockgroup3.destroy()
        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Beispiel #35
0
    def test_serialize(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        layout = DockLayout()
        frame = DockFrame()
        win.add(frame)
        layout.add(frame)
        paned = DockPaned()
        frame.add(paned)
        group = DockGroup()
        paned.add(group)
        item = DockItem(title='t', title_tooltip_text='xx', icon_name='icon', stock_id="")
        item.set_name('fillme')
        group.add(item)

        s = serialize(layout)
        print(s)
        assert bytes(b'<layout><dockframe height="1" width="1">'
                     b'<dockpaned orientation="horizontal">'
                     b'<dockgroup weight="100">'
                     b'<dockitem icon_name="icon" title="t" tooltip="xx" />'
                     b'</dockgroup></dockpaned></dockframe></layout>'
                     ) == s, s
Beispiel #36
0
    def test_get_item_at_pos(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        window = gtk.Window()
        window.add(dockpaned)
        window.show_all()

        child1 = dockpaned.get_item_at_pos(dockgroup1.allocation.x + 1,
                                           dockgroup1.allocation.y + 1)

        child2 = dockpaned.get_item_at_pos(dockgroup2.allocation.x + 1,
                                           dockgroup2.allocation.y + 1)

        self.assertTrue(child1 is dockgroup1)
        self.assertTrue(child2 is dockgroup2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
        window.destroy()
Beispiel #37
0
    def test_get_item_at_pos(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        window = gtk.Window()
        window.add(dockpaned)
        window.show_all()

        child1 = dockpaned.get_item_at_pos(dockgroup1.allocation.x + 1,
                                           dockgroup1.allocation.y + 1)

        child2 = dockpaned.get_item_at_pos(dockgroup2.allocation.x + 1,
                                           dockgroup2.allocation.y + 1)

        self.assertTrue(child1 is dockgroup1)
        self.assertTrue(child2 is dockgroup2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
        window.destroy()
Beispiel #38
0
    def test_delitem(self):
        dg = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(DockGroup())
        dockpaned.add(dg)
        dockpaned.add(DockGroup())

        assert dg in dockpaned
        assert len(dockpaned) == 3
        assert dg is dockpaned[1]
        del dockpaned[1]
        assert len(dockpaned) == 2
        assert dg not in dockpaned

        dg.destroy()
        dockpaned.destroy()
Beispiel #39
0
    def test_delitem(self):
        dg = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(DockGroup())
        dockpaned.add(dg)
        dockpaned.add(DockGroup())

        assert dg in dockpaned
        assert len(dockpaned) == 3
        assert dg is dockpaned[1]
        del dockpaned[1]
        assert len(dockpaned) == 2
        assert dg not in dockpaned

        dg.destroy()
        dockpaned.destroy()