[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pyatcron-devel-list] A patch to make it faster to update the UI when ed
From: |
Julien Olivier |
Subject: |
[Pyatcron-devel-list] A patch to make it faster to update the UI when edit the task's properties |
Date: |
Fri, 23 Apr 2004 12:28:19 +0100 |
Hi again.
The attached patch makes it possible to only update one task in the
list, and only the name field, or only the scheduler field.
This makes editing tasks WAY faster, as it doesn't have to re-calculate
the next run times.
PS: if you wonder why I do the following:
+ if (onlyCurrentTask):
+ self.updateCurrentTask ()
It's a little hack to prevent inactive tasks to look weird when editing
them. Just comment the "self.updateCurrentTask ()" part, and try to edit
an inactive task. You'll see that the description of the task will
appear in grey instead of white. And the "self.updateCurrentTask ()" is
responsible for reverting the color to white for inactive tasks that are
highlighted.
--
Julien Olivier <address@hidden>
Index: pyatcron/src/lib/mainwin.py
===================================================================
RCS file: /cvsroot/pyatcron/pyatcron/src/lib/mainwin.py,v
retrieving revision 1.6
diff -u -r1.6 mainwin.py
--- pyatcron/src/lib/mainwin.py 20 Apr 2004 22:21:47 -0000 1.6
+++ pyatcron/src/lib/mainwin.py 23 Apr 2004 11:19:54 -0000
@@ -254,13 +254,13 @@
def on_editor_changed(self, *args):
- print "Updating list"
- self.updateTaskList()
+ print "Updating list (only the task, not the scheduler)"
+ self.updateTaskList (True, True, False)
# Launches the properties dialog and refreshes the task list if changes
were made.
def editTask (self):
print "edit task #" + str (self.taskIndex)
self.editor = SchedulerEditor(self.list[self.taskIndex])
- self.editor.show()
+ self.editor.show(self.win)
self.list[self.taskIndex].task.connect('changed',
self.on_editor_changed)
#self.updateTaskList ()
@@ -303,28 +303,45 @@
aboutObject = About (self.win)
# Builds or refreshes the task list.
- def updateTaskList (self):
+ def updateTaskList (self, onlyCurrentTask = False, updateTask = True,
updateScheduler = True):
+
taskList = self.widgetTree.get_widget ("tasklist")
-
+
# If the task list has not already been built, ceate it. Else, get its
current model, get the position of the cursor from it and clear the current
model.
if (taskList.get_model () == None):
model = gtk.ListStore (gobject.TYPE_INT, gobject.TYPE_BOOLEAN,
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
else:
model = taskList.get_model ()
cursor = taskList.get_cursor ()
- model.clear ()
-
- # Add each task.
+ if (not onlyCurrentTask):
+ model.clear ()
+
+ # Add each task, or update the current one
curIndex = 0
+ if (onlyCurrentTask):
+ self.updateCurrentTask ()
+ iter = model.get_iter_first ()
+
for entry in self.list:
- # Determine when the task will occur next
- syntactic = SyntacticEngine(entry)
- model.set (model.append (), 0, curIndex, 1,
- entry.isActive () == False, 2,
- entry, 3,
- syntactic.getNextRunString(), 4,
- self.insensitiveColor)
- curIndex = curIndex + 1
+ if (curIndex == self.taskIndex or not onlyCurrentTask):
+ if (not onlyCurrentTask):
+ iter = model.append ()
+
+ model.set (iter, 0, curIndex)
+ model.set (iter, 1, entry.isActive () == False)
+ if (updateTask):
+ model.set (iter, 2, entry)
+
+ if (updateScheduler):
+ # Determine when the task will occur next
+ syntactic = SyntacticEngine(entry)
+ model.set (iter, 3, syntactic.getNextRunString())
+
+ model.set (iter, 4, self.insensitiveColor)
+
+ if (onlyCurrentTask):
+ iter = model.iter_next (iter)
+ curIndex = curIndex + 1
# If we are building the task list, associate the model to the task
list and create the headers. Else, restore the cursor's position.
if (taskList.get_model () == None):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pyatcron-devel-list] A patch to make it faster to update the UI when edit the task's properties,
Julien Olivier <=