def __init__(self, uimanager, pageview): self.uimanager = uimanager self.pageview = pageview self._ui_id = None self._actiongroup = None self.add_ui() ObjectManager.connect('changed', self.on_changed)
def __init__(self, config=None): PluginClass.__init__(self, config) ObjectManager.register_object( OBJECT_TYPE, self.create_object ) # register the plugin in the main init so it works for a non-gui export self.connectto(self.preferences, 'changed', self.on_preferences_changed)
def load_insertedobject_types(self): '''Loads L{InsertedObjectType} classes defined in the same modul as the plugin. ''' from zim.objectmanager import ObjectManager self._objecttypes = [ objtype(self) for objtype in self.discover_classes(InsertedObjectType) ] for obj in self._objecttypes: ObjectManager.register_object(obj)
def _get_object(self, elt): ## TODO optimize using self._object_cache or new API for ## passing on objects in the tree type = elt.attrib.get('type') if elt.tag == OBJECT and type: return ObjectManager.get_object(type, elt.attrib, elt.text) else: return None
def dump_object(self, tag, attrib, strings=None): '''Dumps object using proper ObjectManager''' format = str(self.__class__.__module__).split('.')[-1] if 'type' in attrib: obj = ObjectManager.get_object(attrib['type'], attrib, u''.join(strings)) output = obj.dump(format, self, self.linker) if output is not None: return [output] return self.dump_object_fallback(tag, attrib, strings)
def __init__(self, type, buffer): TextViewWidget.__init__(self, buffer) #~ self.view.set_editable(False) # object knows best how to manage content # TODO set background grey ? plugin = ObjectManager.find_plugin(type) if type else None if plugin: self._add_load_plugin_bar(plugin) else: label = gtk.Label(_("No plugin is available to display this object.")) # T: Label for object manager self.vbox.pack_start(label)
def _action_handler(self, action): try: name = action.get_name()[7:] # len('insert_') = 7 obj = ObjectManager.get_object(name) try: attrib, data = obj.new_object_interactive(self.pageview) except ValueError: return # dialog cancelled self.pageview.insert_object(attrib, data) except: zim.errors.exception_handler('Exception during action: %s' % tool.name)
def destroy(self): '''Destroy the plugin object and all extensions It is only called when a user actually disables the plugin, not when the application exits. Destroys all active extensions and disconnects all signals. This should revert any changes the plugin made to the application (although preferences etc. can be left in place). ''' from zim.objectmanager import ObjectManager for obj in self.extensions: obj.destroy() for obj in self._objecttypes: ObjectManager.unregister_object(obj) try: self.disconnect_all() self.teardown() except: logger.exception('Exception while disconnecting %s', self)
def __init__(self, buffer): TextViewWidget.__init__(self, buffer) #~ self.view.set_editable(False) # object knows best how to manage content # TODO set background grey ? type = buffer.object_attrib.get('type') plugin = ObjectManager.find_plugin(type) if type else None if plugin: header = self._add_load_plugin_bar(plugin) self.add_header(header) else: label = Gtk.Label( _("No plugin available to display objects of type: %s") % type # T: Label for object manager ) self.add_header(label)
def dump_object(self, tag, attrib, strings=[]): '''Dumps objects defined by L{InsertedObjectType}''' format = str(self.__class__.__module__).split('.')[-1] try: obj = ObjectManager.get_object(attrib['type']) except KeyError: pass else: try: output = obj.format(format, self, attrib, ''.join(strings)) except ValueError: pass else: assert isinstance(output, list) return output return self.dump_object_fallback(tag, attrib, strings)
def __init__(self, plugin, window): WindowExtension.__init__(self, plugin, window) ObjectManager.register_object(OBJECT_TYPE, self.plugin.create_object)
def teardown(self): ''' Deconstructor ''' ObjectManager.unregister_object(OBJECT_TYPE)
def __init__(self, plugin, window): WindowExtension.__init__(self, plugin, window) ObjectManager.register_object(OBJECT_TYPE_BIB, self.plugin.create_bib) ObjectManager.register_object(OBJECT_TYPE_REF, self.plugin.create_ref)
def on_preferences_changed(self, preferences): '''Update preferences on open objects''' for obj in ObjectManager.get_active_objects(OBJECT_TYPE): obj.set_preferences(self.preferences)
def __init__(self, config=None): ''' Constructor ''' PluginClass.__init__(self, config) ObjectManager.register_object(OBJECT_TYPE, self.create_table) self.connectto(self.preferences, 'changed', self.on_preferences_changed)
def teardown(self): ObjectManager.unregister_object(OBJECT_TYPE)
def teardown(self): ''' Deconstructor ''' ObjectManager.unregister_object(OBJECT_TYPE) self.window.ui.reload_page()