Esempio n. 1
0
    def __init__ (self, controller=None, parameters=None, filename=None):
        super(TranscriptionEdit, self).__init__(controller=controller)
        self.close_on_package_load = False
        self.contextual_actions = (
            (_("Save view"), self.save_view),
            (_("Save default options"), self.save_default_options),
            (_("Export as static view"), lambda v, t: self.export_as_static_view()),
            )

        self.controller=controller
        self.package=controller.package

        self.sourcefile=None
        self.empty_re = re.compile('^\s*$')

        # When importing existing annotations, memorize their type so
        # that we can propose it by default when exporting again.
        self.imported_type=None

        self.options = {
            'timestamp': True, # _("If checked, click inserts timestamp marks"))
            'play-on-scroll': False,
            'empty-annotations': True, # _("Do not generate annotations for empty text"))
            'delay': config.data.reaction_time,
            # Marks will be automatically inserted it no keypress occurred in the 3 previous seconds.
            'automatic-mark-insertion-delay': 1500,
            'insert-on-single-click': False,
            'autoscroll': True,
            'autoinsert': True,
            'snapshot-size': 32,
            'font-size': 0,
            }

        self.colors = {
            'default': name2color('lightblue'),
            'ignore':  name2color('tomato'),
            'current': name2color('green'),
            }

        self.marks = []

        self.current_mark = None

        opt, arg = self.load_parameters(parameters)
        self.options.update(opt)

        self.button_height=20

        # When modifying an offset with Control+Scroll, store the last value.
        # If play-on-scroll, then set the destination upon Control release
        self.timestamp_play = None

        self.widget=self.build_widget()
        self.update_font_size()
        if filename is not None:
            self.load_transcription(filename=filename)
        for n, v in arg:
            if n == 'text':
                self.load_transcription(buffer=urllib.unquote_plus(v))
Esempio n. 2
0
    def __init__ (self, controller=None, parameters=None, filename=None):
        super(TranscriptionEdit, self).__init__(controller=controller)
        self.close_on_package_load = False
        self.contextual_actions = (
            (_("Save view"), self.save_view),
            (_("Save default options"), self.save_default_options),
            )

        self.controller=controller
        self.package=controller.package

        self.sourcefile=None
        self.empty_re = re.compile('^\s*$')

        self.options = {
            'timestamp': True, # _("If checked, click inserts timestamp marks"))
            'play-on-scroll': False,
            'empty-annotations': True, # _("Do not generate annotations for empty text"))
            'delay': config.data.reaction_time,
            # Marks will be automatically inserted it no keypress occurred in the 3 previous seconds.
            'automatic-mark-insertion-delay': 1500,
            'insert-on-double-click': True,
            'insert-on-single-click': False,
            'mark-prefix': "",
            'mark-suffix': "",
            'autoscroll': True,
            'autoinsert': True,
            'snapshot-size': 32,
            'font-size': 0,
            'annotation-type-id': None,
            }

        self.colors = {
            'default': name2color('lightblue'),
            'ignore':  name2color('tomato'),
            'current': name2color('green'),
            }

        self.marks = []

        self.current_mark = None

        opt, arg = self.load_parameters(parameters)
        self.options.update(opt)

        self.button_height=20

        # When modifying an offset with Control+Scroll, store the last value.
        # If play-on-scroll, then set the destination upon Control release
        self.timestamp_play = None

        self.widget=self.build_widget()
        self.update_font_size()
        if filename is not None:
            self.load_transcription(filename=filename)
        for n, v in arg:
            if n == 'text':
                self.load_transcription(buffer=v)
Esempio n. 3
0
 def refresh(self, *p, **kw):
     def display_popup(widget, event, element):
         if event.button == 3:
             menu = advene.gui.popup.Menu(element, controller=self.controller)
             menu.popup()
             return True
         return False
     g=self.controller.gui
     for (w, elements) in ( (self.created, g.last_created),
                            (self.edited, g.last_edited) ):
         w.foreach(w.remove)
         for e in reversed(elements):
             b=gtk.Button("\n".join((helper.get_type(e), self.controller.get_title(e))), use_underline=False)
             b.set_alignment(0, 0)
             colorname=self.controller.get_element_color(e)
             if colorname:
                 if config.data.os == 'win32':
                     text=b.get_label()
                     b.foreach(b.remove)
                     l=gtk.Label()
                     l.set_markup('<span background="%s">%s</span>' % (colorname, text))
                     l.show()
                     b.add(l)
                 else:
                     style = b.modify_bg(gtk.STATE_NORMAL, name2color(colorname))
             b.connect('clicked', (lambda i, el: self.controller.gui.edit_element(el)),
                       e)
             content=getattr(e, 'content', None)
             if content:
                 b.set_tooltip_text(content.data)
             enable_drag_source(b, e, self.controller)
             b.connect('button-press-event', display_popup, e)
             w.pack_start(b, expand=False)
     self.widget.show_all()
     return True
