tasks are selectable
This commit is contained in:
parent
19f3e8ec1b
commit
dc0acdae22
22
Window.py
22
Window.py
@ -107,7 +107,7 @@ class Window:
|
|||||||
|
|
||||||
self.tasks = self.ds.getTasks(self.currProject)
|
self.tasks = self.ds.getTasks(self.currProject)
|
||||||
self.task_hour_labels = {}
|
self.task_hour_labels = {}
|
||||||
self.task_labels_to_pnum = {}
|
self.task_labels_to_tnum = {}
|
||||||
|
|
||||||
# Header row
|
# Header row
|
||||||
col_headers = ('Project',
|
col_headers = ('Project',
|
||||||
@ -184,14 +184,23 @@ class Window:
|
|||||||
l.set_alignment(0.0, 0.0)
|
l.set_alignment(0.0, 0.0)
|
||||||
e = gtk.EventBox()
|
e = gtk.EventBox()
|
||||||
e.add(l)
|
e.add(l)
|
||||||
|
self.task_labels_to_tnum[l] = tnum
|
||||||
|
if tnum == self.currTask:
|
||||||
|
e.set_state(gtk.STATE_SELECTED)
|
||||||
e.add_events(gtk.gdk.BUTTON_PRESS_MASK)
|
e.add_events(gtk.gdk.BUTTON_PRESS_MASK)
|
||||||
e.connect("button-press-event", self.task_click_event)
|
e.connect("button-press-event", self.task_click_event)
|
||||||
self.projects_table.attach(e, 0, 1, row, row + 1)
|
self.projects_table.attach(e, 0, 1, row, row + 1)
|
||||||
self.task_hour_labels[tnum] = {}
|
self.task_hour_labels[tnum] = {}
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
|
e = gtk.EventBox()
|
||||||
l = gtk.Label()
|
l = gtk.Label()
|
||||||
self.projects_table.attach(l, i + 1, i + 2, row, row + 1)
|
e.add(l)
|
||||||
|
if tnum == self.currTask:
|
||||||
|
e.set_state(gtk.STATE_SELECTED)
|
||||||
|
self.projects_table.attach(e, i + 1, i + 2, row, row + 1)
|
||||||
self.task_hour_labels[tnum][i] = l
|
self.task_hour_labels[tnum][i] = l
|
||||||
|
e.connect("button-press-event", self.task_click_event)
|
||||||
|
self.task_labels_to_tnum[l] = tnum
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
# Totals row
|
# Totals row
|
||||||
@ -326,6 +335,7 @@ class Window:
|
|||||||
def project_select_event(self, pnum):
|
def project_select_event(self, pnum):
|
||||||
if pnum:
|
if pnum:
|
||||||
self.currProject = pnum
|
self.currProject = pnum
|
||||||
|
self.currTask = 0
|
||||||
self.updateProjects()
|
self.updateProjects()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -340,7 +350,7 @@ class Window:
|
|||||||
tnum = 0
|
tnum = 0
|
||||||
if tnum:
|
if tnum:
|
||||||
self.tasks = self.ds.getTasks(self.currProject)
|
self.tasks = self.ds.getTasks(self.currProject)
|
||||||
self.task_select_event(tname)
|
self.task_select_event(tnum)
|
||||||
self.updateProjects()
|
self.updateProjects()
|
||||||
|
|
||||||
def task_key_press_event(self, widget, event, data=None):
|
def task_key_press_event(self, widget, event, data=None):
|
||||||
@ -353,14 +363,14 @@ class Window:
|
|||||||
lbl = ebox.get_child()
|
lbl = ebox.get_child()
|
||||||
if lbl:
|
if lbl:
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
return self.task_select_event(lbl.get_text())
|
if lbl in self.task_labels_to_tnum:
|
||||||
|
return self.task_select_event(self.task_labels_to_tnum[lbl])
|
||||||
elif event.button == 3:
|
elif event.button == 3:
|
||||||
# TODO: handle right-click
|
# TODO: handle right-click
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def task_select_event(self, taskName):
|
def task_select_event(self, tnum):
|
||||||
tnum = self.getTaskNum(taskName)
|
|
||||||
if tnum:
|
if tnum:
|
||||||
self.updateCurrTaskHours()
|
self.updateCurrTaskHours()
|
||||||
self.currTask = tnum
|
self.currTask = tnum
|
||||||
|
Loading…
x
Reference in New Issue
Block a user