예제 #1
0
파일: tts.py 프로젝트: eamexicano/advene
 def parse_parameter(self, context, parameters, name, default_value):
     """Helper method used in actions.
     """
     if name in parameters:
         try:
             result=context.evaluateValue(parameters[name])
         except advene.model.tal.context.AdveneTalesException, e:
             try:
                 rulename=context.evaluateValue('rule')
             except advene.model.tal.context.AdveneTalesException:
                 rulename=_("Unknown rule")
             self.controller.log(_("Rule %(rulename)s: Error in the evaluation of the parameter %(parametername)s:") % {'rulename': rulename,
                                                                                                                       'parametername': name})
             self.controller.log(unicode(e.message)[:160])
             result=default_value
예제 #2
0
 def parse_parameter(self, context, parameters, name, default_value):
     """Helper method used in actions.
     """
     if name in parameters:
         try:
             result=context.evaluateValue(parameters[name])
         except advene.model.tal.context.AdveneTalesException, e:
             try:
                 rulename=context.evaluateValue('rule')
             except advene.model.tal.context.AdveneTalesException:
                 rulename=_("Unknown rule")
             self.controller.log(_("Rule %(rulename)s: Error in the evaluation of the parameter %(parametername)s:") % {'rulename': rulename,
                                                                                                                       'parametername': name})
             self.controller.log(unicode(e)[:160])
             result=default_value
예제 #3
0
 def _find_named_view (self, view_id, context):
     res=None
     try:
         path =('view/ownerPackage/views/%s | '
               +'here/ownerPackage/views/%s') % (view_id, view_id)
         res=context.evaluateValue (path)
     except AdveneException:
         pass
     return res
예제 #4
0
 def _find_named_view (self, view_id, context):
     res=None
     try:
         path =('view/ownerPackage/views/%s | '
               +'here/ownerPackage/views/%s') % (view_id, view_id)
         res=context.evaluateValue (path)
     except AdveneException:
         pass
     return res
예제 #5
0
    def action_popup_goto_outgoing_related(self, context, parameters):
        """PopupGotoOutgoingRelated action.

        Displays a popup proposing to navigate to related outgoing annotations.
        """
        def handle_response(button, position, widget):
            self.controller.update_status("seek", position)
            self.gui.popupwidget.undisplay(widget)
            return True

        annotation = context.evaluateValue('annotation')
        if annotation is None:
            return True
        relations = annotation.outgoingRelations
        if not relations:
            return True

        message = self.parse_parameter(
            context, parameters, 'message',
            _("Choose the related annotation you want to visualise."))
        message = message.replace('\\n', '\n')
        message = textwrap.fill(
            message, config.data.preferences['gui']['popup-textwidth'])

        vbox = Gtk.VBox()

        vbox.pack_start(self.gui.get_illustrated_text(message), False, False,
                        0)

        for r in relations:
            a = r.members[-1]
            b = Gtk.Button()
            t = ''
            if r.content.data:
                t = ' (%s)' % r.content.data
            c = _(
                "Through %(title)s%(relation_content)s:\n%(annotation_content)s"
            ) % {
                'title': self.controller.get_title(r.type),
                'relation_content': t,
                'annotation_content': self.controller.get_title(a)
            }
            b.add(self.gui.get_illustrated_text(c, a.fragment.begin))
            vbox.pack_start(b, False, True, 0)
            b.connect('clicked', handle_response, a.fragment.begin, vbox)

        self.gui.popupwidget.display(widget=vbox,
                                     timeout=annotation.fragment.duration,
                                     title=_("Relation navigation"))
        return True
예제 #6
0
    def action_popup_goto_outgoing_related (self, context, parameters):
        """PopupGotoOutgoingRelated action.

        Displays a popup proposing to navigate to related outgoing annotations.
        """
        def handle_response(button, position, widget):
            self.controller.update_status("set", position)
            self.gui.popupwidget.undisplay(widget)
            return True

        annotation=context.evaluateValue('annotation')
        if annotation is None:
            return True
        relations=annotation.outgoingRelations
        if not relations:
            return True

        message=self.parse_parameter(context, parameters, 'message', _("Choose the related annotation you want to visualise."))
        message=message.replace('\\n', '\n')
        message=textwrap.fill(message, config.data.preferences['gui']['popup-textwidth'])

        vbox=gtk.VBox()

        vbox.pack_start(self.gui.get_illustrated_text(message), expand=False)

        for r in relations:
            a=r.members[-1]
            b=gtk.Button()
            t=''
            if r.content.data:
                t=' (%s)' % r.content.data
            c=_("Through %(title)s%(relation_content)s:\n%(annotation_content)s") % {
                'title': self.controller.get_title(r.type),
                'relation_content': t,
                'annotation_content': self.controller.get_title(a) }
            b.add(self.gui.get_illustrated_text(c, a.fragment.begin))
            vbox.pack_start(b, expand=False)
            b.connect('clicked', handle_response, a.fragment.begin, vbox)

        self.gui.popupwidget.display(widget=vbox, timeout=annotation.fragment.duration, title=_("Relation navigation"))
        return True