Esempio n. 4
0
    def __init__(self,
                 controller=None,
                 autohide=False,
                 size=3,
                 vertical=False,
                 scrollable=False,
                 parameters=None):
        super(AccumulatorPopup, self).__init__(controller=controller)

        self.close_on_package_load = False

        self.size = size
        self.controller = controller
        # Hide the window if there is no widget
        self.autohide = autohide
        self.vertical = vertical
        self.scrollable = scrollable

        self.new_color = name2color('tomato')
        self.old_color = gtk.Button().get_style().bg[0]

        # List of tuples (widget, hidetime, frame)
        self.widgets = []
        # Lock on self.widgets
        self.lock = DummyLock()

        # FIXME: find a way to make AdhocView.close() convert to hide()
        self.widget = self.build_widget()
Esempio n. 5
0
 def get_element_color(self, tag):
     """Return the gtk color for the given tag.
     Return None if no color is defined.
     """
     try:
         col=self.controller.package._tag_colors[tag]
     except KeyError:
         col=None
     return name2color(col)
Esempio n. 6
0
 def get_element_color(self, tag):
     """Return the gtk color for the given tag.
     Return None if no color is defined.
     """
     try:
         col = self.controller.package._tag_colors[tag]
     except KeyError:
         col = None
     return name2color(col)
Esempio n. 7
0
    def __init__(self, package=None, controller=None):
        self.view_name = _("Relations view")
        self.view_id = 'relationview'
        self.close_on_package_load = True

        self.package = package
        self.controller = controller
        self.relationviews = []
        self.active_color = name2color('red')
        self.inactive_color = gtk.Button().get_style().bg[0]
        self.widget = self.build_widget()
Esempio n. 8
0
    def __init__(self, package=None, controller=None):
        self.view_name = _("Relations view")
        self.view_id = "relationview"
        self.close_on_package_load = True

        self.package = package
        self.controller = controller
        self.relationviews = []
        self.active_color = name2color("red")
        self.inactive_color = gtk.Button().get_style().bg[0]
        self.widget = self.build_widget()
Esempio n. 9
0
    def __init__ (self, controller=None, autohide=False, size=3,
                  vertical=False, scrollable=False, parameters=None):
        super(AccumulatorPopup, self).__init__(controller=controller)

        self.close_on_package_load = False

        self.size=size
        self.controller=controller
        # Hide the window if there is no widget
        self.autohide = autohide
        self.vertical=vertical
        self.scrollable=scrollable

        self.new_color = name2color('tomato')
        # List of tuples (widget, hidetime, frame)
        self.widgets=[]
        # Lock on self.widgets
        self.lock=DummyLock()

        # FIXME: find a way to make AdhocView.close() convert to hide()
        self.widget=self.build_widget()
Esempio n. 10
0
    import rsvg
except ImportError:
    import advene.util.ctypesrsvg as rsvg

# Advene part
import advene.core.config as config
from advene.core.imagecache import ImageCache

from advene.gui.util import png_to_pixbuf, enable_drag_source, name2color
from advene.gui.util import get_color_style
import advene.util.helper as helper
from libadvene.model.cam.annotation import Annotation

import advene.gui.popup

active_color=name2color('#fdfd4b')

class GenericColorButtonWidget(gtk.DrawingArea):
    """ Widget emulating a color button widget
    """
    def __init__(self, element=None, container=None):
        gtk.DrawingArea.__init__(self)
        self.set_flags(self.flags() | gtk.CAN_FOCUS)
        self.element=element

        # If not None, it should contain a gtk.gdk.Color
        # which will override the normal color
        self.local_color=None
        # Alpha will be used to draw features
        self.alpha=1.0
        # expose_alpha will be used when rendering the surface on the widget
Esempio n. 11
0
try:
    import rsvg
except ImportError:
    import advene.util.ctypesrsvg as rsvg

# Advene part
import advene.core.config as config
from advene.core.imagecache import ImageCache

from advene.gui.util import png_to_pixbuf, enable_drag_source, name2color
from advene.gui.util import get_color_style
import advene.util.helper as helper
from advene.model.annotation import Annotation
import advene.gui.popup

active_color=name2color('#fdfd4b')

