making the move arrows work
authorLincoln de Sousa <lincoln@minaslivre.org>
Wed, 13 Aug 2008 04:20:34 +0000 (01:20 -0300)
committerLincoln de Sousa <lincoln@minaslivre.org>
Wed, 13 Aug 2008 04:20:34 +0000 (01:20 -0300)
gzv.glade
gzv.py

index 0647068..71bb68f 100644 (file)
--- a/gzv.glade
+++ b/gzv.glade
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Wed Aug 13 00:43:44 2008 -->
+<!--Generated with glade3 3.4.5 on Wed Aug 13 00:51:49 2008 -->
 <glade-interface>
   <widget class="GtkWindow" id="main-window">
     <property name="title" translatable="yes">Gzv</property>
                         <property name="receives_default">True</property>
                         <property name="tooltip" translatable="yes">Move the selected focus point up</property>
                         <property name="response_id">0</property>
+                        <signal name="clicked" handler="move_fp_up"/>
                         <child>
                           <widget class="GtkImage" id="image4">
                             <property name="visible">True</property>
                         <property name="receives_default">True</property>
                         <property name="tooltip" translatable="yes">Move the selected focus point down</property>
                         <property name="response_id">0</property>
+                        <signal name="clicked" handler="move_fp_down"/>
                         <child>
                           <widget class="GtkImage" id="image5">
                             <property name="visible">True</property>
diff --git a/gzv.py b/gzv.py
index c10f86a..f190f86 100644 (file)
--- a/gzv.py
+++ b/gzv.py
@@ -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