def convert_to_annotations(self, *p): """Convert bookmarks to annotations with a fixed duration. """ at=self.controller.gui.ask_for_annotation_type(text=_("Select the annotation type to generate"), create=True) if at is None: return True d=dialog.entry_dialog(title=_("Choose a duration"), text=_("Enter the standard duration (in ms) of created annotations."), default="2000") if d is None: return True try: d=int(d) except ValueError: # Use a default value d=2000 ti=HistoryImporter(package=self.controller.package, controller=self.controller, defaulttype=at, elements=self.bookmarks, duration=d) ti.process_file('history') self.controller.package._modified=True self.log(_('Converted from bookmarks')) self.log(ti.statistics_formatted()) # Feedback dialog.message_dialog( _("Conversion completed.\n%s annotations generated.") % ti.statistics['annotation']) return True
def insert_resource_data(self, widget, parent=None, title=None, filter=None): if title is None: title = _("Choose the file to insert") filename = dialog.get_filename(title=title, filter=filter) if filename is None: return True basename = os.path.basename(filename) id_ = re.sub('[^a-zA-Z0-9_.]', '_', basename) if id_ != basename: while True: id_ = dialog.entry_dialog( title=_("Select a valid identifier"), text= _("The filename %s contains invalid characters\nthat have been replaced.\nYou can modify this identifier if necessary:" ) % filename, default=id_) if id_ is None: # Edition cancelled return True elif re.match('^[a-zA-Z0-9_.]+$', id_): break self.do_insert_resource_file(parent=parent, filename=filename, id_=id_) return True
def popup_get_offset(self): offset=dialog.entry_dialog(title='Enter an offset', text=_("Give the offset to use\non specified element.\nIt is in ms and can be\neither positive or negative."), default="0") if offset is not None: return long(offset) else: return offset
def popup_menu(button, event, view): if event.button == 3: menu = gtk.Menu() if not permanent: # Relocation submenu submenu = gtk.Menu() for (label, destination) in ( (_("...in its own window"), 'popup'), (_("...embedded east of the video"), 'east'), (_("...embedded west of the video"), 'west'), (_("...embedded south of the video"), 'south'), (_("...embedded at the right of the window"), 'fareast')): if destination == self.location: continue item = gtk.MenuItem(label) item.connect('activate', relocate_view, view, destination) submenu.append(item) item = gtk.MenuItem(_("Detach")) item.set_submenu(submenu) menu.append(item) item = gtk.MenuItem(_("Close")) item.connect('activate', close_view, view) menu.append(item) try: for label, action in view.contextual_actions: item = gtk.MenuItem(label, use_underline=False) item.connect('activate', action, view) menu.append(item) except AttributeError: pass menu.show_all() menu.popup(None, None, None, 0, gtk.get_current_event_time()) return True elif event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS: # Double click: propose to rename the view label_widget = button.get_children()[0] lab = dialog.entry_dialog( title=_("Rename the view"), text=_("Please enter the new name of the view"), default=view._label) if lab is not None: view.set_label(lab) return True return False
def popup_menu(button, event, view): if event.button == 3: menu = gtk.Menu() if not permanent: # Relocation submenu submenu=gtk.Menu() for (label, destination) in ( (_("...in its own window"), 'popup'), (_("...embedded east of the video"), 'east'), (_("...embedded west of the video"), 'west'), (_("...embedded south of the video"), 'south'), (_("...embedded at the right of the window"), 'fareast')): if destination == self.location: continue item = gtk.MenuItem(label) item.connect('activate', relocate_view, view, destination) submenu.append(item) item=gtk.MenuItem(_("Detach")) item.set_submenu(submenu) menu.append(item) item = gtk.MenuItem(_("Close")) item.connect('activate', close_view, view) menu.append(item) try: for label, action in view.contextual_actions: item = gtk.MenuItem(label, use_underline=False) item.connect('activate', action, view) menu.append(item) except AttributeError: pass menu.show_all() menu.popup(None, None, None, 0, gtk.get_current_event_time()) return True elif event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS: # Double click: propose to rename the view label_widget=button.get_children()[0] lab=dialog.entry_dialog(title=_("Rename the view"), text=_("Please enter the new name of the view"), default=view._label) if lab is not None: view.set_label(lab) return True return False
def insert_resource_data(self, widget, parent=None, title=None, filter=None): if title is None: title = _("Choose the file to insert") filename=dialog.get_filename(title=title, filter=filter) if filename is None: return True basename = os.path.basename(filename) id_=re.sub('[^a-zA-Z0-9_.]', '_', basename) if id_ != basename: while True: id_ = dialog.entry_dialog(title=_("Select a valid identifier"), text=_("The filename %s contains invalid characters\nthat have been replaced.\nYou can modify this identifier if necessary:") % filename, default=id_) if id_ is None: # Edition cancelled return True elif re.match('^[a-zA-Z0-9_.]+$', id_): break self.do_insert_resource_file(parent=parent, filename=filename, id_=id_) return True