コード例 #1
0
 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)
コード例 #2
0
ファイル: sourceview.py プロジェクト: xbynet/zim-desktop-wiki
 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)
コード例 #3
0
ファイル: __init__.py プロジェクト: rayleyva/zim-desktop-wiki
    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)
コード例 #4
0
ファイル: __init__.py プロジェクト: gdw2/zim
	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
コード例 #5
0
ファイル: __init__.py プロジェクト: fabricehong/zim-desktop
 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
コード例 #6
0
ファイル: __init__.py プロジェクト: gdw2/zim
	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)
コード例 #7
0
	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)
コード例 #8
0
ファイル: objectmanager.py プロジェクト: hjq300/zim-wiki
	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)
コード例 #9
0
    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)
コード例 #10
0
 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)
コード例 #11
0
ファイル: __init__.py プロジェクト: rayleyva/zim-desktop-wiki
    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)
コード例 #12
0
    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)
コード例 #13
0
ファイル: __init__.py プロジェクト: rayleyva/zim-desktop-wiki
	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)
コード例 #14
0
ファイル: sourceview.py プロジェクト: pombredanne/zim
	def __init__(self, plugin, window):
		WindowExtension.__init__(self, plugin, window)
		ObjectManager.register_object(OBJECT_TYPE, self.plugin.create_object)
コード例 #15
0
 def teardown(self):
     ''' Deconstructor '''
     ObjectManager.unregister_object(OBJECT_TYPE)
コード例 #16
0
ファイル: bibtexeditor.py プロジェクト: wiwie/zim_bibtex
 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)
コード例 #17
0
ファイル: sourceview.py プロジェクト: pombredanne/zim
	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)
コード例 #18
0
ファイル: tableeditor.py プロジェクト: hjq300/zim-wiki
 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)
コード例 #19
0
ファイル: sourceview.py プロジェクト: pombredanne/zim
	def teardown(self):
		ObjectManager.unregister_object(OBJECT_TYPE)
コード例 #20
0
ファイル: tableeditor.py プロジェクト: hjq300/zim-wiki
 def teardown(self):
     ''' Deconstructor '''
     ObjectManager.unregister_object(OBJECT_TYPE)
     self.window.ui.reload_page()