If picture does no exist, warn and exit
[cascardo/movie.git] / gzv.py
diff --git a/gzv.py b/gzv.py
index c10f86a..ac4dce3 100644 (file)
--- a/gzv.py
+++ b/gzv.py
@@ -1,5 +1,5 @@
 # -*- coding: utf-8; -*-
-# gzv.py - an user interface to generate-zooming-video
+# gzv.py - an user interface to select people in a picture
 #
 # Copyright (C) 2008  Lincoln de Sousa <lincoln@minaslivre.org>
 #
@@ -318,10 +318,8 @@ class Gzv(GladeLoader):
             # point begining from the left image border
             wib = self.point_with_border(ball)
 
-            print wib.x, w
-
-            self.wid('viewport').get_vadjustment().value = wib.x # + (w / 2)
-            self.wid('viewport').get_hadjustment().value = wib.y # + (h / 2)
+            #self.wid('viewport').get_vadjustment().value = wib.x # + (w / 2)
+            #self.wid('viewport').get_hadjustment().value = wib.y # + (h / 2)
 
             self.draw.queue_draw()
 
@@ -357,6 +355,40 @@ class Gzv(GladeLoader):
 
         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))
+
     def expose_draw(self, draw, event):
         if not self.image:
             return