Пример #1
0
    def _addFactory(self, factory):
        video = factory.getOutputStreams(VideoStream)
        if video and video[0].thumbnail:
            thumbnail_file = video[0].thumbnail
            try:
                self.debug("attempting to open thumbnail file '%s'",
                           thumbnail_file)
                pixbuf = gtk.gdk.pixbuf_new_from_file(thumbnail_file)
            except:
                self.error("Failure to create thumbnail from file '%s'",
                           thumbnail_file)
                thumbnail = self.videofilepixbuf
            else:
                desiredheight = int(64 / float(video[0].dar))
                thumbnail = pixbuf.scale_simple(64, desiredheight,
                                                gtk.gdk.INTERP_BILINEAR)
        else:
            if video:
                thumbnail = self.videofilepixbuf
            else:
                thumbnail = self.audiofilepixbuf

        if not factory.duration or factory.duration == gst.CLOCK_TIME_NONE:
            duration = ''
        else:
            duration = beautify_length(factory.duration)

        self.storemodel.append([
            thumbnail,
            beautify_factory(factory), factory, factory.uri, duration,
            factory_name(factory)
        ])
        self._displayTreeView()
Пример #2
0
    def _projectManagerMissingUriCb(self, instance, formatter, uri, factory):
        dialog = gtk.Dialog(_("Locate missing file..."),
            self,
            gtk.DIALOG_MODAL,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        dialog.set_icon_name("pitivi")
        dialog.set_border_width(SPACING * 2)
        dialog.get_content_area().set_spacing(SPACING)
        dialog.set_transient_for(self)

        # TODO: display the filesize to help the user identify the file
        if not factory.duration or factory.duration == gst.CLOCK_TIME_NONE:
            # The file is probably an image, not video or audio.
            text = _('The following file has moved: "<b>%s</b>"'
                     '\nPlease specify its new location:'
                     % factory_name(factory))
        else:
            length = beautify_length(factory.duration)
            text = _('The following file has moved: "<b>%s</b>" (duration: %s)'
                     '\nPlease specify its new location:'
                     % (factory_name(factory), length))

        label = gtk.Label()
        label.set_markup(text)
        dialog.get_content_area().pack_start(label, False, False)
        label.show()

        chooser = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_OPEN)
        chooser.set_select_multiple(False)
        pw = PreviewWidget(self.app)
        chooser.set_preview_widget(pw)
        chooser.set_use_preview_label(False)
        chooser.connect('update-preview', pw.add_preview_request)
        chooser.set_current_folder(self.settings.lastProjectFolder)
        dialog.get_content_area().pack_start(chooser, True, True)
        chooser.show()

        # If the window is too big, the window manager will resize it so that
        # it fits on the screen.
        dialog.set_default_size(1024, 1000)
        response = dialog.run()

        if response == gtk.RESPONSE_OK:
            self.log("User chose a new URI for the missing file")
            new = chooser.get_uri()
            if new:
                formatter.addMapping(uri, unquote(new))
                self._missingUriOnLoading = True
        else:
            self.log("User didn't choose a URI for the missing file")
            # FIXME: not calling addMapping doesn't keep the formatter from
            # re-emitting the same signal. How do we get out of this
            # situation?
            pass

        dialog.destroy()
Пример #3
0
    def _projectManagerMissingUriCb(self, instance, formatter, uri, factory):
        dialog = gtk.Dialog(_("Locate missing file..."),
            self,
            gtk.DIALOG_MODAL,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        dialog.set_icon_name("pitivi")
        dialog.set_border_width(SPACING * 2)
        dialog.get_content_area().set_spacing(SPACING)
        dialog.set_transient_for(self)

        # TODO: display the filesize to help the user identify the file
        if not factory.duration or factory.duration == gst.CLOCK_TIME_NONE:
            # The file is probably an image, not video or audio.
            text = _('The following file has moved: "<b>%s</b>"'
                     '\nPlease specify its new location:'
                     % factory_name(factory))
        else:
            length = beautify_length(factory.duration)
            text = _('The following file has moved: "<b>%s</b>" (duration: %s)'
                     '\nPlease specify its new location:'
                     % (factory_name(factory), length))

        label = gtk.Label()
        label.set_markup(text)
        dialog.get_content_area().pack_start(label, False, False)
        label.show()

        chooser = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_OPEN)
        chooser.set_select_multiple(False)
        pw = PreviewWidget(self.app)
        chooser.set_preview_widget(pw)
        chooser.set_use_preview_label(False)
        chooser.connect('update-preview', pw.add_preview_request)
        chooser.set_current_folder(self.settings.lastProjectFolder)
        dialog.get_content_area().pack_start(chooser, True, True)
        chooser.show()

        # If the window is too big, the window manager will resize it so that
        # it fits on the screen.
        dialog.set_default_size(1024, 1000)
        response = dialog.run()

        if response == gtk.RESPONSE_OK:
            self.log("User chose a new URI for the missing file")
            new = chooser.get_uri()
            if new:
                formatter.addMapping(uri, unquote(new))
                self._missingUriOnLoading = True
        else:
            self.log("User didn't choose a URI for the missing file")
            # FIXME: not calling addMapping doesn't keep the formatter from
            # re-emitting the same signal. How do we get out of this
            # situation?
            pass

        dialog.destroy()
