[pitivi/ges: 178/287] Rename SourceList into MediaLibrary



commit 43f585fb07ba73df37c5a72d2a5f28f08de1bcaf
Author: Thibault Saunier <thibault saunier collabora com>
Date:   Mon Jan 9 20:25:45 2012 -0300

    Rename SourceList into MediaLibrary

 pitivi/Makefile.am                        |    2 +-
 pitivi/application.py                     |   10 ++--
 pitivi/{sourcelist.py => medialibrary.py} |   46 ++++++++--------
 pitivi/project.py                         |    6 +-
 pitivi/settings.py                        |    2 +-
 pitivi/ui/mainwindow.py                   |   22 ++++----
 pitivi/undo/Makefile.am                   |    2 +-
 pitivi/undo/medialibrary.py               |   82 +++++++++++++++++++++++++++++
 pitivi/undo/sourcelist.py                 |   82 -----------------------------
 po/POTFILES.in                            |    2 +-
 tests/test_integration.py                 |    6 +-
 11 files changed, 131 insertions(+), 131 deletions(-)
---
diff --git a/pitivi/Makefile.am b/pitivi/Makefile.am
index 5ea5592..e74801b 100644
--- a/pitivi/Makefile.am
+++ b/pitivi/Makefile.am
@@ -16,7 +16,7 @@ pitivi_PYTHON = \
 	project.py 	\
 	projectmanager.py 	\
 	settings.py 	\
-	sourcelist.py 	\
+	medialibrary.py 	\
 	thumbnailcache.py
 
 BUILT_SOURCES=configure.py
diff --git a/pitivi/application.py b/pitivi/application.py
index 859a139..0cf30aa 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -51,7 +51,7 @@ from pitivi.projectmanager import ProjectManager, ProjectLogObserver
 from pitivi.undo.undo import UndoableActionLog, DebugActionLogObserver
 #FIXME GES port disabled it
 #from pitivi.undo.timeline import TimelineLogObserver
-from pitivi.undo.sourcelist import SourceListLogObserver
+from pitivi.undo.medialibrary import MediaLibraryLogObserver
 from pitivi.ui.startupwizard import StartUpWizard
 
 # FIXME : Speedup loading time
@@ -137,7 +137,7 @@ class Pitivi(Loggable, Signallable):
         # TODO reimplement the observing after GES port
         #self.timelineLogObserver = TimelineLogObserver(self.action_log)
         self.projectLogObserver = ProjectLogObserver(self.action_log)
