Example #1
0
    def initialize(self):
        site = getSite()
        self.settings = Settings(self.context)
        self.global_settings = GlobalSettings(site)

        utils = getToolByName(self.context, 'plone_utils')
        msg = None

        if self.context.getContentType() in ('application/pdf',
                                             'application/x-pdf', 'image/pdf'):
            if not self.installed:
                msg = "Since you do not have swftools installed on this " + \
                      "system, we can not render the pages of this PDF."
            elif self.settings.converting is not None and \
                    self.settings.converting:
                msg = "The PDF is currently being converted to the " + \
                      "FlexPaper view..."
                self.enabled = False
            elif not self.settings.successfully_converted:
                msg = "There was an error trying to convert the PDF. Maybe " +\
                      "the PDF is encrypted, corrupt or malformed?"
                self.enabled = False
        else:
            self.enabled = False
            msg = "The file is not a PDF. No need for this view."

        if msg:
            mtool = getToolByName(self.context, 'portal_membership')
            if mtool.checkPermission('cmf.ModifyPortalContent', self.context):
                utils.addPortalMessage(msg)
Example #2
0
def convert(context):
    """
    Convert PDF to Flex Paper
    """

    settings = Settings(context)
    site = getSite()
    global_settings = GlobalSettings(site)

    if DateTime(settings.last_updated) < DateTime(context.ModificationDate()):
        context = aq_inner(context)
        field = context.getField('file') or context.getPrimaryField()

        import transaction
        # commit anything done before the expensive operation
        transaction.commit()
        try:
            s_options = settings.command_line_options and \
                settings.command_line_options or \
                global_settings.command_line_options
            if s_options:
                opts = [
                    o.strip().replace(' ', '').replace('\t', '')
                    for o in s_options.split(',')
                ]
            else:
                opts = []
            result = pdf2swf.convert(str(field.get(context).data),
                                     opts,
                                     password=settings.encryption_password)
            transaction.begin()
            if has_pab:
                blob = Blob()
                bfile = blob.open('w')
                bfile.write(result)
                bfile.close()
                settings.data = blob
            else:
                file = BaseUnit('_converted_file',
                                result,
                                mimetype='application/x-shockwave-flash',
                                filename=context.getFilename().replace(
                                    '.pdf', '.swf'),
                                context=context)
                converted_field.set(context, file, _initializing_=True)
            settings.successfully_converted = True
        except:
            logger.exception('Error converting PDF')
            settings.successfully_converted = False
        settings.last_updated = DateTime().ISO8601()
        settings.converting = False
        transaction.commit()
from configure import get_pixmap_dir
from loggable import Loggable
from misc import uri_is_valid
from ui import beautify_length, beautify_stream,\
    SPACING

from viewer import ViewerWidget
from settings import GlobalSettings

DEFAULT_AUDIO_IMAGE = os.path.join(get_pixmap_dir(), "pitivi-sound.png")

PREVIEW_WIDTH = 250
PREVIEW_HEIGHT = 100

GlobalSettings.addConfigSection('filechooser-preview')
GlobalSettings.addConfigOption('FCEnablePreview',
    section='filechooser-preview',
    key='do-preview-on-clip-import',
    default=True)
GlobalSettings.addConfigOption('FCpreviewWidth',
    section='filechooser-preview',
    key='video-preview-width',
    default=PREVIEW_WIDTH)
GlobalSettings.addConfigOption('FCpreviewHeight',
    section='filechooser-preview',
    key='video-preview-height',
    default=PREVIEW_HEIGHT)


class PreviewWidget(gtk.VBox, Loggable):
Example #4
0
import gobject
import gtk
import gst
import cairo

from gettext import gettext as _
from time import time
from math import pi

from settings import GlobalSettings
from pipeline import Seeker, SimplePipeline
from ui import SPACING, hex_to_rgb
from widgets import TimeWidget
from loggable import Loggable

GlobalSettings.addConfigSection("viewer")
GlobalSettings.addConfigOption("viewerDocked", section="viewer", key="docked", default=True)
GlobalSettings.addConfigOption("viewerWidth", section="viewer", key="width", default=320)
GlobalSettings.addConfigOption("viewerHeight", section="viewer", key="height", default=240)
GlobalSettings.addConfigOption("viewerX", section="viewer", key="x-pos", default=0)
GlobalSettings.addConfigOption("viewerY", section="viewer", key="y-pos", default=0)
GlobalSettings.addConfigOption("pointSize", section="viewer", key="point-size", default=25)
GlobalSettings.addConfigOption("clickedPointColor", section="viewer", key="clicked-point-color", default="ffa854")
GlobalSettings.addConfigOption("pointColor", section="viewer", key="point-color", default="49a0e0")


class PitiviViewer(gtk.VBox, Loggable):
    """
    A Widget to control and visualize a Pipeline

    @ivar pipeline: The current pipeline