Пример #4
0
 def _positionCb(self, unused_pipeline, position):
     self.debug("%r %r", unused_pipeline, position)
     timediff = time.time() - self.timestarted
     length = self.project.timeline.duration
     self.progressbar.set_fraction(float(min(position, length)) / float(length))
     if timediff > 5.0 and position:
         # only display ETA after 5s in order to have enough averaging and
         # if the position is non-null
         totaltime = (timediff * float(length) / float(position)) - timediff
         length = beautify_length(int(totaltime * gst.SECOND))
         if length:
             self.progressbar.set_text(_("About %s left") % length)
Пример #5
0
    def _addFactory(self, factory):
        video = factory.getOutputStreams(VideoStream)
        if video and video[0].thumbnail:
            thumbnail_file = video[0].thumbnail
            try:
                self.debug("attempting to open thumbnail file '%s'",
                        thumbnail_file)
                pixbuf = gtk.gdk.pixbuf_new_from_file(thumbnail_file)
            except:
                self.error("Failure to create thumbnail from file '%s'",
                        thumbnail_file)
                thumbnail = self.videofilepixbuf
                thumbnail_large = self.videofilepixbuf
            else:
                desiredheight = int(64 / float(video[0].dar))
                thumbnail = pixbuf.scale_simple(64,
                        desiredheight, gtk.gdk.INTERP_BILINEAR)
                desiredheight = int(96 / float(video[0].dar))
                thumbnail_large = pixbuf.scale_simple(96,
                        desiredheight, gtk.gdk.INTERP_BILINEAR)
        else:
            if video:
                thumbnail = self.videofilepixbuf
                thumbnail_large = self.videofilepixbuf
            else:
                thumbnail = self.audiofilepixbuf
                thumbnail_large = self.audiofilepixbuf

        if not factory.duration or factory.duration == gst.CLOCK_TIME_NONE:
            duration = ''
        else:
            duration = beautify_length(factory.duration)

        short_text = None
        uni = unicode(factory_name(factory), 'utf-8')

        if len(uni) > 34:
            short_uni = uni[0:29]
            short_uni += unicode('...')
            short_text = short_uni.encode('utf-8')
        else:
            short_text = factory_name(factory)

        self.storemodel.append([thumbnail,
            thumbnail_large,
            beautify_factory(factory),
            factory,
            factory.uri,
            duration,
            factory_name(factory),
            short_text])
        self._displayClipView()
Пример #6
0
 def _positionCb(self, unused_pipeline, position):
     self.debug("%r %r", unused_pipeline, position)
     fraction = None
     text = None
     timediff = time.time() - self.timestarted
     length = self.project.timeline.duration
     fraction = float(min(position, length)) / float(length)
     if timediff > 5.0 and position:
         # only display ETA after 5s in order to have enough averaging and
         # if the position is non-null
         totaltime = (timediff * float(length) / float(position)) - timediff
         text = beautify_length(int(totaltime * gst.SECOND))
     self.updatePosition(fraction, text)
Пример #7
0
 def _positionCb(self, unused_pipeline, position):
     self.debug("%r %r", unused_pipeline, position)
     timediff = time.time() - self.timestarted
     length = self.project.timeline.duration
     self.progressbar.set_fraction(
         float(min(position, length)) / float(length))
     if timediff > 5.0 and position:
         # only display ETA after 5s in order to have enough averaging and
         # if the position is non-null
         totaltime = (timediff * float(length) / float(position)) - timediff
         length = beautify_length(int(totaltime * gst.SECOND))
         if length:
             self.progressbar.set_text(_("About %s left") % length)
Пример #8
0
 def _positionCb(self, unused_pipeline, position):
     self.debug("%r %r", unused_pipeline, position)
     fraction = None
     text = None
     timediff = time.time() - self.timestarted
     length = self.project.timeline.duration
     fraction = float(min(position, length)) / float(length)
     if timediff > 5.0 and position:
         # only display ETA after 5s in order to have enough averaging and
         # if the position is non-null
         totaltime = (timediff * float(length) / float(position)) - timediff
         text = beautify_length(int(totaltime * gst.SECOND))
     self.updatePosition(fraction, text)
