pyatcron-devel-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pyatcron-devel-list] A patch to fix the task::Id problem


From: Julien Olivier
Subject: [Pyatcron-devel-list] A patch to fix the task::Id problem
Date: Thu, 15 Apr 2004 17:49:38 +0100

Hi list

The attached patch gets rid of the task's id property. As discussed, we
now use the index instead of the Id. I also implemented
activation/deactivation of tasks through the UI, and deletion of tasks.

-- 
Julien Olivier <address@hidden>
Index: pyatcron/src/lib/mainwin.py
===================================================================
RCS file: /cvsroot/pyatcron/pyatcron/src/lib/mainwin.py,v
retrieving revision 1.4
diff -u -r1.4 mainwin.py
--- pyatcron/src/lib/mainwin.py 15 Apr 2004 14:37:49 -0000      1.4
+++ pyatcron/src/lib/mainwin.py 15 Apr 2004 16:45:29 -0000
@@ -18,8 +18,8 @@
 # The main window's class.
 class MainWin:
     def __init__ (self):
-        # The Id of the task currently highlighted (if any).
-        self.taskId = None
+        # The index of the task currently highlighted (if any).
+        self.taskIndex = None
     
         # Get the list of schedulers
         self.list = ScheduleList ()
@@ -80,7 +80,7 @@
         # We build the task list.
         self.updateTaskList ()
 
-        # We get the current highlighted task's Id.
+        # We get the current highlighted task's index.
         self.updateCurrentTask ()
     
     # Gets the colors from the GTK theme
@@ -202,7 +202,7 @@
         self.save ()
         gtk.main_quit ()
     
-    # Gets the current highlighted task's Id.
+    # Gets the current highlighted task's index.
     def updateCurrentTask (self):
         taskList = self.widgetTree.get_widget ("tasklist")
         iter = taskList.get_selection ().get_selected () [1]
@@ -236,8 +236,8 @@
             self.widgetTree.get_widget ("mainmenu_deactivate").set_sensitive 
(1 - activable)
             self.widgetTree.get_widget ("mainmenu_delete").set_sensitive (1)
     
-            # Here, we get the task's Id.
-            self.taskId = model.get_value (iter, 0)
+            # Here, we get the task's index.
+            self.taskIndex = model.get_value (iter, 0)
     
             if (activable == 1):
                 # We save the task's path for next time.
@@ -253,17 +253,18 @@
     
     # Launches the properties dialog and refreshes the task list if changes 
were made.
     def editTask (self):
-        print "TODO: edit task #" + str (self.taskId)
+        print "TODO: edit task #" + str (self.taskIndex)
         self.updateTaskList ()
     
     # Makes the current task active and refreshes the task list.
     def activateTask (self):
-        print "TODO: activate task #" + str (self.taskId)
+        self.list [self.taskIndex].setActive (1)
+        self.lastPath = None
         self.updateTaskList ()
     
     # Makes the current task inactive and refreshes the task list.
     def deactivateTask (self):
-        print "TODO: deactivate task #" + str (self.taskId)
+        self.list [self.taskIndex].setActive (0)
         self.updateTaskList ()
     
     # Show a confirmation dialog before deleting the task.
@@ -286,8 +287,7 @@
     
     # Deletes the current task and refreshes the task list.
     def deleteTask (self):
-        print "TODO: delete task #" + str (self.taskId)
-        del(self.list[self.taskId])
+        del(self.list[self.taskIndex])
         self.updateTaskList ()
     
     # Launches the "about" dialog.
@@ -307,14 +307,16 @@
             model.clear ()
     
         # Add each task.
+        curIndex = 0
         for entry in self.list:
             # Determine when the task will occur next
             syntactic = SyntacticEngine(entry)
-            model.set (model.append (), 0, entry.getId (), 1,
+            model.set (model.append (), 0, curIndex, 1,
             entry.isActive () == False, 2,
             entry, 3,
             syntactic.getNextRunString(), 4,
             self.insensitiveColor)
+            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):
Index: pyatcron/src/lib/scheduler.py
===================================================================
RCS file: /cvsroot/pyatcron/pyatcron/src/lib/scheduler.py,v
retrieving revision 1.6
diff -u -r1.6 scheduler.py
--- pyatcron/src/lib/scheduler.py       14 Apr 2004 14:57:59 -0000      1.6
+++ pyatcron/src/lib/scheduler.py       15 Apr 2004 16:45:29 -0000
@@ -5,7 +5,6 @@
     def __init__(self,timerList,task):
         "Constructor of the class"
         # Initialize schedule type attributes
-        self.id = 0
         self.type = "PYATCRON"
         self.description = ""
         self.name = ""
@@ -34,18 +33,14 @@
     def __str__(self):
         return str(self.task)
 
-    def getId(self):
-        return(self.id)
-
     def setActive(self,value):
         if value == 1:
             self.active = 1
         else:
-            self.value = 0
+            self.active = 0
         return
 
     def isActive(self):
-        print "Comment     : ",self.id, " ",self
         return(self.active == 1)
 
     def getAttributes(self):
@@ -58,7 +53,6 @@
 
     # method mainly used for debugging purpose. not to be used in production
     def prettyPrint(self):
-        print "Scheduler id: ",self.id
         print "Name        : ",self.name
         print "Type        : ",self.type
         print "minute      : ",self.minute

reply via email to

[Prev in Thread] Current Thread [Next in Thread]