Exemple #1
0
    def test_scaled_proxy_size(self):
        app = common.create_pitivi_mock(default_scaled_proxy_width=123,
                                        default_scaled_proxy_height=456)
        manager = ProjectManager(app)
        project = manager.new_blank_project()
        self.assertFalse(project.has_scaled_proxy_size())
        self.assertEqual(project.scaled_proxy_width, 123)
        self.assertEqual(project.scaled_proxy_height, 456)

        with tempfile.NamedTemporaryFile() as temp_file:
            uri = Gst.filename_to_uri(temp_file.name)
            manager.save_project(uri=uri, backup=False)
            app2 = common.create_pitivi_mock(default_scaled_proxy_width=12,
                                             default_scaled_proxy_height=45)
            project2 = ProjectManager(app2).load_project(uri)
            self.assertFalse(project2.has_scaled_proxy_size())
            self.assertEqual(project2.scaled_proxy_width, 12)
            self.assertEqual(project2.scaled_proxy_height, 45)

        project.scaled_proxy_width = 123
        project.scaled_proxy_height = 456
        self.assertTrue(project.has_scaled_proxy_size())
        self.assertEqual(project.scaled_proxy_width, 123)
        self.assertEqual(project.scaled_proxy_height, 456)

        with tempfile.NamedTemporaryFile() as temp_file:
            manager.save_project(uri=uri, backup=False)
            app2 = common.create_pitivi_mock(default_scaled_proxy_width=1,
                                             default_scaled_proxy_height=4)
            project2 = ProjectManager(app2).load_project(uri)
            self.assertTrue(project2.has_scaled_proxy_size())
            self.assertEqual(project2.scaled_proxy_width, 123)
            self.assertEqual(project2.scaled_proxy_height, 456)
Exemple #2
0
    def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="org.pitivi.Pitivi",
                                 flags=Gio.ApplicationFlags.NON_UNIQUE
                                 | Gio.ApplicationFlags.HANDLES_OPEN)
        Loggable.__init__(self)

        self.settings = None
        self.threads = None
        self.effects = None
        self.system = None
        self.project_manager = ProjectManager(self)

        self.action_log = None
        self.project_observer = None
        self._last_action_time = Gst.util_get_timestamp()

        self.gui = None
        self.recent_manager = Gtk.RecentManager.get_default()
        self.__inhibit_cookies = {}

        self._version_information = {}

        self._scenario_file = None
        self._first_action = True

        Zoomable.app = self
        self.shortcuts = ShortcutsManager(self)
Exemple #3
0
def _createRealProject(name=None):
    app = Pitivi()
    project_manager = ProjectManager(app)
    project_manager.newBlankProject()
    if name:
        project_manager.current_project.name = name
    return project_manager.current_project
Exemple #4
0
    def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="org.pitivi",
                                 flags=Gio.ApplicationFlags.HANDLES_OPEN)
        Loggable.__init__(self)

        self.settings = None
        self.threads = None
        self.effects = None
        self.system = None
        self.project_manager = ProjectManager(self)

        self.action_log = UndoableActionLog(self)
        self.timeline_log_observer = None
        self.project_log_observer = None
        self._last_action_time = Gst.util_get_timestamp()

        self.gui = None
        self.welcome_wizard = None

        self._version_information = {}

        self._scenario_file = None
        self._first_action = True

        self.connect("startup", self._startupCb)
        self.connect("activate", self._activateCb)
        self.connect("open", self.openCb)
Exemple #5
0
    def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="org.pitivi",
                                 flags=Gio.ApplicationFlags.HANDLES_OPEN)
        Loggable.__init__(self)

        self.settings = None
        self.threads = None
        self.effects = None
        self.system = None
        self.project_manager = ProjectManager(self)

        self.action_log = None
        self.project_observer = None
        self._last_action_time = Gst.util_get_timestamp()

        self.gui = None
        self.__welcome_wizard = None

        self._version_information = {}

        self._scenario_file = None
        self._first_action = True

        Zoomable.app = self
        self.shortcuts = ShortcutsManager(self)
