Mercurial > pidgin.yaz
view finch/libgnt/pygnt/test.py @ 19649:c6f1f9971c4a
When doing oscar server-side list management, do deletions before
additions because if it's done the other way then it's possible for
Pidgin to try to add one buddy to two different groups, which isn't
allowed for ICQ. Fixes schoen's comment at
http://developer.pidgin.im/ticket/576
References #576.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 05 Sep 2007 05:43:08 +0000 |
parents | 6b16fca71f8b |
children | 44b070f6a3f8 |
line wrap: on
line source
#!/usr/bin/python import gobject import gnt class MyObject(gobject.GObject): __gproperties__ = { 'mytype': (gobject.TYPE_INT, 'mytype', 'the type of the object', 0, 10000, 0, gobject.PARAM_READWRITE), 'string': (gobject.TYPE_STRING, 'string property', 'the string', None, gobject.PARAM_READWRITE), 'gobject': (gobject.TYPE_OBJECT, 'object property', 'the object', gobject.PARAM_READWRITE), } def __init__(self, type = 'string', value = None): self.__gobject_init__() self.set_property(type, value) def do_set_property(self, pspec, value): if pspec.name == 'string': self.string = value self.type = gobject.TYPE_STRING elif pspec.name == 'gobject': self.gobject = value self.type = gobject.TYPE_OBJECT else: raise AttributeError, 'unknown property %s' % pspec.name def do_get_property(self, pspec): if pspec.name == 'string': return self.string elif pspec.name == 'gobject': return self.gobject elif pspec.name == 'mytype': return self.type else: raise AttributeError, 'unknown property %s' % pspec.name gobject.type_register(MyObject) def button_activate(button, tree): list = tree.get_selection_text_list() ent = tree.get_selection_data() if ent.type == gobject.TYPE_STRING: str = "" for i in list: str = str + i entry.set_text("clicked!!!" + str) elif ent.type == gobject.TYPE_OBJECT: ent.gobject.set_text("mwhahaha!!!") gnt.gnt_init() win = gnt.Window() entry = gnt.Entry("") obj = MyObject() obj.set_property('gobject', entry) win.add_widget(entry) win.set_title("Entry") button = gnt.Button("Click!") win.add_widget(button) tree = gnt.Tree() tree.set_property("columns", 1) win.add_widget(tree) # so random non-string values can be used as the key for a row in a GntTree! last = None for i in range(1, 100): key = MyObject('string', str(i)) tree.add_row_after(key, [str(i)], None, last) last = key tree.add_row_after(MyObject('gobject', entry), ["asd"], None, None) tree.add_row_after(MyObject('string', "b"), ["123"], MyObject('gobject', entry), None) button.connect("activate", button_activate, tree) tv = gnt.TextView() win.add_widget(tv) tv.append_text_with_flags("What up!!", gnt.TEXT_FLAG_BOLD) win.show() gnt.gnt_main() gnt.gnt_quit()