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



Author: blewis
Date: Mon Jun  2 05:02:18 2008
New Revision: 1131
URL: http://svn.gnome.org/viewvc/pitivi?rev=1131&view=rev

Log:
* pitivi/ui/timelineobjects.py:
External drag and drop to add files to the canvas now works minimally.
Internal drag-and-drop does not seem to work for widgets--the signals
for pointer events are not getting called. Deletion works okay. Trying
to edit an item hangs the python interpreter. I might have to rewrite
the timeline widgets after all.
SimpleSourceWidgets are no longer drag sources, since this is
unecessary with goocanvas.
* pitivi/ui/util.py:
Fixed a few errors in util.py that turned up once the drag-and-drop
code was operational.


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

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	Mon Jun  2 05:02:18 2008
@@ -95,11 +95,13 @@
         self.items.connect("notify::height", self._request_size)
 
         self.scale = 1.0
+        self.set_size_request(int(MINIMUM_WIDTH), int(MINIMUM_HEIGHT))
 
         # timeline and top level compositions
         self.timeline = instance.PiTiVi.current.timeline
         self.condensed = self.timeline.videocomp.condensed
 
+
         # widgets correspondance dictionnary
         # MAPPING timelineobject => widget
         self.widgets = {}
@@ -115,6 +117,8 @@
         # changing project.
 
         self.project_signals = SignalGroup()
+        self._connectToTimeline(self.timeline)
+
         # FIXME: do we need this? or will the newproject sginal implicitly
         # handle this???
         self._connectToTimeline(instance.PiTiVi.current.timeline)
@@ -126,21 +130,13 @@
         instance.PiTiVi.connect("new-project-failed",
             self._newProjectFailedCb)
 
-#        # size
-#        self.width = int(DEFAULT_WIDTH)
-#        self.height = int(DEFAULT_HEIGHT)
-#        self.realWidth = 0 # displayed width of the layout
-#        self.childheight = int(DEFAULT_SIMPLE_ELEMENT_HEIGHT)
-#        self.childwidth = int(DEFAULT_SIMPLE_ELEMENT_WIDTH)
-        self.set_size_request(int(MINIMUM_WIDTH), int(MINIMUM_HEIGHT))
         # drag and drop
-        self.drag_dest_set(gtk.DEST_DEFAULT_DROP | 
-            gtk.DEST_DEFAULT_MOTION, [dnd.FILESOURCE_TUPLE],
+        self.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, 
+            [dnd.FILESOURCE_TUPLE],
             gtk.gdk.ACTION_COPY)
         self.connect("drag-data-received", self._dragDataReceivedCb)
         self.connect("drag-leave", self._dragLeaveCb)
         self.connect("drag-motion", self._dragMotionCb)