Пример #9
0
    def _addFactory(self, factory):
        video = factory.getOutputStreams(VideoStream)
        if video and video[0].thumbnail:
            thumbnail_file = video[0].thumbnail
            try:
                self.debug("attempting to open thumbnail file '%s'",
                           thumbnail_file)
                pixbuf = gtk.gdk.pixbuf_new_from_file(thumbnail_file)
            except:
                self.error("Failure to create thumbnail from file '%s'",
                           thumbnail_file)
                thumbnail = self.videofilepixbuf
                thumbnail_large = self.videofilepixbuf
            else:
                desiredheight = int(64 / float(video[0].dar))
                thumbnail = pixbuf.scale_simple(64, desiredheight,
                                                gtk.gdk.INTERP_BILINEAR)
                desiredheight = int(96 / float(video[0].dar))
                thumbnail_large = pixbuf.scale_simple(96, desiredheight,
                                                      gtk.gdk.INTERP_BILINEAR)
        else:
            if video:
                thumbnail = self.videofilepixbuf
                thumbnail_large = self.videofilepixbuf
            else:
                thumbnail = self.audiofilepixbuf
                thumbnail_large = self.audiofilepixbuf

        if not factory.duration or factory.duration == gst.CLOCK_TIME_NONE:
            duration = ''
        else:
            duration = beautify_length(factory.duration)

        short_text = None
        uni = unicode(factory_name(factory), 'utf-8')

        if len(uni) > 34:
            short_uni = uni[0:29]
            short_uni += unicode('...')
            short_text = short_uni.encode('utf-8')
        else:
            short_text = factory_name(factory)

        self.storemodel.append([
            thumbnail, thumbnail_large,
            beautify_factory(factory), factory, factory.uri, duration,
            factory_name(factory), short_text
        ])
        self._displayClipView()
Пример #10
0
 def _progressCb(self, current, total) :
     current = float(current)
     total = float(total)
     fraction = (current/total)
     self._progressBar.set_fraction(fraction)
     timediff = time.time() - self.timestarted
     if timediff > 7.0 and self.count % 100 == 0:
         speed = (current-self.previous_current)/(timediff-self.previous_timediff)
         remaining_time = (total-current) / speed
         self.builder.get_object("window1").set_title("%.0f%% downloaded at %.0f Kbps" % (fraction*100, speed/1000))
         text = beautify_length(int(remaining_time * gst.SECOND))
         self._progressBar.set_text("About %s left" % text)
     if self.count == 400:
         self.previous_current = current
         self.previous_timediff = timediff
         self.count = 0
     self.count += 1
Пример #11
0
    def _projectManagerMissingUriCb(self, instance, formatter, uri, factory):
        dialog = gtk.Dialog(_("Locate missing file..."),
                            self,
                            gtk.DIALOG_MODAL,
                            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                     gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        dialog.set_icon_name("pitivi")
        dialog.set_border_width(12)
        dialog.get_content_area().set_spacing(6)

        text = _("The following file has moved," +
            " please tell PiTiVi where to find it.") + "\n\n" + \
            beautify_factory(factory) + "\n" +\
            _("<b>Duration:</b>") + beautify_length(factory.duration)

        label = gtk.Label()
        label.set_markup(text)
        label.set_justify(gtk.JUSTIFY_CENTER)
        dialog.get_content_area().pack_start(label, False, False)
        label.show()

        chooser = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_OPEN)
        chooser.set_select_multiple(False)
        chooser.set_current_folder(self.settings.lastProjectFolder)
        dialog.get_content_area().pack_start(chooser, True, True)
        chooser.show()

        dialog.set_size_request(640, 480)
        response = dialog.run()

        if response == gtk.RESPONSE_OK:
            self.log("User chose a URI to save project to")
            new = chooser.get_uri()
            if new:
                formatter.addMapping(uri, unquote(new))
        else:
            self.log("User didn't choose a URI to save project to")
            # FIXME: not calling addMapping doesn't keep the formatter from
            # re-emitting the same signal. How do we get out of this
            # situation?
            pass

        dialog.destroy()
