def update_modified(self, l): b = self.textview.get_buffer() impossible = [] batch_id = object() for a in l: m = b.get_mark("b_%s" % a.id) if not m: break beginiter = b.get_iter_at_mark(m) m = b.get_mark("e_%s" % a.id) if not m: break enditer = b.get_iter_at_mark(m) new_content = helper.title2content( b.get_text(beginiter, enditer, False).strip(ZERO_WIDTH_NOBREAK_SPACE), a.content, a.type.getMetaData(config.data.namespace, 'representation') if self.options['default-representation'] else self.options['representation']) if new_content is None: impossible.append(a) elif a.content.data != new_content: self.controller.notify('EditSessionStart', element=a, immediate=True) a.content.data = new_content self.controller.notify("AnnotationEditEnd", annotation=a, batch=batch_id) self.controller.notify('EditSessionEnd', element=a) if impossible: dialog.message_dialog(label=_( "Cannot convert the following annotations,\nthe representation pattern is too complex.\n%s" ) % ",".join([a.id for a in impossible])) return True
def update_modified(self, l): b=self.textview.get_buffer() impossible=[] batch_id=object() for a in l: m = b.get_mark("b_%s" % a.id) if not m: break beginiter = b.get_iter_at_mark(m) m = b.get_mark("e_%s" % a.id) if not m: break enditer = b.get_iter_at_mark(m) new_content = helper.title2content(b.get_text(beginiter, enditer, False).strip(ZERO_WIDTH_NOBREAK_SPACE), a.content, a.type.getMetaData(config.data.namespace, 'representation') if self.options['default-representation'] else self.options['representation']) if new_content is None: impossible.append(a) elif a.content.data != new_content: self.controller.notify('EditSessionStart', element=a, immediate=True) a.content.data = new_content self.controller.notify("AnnotationEditEnd", annotation=a, batch=batch_id) self.controller.notify('EditSessionEnd', element=a) if impossible: dialog.message_dialog(label=_("Cannot convert the following annotations,\nthe representation pattern is too complex.\n%s") % ",".join( [ a.id for a in impossible ] )) return True
def cell_edited(cell, path_string, text): it = self.model.get_iter_from_string(path_string) if not it: return a = self.model.get_value (it, COLUMN_ELEMENT) new_content = helper.title2content(text, a.content, a.type.getMetaData(config.data.namespace, "representation")) if new_content is None: self.log(_("Cannot update the annotation, its representation is too complex")) elif a.content.data != new_content: self.last_edited_path = Gtk.TreePath.new_from_string(path_string) self.controller.notify('EditSessionStart', element=a) a.content.data = new_content self.controller.notify('AnnotationEditEnd', annotation=a) self.controller.notify('EditSessionEnd', element=a) return True
def cell_edited(cell, path_string, text): it = self.model.get_iter_from_string(path_string) if not it: return a = self.model.get_value(it, COLUMN_ELEMENT) new_content = helper.title2content( text, a.content, a.type.getMetaData(config.data.namespace, "representation")) if new_content is None: self.log( _("Cannot update the annotation, its representation is too complex" )) elif a.content.data != new_content: self.last_edited_path = Gtk.TreePath.new_from_string( path_string) self.controller.notify('EditSessionStart', element=a) a.content.data = new_content self.controller.notify('AnnotationEditEnd', annotation=a) self.controller.notify('EditSessionEnd', element=a) return True