Ticket #177: add_scheduler_drag_select.patch

File add_scheduler_drag_select.patch, 2.1 KB (added by ben@…, 16 years ago)
  • plugin.py

    diff --git a/plugin.py b/plugin.py
    index 9ac8667..07884f2 100644
    a b class scheduler_select(gtk.DrawingArea): 
    293293        self.start_point = self.get_point(event) 
    294294        self.button_state_temp = copy.deepcopy(self.button_state) 
    295295 
     296        self.new_state = self.button_state[self.start_point[0]][self.start_point[1]] 
     297 
     298        if event.button == 1: 
     299            self.new_state += 1 
     300            if self.new_state > 2: 
     301                self.new_state = 0 
     302 
     303        elif event.button == 3: 
     304            self.new_state -= 1 
     305            if self.new_state < 0: 
     306                self.new_state = 2 
     307 
     308        self.button_state[self.start_point[0]][self.start_point[1]] = self.new_state 
     309 
     310        self.queue_draw() 
     311 
    296312    #if the same box -> change it 
    297313    def mouse_up(self, widget, event): 
    298314        self.mouse_press = False 
    299         end_point = self.get_point(event) 
    300  
    301         #change color on mouseclick depending on the button 
    302         if end_point[0] is self.start_point[0] and end_point[1] is self.start_point[1]: 
    303             if event.button == 1: 
    304                 self.button_state[end_point[0]][end_point[1]] += 1 
    305                 if self.button_state[end_point[0]][end_point[1]] > 2: 
    306                     self.button_state[end_point[0]][end_point[1]] = 0 
    307             elif event.button == 3: 
    308                 self.button_state[end_point[0]][end_point[1]] -= 1 
    309                 if self.button_state[end_point[0]][end_point[1]] < 0: 
    310                     self.button_state[end_point[0]][end_point[1]] = 2 
    311             self.queue_draw() 
     315 
     316        self.queue_draw() 
    312317         
    313318    #if box changed and mouse is pressed draw all boxes from start point to end point 
    314319    #set hover text etc.. 
    class scheduler_select(gtk.DrawingArea): 
    325330 
    326331                for x in xrange(min(points[0]), max(points[0])+1): 
    327332                    for y in xrange(min(points[1]), max(points[1])+1): 
    328                         self.button_state[x][y] = self.button_state[self.start_point[0]][self.start_point[1]] 
     333                        self.button_state[x][y] = self.new_state 
    329334 
    330335                self.queue_draw() 
    331336