Пример #12
0
    def _projectManagerMissingUriCb(self, instance, formatter, uri, factory):
        dialog = gtk.Dialog(_("Locate missing file..."),
            self,
            gtk.DIALOG_MODAL,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        dialog.set_icon_name("pitivi")
        dialog.set_border_width(12)
        dialog.get_content_area().set_spacing(6)

        text = _("The following file has moved, please tell PiTiVi where to find it.") + \
            "\n\n" + beautify_factory(factory) + "\n" + \
            "<b>%s</b>" % _("Duration:") + beautify_length(factory.duration)

        label = gtk.Label()
        label.set_markup(text)
        label.set_justify(gtk.JUSTIFY_CENTER)
        dialog.get_content_area().pack_start(label, False, False)
        label.show()

        chooser = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_OPEN)
        chooser.set_select_multiple(False)
        chooser.set_current_folder(self.settings.lastProjectFolder)
        dialog.get_content_area().pack_start(chooser, True, True)
        chooser.show()

        dialog.set_size_request(640, 480)
        response = dialog.run()

        if response == gtk.RESPONSE_OK:
            self.log("User chose a URI to save project to")
            new = chooser.get_uri()
            if new:
                formatter.addMapping(uri, unquote(new))
                self._missingUriOnLoading = True
        else:
            self.log("User didn't choose a URI to save project to")
            # FIXME: not calling addMapping doesn't keep the formatter from
            # re-emitting the same signal. How do we get out of this
            # situation?
            pass

        dialog.destroy()
Пример #13
0
 def testBeautifyHoursAndMinutes(self):
     self.failUnlessEqual(beautify_length(hour + minute + second),
                          "1 hour, 1 minute")
Пример #14
0
 def testBeautifyHoursAndMinutes(self):
     self.failUnlessEqual(beautify_length(hour + minute + second),
             "1 hour, 1 minute")
Пример #15
0
 def testBeautifyMinutesAndSeconds(self):
     self.failUnlessEqual(beautify_length(minute + second),
             "1 minute, 1 second")
Пример #16
0
 def testBeautifyHours(self):
     self.failUnlessEqual(beautify_length(hour), "1 hour")
     self.failUnlessEqual(beautify_length(hour * 2), "2 hours")
Пример #17
0
 def testBeautifyMinutes(self):
     self.failUnlessEqual(beautify_length(minute), "1 minute")
     self.failUnlessEqual(beautify_length(minute * 2), "2 minutes")
Пример #18
0
 def testBeautifySeconds(self):
     self.failUnlessEqual(beautify_length(second), "1 second")
     self.failUnlessEqual(beautify_length(second * 2), "2 seconds")
Пример #19
0
 def show_preview(self, uri):
     self.log("Show preview for " + uri)
     factory = self.preview_cache.get(uri, None)
     if factory is None:
         self.log("No preview for " + uri)
         return
     if not factory.duration or factory.duration == gst.CLOCK_TIME_NONE:
         duration = ''
     else:
         duration = beautify_length(factory.duration)
     video = factory.getOutputStreams(VideoStream)
     if video:
         video = video[0]
         if type(factory) == PictureFileSourceFactory:
             self.current_preview_type = 'image'
             self.preview_video.hide()
             pixbuf = gtk.gdk.pixbuf_new_from_file(gst.uri_get_location(uri))
             pixbuf_w = pixbuf.get_width()
             pixbuf_h = pixbuf.get_height()
             w, h = self.__get_best_size(pixbuf_w, pixbuf_h)
             pixbuf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_NEAREST)
             self.preview_image.set_from_pixbuf(pixbuf)
             self.preview_image.set_size_request(self.settings.FCpreviewWidth, self.settings.FCpreviewHeight)
             self.preview_image.show()
             self.bbox.show()
             self.play_button.hide()
             self.seeker.hide()
             self.b_zoom_in.show()
             self.b_zoom_out.show()
         else:
             self.current_preview_type = 'video'
             self.preview_image.hide()
             self.player.set_property("video-sink", self.__videosink)
             self.player.set_property("uri", self.current_selected_uri)
             self.player.set_state(gst.STATE_PAUSED)
             self.clip_duration = factory.duration
             self.pos_adj.upper = self.clip_duration
             w, h = self.__get_best_size(video.par * video.width, video.height)
             self.preview_video.set_size_request(w, h)
             self.preview_video.show()
             self.bbox.show()
             self.play_button.show()
             self.seeker.show()
             self.b_zoom_in.show()
             self.b_zoom_out.show()
             self.description = _(u"<b>Resolution</b>: %d×%d") % \
                 (video.par * video.width, video.height) + "\n" + \
                 _("<b>Duration</b>: %s") % duration + "\n"
     else:
         self.current_preview_type = 'audio'
         self.preview_video.hide()
         audio = factory.getOutputStreams(AudioStream)
         audio = audio[0]
         self.clip_duration = factory.duration
         self.pos_adj.upper = self.clip_duration
         self.preview_image.set_from_file(DEFAULT_AUDIO_IMAGE)
         self.preview_image.show()
         self.preview_image.set_size_request(PREVIEW_WIDTH, PREVIEW_HEIGHT)
         self.description = beautify_stream(audio) + "\n" + \
             _("<b>Duration</b>: %s") % duration + "\n"
         self.player.set_state(gst.STATE_NULL)
         self.player.set_property("uri", self.current_selected_uri)
         self.player.set_property("video-sink", self.__fakesink)
         self.player.set_state(gst.STATE_PAUSED)
         self.play_button.show()
         self.seeker.show()
         self.b_zoom_in.hide()
         self.b_zoom_out.hide()
         self.bbox.show()