-        self.sourcelist_log_observer = SourceListLogObserver(self.action_log)
+        self.medialibrary_log_observer = MediaLibraryLogObserver(self.action_log)
 
     def shutdown(self):
         """
@@ -188,7 +188,7 @@ class Pitivi(Loggable, Signallable):
         self.action_log.clean()
         #self.timelineLogObserver.startObserving(project.timeline)
         self.projectLogObserver.startObserving(project)
-        self.sourcelist_log_observer.startObserving(project.sources)
+        self.medialibrary_log_observer.startObserving(project.sources)
         self._newProjectLoaded(project)
         self.emit("new-project-loaded", project)
 
@@ -326,7 +326,7 @@ class ProjectCreatorGuiPitivi(FullGuiPitivi):
                 self._discoveryErrorCb, uris)
         self.current.sources.addUris(uris)
 
-    def _sourceAddedCb(self, sourcelist, info,
+    def _sourceAddedCb(self, medialibrary, info,
             startup_uris, add_to_timeline):
         if self._maybePopStartupUri(startup_uris, info.get_uri()) \
                 and add_to_timeline:
@@ -336,7 +336,7 @@ class ProjectCreatorGuiPitivi(FullGuiPitivi):
             self.current.timeline.get_layers()[0].add_object(src)
             self.action_log.commit()
 
-    def _discoveryErrorCb(self, sourcelist, uri, error, debug, startup_uris):
+    def _discoveryErrorCb(self, medialibrary, uri, error, debug, startup_uris):
         self._maybePopStartupUri(startup_uris, uri)
 
     def _maybePopStartupUri(self, startup_uris, uri):
diff --git a/pitivi/sourcelist.py b/pitivi/medialibrary.py
similarity index 97%
rename from pitivi/sourcelist.py
rename to pitivi/medialibrary.py
index fedf45e..af724ee 100644
--- a/pitivi/sourcelist.py
+++ b/pitivi/medialibrary.py
@@ -1,6 +1,6 @@
 # PiTiVi , Non-linear video editor
 #
-#       pitivi/sourcelist.py
+#       pitivi/medialibrary.py
 #
 # Copyright (c) 2005, Edward Hervey <bilboed bilboed com>
 # Copyright (c) 2009, Alessandro Decina <alessandro d gmail com>
@@ -87,7 +87,7 @@ ui = '''
 <ui>
     <menubar name="MainMenuBar">
         <menu action="Library">
-            <placeholder name="SourceList" >
+            <placeholder name="MediaLibrary" >
                 <menuitem action="ImportSources" />
                 <menuitem action="ImportSourcesFolder" />
                 <separator />
@@ -99,7 +99,7 @@ ui = '''
         </menu>
     </menubar>
     <toolbar name="MainToolBar">
-        <placeholder name="SourceList">
+        <placeholder name="MediaLibrary">
             <toolitem action="ImportSources" />
         </placeholder>
     </toolbar>
@@ -110,11 +110,11 @@ INVISIBLE = gtk.gdk.pixbuf_new_from_file(os.path.join(get_pixmap_dir(),
     "invisible.png"))
 
 
-class SourceListError(Exception):
+class MediaLibraryError(Exception):
     pass
 
 
-class SourceList(Signallable, Loggable):
+class MediaLibrary(Signallable, Loggable):
     discovererClass = gst.pbutils.Discoverer
 
     """
@@ -129,8 +129,8 @@ class SourceList(Signallable, Loggable):
     @type nb_imported_files: int
 
     Signals:
-     - C{source-added} : A source has been discovered and added to the SourceList.
-     - C{source-removed} : A source was removed from the SourceList.
+     - C{source-added} : A source has been discovered and added to the MediaLibrary.
+     - C{source-removed} : A source was removed from the MediaLibrary.
      - C{discovery-error} : The given uri is not a media file.
      - C{ready} : No more files are being discovered/added.
      - C{starting} : Some files are being discovered/added.
@@ -195,7 +195,7 @@ class SourceList(Signallable, Loggable):
         try:
             info = self._sources.pop(uri)
         except KeyError:
-            raise SourceListError("URI not in the sourcelist", uri)
+            raise MediaLibraryError("URI not in the medialibrary", uri)
         try:
             self._ordered_sources.remove(info)
         except ValueError:
@@ -212,7 +212,7 @@ class SourceList(Signallable, Loggable):
         """
         info = self._sources.get(uri)
         if info is None:
-            raise SourceListError("URI not in the sourcelist", uri)
+            raise MediaLibraryError("URI not in the medialibrary", uri)
         return info
 
     def addDiscovererInfo(self, info):
@@ -221,7 +221,7 @@ class SourceList(Signallable, Loggable):
         """
         uri = info.get_uri()
         if self._sources.get(uri, None) is not None:
-            raise SourceListError("We already have a info for this URI",
+            raise MediaLibraryError("We already have a info for this URI",
                     uri)
         self._sources[uri] = info
         self._ordered_sources.append(info)
@@ -238,7 +238,7 @@ class SourceList(Signallable, Loggable):
         return self._ordered_sources
 
 
-class SourceListWidget(gtk.VBox, Loggable):
+class MediaLibraryWidget(gtk.VBox, Loggable):
     """ Widget for listing sources """
 
     __gsignals__ = {
@@ -462,12 +462,12 @@ class SourceListWidget(gtk.VBox, Loggable):
                 self._insertEndCb),
         )
 