-        self.draggedelement = None
 
     def _request_size(self, item, prop):
         self.set_size_request(int(self.items.width), int(
@@ -157,14 +153,14 @@
             self.set_scale(self.scale)
         return True
 
-    ## Project callbacks
+## Project callbacks
 
     def _connectToTimeline(self, timeline):
         self.timeline = timeline
         self.condensed = self.timeline.videocomp.condensed
-        #self.project_signals.connect(self.timeline.videocomp,
-        #                             "condensed-list-changed",
-        #                             None, self._condensedListChangedCb)
+        self.project_signals.connect(self.timeline.videocomp, 
+            "condensed-list-changed", 
+            None, self._condensedListChangedCb)
 
     def _newProjectLoadingCb(self, unused_inst, unused_project):
         gst.log("...")
@@ -195,7 +191,6 @@
     def _condensedListChangedCb(self, unused_videocomp, clist):
         """ add/remove the widgets """
         gst.debug("condensed list changed in videocomp")
-
         current = self.condensed
         self.condensed = clist
 
@@ -210,14 +205,17 @@
                 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)
             else:
-                widget = SimpleTransitionWidget(element)
-            self.widgets[element] = goocanvas.Widget(widget=widget)
+                gst.warning("this is not implemented")
+            self.widgets[element] = item
             self.items.add_child(self.widgets[element])
 
         # removed elements
         for element in removed:
-            self.items.remove(self.widgets[element])
+            self.items.remove_child(self.widgets[element])
             del self.widgets[element]
 
     def _gotFileFactory(self, filefactory, x, y):
@@ -225,46 +223,37 @@
         # remove the slot
         if not filefactory or not filefactory.is_video:
             return
-        pos_ = self.items.point_to_index(pixel_coords(self, (x, y)))
+        #pos_ = self.items.point_to_index(pixel_coords(self, (x, y)))
+        pos_ = 0
         gst.debug("_got_filefactory pos : %d" % pos_)
-
         # we just add it here, the drawing will be done in the condensed_list
         # callback
-#        source = TimelineFileSource(factory=filefactory,
-#                                    media_type=MEDIA_TYPE_VIDEO,
-#                                    name=filefactory.name)
-#
-#        # ONLY FOR SIMPLE TIMELINE : if video-only, we link a blank audio object
-#        if not filefactory.is_audio:
-#            audiobrother = TimelineBlankSource(factory=filefactory,
-#                                               media_type=MEDIA_TYPE_AUDIO,
-#                                               name=filefactory.name)
-#            source.setBrother(audiobrother)
-#
-#        if pos == -1:
-#            self.timeline.videocomp.appendSource(source)
-#        elif pos:
-#            self.timeline.videocomp.insertSourceAfter(source, self.condensed[pos - 1])
-#        else:
-#            self.timeline.videocomp.prependSource(source)
-#
-#    def _moveElement(self, element, x):
-#        gst.debug("TimelineSource, move %s to x:%d" % (element, x))
-#        # remove the slot
-#        self._eraseDragSlot()
-#        self.slotposition = -1
-#        pos = self._getNearestSourceSlot(x)
-#
-#        self.timeline.videocomp.moveSource(element, pos)
+        source = TimelineFileSource(factory=filefactory,
+                                    media_type=MEDIA_TYPE_VIDEO,
+                                    name=filefactory.name)
+
+        # ONLY FOR SIMPLE TIMELINE : if video-only, we link a blank audio object
+        if not filefactory.is_audio:
+            audiobrother = TimelineBlankSource(factory=filefactory,
+                                               media_type=MEDIA_TYPE_AUDIO,
+                                               name=filefactory.name)
+            source.setBrother(audiobrother)
+
+        if pos_ == -1:
+            self.timeline.videocomp.appendSource(source)
+        elif pos_:
+            self.timeline.videocomp.insertSourceAfter(source,
+                self.condensed[pos_ - 1])
+        else:
+            self.timeline.videocomp.prependSource(source)
 
-#    ## Drag and Drop callbacks
+## Drag and Drop callbacks
 
-    def _dragMotionCb(self, unused_layout, unused_context, x, y, 
-        unused_timestamp):
-        gst.log("SimpleTimeline x:%d , source would go at %d" % (x, 0))
+    def _dragMotionCb(self, unused_layout, unused_context, x, y, timestamp):
+        gst.info("SimpleTimeline x:%d , source would go at %d" % (x, 0))
 
     def _dragLeaveCb(self, unused_layout, unused_context, unused_tstamp):
-        gst.log("SimpleTimeline")
+        gst.info("SimpleTimeline")
 
     def _dragDataReceivedCb(self, unused_layout, context, x, y, 
         selection, targetType, timestamp):
@@ -273,11 +262,11 @@
         if targetType == dnd.TYPE_PITIVI_FILESOURCE:
             uri = selection.data
         else:
-            self._gotFileFactory(instance.PiTiVi.current.sources[uri], 
-                x, y)
+            context.finish(False, False, timestamp)
+        self._gotFileFactory(instance.PiTiVi.current.sources[uri], x, y)
         context.finish(True, False, timestamp)
         instance.PiTiVi.playground.switchToTimeline()
-#
+
     def _areaIntersect(self, x, y, w, h, x2, y2, w2, h2):
         """ returns True if the area intersects, else False """
         # is zone to the left of zone2
@@ -288,7 +277,8 @@
         if a or b or c or d:
             return True
         return False
-    ## Child callbacks
+
+## Child callbacks
 
     def _sourceDeleteMeCb(self, unused_widget, element):
         # remove this element from the timeline
@@ -303,7 +293,8 @@
         # switch back to timeline in playground !
         instance.PiTiVi.playground.switchToTimeline()
 
-    ## Editing mode
+## Editing mode
+
     def _switchEditingMode(self, source, mode=True):
         """ Switch editing mode for the given TimelineSource """
         gst.log("source:%s , mode:%s" % (source, mode))
@@ -615,8 +606,6 @@
             self._mediaDuration, gst.FORMAT_TIME)
 
     def _updateStartDuration(self):
