Index: src/glade/taskproperties.glade =================================================================== RCS file: /cvsroot/pyatcron/pyatcron/src/glade/taskproperties.glade,v retrieving revision 1.1 diff -u -r1.1 taskproperties.glade --- src/glade/taskproperties.glade 14 Apr 2004 14:57:59 -0000 1.1 +++ src/glade/taskproperties.glade 16 Apr 2004 15:04:51 -0000 @@ -4,14 +4,13 @@ - 500 - 400 - True Edit task properties GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER_ON_PARENT True - True + 200 + 150 + False False True False @@ -34,30 +33,16 @@ GTK_BUTTONBOX_END - + True True True - gtk-cancel + gtk-close True GTK_RELIEF_NORMAL True - -6 - - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - + -7 + @@ -84,61 +69,7 @@ - - True - Task - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - Insert needed buttons to define schedule - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - False - True - - - - - - True - Schedule - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - + Index: src/lib/gui.py =================================================================== RCS file: /cvsroot/pyatcron/pyatcron/src/lib/gui.py,v retrieving revision 1.2 diff -u -r1.2 gui.py --- src/lib/gui.py 15 Apr 2004 15:57:11 -0000 1.2 +++ src/lib/gui.py 16 Apr 2004 15:04:51 -0000 @@ -6,6 +6,8 @@ class SchedulerEditor: def __init__(self, scheduler): + self.scheduler = scheduler + self.wtree = gtk.glade.XML(GLADE_FILE_PATH + '/taskproperties.glade') # You need to create this dictionary in order to get the # bound methods that you can autoconnect with. @@ -26,10 +28,16 @@ gtk.Label("Schedule"),1) # set the Task editor page active notebook.set_current_page(0) - + # Connect to the 'changed' signal of the Task scheduler.task.connect('changed',self.on_task_changed) + # Display window + # self.wtree.get_widget('taskProperties').show_all() + + def show(self): + self.wtree.get_widget("taskProperties").show_all() + def on_task_changed(self,obj): print "Signal 'changed' from Task object received" @@ -39,8 +47,6 @@ def on_taskProperties_destroy_event(self, obj, event): print "Destroy event traped" - def on_cancelButton_clicked(self,*args): - print "Cancel clicked", args - - def on_okButton_clicked(self,*args): + def on_closeButton_clicked(self,*args): print "OK", args + self.wtree.get_widget('taskProperties').hide() Index: src/lib/mainwin.py =================================================================== RCS file: /cvsroot/pyatcron/pyatcron/src/lib/mainwin.py,v retrieving revision 1.5 diff -u -r1.5 mainwin.py --- src/lib/mainwin.py 16 Apr 2004 09:13:58 -0000 1.5 +++ src/lib/mainwin.py 16 Apr 2004 15:04:51 -0000 @@ -6,6 +6,7 @@ from lib.schedulelist import ScheduleList from syntacticengine import SyntacticEngine +from lib.gui import SchedulerEditor # import glade path from config module from config import GLADE_FILE_PATH @@ -250,11 +251,18 @@ def createTask (self): assistantObject = NewTask (self) self.updateTaskList () - + + + def on_editor_changed(self, *args): + print "Updating list" + self.updateTaskList() # Launches the properties dialog and refreshes the task list if changes were made. def editTask (self): - print "TODO: edit task #" + str (self.taskIndex) - self.updateTaskList () + print "edit task #" + str (self.taskIndex) + self.editor = SchedulerEditor(self.list[self.taskIndex]) + self.editor.show() + self.list[self.taskIndex].task.connect('changed', self.on_editor_changed) + #self.updateTaskList () # Makes the current task active and refreshes the task list. def activateTask (self): Index: src/lib/task.py =================================================================== RCS file: /cvsroot/pyatcron/pyatcron/src/lib/task.py,v retrieving revision 1.4 diff -u -r1.4 task.py --- src/lib/task.py 15 Apr 2004 15:57:11 -0000 1.4 +++ src/lib/task.py 16 Apr 2004 15:04:51 -0000 @@ -7,64 +7,88 @@ 'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()) } - + + # Constructor of the class. Calls the self.buildWidget method to + # initialize internal widget object def __init__(self): gobject.GObject.__init__(self) - self.command = "/bin/false" - self.arguments = [] - self.widget = None + self.widget = self.getWidget() return - def on_changed(self,obj): - self.emit('changed') - + # Well, see Python documentation to learn more about this method ;-) def __str__(self): return "Generic task" + + # Returns a command line ready to be executed by a shell + # WARNING: Role of this method has to be defined. Not clear at the + # moment def getCmdLine(self): if len(self.arguments) > 0: return self.command+" "+string.join(self.arguments," ") else: return self.command + # Returns the internal widget object def getEditorWidget(self): - self.widget = gtk.Label("GenericTask widget - not implemented") - self.widget.show() return self.widget + # This method should be called whenever the Task widget + # elements are changed. + def on_changed(self,obj): + self.changedSignalPreProcessing() + self.emit('changed') + + ########################################################### + # # + # Class methods that has to be overwritten by child class # + # # + ########################################################### + + def getWidget(self): + return Gtk.Label("Widget not set") + + def changedSignalPreProcessing(self): + return + + +# This is to register the GenericTask class in the Glib namespace gobject.type_register(GenericTask) class CmdLineTask(GenericTask): def __init__(self,cmdLine): + self.parseCmdLine(cmdLine) GenericTask.__init__(self) - self.command = cmdLine return def __str__(self): return "Command line task: " + self.command - - def on_cmdEntry_changed(self,*args): - print "CHANGED" - - def getEditorWidget(self): - table = gtk.Table(rows=2, columns=2, homogeneous=False,) + def parseCmdLine(self,cmdLine): + self.command = string.split(cmdLine,' ')[0] + self.arguments = string.split(cmdLine,' ')[1:] + + def getWidget(self): + self.cmdEntry = gtk.Entry(max = 0) + self.cmdEntry.set_text(self.command) + self.cmdEntry.connect('changed',self.on_changed) + + self.optionsEntry = gtk.Entry(max = 0) + self.optionsEntry.set_text(string.join(self.arguments)) + self.optionsEntry.connect('changed',self.on_changed) - + table = gtk.Table(2,2) table.attach(gtk.Label("Command to run:"),0,1,0,1, xpadding = 10,ypadding=10) table.attach(gtk.Label("Command options:"),0,1,1,2, xpadding = 10,ypadding=10) + table.attach(self.cmdEntry,1,2,0,1) + table.attach(self.optionsEntry,1,2,1,2) - cmdEntry = gtk.Entry(max = 0) - cmdEntry.connect('changed',self.on_changed) - optionsEntry = gtk.Entry(max = 0) - - table.attach(cmdEntry,1,2,0,1) - table.attach(optionsEntry,1,2,1,2) + return table - table.show_all() - - self.widget = table - return self.widget + def changedSignalPreProcessing(self): + self.parseCmdLine(self.cmdEntry.get_text()+" "+ + self.optionsEntry.get_text()) + print self.getCmdLine()