-        actiongroup = gtk.ActionGroup("sourcelistpermanent")
+        actiongroup = gtk.ActionGroup("medialibrarypermanent")
         actiongroup.add_actions(actions)
         actiongroup.get_action("ImportSources").props.is_important = True
         uiman.insert_action_group(actiongroup, 0)
 
-        self.selection_actions = gtk.ActionGroup("sourcelistselection")
+        self.selection_actions = gtk.ActionGroup("medialibraryselection")
         self.selection_actions.add_actions(selection_actions)
         self.selection_actions.set_sensitive(False)
         uiman.insert_action_group(self.selection_actions, 0)
@@ -630,7 +630,7 @@ class SourceListWidget(gtk.VBox, Loggable):
             project.sources, "starting", None, self._sourcesStartedImportingCb)
 
     def _setClipView(self, show):
-        """ Set which clip view to use when sourcelist is showing clips. If
+        """ Set which clip view to use when medialibrary is showing clips. If
         none is given, the current one is used. Show: one of SHOW_TREEVIEW or
         SHOW_ICONVIEW """
 
@@ -778,18 +778,18 @@ class SourceListWidget(gtk.VBox, Loggable):
             short_text])
         self._displayClipView()
 
-    # sourcelist callbacks
+    # medialibrary callbacks
 
-    def _sourceAddedCb(self, sourcelist, factory):
-        """ a file was added to the sourcelist """
+    def _sourceAddedCb(self, medialibrary, factory):
+        """ a file was added to the medialibrary """
         self._updateProgressbar()
         self._addDiscovererInfo(factory)
         if len(self.storemodel):
             self.infobar.hide_all()
             self.search_hbox.show_all()
 
-    def _sourceRemovedCb(self, sourcelist, uri, factory):
-        """ the given uri was removed from the sourcelist """
+    def _sourceRemovedCb(self, medialibrary, uri, factory):
+        """ the given uri was removed from the medialibrary """
         # find the good line in the storemodel and remove it
         model = self.storemodel
         for row in model:
@@ -801,16 +801,16 @@ class SourceListWidget(gtk.VBox, Loggable):
             self.search_hbox.hide()
         self.debug("Removing %s", uri)
 
-    def _discoveryErrorCb(self, unused_sourcelist, uri, reason, extra):
+    def _discoveryErrorCb(self, unused_medialibrary, uri, reason, extra):
         """ The given uri isn't a media file """
         error = (uri, reason, extra)
         self._errors.append(error)
 
-    def _sourcesStartedImportingCb(self, sourcelist):
+    def _sourcesStartedImportingCb(self, medialibrary):
         self._progressbar.show()
         self._updateProgressbar()
 
-    def _sourcesStoppedImportingCb(self, unused_sourcelist):
+    def _sourcesStoppedImportingCb(self, unused_medialibrary):
         self._progressbar.hide()
         if self._errors:
             if len(self._errors) > 1:
@@ -1265,4 +1265,4 @@ class SourceListWidget(gtk.VBox, Loggable):
         selection.set(selection.target, 8, '\n'.join(uris))
         context.set_icon_pixbuf(INVISIBLE, 0, 0)
 
-gobject.type_register(SourceListWidget)
+gobject.type_register(MediaLibraryWidget)
diff --git a/pitivi/project.py b/pitivi/project.py
index 28ee297..9167e2f 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -28,7 +28,7 @@ import gst
 
 from pitivi.utils.playback import Seeker
 from pitivi.utils.loggable import Loggable
-from pitivi.sourcelist import SourceList
+from pitivi.medialibrary import MediaLibrary
 from pitivi.settings import MultimediaSettings
 from pitivi.utils.signal import Signallable
 from pitivi.utils.timeline import Selection
@@ -47,7 +47,7 @@ class Project(Signallable, Loggable):
     @ivar description: A description of the project
     @type description: C{str}
     @ivar sources: The sources used by this project
-    @type sources: L{SourceList}
+    @type sources: L{MediaLibrary}
     @ivar timeline: The timeline
     @type timeline: L{ges.Timeline}
     @ivar pipeline: The timeline's pipeline
