Beispiel #1
0
 def update_treeview_text(self, cell, path, new_text, model, column):
     """
     Called when a text cell is edited. It puts the new text
     in the model so that it is displayed properly.
     """
     model[path][column] = new_text
     nuclasses.taskFromUid(model[path][COLUMN_TASKS_UID]).description = new_text
Beispiel #2
0
 def update_statusbar(self, buffer):
     # clear any previous message, underflow is allowed
     self.statusbar.pop(0)
     # count = buffer.get_char_count()
     (model, iter) = buffer.get_selected()
     
     #iter = buffer.get_iter_at_mark(buffer.get_insert())
     # row = iter.get_line()
     # col = iter.get_line_offset()
     
     if iter != None:
         nameData = model.get(iter, COLUMN_TASKS_NAME)[0]
         dateData = model.get(iter, COLUMN_TASKS_DUE)[0]
         timeNow = datetime.datetime.now()
         timeOfTask = nuclasses.taskFromUid(model.get(iter, COLUMN_TASKS_UID)[0]).dueTime
         if timeOfTask == None:
             messageString = "There is no due date set for '%s'" % (nameData)
         else:
             delta = timeOfTask - timeNow
             deltaHours = nuclasses.secondsToHours(delta.seconds, 1)
             if delta.days < 0: #Task due in the past
                 if delta.days <= -2: #If it was due at least one day ago, we put days and hours
                     deltaDays = -(delta.days) - 1 #Negative day format is given as -Xdays, +Yseconds
                     deltaHours = nuclasses.secondsToHours(24*3600 - delta.seconds, 1) #function(seconds, roundDown?)
                     messageString = "%s was due % days and % hours ago. Yikes!" % (nameData, deltaDays, deltaHours)
                 elif delta.days > -2: #Otherwise, we only put hours
                     messageString = "%s was due % hours ago. Yikes!" % (nameData, deltaHours)
                     if deltaHours < 4:
                         if deltaHours < 1:
                             (deltaHours, deltaMinutes) = nuclasses.secondsToHoursMinutes(24*3600 - delta.seconds, 1) # function(seconds, round down?)
                             messageString = "%s was due % minutes ago. Yikes!" % (nameData, deltaMinutes)
                         else:
                             (deltaHours, deltaMinutes) = nuclasses.secondsToHoursMinutes(24*3600 - delta.seconds, 1) # function(seconds, round down?)
                             messageString = "%s was due % hours and % minutes ago. Yikes!" % (nameData, deltaHours, deltaMinutes)
                     
             elif delta.days >= 0: #Task due in the future
                 if delta.days >= 1: #If it will be due >1 day, put days + hours
                     deltaDays = delta.days
                     deltaHours = nuclasses.secondsToHours(delta.seconds, 1) #function(seconds, roundDown?)
                     messageString = "%s is due %s hours. This is %s days and %s hours from now" % (nameData, dateData, deltaDays, deltaHours)
                 elif delta.days < 1: #Otherwise, we only put hours
                     if deltaHours < 4:
                         if deltaHours < 1:
                             (deltaHours, deltaMinutes) = nuclasses.secondsToHoursMinutes(delta.seconds, 1) # function(seconds, round down?)
                             messageString = '%s is due in %s minutes!' % (nameData, deltaMinutes)                        
                         else:
                             (deltaHours, deltaMinutes) = nuclasses.secondsToHoursMinutes(delta.seconds, 1) # function(seconds, round down?)
                             messageString = '%s is due %s hours. This is %s hours and %s minutes from now' % (nameData, dateData, deltaHours, deltaMinutes)
                     else:
                         messageString = '%s is due %s hours. This is %s hours from now' % (nameData, dateData, deltaHours)
         self.statusbar.push(0, messageString)        
         hoursFromNow = "<Sorry - Incomplete>"
         #self.statusbar.push(0,
     #'%s is due %s hours. This is %s hours from now' % (nameData, dateData, hoursFromNow))
     else:
         self.statusbar.push(0,
     'No Task Selected')
Beispiel #3
0
 def activate_remove(self, action):
     page = self.theNotebook.get_current_page()
     if page == NOTEBOOK_BOTH:
         (store, iter) = self.treeview_both.get_selection().get_selected()
         uid = store.get(iter, COLUMN_BOTH_UID)
         column_name = COLUMN_BOTH_NAME
         type = store.get(iter, COLUMN_BOTH_TYPE)[0]
         if type == "Task": #Yes, it's only capitalized in this instance
             type = "task"
             item = nuclasses.taskFromUid(uid[0])
         elif type == "Event":
             type = "event"
             item = nuclasses.eventFromUid(uid[0])
         else:
             nuclasses.log_error("Error: Could not determine type. Item '%s' did not match either Task or Event." % type)
     elif page == NOTEBOOK_TASKS:
         (store, iter) = self.treeview.get_selection().get_selected()
         uid = store.get(iter, COLUMN_TASKS_UID)
         column_name = COLUMN_TASKS_NAME
         item = nuclasses.taskFromUid(uid[0])
     elif page == NOTEBOOK_EVENTS:
         pass
     else:
         nuclasses.log_error("No page selected? Error with determining the active notebook page")
     dialog = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
         gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, 
         'Do you really want to remove the %s: "%s"' % (item.__name__, store.get(iter, column_name)[0]))
     def do_response(d, r):
         d.destroy()
         if r == -9:
             pass
         elif r == -8:
             try:
                 nuclasses.tasks.remove(item)
             except:
                 nuclasses.events.remove(item)
             self.treeview_both.set_model(self.__create_model_both(nuclasses.tasks, nuclasses.events))
             self.treeview.set_model(self.__create_model_tasks(nuclasses.tasks))
     dialog.connect("response", do_response)
     dialog.show()