+ def remove_fp(self, *args):
+ selection = self.treeview.get_selection()
+ model, path = selection.get_selected()
+ if path:
+ position = model[path][0]
+ for i in self.balls:
+ if i.position == int(position):
+ self.balls.remove(i)
+ del model[path]
+ self.draw.queue_draw()
+
+ def select_fp(self, treeview, event):
+ path, column, x, y = \
+ self.treeview.get_path_at_pos(int(event.x), int(event.y))
+ if path:
+ model = self.treeview.get_model()
+ ball = self.balls[model[path][0]]
+
+ # making sure that only one ball is selected
+ for i in self.balls:
+ i.selected = False
+ ball.selected = True
+
+ # available space to the image
+ w = self.evtbox.get_allocation().width
+ h = self.evtbox.get_allocation().height
+
+ # point begining from the left image border
+ wib = self.point_with_border(ball)
+
+ #self.wid('viewport').get_vadjustment().value = wib.x # + (w / 2)
+ #self.wid('viewport').get_hadjustment().value = wib.y # + (h / 2)
+
+ self.draw.queue_draw()
+
+ def select_fp_from_image(self, ball):
+ selection = self.treeview.get_selection()
+ selection.select_path(str(ball.position))
+
+ # making sure that only one ball is selected
+ for i in self.balls:
+ i.selected = False
+ ball.selected = True
+
+ self.draw.queue_draw()
+
+ def save_fp_list(self, *args):
+ assert self.project is not None
+
+ # if the project has no
+ if self.project and not self.project.focus_points_file:
+ fc = gtk.FileChooserDialog(_('Save the focus points file'),
+ self.window,
+ action=gtk.FILE_CHOOSER_ACTION_SAVE,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_SAVE,
+ gtk.RESPONSE_OK))
+ if fc.run() == gtk.RESPONSE_OK:
+ self.project.focus_points_file = fc.get_filename()
+ fc.destroy()
+ else:
+ fc.destroy()
+ return
+
+ self.balls.save_to_file(self.project.focus_points_file)
+
+ def move_fp_up(self, *args):
+ selection = self.treeview.get_selection()
+ model, path = selection.get_selected()
+ if not path:
+ return
+
+ pos = model[path][0]
+ newpos = max(pos - 1, 0)
+ self.balls.insert(newpos, self.balls.pop(pos))
+
+ # normalizing the position of elements.
+ for index, item in enumerate(self.balls):
+ item.position = index
+
+ self.load_balls_to_treeview()
+ selection.select_path(str(newpos))
+
+ def move_fp_down(self, *args):
+ selection = self.treeview.get_selection()
+ model, path = selection.get_selected()
+ if not path:
+ return
+
+ pos = model[path][0]
+ newpos = min(pos + 1, len(self.balls))
+ self.balls.insert(newpos, self.balls.pop(pos))
+
+ # normalizing the position of elements.
+ for index, item in enumerate(self.balls):
+ item.position = index
+
+ self.load_balls_to_treeview()
+ selection.select_path(str(newpos))
+