@@ -82,7 +82,7 @@ class Project(Signallable, Loggable):
         self.uri = uri
         self.urichanged = False
         self.format = None
-        self.sources = SourceList()
+        self.sources = MediaLibrary()
 
         self._dirty = False
 
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 7d9d757..cdf79e8 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -259,7 +259,7 @@ class GlobalSettings(Signallable):
         the config file is read. Only options registered before the config
         file is read will be loaded.
 
-        see pitivi/ui/mainwindow.py, pitivi/ui/sourcelist.py for examples of
+        see pitivi/ui/mainwindow.py, pitivi/ui/medialibrary.py for examples of
         usage.
 
         @param attrname: the attribute of this class which represents the option
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 339edb9..b5ada4b 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -45,7 +45,7 @@ from pitivi.utils.ui import SPACING, info_name, FILESOURCE_TUPLE, URI_TUPLE, \
 from pitivi.ui.timeline import Timeline
 from pitivi.ui.basetabs import BaseTabs
 from pitivi.ui.viewer import PitiviViewer
-from pitivi.sourcelist import SourceListWidget, SourceListError
+from pitivi.medialibrary import MediaLibraryWidget, MediaLibraryError
 from pitivi.effects import EffectListWidget
 from pitivi.ui.zoominterface import Zoomable
 from pitivi.ui.clipproperties import ClipProperties
@@ -375,10 +375,10 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         self.projecttabs = BaseTabs(instance)
 
-        self.sourcelist = SourceListWidget(instance, self.uimanager)
-        self.projecttabs.append_page(self.sourcelist, gtk.Label(_("Media Library")))
-        self._connectToSourceList()
-        self.sourcelist.show()
+        self.medialibrary = MediaLibraryWidget(instance, self.uimanager)
+        self.projecttabs.append_page(self.medialibrary, gtk.Label(_("Media Library")))
+        self._connectToMediaLibrary()
+        self.medialibrary.show()
 
         self.effectlist = EffectListWidget(instance, self.uimanager)
         self.projecttabs.append_page(self.effectlist, gtk.Label(_("Effect Library")))
@@ -455,8 +455,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
         os.environ["PULSE_PROP_media.role"] = "production"
         os.environ["PULSE_PROP_application.icon_name"] = "pitivi"
 
-    def _connectToSourceList(self):
-        self.sourcelist.connect('play', self._sourceListPlayCb)
+    def _connectToMediaLibrary(self):
+        self.medialibrary.connect('play', self._sourceListPlayCb)
 
     def setFullScreen(self, fullscreen):
         """ Toggle the fullscreen mode of the application """
@@ -525,7 +525,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
         self.settings.mainWindowShowMainToolbar = mtb.props.active
         self.settings.mainWindowShowTimelineToolbar = ttb.props.active
 
-    def _sourceListPlayCb(self, sourcelist, uri):
+    def _sourceListPlayCb(self, medialibrary, uri):
         self._viewUri(uri)
 
 ## Toolbar/Menu actions callback
@@ -911,8 +911,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         dialog.destroy()
 
-    def _connectToProjectSources(self, sourcelist):
-        sourcelist.connect("missing-plugins", self._sourceListMissingPluginsCb)
+    def _connectToProjectSources(self, medialibrary):
+        medialibrary.connect("missing-plugins", self._sourceListMissingPluginsCb)
 
     def _actionLogCommit(self, action_log, stack, nested):
         if nested:
@@ -1084,7 +1084,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         try:
             info = self.project.sources.getInfoFromUri(uri)
-        except SourceListError:
+        except MediaLibraryError:
             self.project.sources.addUri(uri)
             # FIXME Add a delay/catch signal when we start doing the discovering
             # async
diff --git a/pitivi/undo/Makefile.am b/pitivi/undo/Makefile.am
index 4303b76..9be4f5d 100644
--- a/pitivi/undo/Makefile.am
+++ b/pitivi/undo/Makefile.am
@@ -5,7 +5,7 @@ undo_PYTHON =    \
 	undo.py      \
 	timeline.py  \
 	effect.py    \
