-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZimTaskSquasher.py
166 lines (127 loc) · 5.42 KB
/
ZimTaskSquasher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python
import sys
try:
import pygtk
pygtk.require("2.0")
except:
pass
try:
import gtk
import gtk.glade
import pango
except:
sys.exit(1)
import SquasherConfig
import SquasherTasks
class ZimTaskSquasherWindow:
## Member variables ##
tasksIn = []
tasksDo = []
tasksOut = []
settings = SquasherConfig.defaultSettings
## Member functions ##
def save_task_list(self, filename):
pass
## Ui handling helpers ##
def update_lists(self):
tasklists = [(self.tasksIn,self.inModel),
(self.tasksDo,self.doModel),
(self.tasksOut,self.outModel)]
dummyid = 0
for tlist, tmodel in tasklists:
tmodel.clear()
for task in tlist:
dummyid+=1
# generate effort
effortfield = ""
effortfield+=str(task.effortReal) if task.effortReal else "?"
effortfield+="/"
effortfield+=str(task.effortEstimate) if task.effortEstimate else "?"
# add data
tmodel.append([
dummyid,
"%s %s" % (task.verb, task.task),
task.priority,
effortfield ])
print "add data"
print tmodel
## Signal callback functions. ##
def on_mcRevert_activate(self, widget, data=None):
# Load data
self.tasksIn, self.tasksDo, self.tasksOut = \
self.load_task_list(self.settings["task_source_file"] )
self.update_lists()
def on_mcRefresh_activate(self, widget, data=None):
pass
def on_mcCommit_activate(self, widget, data=None):
pass
def on_toolbuttonAdd_clicked(self, widget, data=None):
pass
def on_toolbuttonReject_clicked(self, widget, data=None):
pass
def on_toolbuttonNext_clicked(self, widget, data=None):
pass
def on_toolbuttonLater_clicked(self, widget, data=None):
pass
def on_toolbuttonDo_clicked(self, widget, data=None):
pass
def on_toolbuttonPause_clicked(self, widget, data=None):
pass
def on_toolbuttonDone_clicked(self, widget, data=None):
pass
def on_toolbuttonRedo_clicked(self, widget, data=None):
pass
def on_toolbuttonHistory_clicked(self, widget, data=None):
pass
#PANGO_WRAP_WORD_CHAR
def on_DescriptionColWidth_changed(self, column, width):
# Fist children should be painter
widthvalue = column.props.width
renderer = column.get_cell_renderers()[0]
renderer.set_property('wrap-width', widthvalue )
renderer.set_property('wrap-mode', pango.WRAP_WORD_CHAR )
def delete_event(self, widget, event, data=None):
# Change FALSE to TRUE and the main window will not be destroyed
# with a "delete_event".
return False
def destroy(self, widget, data=None):
gtk.main_quit()
def __init__(self):
#Set the Glade file
self.gladefile = "taskSquashWindow.glade"
self.wTree = gtk.Builder()
self.wTree.add_from_file(self.gladefile)
self.window = self.wTree.get_object ("windowMain")
if (self.window):
dic = { "on_mcRevert_activate" : self.on_mcRevert_activate,
"on_mcRefresh_activate" : self.on_mcRefresh_activate,
"on_mcCommit_activate" : self.on_mcCommit_activate,
"on_toolbuttonAdd_clicked" : self.on_toolbuttonAdd_clicked,
"on_toolbuttonReject_clicked" : self.on_toolbuttonReject_clicked,
"on_toolbuttonNext_clicked" : self.on_toolbuttonNext_clicked,
"on_toolbuttonLater_clicked" : self.on_toolbuttonLater_clicked,
"on_toolbuttonDo_clicked" : self.on_toolbuttonDo_clicked,
"on_toolbuttonPause_clicked" : self.on_toolbuttonPause_clicked,
"on_toolbuttonDone_clicked" : self.on_toolbuttonDone_clicked,
"on_toolbuttonRedo_clicked" : self.on_toolbuttonRedo_clicked,
"on_toolbuttonHistory_clicked" : self.on_toolbuttonHistory_clicked,
"on_windowMain_destroy" : self.destroy}
self.wTree.connect_signals(dic)
self.inModel = self.wTree.get_object('liststoreIn')
self.doModel = self.wTree.get_object('liststoreDo')
self.outModel = self.wTree.get_object('liststoreOut')
defaultColumns = ['columnDescription1','columnDescription2','columnDescription3']
for colname in defaultColumns:
columnObject = self.wTree.get_object(colname)
columnObject.connect("notify::width", self.on_DescriptionColWidth_changed)
#gtk.TreeView.get_column()
self.tasksIn, self.tasksDo, self.tasksOut = \
self.load_task_list(self.settings["task_source_file"] )
self.update_lists()
# and the window
self.window.show()
def main(self):
gtk.main()
if __name__ == "__main__":
app = ZimTaskSquasherWindow()
app.main()