Mon, 12 Nov 2007 17:13:44 +0000
Add maximize flags for windows.
|
15992
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1 | #!/usr/bin/python |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
2 | import gobject |
|
15992
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
3 | import gnt |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
4 | |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
5 | class MyObject(gobject.GObject): |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
6 | __gproperties__ = { |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
7 | 'mytype': (gobject.TYPE_INT, 'mytype', 'the type of the object', |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
8 | 0, 10000, 0, gobject.PARAM_READWRITE), |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
9 | 'string': (gobject.TYPE_STRING, 'string property', 'the string', |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
10 | None, gobject.PARAM_READWRITE), |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
11 | 'gobject': (gobject.TYPE_OBJECT, 'object property', 'the object', |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
12 | gobject.PARAM_READWRITE), |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
13 | } |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
14 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
15 | def __init__(self, type = 'string', value = None): |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
16 | self.__gobject_init__() |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
17 | self.set_property(type, value) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
18 | |
|
19814
05ce6c570b47
Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19173
diff
changeset
|
19 | def __del__(self): |
|
05ce6c570b47
Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19173
diff
changeset
|
20 | pass |
|
05ce6c570b47
Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19173
diff
changeset
|
21 | |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
22 | def do_set_property(self, pspec, value): |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
23 | if pspec.name == 'string': |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
24 | self.string = value |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
25 | self.type = gobject.TYPE_STRING |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
26 | elif pspec.name == 'gobject': |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
27 | self.gobject = value |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
28 | self.type = gobject.TYPE_OBJECT |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
29 | else: |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
30 | raise AttributeError, 'unknown property %s' % pspec.name |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
31 | def do_get_property(self, pspec): |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
32 | if pspec.name == 'string': |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
33 | return self.string |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
34 | elif pspec.name == 'gobject': |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
35 | return self.gobject |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
36 | elif pspec.name == 'mytype': |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
37 | return self.type |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
38 | else: |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
39 | raise AttributeError, 'unknown property %s' % pspec.name |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
40 | gobject.type_register(MyObject) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
41 | |
|
18826
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
42 | def button_activate(button, tree): |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
43 | list = tree.get_selection_text_list() |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
44 | ent = tree.get_selection_data() |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
45 | if ent.type == gobject.TYPE_STRING: |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
46 | str = "" |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
47 | for i in list: |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
48 | str = str + i |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
49 | entry.set_text("clicked!!!" + str) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
50 | elif ent.type == gobject.TYPE_OBJECT: |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
51 | ent.gobject.set_text("mwhahaha!!!") |
|
15992
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
52 | |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
53 | gnt.gnt_init() |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
54 | |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
55 | win = gnt.Window() |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
56 | |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
57 | entry = gnt.Entry("") |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
58 | obj = MyObject() |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
59 | obj.set_property('gobject', entry) |
|
15992
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
60 | |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
61 | win.add_widget(entry) |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
62 | win.set_title("Entry") |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
63 | |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
64 | button = gnt.Button("Click!") |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
65 | win.add_widget(button) |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
66 | |
|
18826
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
67 | tree = gnt.Tree() |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
68 | tree.set_property("columns", 1) |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
69 | win.add_widget(tree) |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
70 | |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
71 | # so random non-string values can be used as the key for a row in a GntTree! |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
72 | last = None |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
73 | for i in range(1, 100): |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
74 | key = MyObject('string', str(i)) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
75 | tree.add_row_after(key, [str(i)], None, last) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
76 | last = key |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
77 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
78 | tree.add_row_after(MyObject('gobject', entry), ["asd"], None, None) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
79 | tree.add_row_after(MyObject('string', "b"), ["123"], MyObject('gobject', entry), None) |
|
18826
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
80 | |
|
a276583c694c
Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15992
diff
changeset
|
81 | button.connect("activate", button_activate, tree) |
|
15992
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
82 | |
|
19173
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
83 | tv = gnt.TextView() |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
84 | |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
85 | win.add_widget(tv) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
86 | tv.append_text_with_flags("What up!!", gnt.TEXT_FLAG_BOLD) |
|
467db4a9cc44
Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18826
diff
changeset
|
87 | |
|
15992
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
88 | win.show() |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
89 | |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
90 | gnt.gnt_main() |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
91 | |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
92 | gnt.gnt_quit() |
|
76e7972b3ff9
python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
93 |