-	sourcelist.py
+	medialibrary.py
 
 clean-local:
 	rm -rf *.pyc *.pyo
diff --git a/pitivi/undo/medialibrary.py b/pitivi/undo/medialibrary.py
new file mode 100644
index 0000000..09b3498
--- /dev/null
+++ b/pitivi/undo/medialibrary.py
@@ -0,0 +1,82 @@
+# PiTiVi , Non-linear video editor
+#
+#       pitivi/medialibrary_undo.py
+#
+# Copyright (c) 2009, Alessandro Decina <alessandro d gmail com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+from pitivi.undo.undo import UndoableAction
+
+
+class MediaLibrarySourceAddedAction(UndoableAction):
+    def __init__(self, medialibrary, source):
+        self.medialibrary = medialibrary
+        self.source = source
+
+    def undo(self):
+        self.medialibrary.removeUri(self.source.uri)
+        self._undone()
+
+    def do(self):
+        self.medialibrary.addDiscovererInfo(self.source)
+        self._done()
+
+
+class MediaLibrarySourceRemovedAction(UndoableAction):
+    def __init__(self, medialibrary, uri, source):
+        self.medialibrary = medialibrary
+        self.uri = uri
+        self.source = source
+
+    def undo(self):
+        self.medialibrary.addDiscovererInfo(self.source)
+        self._undone()
+
+    def do(self):
+        self.medialibrary.removeUri(self.source.uri)
+        self._done()
+
+
+class MediaLibraryLogObserver(object):
+    def __init__(self, log):
+        self.log = log
+
+    def startObserving(self, medialibrary):
+        self._connectToSourcelist(medialibrary)
+
+    def stopObserving(self, medialibrary):
+        self._disconnectFromSourcelist(medialibrary)
+
+    def _connectToSourcelist(self, medialibrary):
+        medialibrary.connect("source-added", self._sourceAddedCb)
+        medialibrary.connect("source-removed", self._sourceRemovedCb)
+
+    def _disconnectFromSourcelist(self, medialibrary):
+        medialibrary.disconnect_by_func(self._sourceAddedCb)
+        medialibrary.disconnect_by_func(self._sourceRemovedCb)
+
+    def _sourceAddedCb(self, medialibrary, factory):
+        self.log.begin("add source")
+        action = MediaLibrarySourceAddedAction(medialibrary, factory)
+        self.log.push(action)
+        self.log.commit()
+
+    def _sourceRemovedCb(self, medialibrary, uri, factory):
+        self.log.begin("remove source")
+        action = MediaLibrarySourceRemovedAction(medialibrary, uri, factory)
+        self.log.push(action)
+        self.log.commit()
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b19fea6..3943cf1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -18,7 +18,7 @@ pitivi/effects.py
 pitivi/projectmanager.py
 pitivi/project.py
 pitivi/settings.py
-pitivi/sourcelist.py
+pitivi/medialibrary.py
 pitivi/ui/basetabs.py
 pitivi/ui/clipproperties.py
 pitivi/ui/encodingdialog.py
diff --git a/tests/test_integration.py b/tests/test_integration.py
index cb939a0..b6476ce 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -241,10 +241,10 @@ class InstanceRunner(Signallable):
         if self.pending_configuration:
             self._loadSources(self.pending_configuration)
 
-    def _sourceAdded(self, sourcelist, factory):
+    def _sourceAdded(self, medialibrary, factory):
         self.factories.add(factory.uri)
 
-    def _discoveryError(self, sourcelist, uri, reason, unused):
+    def _discoveryError(self, medialibrary, uri, reason, unused):
         self.errors.add(uri)
 
     def _readyCb(self, soucelist):
@@ -282,7 +282,7 @@ class InstanceRunner(Signallable):
         for name, uri, props in configuration:
             factory = self.project.sources.getInfoFromUri(uri)
             if not factory:
-                raise Exception("Could not find '%s' in sourcelist" %
+                raise Exception("Could not find '%s' in medialibrary" %
                     source)
 
             if not props:



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