Пример #20
0
 def testBeautifySeconds(self):
     self.failUnlessEqual(beautify_length(second), "1 second")
     self.failUnlessEqual(beautify_length(second * 2), "2 seconds")
Пример #21
0
 def show_preview(self, uri):
     self.log("Show preview for " + uri)
     factory = self.preview_cache.get(uri, None)
     if factory is None:
         self.log("No preview for " + uri)
         return
     if not factory.duration or factory.duration == gst.CLOCK_TIME_NONE:
         duration = ''
     else:
         duration = beautify_length(factory.duration)
     video = factory.getOutputStreams(VideoStream)
     if video:
         video = video[0]
         if type(factory) == PictureFileSourceFactory:
             self.current_preview_type = 'image'
             self.preview_video.hide()
             pixbuf = gtk.gdk.pixbuf_new_from_file(
                 gst.uri_get_location(uri))
             pixbuf_w = pixbuf.get_width()
             pixbuf_h = pixbuf.get_height()
             w, h = self.__get_best_size(pixbuf_w, pixbuf_h)
             pixbuf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_NEAREST)
             self.preview_image.set_from_pixbuf(pixbuf)
             self.preview_image.set_size_request(
                 self.settings.FCpreviewWidth,
                 self.settings.FCpreviewHeight)
             self.preview_image.show()
             self.bbox.show()
             self.play_button.hide()
             self.seeker.hide()
             self.b_zoom_in.show()
             self.b_zoom_out.show()
         else:
             self.current_preview_type = 'video'
             self.preview_image.hide()
             self.player.set_property("video-sink", self.__videosink)
             self.player.set_property("uri", self.current_selected_uri)
             self.player.set_state(gst.STATE_PAUSED)
             self.clip_duration = factory.duration
             self.pos_adj.upper = self.clip_duration
             w, h = self.__get_best_size(video.par * video.width,
                                         video.height)
             self.preview_video.set_size_request(w, h)
             self.preview_video.show()
             self.bbox.show()
             self.play_button.show()
             self.seeker.show()
             self.b_zoom_in.show()
             self.b_zoom_out.show()
             self.description = _(u"<b>Resolution</b>: %d×%d") % \
                 (video.par * video.width, video.height) + "\n" + \
                 _("<b>Duration</b>: %s") % duration + "\n"
     else:
         self.current_preview_type = 'audio'
         self.preview_video.hide()
         audio = factory.getOutputStreams(AudioStream)
         audio = audio[0]
         self.clip_duration = factory.duration
         self.pos_adj.upper = self.clip_duration
         self.preview_image.set_from_file(DEFAULT_AUDIO_IMAGE)
         self.preview_image.show()
         self.preview_image.set_size_request(PREVIEW_WIDTH, PREVIEW_HEIGHT)
         self.description = beautify_stream(audio) + "\n" + \
             _("<b>Duration</b>: %s") % duration + "\n"
         self.player.set_state(gst.STATE_NULL)
         self.player.set_property("uri", self.current_selected_uri)
         self.player.set_property("video-sink", self.__fakesink)
         self.player.set_state(gst.STATE_PAUSED)
         self.play_button.show()
         self.seeker.show()
         self.b_zoom_in.hide()
         self.b_zoom_out.hide()
         self.bbox.show()
Пример #22
0
 def testBeautifyMinutes(self):
     self.failUnlessEqual(beautify_length(minute), "1 minute")
     self.failUnlessEqual(beautify_length(minute * 2), "2 minutes")
Пример #23
0
 def testBeautifyHours(self):
     self.failUnlessEqual(beautify_length(hour), "1 hour")
     self.failUnlessEqual(beautify_length(hour * 2), "2 hours")
Пример #24
0
 def testBeautifyMinutesAndSeconds(self):
     self.failUnlessEqual(beautify_length(minute + second),
                          "1 minute, 1 second")