[pitivi] Some fixes in ui/effectlist.py
- From: Edward Hervey <edwardrv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Some fixes in ui/effectlist.py
- Date: Wed, 22 Sep 2010 13:34:52 +0000 (UTC)
commit 5a9b4285cd4f1b5cccfd885c4b1d66c0eecf36ca
Author: Thibault Saunier <tsaunier src gnome org>
Date: Thu May 20 22:21:50 2010 -0400
Some fixes in ui/effectlist.py
pitivi/ui/effectlist.py | 152 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 129 insertions(+), 23 deletions(-)
---
diff --git a/pitivi/ui/effectlist.py b/pitivi/ui/effectlist.py
index 441ff10..e534552 100644
--- a/pitivi/ui/effectlist.py
+++ b/pitivi/ui/effectlist.py
@@ -2,7 +2,7 @@
#
# ui/effectlist.py
#
-# Copyright (c) 2005, Edward Hervey <bilboed bilboed com>
+# Copyright (c) 2010, Thibault Saunier <tsaunier gnome org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -31,11 +31,6 @@ from gettext import gettext as _
from gettext import ngettext
import pitivi.ui.dnd as dnd
-from pitivi.ui.pathwalker import PathWalker, quote_uri
-from pitivi.ui.filelisterrordialog import FileListErrorDialog
-from pitivi.configure import get_pixmap_dir
-from pitivi.signalgroup import SignalGroup
-
from pitivi.factories.operation import VideoEffectFactory, AudioEffectFactory
from pitivi.settings import GlobalSettings
@@ -49,13 +44,8 @@ from pitivi.log.loggable import Loggable
COL_ICON_LARGE,
COL_INFOTEXT,
COL_FACTORY,
- COL_URI,
- COL_LENGTH,
COL_SEARCH_TEXT,
- COL_SHORT_TEXT) = range(8)
-
-INVISIBLE = gtk.gdk.pixbuf_new_from_file(os.path.join(get_pixmap_dir(),
- "invisible.png"))
+ COL_SHORT_TEXT) = range(6)
class EffectList(gtk.VBox, Loggable):
""" Widget for listing effects """
@@ -68,12 +58,17 @@ class EffectList(gtk.VBox, Loggable):
self.settings = instance.settings
#TODO check that
- self._dragButton = False
+ self._dragButton = None
+ self._dragStarted = False
+ self._dragSelection = False
+ self._dragX = 0
+ self._dragY = 0
+ self._ignoreRelease = False
# Store
# icon, icon, infotext, objectfactory
- self.storemodel = gtk.ListStore(gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, str, object,
- str, str)
+ self.storemodel = gtk.ListStore(gtk.gdk.Pixbuf, gtk.gdk.Pixbuf,
+ str, object, str, str)
# Scrolled Windows
self.treeview_scrollwin = gtk.ScrolledWindow()
@@ -81,7 +76,7 @@ class EffectList(gtk.VBox, Loggable):
self.treeview_scrollwin.set_shadow_type(gtk.SHADOW_ETCHED_IN)
# TreeView
- # Displays icon, name, type
+ # Displays icon, long_name
self.treeview = gtk.TreeView(self.storemodel)
self.treeview_scrollwin.add(self.treeview)
self.treeview.set_property("rules_hint", True)
@@ -89,7 +84,7 @@ class EffectList(gtk.VBox, Loggable):
self.treeview.set_property("search_column", COL_SEARCH_TEXT)
self.treeview.set_property("has_tooltip", True)
tsel = self.treeview.get_selection()
- tsel.set_mode(gtk.SELECTION_MULTIPLE)
+ tsel.set_mode(gtk.SELECTION_SINGLE)
pixbufcol = gtk.TreeViewColumn(_("Icon"))
pixbufcol.set_expand(False)
@@ -111,10 +106,16 @@ class EffectList(gtk.VBox, Loggable):
namecol.pack_start(txtcell)
namecol.add_attribute(txtcell, "markup", COL_INFOTEXT)
+ self.treeview.connect("button-press-event",
+ self._treeViewButtonPressEventCb)
self.treeview.connect("motion-notify-event",
- self._treeViewMotionNotifyEventCb)
+ self._treeViewMotionNotifyEventCb)
self.treeview.connect("query-tooltip",
- self._treeViewQueryTooltipCb)
+ self._treeViewQueryTooltipCb)
+ self.treeview.connect("button-release-event",
+ self._treeViewButtonReleaseCb)
+ self.treeview.connect("drag_begin",
+ self._dndDragBeginCb)
self.pack_start(self.treeview_scrollwin)
#Get all available effects
@@ -126,8 +127,9 @@ class EffectList(gtk.VBox, Loggable):
thumbnail_file = os.path.join (os.getcwd(), "icons", "24x24", "pitivi.png")
pixbuf = gtk.gdk.pixbuf_new_from_file(thumbnail_file)
+
for effect in effects:
- #Check how it would look the best
+ #TODO Check how it would look the best
visualname = ("<b>Name: </b>" + escape(unquote(effect.get_longname())) + "\n" +
"<b>Description: </b>"+ effect.get_description())
@@ -136,8 +138,98 @@ class EffectList(gtk.VBox, Loggable):
factory, effect.get_description(),
factory.name])
+ def _dndDragBeginCb(self, view, context):
+ self.info("tree drag_begin")
+ path = self.treeview.get_selection().get_selected_rows()[1]
+
+ if len(path) < 1:
+ context.drag_abort(int(time.time()))
+ else:
+ row = self.storemodel[path[0]]
+ context.set_icon_pixbuf(row[COL_ICON], 0, 0)
+
+ def _rowUnderMouseSelected(self, view, event):
+ result = view.get_path_at_pos(int(event.x), int(event.y))
+ if result:
+ path = result[0]
+ if isinstance(view, gtk.TreeView):
+ selection = view.get_selection()
+ return selection.path_is_selected(path) and selection.count_selected_rows() > 0
+ elif isinstance(view, gtk.IconView):
+ selection = view.get_selected_items()
+
+ return view.path_is_selected(path) and len(selection)
+ else:
+ assert False
+
+ return False
+
+ def _treeViewButtonPressEventCb(self, treeview, event):
+ chain_up = True
+
+ if event.button == 3:
+ self._viewShowPopup(treeview, event)
+ chain_up = False
+ else:
+ if not event.state & (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK):
+ chain_up = not self._rowUnderMouseSelected(treeview, event)
+
+ self._dragStarted = False
+ self._dragSelection = False
+ self._dragButton = event.button
+ self._dragX = int(event.x)
+ self._dragY = int(event.y)
+
+ if chain_up:
+ gtk.TreeView.do_button_press_event(treeview, event)
+ else:
+ treeview.grab_focus()
+
+ self._ignoreRelease = chain_up
+
+ return True
+
+ def _treeViewButtonReleaseCb(self, treeview, event):
+ if event.button == self._dragButton:
+ self._dragButton = None
+ # TODO: What does it do?
+ # if (not self._ignoreRelease) and (not self._dragStarted):
+ # treeview.get_selection().unselect_all()
+ # result = treeview.get_path_at_pos(int(event.x), int(event.y))
+ # if result:
+ # path = result[0]
+ # treeview.get_selection().select_path(path)
+ return False
+
def _treeViewMotionNotifyEventCb(self, treeview, event):
- pass
+ chain_up = True
+
+ if not self._dragButton:
+ return True
+
+ if self._nothingUnderMouse(treeview, event):
+ return True
+
+ if not event.state & (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK):
+ chain_up = not self._rowUnderMouseSelected(treeview, event)
+
+ if treeview.drag_check_threshold(self._dragX, self._dragY,
+ int(event.x), int(event.y)):
+ context = treeview.drag_begin(
+ self._getDndTuple(),
+ gtk.gdk.ACTION_COPY,
+ self._dragButton,
+ event)
+ self._dragStarted = True
+
+ if chain_up:
+ gtk.TreeView.do_button_press_event(treeview, event)
+ else:
+ treeview.grab_focus()
+
+ self._ignoreRelease = chain_up
+
+ return False
def _treeViewQueryTooltipCb(self, treeview, x, y, keyboard_mode, tooltip):
pos = treeview.get_path_at_pos(x,y)[0]
@@ -145,12 +237,20 @@ class EffectList(gtk.VBox, Loggable):
tooltip.set_text(treeview.get_model()[pos[0]][4])
return True
+ def _insertEndCb(self, unused_action):
+ print "T34T"
+
+ def _nothingUnderMouse(self, view, event):
+ return not bool(view.get_path_at_pos(int(event.x), int(event.y)))
def _getEffects():
- pass
+ raise NotImplementedError()
def _getFactoryFromEffect(self, effect):
- pass
+ raise NotImplementedError()
+
+ def _getDndTuple(self):
+ raise NotImplementedError()
class VideoEffectList (EffectList):
@@ -163,6 +263,9 @@ class VideoEffectList (EffectList):
def _getFactoryFromEffect(self, effect):
return VideoEffectFactory(effect.get_name())
+ def _getDndTuple(self):
+ return [dnd.VIDEO_EFFECT_TUPLE, dnd.EFFECT_TUPLE]
+
class AudioEffectList (EffectList):
def __init__(self, instance, uiman):
@@ -173,5 +276,8 @@ class AudioEffectList (EffectList):
def _getFactoryFromEffect(self, effect):
return AudioEffectFactory(effect.get_name())
+
+ def _getDndTuple(self):
+ return [dnd.AUDIO_EFFECT_TUPLE, dnd.EFFECT_TUPLE]
gobject.type_register(EffectList)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]