[pitivi] port to the new DnD TargetEntry API
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] port to the new DnD TargetEntry API
- Date: Sun, 2 Sep 2012 03:56:43 +0000 (UTC)
commit 05bb134f228ac3fc13467ef44bd44716d305c1ca
Author: Thibault Saunier <thibault saunier collabora com>
Date: Mon Jul 2 16:39:58 2012 -0400
port to the new DnD TargetEntry API
pitivi/clipproperties.py | 6 ++--
pitivi/effects.py | 8 ++--
pitivi/mainwindow.py | 6 ++--
pitivi/medialibrary.py | 6 ++--
pitivi/timeline/layer.py | 4 +-
pitivi/timeline/timeline.py | 66 +++++++++++++++++++++++-------------------
pitivi/utils/ui.py | 19 ++++++------
7 files changed, 60 insertions(+), 55 deletions(-)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index 0da2760..69d3b01 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -34,7 +34,7 @@ from pitivi.configure import get_ui_dir
from pitivi.dialogs.depsmanager import DepsManager
-from pitivi.utils.ui import EFFECT_TUPLE
+from pitivi.utils.ui import EFFECT_TARGET_ENTRY
from pitivi.utils.loggable import Loggable
from pitivi.utils.ui import PADDING, SPACING
from pitivi.utils.widgets import GstElementSettingsWidget
@@ -238,7 +238,7 @@ class EffectProperties(gtk.Expander, gtk.HBox):
namecol.add_attribute(namecell, "text", COL_NAME_TEXT)
self.treeview.drag_dest_set(gtk.DEST_DEFAULT_MOTION,
- [EFFECT_TUPLE],
+ [EFFECT_TARGET_ENTRY],
gtk.gdk.ACTION_COPY)
self.selection = self.treeview.get_selection()
@@ -386,7 +386,7 @@ class EffectProperties(gtk.Expander, gtk.HBox):
self.drag_unhighlight()
def _dragMotionCb(self, unused, context, x, y, timestamp):
- atom = gtk.gdk.atom_intern(EFFECT_TUPLE[0])
+ atom = gtk.gdk.atom_intern(EFFECT_TARGET_ENTRY.name)
if not self._factory:
self.drag_get_data(context, atom, timestamp)
self.drag_highlight()
diff --git a/pitivi/effects.py b/pitivi/effects.py
index acaefdc..5b60f7e 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -566,7 +566,7 @@ class EffectListWidget(gtk.VBox, Loggable):
if view.drag_check_threshold(self._dragX, self._dragY,
int(event.x), int(event.y)):
context = view.drag_begin(
- self._getDndTuple(),
+ self._getTargetEntries(),
gtk.gdk.ACTION_COPY,
self._dragButton,
event)
@@ -635,11 +635,11 @@ class EffectListWidget(gtk.VBox, Loggable):
def _nothingUnderMouse(self, view, event):
return not bool(view.get_path_at_pos(int(event.x), int(event.y)))
- def _getDndTuple(self):
+ def _getTargetEntries(self):
if self.effectType.get_active() == VIDEO_EFFECT:
- return [dnd.VIDEO_EFFECT_TUPLE, dnd.EFFECT_TUPLE]
+ return [dnd.VIDEO_EFFECT_TARGET_ENTRY, dnd.EFFECT_TARGET_ENTRY]
else:
- return [dnd.AUDIO_EFFECT_TUPLE, dnd.EFFECT_TUPLE]
+ return [dnd.AUDIO_EFFECT_TARGET_ENTRY, dnd.EFFECT_TARGET_ENTRY]
PROPS_TO_IGNORE = ['name', 'qos', 'silent', 'message']
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 1651cc0..e9c477f 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -46,8 +46,8 @@ from pitivi.medialibrary import MediaLibraryWidget, MediaLibraryError
from pitivi.utils.misc import show_user_manual
from pitivi.utils.ui import info_name, beautify_time_delta, SPACING,\
- FILESOURCE_TUPLE, URI_TUPLE, TYPE_URI_LIST, TYPE_PITIVI_FILESOURCE
-from pitivi.utils.timeline import Zoomable
+ FILESOURCE_TARGET_ENTRY, URI_TARGET_ENTRY, TYPE_URI_LIST, \
+ TYPE_PITIVI_FILESOURCE
from pitivi.timeline.timeline import Timeline
@@ -419,7 +419,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
# Viewer
self.viewer = PitiviViewer(instance, undock_action=self.undock_action)
self.viewer.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
- [FILESOURCE_TUPLE, URI_TUPLE],
+ [FILESOURCE_TARGET_ENTRY, URI_TARGET_ENTRY],
gtk.gdk.ACTION_COPY)
self.viewer.connect("drag_data_received", self._viewerDndDataReceivedCb)
self.mainhpaned.pack2(self.viewer, resize=False, shrink=False)
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index d7022c1..0a78ef4 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -431,7 +431,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
# Drag and Drop
self.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
- [dnd.URI_TUPLE, dnd.FILE_TUPLE],
+ [dnd.URI_TARGET_ENTRY, dnd.FILE_TARGET_ENTRY],
gtk.gdk.ACTION_COPY)
self.connect("drag_data_received", self._dndDataReceivedCb)
@@ -1139,7 +1139,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
if treeview.drag_check_threshold(self._dragX, self._dragY,
int(event.x), int(event.y)):
context = treeview.drag_begin(
- [dnd.URI_TUPLE, dnd.FILESOURCE_TUPLE],
+ [dnd.URI_TARGET_ENTRY, dnd.FILESOURCE_TARGET_ENTRY],
gtk.gdk.ACTION_COPY,
self._dragButton,
event)
@@ -1184,7 +1184,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
if iconview.drag_check_threshold(self._dragX, self._dragY,
int(event.x), int(event.y)):
context = iconview.drag_begin(
- [dnd.URI_TUPLE, dnd.FILESOURCE_TUPLE],
+ [dnd.URI_TARGET_ENTRY, dnd.FILESOURCE_TARGET_ENTRY],
gtk.gdk.ACTION_COPY,
self._dragButton,
event)
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index 41db545..87a0340 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -27,7 +27,7 @@ import gobject
from gettext import gettext as _
from pitivi.utils.loggable import Loggable
-from pitivi.utils.ui import LAYER_CONTROL_TUPLE, TYPE_PITIVI_LAYER_CONTROL
+from pitivi.utils.ui import LAYER_CONTROL_TARGET_ENTRY, TYPE_PITIVI_LAYER_CONTROL
# TODO add tooltips
@@ -150,7 +150,7 @@ class BaseLayerControl(gtk.VBox, Loggable):
# Drag and drop
self.drag_source_set(gtk.gdk.BUTTON1_MASK,
- [LAYER_CONTROL_TUPLE],
+ [LAYER_CONTROL_TARGET_ENTRY],
gtk.gdk.ACTION_MOVE)
def getSelected(self):
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index b3ff4d6..ed6d4ba 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -28,13 +28,13 @@ import sys
import time
import gtk
-import gtk.gdk
import gst
import ges
import glib
import ruler
import gobject
import goocanvas
+import cairo
from gettext import gettext as _
from os.path import join
@@ -56,10 +56,10 @@ from pitivi.dialogs.prefs import PreferencesDialog
from pitivi.utils.receiver import receiver, handler
from pitivi.utils.loggable import Loggable
-from pitivi.utils.ui import SPACING, CANVAS_SPACING, unpack_cairo_pattern, \
- TYPE_PITIVI_FILESOURCE, VIDEO_EFFECT_TUPLE, Point, \
- AUDIO_EFFECT_TUPLE, EFFECT_TUPLE, FILESOURCE_TUPLE, TYPE_PITIVI_EFFECT, \
- LAYER_CREATION_BLOCK_TIME, LAYER_CONTROL_TUPLE
+from pitivi.utils.ui import SPACING, CANVAS_SPACING, \
+ TYPE_PITIVI_FILESOURCE, VIDEO_EFFECT_TARGET_ENTRY, Point, \
+ AUDIO_EFFECT_TARGET_ENTRY, EFFECT_TARGET_ENTRY, FILESOURCE_TARGET_ENTRY, TYPE_PITIVI_EFFECT, \
+ LAYER_CREATION_BLOCK_TIME, LAYER_CONTROL_TARGET_ENTRY
# FIXME GES Port regression
# from pitivi.utils.align import AutoAligner
@@ -97,10 +97,10 @@ PLAYHEAD_CURSOR = gtk.gdk.Cursor(gtk.gdk.SB_H_DOUBLE_ARROW)
# Drag and drop constants/tuples
# FIXME, rethink the way we handle that as it is quite 'hacky'
-DND_EFFECT_LIST = [[VIDEO_EFFECT_TUPLE[0], EFFECT_TUPLE[0]],\
- [AUDIO_EFFECT_TUPLE[0], EFFECT_TUPLE[0]]]
-VIDEO_EFFECT_LIST = [VIDEO_EFFECT_TUPLE[0], EFFECT_TUPLE[0]],
-AUDIO_EFFECT_LIST = [AUDIO_EFFECT_TUPLE[0], EFFECT_TUPLE[0]],
+DND_EFFECT_LIST = [[VIDEO_EFFECT_TARGET_ENTRY.target, EFFECT_TARGET_ENTRY.target],\
+ [AUDIO_EFFECT_TARGET_ENTRY.target, EFFECT_TARGET_ENTRY.target]]
+VIDEO_EFFECT_LIST = [VIDEO_EFFECT_TARGET_ENTRY.target, EFFECT_TARGET_ENTRY.target],
+AUDIO_EFFECT_LIST = [AUDIO_EFFECT_TARGET_ENTRY.target, EFFECT_TARGET_ENTRY.target],
# tooltip text for toolbar
DELETE = _("Delete Selected")
@@ -178,9 +178,6 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
"""
__gtype_name__ = 'TimelineCanvas'
- __gsignals__ = {
- "expose-event": "override",
- }
_tracks = None
@@ -201,17 +198,19 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
self._createUI()
self._timeline = timeline
self.settings = instance.settings
+ self.connect("draw", self.drawCb)
def _createUI(self):
self._cursor = ARROW
root = self.get_root_item()
self.tracks = goocanvas.Group()
self.tracks.set_simple_transform(0, 0, 1.0, 0)
- root.add_child(self.tracks)
+ root.add_child(self.tracks, -1)
self._marquee = goocanvas.Rect(
parent=root,
- stroke_pattern=unpack_cairo_pattern(0x33CCFF66),
- fill_pattern=unpack_cairo_pattern(0x33CCFF66),
+ # FIXME GObject Introspection port
+ #stroke_pattern=unpack_cairo_pattern(0x33CCFF66),
+ #fill_pattern=unpack_cairo_pattern(0x33CCFF66),
visibility=goocanvas.ITEM_INVISIBLE)
self._playhead = goocanvas.Rect(
y=-10,
@@ -252,21 +251,22 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
event.window.set_cursor(self._cursor)
return True
- def do_expose_event(self, event):
+ def drawCb(self, widget, cr):
allocation = self.get_allocation()
width = allocation.width
height = allocation.height
# draw the canvas background
# we must have props.clear_background set to False
- self.style.apply_default_background(event.window,
- True,
- gtk.STATE_ACTIVE,
- event.area,
- event.area.x, event.area.y,
- event.area.width, event.area.height)
+ # FIXME GObject Introspection -> move to Gtk.StyleContext
+ #self.style.apply_default_background(event.window,
+ #True,
+ #gtk.STATE_ACTIVE,
+ #event.area,
+ #event.area.x, event.area.y,
+ #event.area.width, event.area.height)
- goocanvas.Canvas.do_expose_event(self, event)
+ #goocanvas.Canvas.do_expose_event(self, event)
## implements selection marquee
@@ -372,6 +372,12 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
self.position = position
self._playhead.props.x = self.nsToPixel(position)
+ max_duration = 0
+
+ def setMaxDuration(self, duration):
+ self.max_duration = duration
+ self._request_size()
+
def _request_size(self):
alloc = self.get_allocation()
self.set_bounds(0, 0, alloc.width, alloc.height)
@@ -450,7 +456,7 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
track = Track(self.app, track, self._timeline)
self._tracks.append(track)
track.set_canvas(self)
- self.tracks.add_child(track)
+ self.tracks.add_child(track, -1)
self.regroupTracks()
def _trackRemovedCb(self, unused_timeline, position):
@@ -511,10 +517,10 @@ class TimelineControls(gtk.VBox, Loggable):
self.connect("drag_leave", self._dragLeaveCb)
self.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
gtk.DEST_DEFAULT_DROP,
- [LAYER_CONTROL_TUPLE], gtk.gdk.ACTION_MOVE)
+ [LAYER_CONTROL_TARGET_ENTRY], gtk.gdk.ACTION_MOVE)
def _sizeAllocatedCb(self, widget, alloc):
- if self.children():
+ if self.get_children():
self.separator_height = self.children()[0].getSeparatorHeight()
self.app.gui.timeline_ui._canvas.updateTracks()
@@ -1119,7 +1125,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
# drag and drop
self._canvas.drag_dest_set(gtk.DEST_DEFAULT_MOTION,
- [FILESOURCE_TUPLE, EFFECT_TUPLE],
+ [FILESOURCE_TARGET_ENTRY, EFFECT_TARGET_ENTRY],
gtk.gdk.ACTION_COPY)
self._canvas.connect("drag-data-received", self._dragDataReceivedCb)
@@ -1165,9 +1171,9 @@ class Timeline(gtk.Table, Loggable, Zoomable):
if not self._drag_started:
self.debug("Drag start")
if context.targets in DND_EFFECT_LIST:
- atom = gtk.gdk.atom_intern(EFFECT_TUPLE[0])
+ atom = gtk.gdk.atom_intern(EFFECT_TARGET_ENTRY.target)
else:
- atom = gtk.gdk.atom_intern(FILESOURCE_TUPLE[0])
+ atom = gtk.gdk.atom_intern(FILESOURCE_TARGET_ENTRY.target)
self._drag_started = True
self._canvas.drag_get_data(context, atom, timestamp)
self._canvas.drag_highlight()
@@ -1556,7 +1562,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
"""
Set the zoom level so that the entire timeline is in view.
"""
- ruler_width = self.ruler.get_allocation()[2]
+ ruler_width = self.ruler.get_allocation().width
# Add gst.SECOND - 1 to the timeline duration to make sure the
# last second of the timeline will be in view.
duration = self.timeline.get_duration()
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index 3a295fb..51d19ae 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -71,18 +71,17 @@ TYPE_PITIVI_AUDIO_EFFECT = 28
TYPE_PITIVI_VIDEO_EFFECT = 29
TYPE_PITIVI_AUDIO_TRANSITION = 30
TYPE_PITIVI_VIDEO_TRANSITION = 31
-
TYPE_PITIVI_LAYER_CONTROL = 32
-FILE_TUPLE = ("text/plain", 0, TYPE_TEXT_PLAIN)
-URI_TUPLE = ("text/uri-list", 0, TYPE_URI_LIST)
-FILESOURCE_TUPLE = ("pitivi/file-source", 0, TYPE_PITIVI_FILESOURCE)
-EFFECT_TUPLE = ("pitivi/effect", 0, TYPE_PITIVI_EFFECT)
-AUDIO_EFFECT_TUPLE = ("pitivi/audio-effect", 0, TYPE_PITIVI_AUDIO_EFFECT)
-VIDEO_EFFECT_TUPLE = ("pitivi/video-effect", 0, TYPE_PITIVI_VIDEO_EFFECT)
-AUDIO_TRANSITION_TUPLE = ("pitivi/audio-transition", 0, TYPE_PITIVI_AUDIO_TRANSITION)
-VIDEO_TRANSITION_TUPLE = ("pitivi/video-transition", 0, TYPE_PITIVI_VIDEO_TRANSITION)
-LAYER_CONTROL_TUPLE = ("pitivi/layer-control", 0, TYPE_PITIVI_LAYER_CONTROL)
+FILE_TARGET_ENTRY = gtk.TargetEntry.new("text/plain", 0, TYPE_TEXT_PLAIN)
+URI_TARGET_ENTRY = gtk.TargetEntry.new("text/uri-list", 0, TYPE_URI_LIST)
+FILESOURCE_TARGET_ENTRY = gtk.TargetEntry.new("pitivi/file-source", 0, TYPE_PITIVI_FILESOURCE)
+EFFECT_TARGET_ENTRY = gtk.TargetEntry.new("pitivi/effect", 0, TYPE_PITIVI_EFFECT)
+AUDIO_EFFECT_TARGET_ENTRY = gtk.TargetEntry.new("pitivi/audio-effect", 0, TYPE_PITIVI_AUDIO_EFFECT)
+VIDEO_EFFECT_TARGET_ENTRY = gtk.TargetEntry.new("pitivi/video-effect", 0, TYPE_PITIVI_VIDEO_EFFECT)
+AUDIO_TRANSITION_TARGET_ENTRY = gtk.TargetEntry.new("pitivi/audio-transition", 0, TYPE_PITIVI_AUDIO_TRANSITION)
+VIDEO_TRANSITION_TARGET_ENTRY = gtk.TargetEntry.new("pitivi/video-transition", 0, TYPE_PITIVI_VIDEO_TRANSITION)
+LAYER_CONTROL_TARGET_ENTRY = gtk.TargetEntry.new("pitivi/layer-control", 0, TYPE_PITIVI_LAYER_CONTROL)
# ---------------------- ARGB color helper-------------------------------------#
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]