pitivi r1134 - in branches/SOC_2008_BLEWIS: . pitivi/ui



Author: blewis
Date: Tue Jun  3 01:47:39 2008
New Revision: 1134
URL: http://svn.gnome.org/viewvc/pitivi?rev=1134&view=rev

Log:
* pitivi/ui/test.py:
switched testing mode back to goocanvas items, rather than widgets
* pitivi/ui/timelineobjects.py:
factored out _condensedListChanged() callback into
_sourceAddedCb()
_sourceRemoved()
reordreing is temporarily broken, because swap() is overridden and
does nothing. That's okay though, because the reordering doesn't work
right now anyways (it's only been working in the UI all this time).
* pitivi/ui/util.py:
tidy() now calls _set_drag_thresholds() if the list is in drag mode
_child_drag() now calls swap() directly to change element positions


Modified:
   branches/SOC_2008_BLEWIS/ChangeLog
   branches/SOC_2008_BLEWIS/pitivi/ui/test.py
   branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py
   branches/SOC_2008_BLEWIS/pitivi/ui/util.py

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/test.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/test.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/test.py	Tue Jun  3 01:47:39 2008
@@ -68,7 +68,7 @@
 t = HList(c)
 c.get_root_item().add_child(t)
 for word in LABELS:
-    t.add(make_widget(word))
+    t.add(make_box(word))
 t.reorderable = True
 s = gtk.ScrolledWindow()
 s.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER)

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py	Tue Jun  3 01:47:39 2008
@@ -76,56 +76,57 @@
     
     def __init__(self, timeline, *args, **kwargs):
         HList.__init__(self, *args, **kwargs)
-        self.sig_id = None
+        self.sig_ids = None
         self.set_timeline(timeline)
         self.reorderable = True
         self.widgets = {}
 
     def set_timeline(self, timeline):
-        if self.sig_id:
-            self.timeline.videocomp.disconnect(self.sig_id)
+        if self.sig_ids:
+            for sig in self.sig_ids:
+                self.timeline.videocomp.disconnect(sig)
         self.timeline = timeline
         if timeline:
             self.condensed = self.timeline.videocomp.condensed
-            self.sig_id = self.timeline.videocomp.connect(
-                "condensed-list-changed", self._condensedListChangedCb)
+            changed = timeline.videocomp.connect("condensed-list-changed", 
+                self._condensedListChangedCb)
+            added = timeline.videocomp.connect("source-added",
+                self._sourceAddedCb)
+            removed = timeline.videocomp.connect("source-removed",
+                self._sourceRemovedCb)
+            self.sig_ids = (changed, added, removed)
+
+    def swap(self, a, b):
+        pass
 
     def _condensedListChangedCb(self, unused_videocomp, clist):
         """ add/remove the widgets """
         gst.debug("condensed list changed in videocomp")
-        current = self.condensed
-        self.condensed = clist
-        new = [x for x in clist if not x in current]
-        removed = [x for x in current if not x in clist]
-
-        # new elements
-        for element in new:
-            # add the widget to self.widget
-            gst.debug("Adding new element to the layout")
-            if isinstance(element, TimelineFileSource):
-                widget = SimpleSourceWidget(element)
-                widget.connect("delete-me", self._sourceDeleteMeCb, element)
-                widget.connect("edit-me", self._sourceEditMeCb, element)
-                item = goocanvas.Widget(widget=widget, 
-                    width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
-                    height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
-                background = goocanvas.Rect(fill_color="gray",
-                    stroke_color="gray",
-                    width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
-                    height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
-                item = group(background, item)
-            else:
-                gst.warning("this is not implemented")
-            self.widgets[element] = item
-            self.add_child(self.widgets[element])
-
-        # removed elements
-        for element in removed:
-            self.remove_child(self.widgets[element])
-            del self.widgets[element]
-
         order = [self.index(self.widgets[e]) for e in clist]
-        print order
+        self.reorder(order)
+
+    def _sourceAddedCb(self, timeline, element):
+        gst.debug("Adding new element to the layout")
+        if isinstance(element, TimelineFileSource):
+            widget = SimpleSourceWidget(element)
+            widget.connect("delete-me", self._sourceDeleteMeCb, element)
+            widget.connect("edit-me", self._sourceEditMeCb, element)
+            item = goocanvas.Widget(widget=widget, 
+                width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
+                height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
+            background = goocanvas.Rect(fill_color="gray",
+                stroke_color="gray",
+                width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
+                height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
+            item = group(background, item)
+        else:
+            raise Exception("Not Implemented")
+        self.widgets[element] = item
+        self.add_child(self.widgets[element])
+
+    def _sourceRemovedCb(self, timeline, element):
+        self.remove_child(self.widgets[element])
+        del self.widgets[element]
 
 ## Child callbacks
 

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/util.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/util.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/util.py	Tue Jun  3 01:47:39 2008
@@ -316,6 +316,8 @@
             cur += self.spacing + self.dimension(child)
             i += 1
         self.cur_pos = cur
+        if self.draging:
+            self._set_drag_thresholds()
     
     def item_at(self, index):
         return self.order[index]
@@ -369,39 +371,27 @@
         self.tidy()
         return True
 
-    def _swap(self, a, b):
+    def swap(self, a, b):
         a_index = a.get_data("index")
         b_index = b.get_data("index")
         self.order[a_index] = b
         self.order[b_index] = a
         a.set_data("index", b_index)
         b.set_data("index", a_index)
+        self.tidy()
+        return True
 
     def _child_drag(self, pos_):
         x, y = pos_
         x = (min(self.width - width(self.draging),  max(0, x)))
         if self.left:
             if x <= self.l_thresh:
-                self._swap(self.draging, self.left)
-                if self.right:
-                    self.left.x = (left(self.right) - 
-                        width(self.left) - self.spacing)
-                else:
-                    self.left.x = self.width - width(self.left)
-                self._set_drag_thresholds()
+               self.swap(self.draging, self.left)
         if self.right:
             if x >= self.r_thresh:
-                self._swap(self.draging, self.right)
-                if self.left:
-                    self.right.x = right(self.left) + self.spacing
-                else:
-                    self.right.x = 0
-                self._set_drag_thresholds()
+               self.swap(self.draging, self.right)
         return self.cur(x)
 
-    def swap(self, a, b):
-        self._swap(a, b)
-
     def remove_child(self, child):
         SmartGroup.remove_child(self, child)
         self.order.remove(child)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]