Exemple #6
0
    def __loading_failure(self, has_proxy):
        mainloop = common.create_main_loop()

        app = common.create_pitivi_mock(lastProjectFolder="/tmp",
                                        edgeSnapDeadband=32)
        app.project_manager = ProjectManager(app)
        mainwindow = MainWindow(app)
        mainwindow.viewer = mock.MagicMock()

        def __pm_missing_uri_cb(project_manager, project, error, asset):
            nonlocal mainloop
            nonlocal mainwindow
            nonlocal self
            nonlocal app
            nonlocal has_proxy

            with mock.patch('gi.repository.Gtk.Dialog') as dialog:
                failed_cb = mock.MagicMock()
                app.project_manager.connect("new-project-failed", failed_cb)

                dialog.return_value = mock.MagicMock()
                dialog.return_value.run = mock.MagicMock(
                    return_value=Gtk.ResponseType.CLOSE)

                # Call the actual callback
                # pylint: disable=protected-access
                app.proxy_manager.checkProxyLoadingSucceeded =  \
                    mock.MagicMock(return_value=has_proxy)

                mainwindow._projectManagerMissingUriCb(project_manager,
                                                       project, error, asset)

                self.assertTrue(dialog.called)
                self.assertTrue(dialog.return_value.run.called)
                self.assertEqual(failed_cb.called, not has_proxy)

            # pylint: disable=protected-access
            app.project_manager.connect("missing-uri",
                                        mainwindow._projectManagerMissingUriCb)
            # pylint: disable=protected-access
            app.project_manager.connect(
                "new-project-failed",
                mainwindow._projectManagerNewProjectFailedCb)

            mainwindow.destroy()
            mainloop.quit()

        # pylint: disable=protected-access
        disconnectAllByFunc(app.project_manager,
                            mainwindow._projectManagerMissingUriCb)
        disconnectAllByFunc(app.project_manager,
                            mainwindow._projectManagerNewProjectFailedCb)

        app.project_manager.connect("missing-uri", __pm_missing_uri_cb)

        with common.created_project_file() as uri:
            app.project_manager.loadProject(uri)

        mainloop.run()
    def __loading_failure(self, has_proxy):
        mainloop = common.create_main_loop()

        app = common.create_pitivi_mock(lastProjectFolder="/tmp",
                                        edgeSnapDeadband=32)
        app.project_manager = ProjectManager(app)
        editorperspective = EditorPerspective(app)
        editorperspective.setup_ui()
        editorperspective.viewer = mock.MagicMock()
        editorperspective.medialibrary._import_warning_infobar = mock.MagicMock(
        )
        editorperspective.clipconfig.effect_expander._infobar = mock.MagicMock(
        )

        def __pm_missing_uri_cb(project_manager, project, error, asset):
            nonlocal mainloop
            nonlocal editorperspective
            nonlocal self
            nonlocal app
            nonlocal has_proxy

            with mock.patch.object(MissingAssetDialog,
                                   "__new__") as constructor:
                failed_cb = mock.MagicMock()
                app.project_manager.connect("new-project-failed", failed_cb)

                dialog = constructor.return_value
                dialog.get_new_uri.return_value = None

                # Call the actual callback
                app.proxy_manager.checkProxyLoadingSucceeded =  \
                    mock.MagicMock(return_value=has_proxy)

                editorperspective._projectManagerMissingUriCb(
                    project_manager, project, error, asset)

                self.assertTrue(constructor.called)
                self.assertTrue(dialog.get_new_uri.called)
                self.assertEqual(failed_cb.called, not has_proxy)

            app.project_manager.connect(
                "missing-uri", editorperspective._projectManagerMissingUriCb)
            mainloop.quit()

        disconnectAllByFunc(app.project_manager,
                            editorperspective._projectManagerMissingUriCb)

        app.project_manager.connect("missing-uri", __pm_missing_uri_cb)

        with common.cloned_sample():
            asset_uri = common.get_sample_uri("missing.png")
            with common.created_project_file(asset_uri) as uri:
                app.project_manager.load_project(uri)

        mainloop.run()
Exemple #8
0
def create_timeline_container(**settings):
    app = create_pitivi_mock(leftClickAlsoSeeks=False, **settings)
    app.project_manager = ProjectManager(app)
    project = app.project_manager.new_blank_project()

    timeline_container = TimelineContainer(app, app.gui.editor.editor_state)
    timeline_container.set_project(project)

    timeline = timeline_container.timeline
    timeline.get_parent = mock.MagicMock(return_value=timeline_container)

    app.gui.editor.timeline_ui = timeline_container

    return timeline_container
Exemple #9
0
def create_timeline_container():
    app = create_pitivi_mock(leftClickAlsoSeeks=False)
    project_manager = ProjectManager(app)
    project_manager.newBlankProject()
    project = project_manager.current_project

    timeline_container = TimelineContainer(app)
    timeline_container.setProject(project)

    timeline = timeline_container.timeline
    timeline.app.project_manager.current_project = project
    timeline.get_parent = mock.MagicMock(return_value=timeline_container)

    app.gui.timeline_ui = timeline_container

    return timeline_container
    def createTimeline(self):
        app = common.create_pitivi_mock()
        project_manager = ProjectManager(app)
        project_manager.newBlankProject()
        project = project_manager.current_project

        timeline_container = TimelineContainer(app)
        timeline_container.setProject(project)

        timeline = timeline_container.timeline
        timeline.app.project_manager.current_project = project
        timeline.get_parent = mock.MagicMock(return_value=timeline_container)

        timeline.app.settings.leftClickAlsoSeeks = False

        return timeline