class GenericColorButtonWidget(gtk.DrawingArea):
    """ Widget emulating a color button widget
    """
    def __init__(self, element=None, container=None):
        gtk.DrawingArea.__init__(self)
        self.set_flags(self.flags() | gtk.CAN_FOCUS)
        self.element=element

        # If not None, it should contain a gtk.gdk.Color
        # which will override the normal color
        self.local_color=None
        # Alpha will be used to draw features
        self.alpha=1.0
        # expose_alpha will be used when rendering the surface on the widget
Esempio n. 12
0
    def __init__(self, controller=None, elements=None, parameters=None):
        super(Montage, self).__init__(controller=controller)
        self.close_on_package_load = False
        self.contextual_actions = (
            (_("Save view"), self.save_view),
            (_("Clear"), self.clear),
            (_("Play"), self.play),
            (_("Render"), self.render),
        )
        self.options = {}
        self.controller = controller

        def scale_event(*p):
            self.refresh()
            return True

        # How many units (ms) does a pixel represent ?
        # How many units does a pixel represent ?
        # self.scale.get_value() = unit by pixel
        # Unit = ms
        self.scale = Gtk.Adjustment.new(
            int((self.controller.package.cached_duration or 60 * 60 * 1000) /
                Gdk.get_default_root_window().get_width()), 5, 36000, 5, 1000,
            100)
        self.scale.connect('value-changed', scale_event)

        opt, arg = self.load_parameters(parameters)
        self.options.update(opt)
        if elements is None:
            elements = []
            # Get args
            for n, v in arg:
                if n == 'id':
                    try:
                        a = self.controller.package.get_element_by_id(v)
                    except KeyError:
                        # FIXME: should we silently pass, or display missing ids ?
                        pass
                    elements.append(a)

        # Needed by AnnotationWidget
        self.button_height = 20
        self.active_color = name2color('#fdfd4b')

        self.master_view = None

        # In self.contents, we store the AnnotationWidgets We do not
        # store directly the annotations, since there may be multiple
        # occurrences of the same annotations, and we need to
        # differenciate them.
        self.contents = []
        self.duration = 0

        self.mainbox = None
        self.widget = self.build_widget()

        # Annotation widget currently played
        self.current_widget = None

        if elements is not None:
            # Fill with default values
            for a in elements:
                self.insert(a)
        self.refresh()
Esempio n. 13
0
 def get_element_color(self, element):
     """Return the gtk color for the given element.
     Return None if no color is defined.
     """
     color = self.controller.get_element_color(element)
     return name2color(color)
Esempio n. 14
0
    def __init__(self, controller=None, elements=None, parameters=None):
        super(Montage, self).__init__(controller=controller)
        self.close_on_package_load = False
        self.contextual_actions = (
            (_("Save view"), self.save_view),
            (_("Clear"), self.clear),
            (_("Play"), self.play),
            (_("Render"), self.render),
            )
        self.options={
            }
        self.controller=controller

        def scale_event(*p):
            self.refresh()
            return True

        # How many units (ms) does a pixel represent ?
        # How many units does a pixel represent ?
        # self.scale.value = unit by pixel
        # Unit = ms
        self.scale = gtk.Adjustment (value=(self.controller.package.cached_duration or 60*60*1000) / gtk.gdk.get_default_root_window().get_size()[0],
                                     lower=5,
                                     upper=36000,
                                     step_incr=5,
                                     page_incr=1000)
        self.scale.connect('value-changed', scale_event)

        opt, arg = self.load_parameters(parameters)
        self.options.update(opt)
        if elements is None:
            elements=[]
            # Get args
            for n, v in arg:
                if n == 'id':
                    try:
                        a=self.controller.package.get_element_by_id(v)
                    except KeyError:
                        # FIXME: should we silently pass, or display missing ids ?
                        pass
                    elements.append(a)

        # Needed by AnnotationWidget
        self.button_height = 20
        self.active_color=name2color('#fdfd4b')

        self.master_view=None

        # In self.contents, we store the AnnotationWidgets We do not
        # store directly the annotations, since there may be multiple
        # occurrences of the same annotations, and we need to
        # differenciate them.
        self.contents=[]
        self.duration=0

        self.mainbox=None
        self.widget=self.build_widget()

        # Annotation widget currently played
        self.current_widget = None

        if elements is not None:
            # Fill with default values
            for a in elements:
                self.insert(a)
        self.refresh()
Esempio n. 15
0
 def get_element_color(self, element):
     """Return the gtk color for the given element.
     Return None if no color is defined.
     """
     color=self.controller.get_element_color(element)
     return name2color(color)