-        print (time_to_string(self._mediaStart),
-            time_to_string(self._mediaDuration))
         self._updateThumbnails()
         self._updateTextFields(self._mediaStart, self._mediaDuration)
         self._adjustControls()
@@ -904,16 +893,20 @@
         self._popupMenu.append(deleteitem)
         self._popupMenu.append(edititem)
 
+        # Don't need this anymore
+
         # drag and drop
-        self.drag_source_set(gtk.gdk.BUTTON1_MASK,
-                             [dnd.URI_TUPLE, dnd.FILESOURCE_TUPLE],
-                             gtk.gdk.ACTION_COPY)
-        self.connect("drag_data_get", self._dragDataGetCb)
+        #self.drag_source_set(gtk.gdk.BUTTON1_MASK,
+        #                     [dnd.URI_TUPLE, dnd.FILESOURCE_TUPLE],
+        #                     gtk.gdk.ACTION_COPY)
+        #self.connect("drag_data_get", self._dragDataGetCb)
 
     def _createUI(self):
         # basic widget properties
         # TODO: randomly assign this color
-        #self.color = self.get_colormap().alloc_color("green")
+        #self.csdf
+        
+        lor = self.get_colormap().alloc_color("green")
         #self.modify_bg(gtk.STATE_NORMAL, self.color)
 
         # control decorations
@@ -1003,7 +996,7 @@
             vi = self.filesource.factory.video_info_stream
             height = 64 * vi.dar.denom / vi.dar.num
         smallthumb = pixbuf.scale_simple(64, height, gtk.gdk.INTERP_BILINEAR)
-        self.drag_source_set_icon_pixbuf(smallthumb)
+        #self.drag_source_set_icon_pixbuf(smallthumb)
 
     def _mediaStartDurationChangedCb(self, unused_source, start, duration):
         self._updateThumbnails()

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	Mon Jun  2 05:02:18 2008
@@ -326,8 +326,10 @@
     def point_to_index(self, point):
         x, y = point
         bounds = goocanvas.Bounds(x, y, x, y)
-        return [i for i in self.canvas.get_items_in_area(bounds, 
-            True, True, True) if i.get_data("index")]
+        items = self.canvas.get_items_in_area(bounds, True, True, True)
+        if items:
+            return [i for i in items if i.get_data("index")][0]
+        return None
 
     def _reorder(self, new_order):
         order = []
@@ -409,14 +411,14 @@
 
     def remove_all(self):
         while len(self.order):
-            self.remove_child(self.order.pop())
+            self.remove_child(self.order[0])
     
     def make_reorderable(self, child):
         make_dragable(self.canvas, child, self._child_drag,
             self._child_drag_start, self._child_drag_end)
 
     def unmake_reorderable(self, child):
-        unmake_dragble(child)
+        unmake_dragable(child)
 
     def add_child(self, child):
         SmartGroup.add_child(self, child, self.cur(self.cur_pos))



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