def edit_options(self, *p): cache = dict(self.options) ew = EditWidget(cache.__setitem__, cache.get) ew.set_name(_("Tag bag options")) ew.add_checkbox(_("Update with new tags"), "display-new-tags", _("Automatically display new defined tags")) res = ew.popup() if res: self.options.update(cache) return True
def edit_options(self, *p): cache=dict(self.options) ew=EditWidget(cache.__setitem__, cache.get) ew.set_name(_("Tag bag options")) ew.add_checkbox(_("Update with new tags"), "display-new-tags", _("Automatically display new defined tags")) res=ew.popup() if res: self.options.update(cache) return True
def build_widget(self): el = self.node.element vbox = Gtk.VBox() info = Gtk.TextView() info.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) def set_text(widget, t): b = widget.get_buffer() b.delete(*b.get_bounds()) b.set_text(t) b.set_modified(False) return True info.set_text = set_text.__get__(info) sw = Gtk.ScrolledWindow() sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) if isinstance(el, Package): info.set_text( _("""Package %(title)s: %(schema)s %(annotation)s in %(annotation_type)s %(relation)s in %(relation_type)s %(query)s %(view)s Description: %(description)s Annotation statistics: %(statistics)s """) % { 'title': el.title, 'schema': helper.format_element_name('schema', len(el.schemas)), 'annotation': helper.format_element_name('annotation', len( el.annotations)), 'annotation_type': helper.format_element_name('annotation_type', len(el.annotationTypes)), 'relation': helper.format_element_name('relation', len(el.relations)), 'relation_type': helper.format_element_name('relation_type', len(el.relationTypes)), 'query': helper.format_element_name('query', len(el.queries)), 'view': helper.format_element_name('view', len(el.views)), 'description': el.getMetaData(config.data.namespace_prefix['dc'], 'description'), 'statistics': helper.get_annotations_statistics(el.annotations) }) elif isinstance(el, AnnotationType): info.set_text( _("""%(type)s %(title)s\n%(statistics)s""") % ({ "type": helper.get_type(el), "title": self.controller.get_title(el), "statistics": helper.get_annotations_statistics(el.annotations) })) elif isinstance(el, Schema): info.set_text( _("""%(type)s %(title)s\n%(statistics)s""") % ({ "type": helper.get_type(el), "title": self.controller.get_title(el), "statistics": helper.get_schema_statistics(el) })) else: info.set_text( _("""%(type)s %(title)s""") % ({ "type": helper.get_type(el), "title": self.controller.get_title(el) })) sw.add(info) edit_button = Gtk.Button(_("Edit")) edit_button.connect('clicked', lambda w: self.controller.gui.edit_element(el)) frame = Gtk.Expander.new(_("Metadata")) frame.set_expanded(False) self.view = EditWidget(self.node.set_config, self.node.get_config) for p in self.node.list_keys(): self.view.add_entry(p, p, "") frame.add(self.view) vbox.add(sw) if not isinstance(el, (VirtualNode, AbstractBundle)): vbox.pack_start(edit_button, False, False, 0) vbox.pack_start(frame, False, False, 0) vbox.show_all() return vbox
def edit_options(self, button): user_defined=object() cache=dict(self.options) for c in ('representation', 'separator'): cache[c] = cache[c].replace('\n', '\\n').replace('\t', '\\t') old_representation=cache['representation'] cache['user-separator']=cache['separator'] if cache['separator'] not in (' ', '\\n', '\\t', ' - '): cache['separator']=user_defined ew=EditWidget(cache.__setitem__, cache.get) ew.set_name(_("Transcription options")) ew.add_checkbox(_("Default representation"), "default-representation", _("Use the default representation for annotations")) ew.add_entry(_("Representation"), "representation", _("If default representation is unchecked,\nthis TALES expression that will be used to format the annotations.")) ew.add_option(_("Separator"), "separator", _("This separator will be inserted between the annotations."), { _('Whitespace'): ' ', _('Newline'): "\\n", _('Tabulation'): "\\t", _('Dash'): " - ", _('User defined'): user_defined, }) ew.add_entry(_("User-defined separator"), "user-separator", _("Separator used if user-defined is selected.Use \\n for a newline and \\t for a tabulation.")) ew.add_checkbox(_("Display timestamps"), "display-time", _("Insert timestsamp values")) ew.add_checkbox(_("Display annotation bounds"), 'display-bounds', _("Display annotation bounds")) res=ew.popup() if res: if old_representation != cache['representation']: # The user-defined representation was changed. In most # cases, this means that the user wants to use it # instead of the default representation, so force # default-representation to False cache['default-representation']=False if cache['separator'] == user_defined: # User-defined has been selected. Use the user-separator value cache['separator']=cache['user-separator'] self.options.update(cache) # Process special characters for c in ('representation', 'separator'): self.options[c]=self.options[c].replace('\\n', '\n').replace('\\t', '\t') self.generate_buffer_content() return True
def build_widget(self): ew = EditWidget(self.options.__setitem__, self.options.get) ew.set_name(_("Initial Advene configuration")) ew.add_label( _("<span size='large'><b>Welcome in Advene</b>\nThis is the first time that you run Advene. Please answer some basic configuration questions. You will be able to modify these choices from the Advene interface, in the Edit/Preferences menu.</span>" )) ew.add_option(_("Interface language"), 'language', _("Language used for the interface"), { "English": 'C', "Francais": 'fr_FR', _("System default"): '', }) ew.add_checkbox( _("Weekly check for Advene updates on the Advene website"), 'update-check', _("Weekly check for updates on the Advene website")) ew.add_dir_selector( _("Preferred directory for data files"), "data", _("Preferred directory for storing data files (Advene packages)")) #ew.add_dir_selector(_("Imagecache"), "imagecache", _("Directory for storing the snapshot cache")) ew.add_dir_selector( _("Directories to search for movies"), "moviepath", _("List of directories (separated by %(pathsep)s) to search for movie files." ) % {'pathsep': os.path.pathsep}) ew.add_checkbox( _("First look for movie file in the same directory as the package" ), 'movie-in-package-dir', _("If checked, the movie file will be searched for in the same directory as the referencing package." )) return ew
def edit_preferences(self, *p): cache=dict(self.options) ew=EditWidget(cache.__setitem__, cache.get) ew.set_name(_("Preferences")) ew.add_checkbox(_("Timestamp"), "timestamp", _("Click inserts timestamp marks")) ew.add_checkbox(_("Insert on single-click"), 'insert-on-single-click', _("A single click will insert the mark (else a double click is needed)")) ew.add_checkbox(_("Play on scroll"), "play-on-scroll", _("Play the new position upon timestamp modification")) ew.add_checkbox(_("Generate empty annotations"), "empty-annotations", _("If checked, generate annotations for empty text")) ew.add_spin(_("Reaction time"), "delay", _("Reaction time (substracted from current player time, except when paused.)"), -5000, 5000) ew.add_checkbox(_("Auto-insert"), "autoinsert", _("Automatic timestamp mark insertion")) ew.add_spin(_("Automatic insertion delay"), 'automatic-mark-insertion-delay', _("If autoinsert is active, timestamp marks will be automatically inserted when text is entered after no interaction since this delay (in ms).\n1000 is typically a good value."), 0, 100000) ew.add_spin(_("Font size"), "font-size", _("Font size for text (0 for standard size)"), 0, 48) res=ew.popup() if res: if cache['font-size'] != self.options['font-size']: # Font-size was changed. Update the textview. self.update_font_size(cache['font-size']) self.options.update(cache) return True
def build_widget(self): ew=EditWidget(self.options.__setitem__, self.options.get) ew.set_name(_("Initial Advene configuration")) ew.add_label(_("<span size='large'><b>Welcome in Advene</b>\nThis is the first time that you run Advene. Please answer some basic configuration questions. You will be able to modify these choices from the Advene interface, in the Edit/Preferences menu.</span>")) ew.add_option(_("Interface language"), 'language', _("Language used for the interface"), { "English": 'C', "Francais": 'fr_FR', _("System default"): '', }) ew.add_checkbox(_("Weekly check for Advene updates on the Advene website"), 'update-check', _("Weekly check for updates on the Advene website")) ew.add_dir_selector(_("Preferred directory for data files"), "data", _("Preferred directory for storing data files (Advene packages)")) #ew.add_dir_selector(_("Imagecache"), "imagecache", _("Directory for storing the snapshot cache")) ew.add_dir_selector(_("Directories to search for movies"), "moviepath", _("List of directories (separated by %(pathsep)s) to search for movie files.") % { 'pathsep': os.path.pathsep }) ew.add_checkbox(_("First look for movie file in the same directory as the package"), 'movie-in-package-dir', _("If checked, the movie file will be searched for in the same directory as the referencing package.")) return ew
def edit_options(self, button): user_defined = object() cache = dict(self.options) for c in ('representation', 'separator'): cache[c] = cache[c].replace('\n', '\\n').replace('\t', '\\t') old_representation = cache['representation'] cache['user-separator'] = cache['separator'] if cache['separator'] not in (' ', '\\n', '\\t', ' - '): cache['separator'] = user_defined ew = EditWidget(cache.__setitem__, cache.get) ew.set_name(_("Transcription options")) ew.add_checkbox(_("Default representation"), "default-representation", _("Use the default representation for annotations")) ew.add_entry( _("Representation"), "representation", _("If default representation is unchecked,\nthis TALES expression that will be used to format the annotations." )) ew.add_option( _("Separator"), "separator", _("This separator will be inserted between the annotations."), { _('Whitespace'): ' ', _('Newline'): "\\n", _('Tabulation'): "\\t", _('Dash'): " - ", _('User defined'): user_defined, }) ew.add_entry( _("User-defined separator"), "user-separator", _("Separator used if user-defined is selected.Use \\n for a newline and \\t for a tabulation." )) ew.add_checkbox(_("Display timestamps"), "display-time", _("Insert timestsamp values")) ew.add_checkbox(_("Display annotation bounds"), 'display-bounds', _("Display annotation bounds")) res = ew.popup() if res: if old_representation != cache['representation']: # The user-defined representation was changed. In most # cases, this means that the user wants to use it # instead of the default representation, so force # default-representation to False cache['default-representation'] = False if cache['separator'] == user_defined: # User-defined has been selected. Use the user-separator value cache['separator'] = cache['user-separator'] self.options.update(cache) # Process special characters for c in ('representation', 'separator'): self.options[c] = unescape_string(self.options[c]) self.generate_buffer_content() return True
def edit_preferences(self, *p): cache=dict(self.options) ew=EditWidget(cache.__setitem__, cache.get) ew.set_name(_("Preferences")) ew.add_checkbox(_("Timestamp"), "timestamp", _("Click inserts timestamp marks")) ew.add_checkbox(_("Insert on double-click"), 'insert-on-double-click', _("A double click inserts the mark")) ew.add_checkbox(_("Insert on single-click"), 'insert-on-single-click', _("A single click inserts the mark")) ew.add_entry(_("Mark prefix"), 'mark-prefix', _("Text to insert before a mark (use \\n for newline)")) ew.add_entry(_("Mark suffix"), 'mark-suffix', _("Text to insert after a mark (use \\n for newline)")) ew.add_checkbox(_("Play on scroll"), "play-on-scroll", _("Play the new position upon timestamp modification")) ew.add_checkbox(_("Generate empty annotations"), "empty-annotations", _("If checked, generate annotations for empty text")) ew.add_spin(_("Reaction time"), "delay", _("Reaction time (substracted from current player time, except when paused.)"), -5000, 5000) ew.add_checkbox(_("Auto-insert"), "autoinsert", _("Automatic timestamp mark insertion")) ew.add_spin(_("Automatic insertion delay"), 'automatic-mark-insertion-delay', _("If autoinsert is active, timestamp marks will be automatically inserted when text is entered after no interaction since this delay (in ms).\n1000 is typically a good value."), 0, 100000) ew.add_spin(_("Font size"), "font-size", _("Font size for text (0 for standard size)"), 0, 48) res=ew.popup() if res: if cache['font-size'] != self.options['font-size']: # Font-size was changed. Update the textview. self.update_font_size(cache['font-size']) self.options.update(cache) return True
def build_widget(self): el = self.node.element vbox=Gtk.VBox() info = Gtk.TextView() info.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) def set_text(widget, t): b=widget.get_buffer() b.delete(*b.get_bounds()) b.set_text(t) b.set_modified(False) return True info.set_text = set_text.__get__(info) sw = Gtk.ScrolledWindow() sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) if isinstance(el, Package): info.set_text(_("""Package %(title)s: %(schema)s %(annotation)s in %(annotation_type)s %(relation)s in %(relation_type)s %(query)s %(view)s Description: %(description)s Annotation statistics: %(statistics)s """) % { 'title': el.title, 'schema': helper.format_element_name('schema', len(el.schemas)), 'annotation': helper.format_element_name('annotation', len(el.annotations)), 'annotation_type': helper.format_element_name('annotation_type', len(el.annotationTypes)), 'relation': helper.format_element_name('relation', len(el.relations)), 'relation_type': helper.format_element_name('relation_type', len(el.relationTypes)), 'query': helper.format_element_name('query', len(el.queries)), 'view': helper.format_element_name('view', len(el.views)), 'description': el.getMetaData(config.data.namespace_prefix['dc'], 'description'), 'statistics': helper.get_annotations_statistics(el.annotations) }) elif isinstance(el, AnnotationType): info.set_text(_("""%(type)s %(title)s\n%(statistics)s""") % ({ "type": helper.get_type(el), "title": self.controller.get_title(el), "statistics": helper.get_annotations_statistics(el.annotations) })) elif isinstance(el, Schema): info.set_text(_("""%(type)s %(title)s\n%(statistics)s""") % ({ "type": helper.get_type(el), "title": self.controller.get_title(el), "statistics": helper.get_schema_statistics(el) })) else: info.set_text(_("""%(type)s %(title)s""") % ({"type": helper.get_type(el), "title": self.controller.get_title(el)})) sw.add(info) edit_button = Gtk.Button(_("Edit")) edit_button.connect('clicked', lambda w: self.controller.gui.edit_element(el)) frame = Gtk.Expander.new(_("Metadata")) frame.set_expanded(False) self.view = EditWidget(self.node.set_config, self.node.get_config) for p in self.node.list_keys(): self.view.add_entry(p, p, "") frame.add(self.view) vbox.add(sw) if not isinstance(el, (VirtualNode, AbstractBundle)): vbox.pack_start(edit_button, False, False, 0) vbox.pack_start(frame, False, False, 0) vbox.show_all() return vbox