Exemple #11
0
    def __init__(self):
        """
        initialize pitivi with the command line arguments
        """
        Loggable.__init__(self)

        # init logging as early as possible so we can log startup code
        enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR',
                                      '0') in ('', '0')
        # Let's show a human-readable pitivi debug output by default, and only
        # show a crazy unreadable mess when surrounded by gst debug statements.
        enable_crack_output = "GST_DEBUG" in os.environ
        log.init('PITIVI_DEBUG', enable_color, enable_crack_output)

        self.info('starting up')

        # store ourself in the instance global
        if instance.PiTiVi:
            raise RuntimeWarning(
                _("There is already a %s instance, please inform "
                  "the developers by filing a bug at "
                  "http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi") %
                APPNAME)
        instance.PiTiVi = self

        self.current = None

        # get settings
        self.settings = GlobalSettings()
        self.threads = ThreadMaster()
        #self.screencast = False

        self.effects = EffectsHandler()
        self.system = getSystem()

        self.projectManager = ProjectManager(self)
        self._connectToProjectManager(self.projectManager)

        self.action_log = UndoableActionLog()
        self.debug_action_log_observer = DebugActionLogObserver()
        self.debug_action_log_observer.startObserving(self.action_log)
        # TODO reimplement the observing after GES port
        #self.timelineLogObserver = TimelineLogObserver(self.action_log)
        self.projectLogObserver = ProjectLogObserver(self.action_log)

        self.version_information = {}
        self._checkVersion()
Exemple #12
0
    def test_toggle_safe_areas_action(self):
        """Checks the effect of the toggle_safe_areas_action."""
        app = common.create_pitivi_mock()
        app.project_manager = ProjectManager(app)
        viewer_container = ViewerContainer(app)

        project = app.project_manager.new_blank_project()
        viewer_container.set_project(project)
        self.assertFalse(
            viewer_container.overlay_stack.safe_areas_overlay.get_visible())

        viewer_container.toggle_safe_areas_action.activate()
        self.assertTrue(
            viewer_container.overlay_stack.safe_areas_overlay.get_visible())

        viewer_container.toggle_safe_areas_action.activate()
        self.assertFalse(
            viewer_container.overlay_stack.safe_areas_overlay.get_visible())
    def _custom_set_up(self, project_uri=None, **settings):
        # Always make sure we start with a clean medialibrary, and no other
        # is connected to some assets.
        self.clean()

        self.mainloop = common.create_main_loop()
        self.check_no_transcoding = False
        self.app = common.create_pitivi_mock(**settings)
        self.app.project_manager = ProjectManager(self.app)
        self.medialibrary = MediaLibraryWidget(self.app)

        if project_uri:
            self.app.project_manager.load_project(project_uri)
        else:
            self.app.project_manager.new_blank_project()

        self.app.project_manager.current_project.connect(
            "loaded", self.project_loaded_cb)
        self.mainloop.run()
Exemple #14
0
    def _customSetUp(self, project_uri=None, **kwargs):
        # Always make sure we start with a clean medialibrary, and no other
        # is connected to some assets.
        self.clean()

        self.mainloop = common.create_main_loop()
        self.check_no_transcoding = False
        self.app = common.create_pitivi_mock(**kwargs)
        self.app.project_manager = ProjectManager(self.app)
        self.medialibrary = medialibrary.MediaLibraryWidget(self.app)

        if project_uri:
            self.app.project_manager.loadProject(project_uri)
        else:
            self.app.project_manager.newBlankProject(
                ignore_unsaved_changes=True)

        self.app.project_manager.current_project.connect(
            "loaded", self.projectLoadedCb)
        self.mainloop.run()
Exemple #15
0
 def setUp(self):
     self.manager = ProjectManager(None)
     self.listener = ProjectManagerListener(self.manager)
     self.signals = self.listener.signals
 def setupApp(self, app=None):
     if not app:
         app = mock.MagicMock()
     self.manager = ProjectManager(app)
     self.listener = ProjectManagerListener(self.manager)
     self.signals = self.listener.signals
Exemple #17
0
 def setUp(self):
     app = mock.MagicMock()
     self.manager = ProjectManager(app)
     self.listener = ProjectManagerListener(self.manager)
     self.signals = self.listener.signals
Exemple #18
0
def create_project():
    project_manager = ProjectManager(create_pitivi_mock())
    project_manager.newBlankProject()
    project = project_manager.current_project
    return project
Exemple #19
0
def create_project():
    project_manager = ProjectManager(create_pitivi_mock())
    project = project_manager.new_blank_project()
    return project
Exemple #20
0
 def setUp(self):
     super(TestProjectManager, self).setUp()
     app = mock.MagicMock()
     self.manager = ProjectManager(app)
     self.listener = ProjectManagerListener(self.manager)
     self.signals = self.listener.signals