def test_prop_icon_name(self): global notify_called def _on_notify(gobject, pspec): global notify_called notify_called = True dockitem = DockItem() dockitem.connect('notify::icon-name', _on_notify) notify_called = False dockitem.set_icon_name('someicon') self.assertEquals(dockitem.get_icon_name(), 'someicon', msg='get_icon_name method did not return expected value') self.assertTrue(notify_called, msg='icon-name property change notification failed when using set_icon_name method') notify_called = False dockitem.set_property('icon-name', 'anothericon') self.assertEquals(dockitem.get_property('icon-name'), 'anothericon', msg='get_property method did not return expected value') self.assertTrue(notify_called, msg='icon-name property change notification failed when using set_property method') notify_called = False dockitem.props.icon_name = 'niceicon' self.assertEquals(dockitem.props.icon_name, 'niceicon', msg='.props attribute did not return expected value') self.assertTrue(notify_called, msg='icon-name property change notification failed when using .props attribute') dockitem.destroy()
def test_prop_title_tooltip_text(self): global notify_called def _on_notify(gobject, pspec): global notify_called notify_called = True dockitem = DockItem() dockitem.connect('notify::title-tooltip-text', _on_notify) notify_called = False dockitem.set_title_tooltip_text('sometext') self.assertEquals(dockitem.get_title_tooltip_text(), 'sometext', msg='get_title_tooltip_text method did not return expected value') self.assertTrue(notify_called, msg='title-tooltip-text property change notification failed when using set_title_tooltip_text method') notify_called = False dockitem.set_property('title-tooltip-text', 'anothertext') self.assertEquals(dockitem.get_property('title-tooltip-text'), 'anothertext', msg='get_property method did not return expected value') self.assertTrue(notify_called, msg='title-tooltip-text property change notification failed when using set_title_tooltip_text method') notify_called = False dockitem.props.title_tooltip_text = 'hello' self.assertEquals(dockitem.props.title_tooltip_text, 'hello', msg='.props attribute did not return expected value') self.assertTrue(notify_called, msg='title-tooltip-text property change notification failed when using .props attribute') dockitem.destroy()
def test_prop_stock(self): global notify_called def _on_notify(gobject, pspec): global notify_called notify_called = True dockitem = DockItem() dockitem.connect('notify::stock', _on_notify) notify_called = False dockitem.set_stock(gtk.STOCK_ABOUT) self.assertEquals(dockitem.get_stock(), gtk.STOCK_ABOUT, msg='get_stock method did not return expected value') self.assertTrue(notify_called, msg='stock property change notification failed when using set_stock method') notify_called = False dockitem.set_property('stock', gtk.STOCK_ADD) self.assertEquals(dockitem.get_property('stock'), gtk.STOCK_ADD, msg='get_property method did not return expected value') self.assertTrue(notify_called, msg='stock property change notification failed when using set_property method') notify_called = False dockitem.props.stock = gtk.STOCK_APPLY self.assertEquals(dockitem.props.stock, gtk.STOCK_APPLY, msg='.props attribute did not return expected value') self.assertTrue(notify_called, msg='stock property change notification failed when using .props attribute') dockitem.destroy()
def test_item_closed_event_is_emited_on_close(self): dockitem = DockItem() dockgroup = DockGroup() dockgroup.add(dockitem) tab = dockgroup._tabs[0] item_closed = [] def item_closed_handler(item): item_closed.append(item) dockitem.connect('close', item_closed_handler) # Simulate clicking the close button tab.button.emit('clicked') assert [dockitem] == item_closed
def _add_dockitems(self, dockgroup): examples = [ (gtk.STOCK_EXECUTE, "calculator", "#!/usr/bin/env python\n\nprint 'Hello!'"), (gtk.STOCK_OPEN, "Hi!", "Hello!"), (gtk.STOCK_FILE, "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), (gtk.STOCK_FIND, "abc", "abcdefghijklmnopqrstuvwxyz"), (gtk.STOCK_HARDDISK, "browser", "0123456789"), (gtk.STOCK_HOME, "today", "9876543210"), gtk.Notebook, ] for i in [1]: # range(random.randrange(1, 10, 1)): example = random.choice(examples) if example is gtk.Notebook: child = gtk.Notebook() child.append_page(gtk.Button("Click me"), gtk.Label("New %s" % self.file_counter)) stock_id = "" tooltip_text = "notebook" else: stock_id, tooltip_text, text = example child = self._create_content(text) child.set_name(stock_id) # Create a DockItem and add our TextView di = DockItem(title="New %s" % self.file_counter, title_tooltip_text=tooltip_text, stock_id=stock_id) def on_close(item): print "close:", item di.connect("close", on_close) di.add(child) di.show_all() # Add out DockItem to the DockGroup dockgroup.add(di) # Increment file counter self.file_counter += 1