Ejemplo n.º 1
0
 def __init__(self, app, dlg):
     self.app = app
     self.dlg = dlg
     self.fmt_config = PDXF_Config()
     config_dir = self.app.appdata.app_config_dir
     config_file = os.path.join(config_dir, 'pdxf_config.xml')
     self.fmt_config.load(config_file)
     gtk.HPaned.__init__(self)
     self.set_size_request(700, 400)
     self.build_model()
     self.viewer = PluginViewer(self)
     self.pack1(self.viewer, False, False)
     self.show_all()
Ejemplo n.º 2
0
class PrefsContainer(gtk.HPaned):

    model = None
    plugins = []
    current_plg = None

    def __init__(self, app, dlg):
        self.app = app
        self.dlg = dlg
        self.fmt_config = PDXF_Config()
        config_dir = self.app.appdata.app_config_dir
        config_file = os.path.join(config_dir, 'pdxf_config.xml')
        self.fmt_config.load(config_file)
        gtk.HPaned.__init__(self)
        self.set_size_request(700, 400)
        self.build_model()
        self.viewer = PluginViewer(self)
        self.pack1(self.viewer, False, False)
        self.show_all()

    def build_model(self):
        self.model = PrefsNode(_('Preferences'), gtk.STOCK_PREFERENCES)
        self.app_prefs = PrefsNode(_('Application'),
                                   gtk.STOCK_LEAVE_FULLSCREEN)
        self.model.childs.append(self.app_prefs)
        self.doc_prefs = PrefsNode(_('New document'), gtk.STOCK_NEW)
        self.model.childs.append(self.doc_prefs)
        for item in PLUGINS:
            plg = item(self.app, self.dlg, self.fmt_config)
            if plg.cid == const.PREFS_APP_PLUGIN:
                self.app_prefs.childs.append(plg)
            else:
                self.doc_prefs.childs.append(plg)
            self.plugins.append(plg)

    def load_plugin(self, plg):
        if not plg.leaf: return
        if not self.current_plg is None: self.remove(self.current_plg)
        if not plg.built:
            plg.build()
        self.pack2(plg, True, False)
        plg.show_all()
        self.current_plg = plg

    def apply_changes(self):
        for item in self.plugins:
            if item.built:
                item.apply_changes()

    def restore_defaults(self, *args):
        self.current_plg.restore_defaults()
Ejemplo n.º 3
0
class PDXF_Presenter(TaggedModelPresenter):

	cid = uc2const.PDXF

	methods = None
	cms = None


	def __init__(self, appdata, cnf={}, filepath=None):
		self.config = PDXF_Config()
		config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
		self.config.load(config_file)
		self.config.update(cnf)
		self.appdata = appdata
		self.doc_id = generate_id()
		self.loader = PDXF_Loader()
		self.saver = PDXF_Saver()
		self.methods = PDXF_Methods(self)
		self.rm = ResourceManager(self)
		self.create_cache_structure()
		if filepath is None:
			self.new()
		else:
			self.load(filepath)

	def create_cache_structure(self):
		doc_cache_dir = os.path.join(self.appdata.app_config_dir, 'docs_cache')
		self.doc_dir = os.path.join(doc_cache_dir, 'doc_' + self.doc_id)
		for dir in const.DOC_STRUCTURE:
			path = os.path.join(self.doc_dir, dir)
			os.makedirs(path)
		mime = open(os.path.join(self.doc_dir, 'mimetype') , 'wb')
		mime.write(const.DOC_MIME)
		mime.close()

	def init_cms(self):
		self.cms = PDXF_ColorManager(self)

	def new(self):
		self.model = methods.create_new_doc(self.config)
		self.update()

	def merge(self):
		pass

	def update(self):
		self.init_cms()
		TaggedModelPresenter.update(self)
		if not self.model is None:
			self.methods.update()
Ejemplo n.º 4
0
class PrefsContainer(gtk.HPaned):

	model = None
	plugins = []
	current_plg = None

	def __init__(self, app, dlg):
		self.app = app
		self.dlg = dlg
		self.fmt_config = PDXF_Config()
		config_dir = self.app.appdata.app_config_dir
		config_file = os.path.join(config_dir, 'pdxf_config.xml')
		self.fmt_config.load(config_file)
		gtk.HPaned.__init__(self)
		self.set_size_request(700, 400)
		self.build_model()
		self.viewer = PluginViewer(self)
		self.pack1(self.viewer, False, False)
		self.show_all()

	def build_model(self):
		self.model = PrefsNode(_('Preferences'), gtk.STOCK_PREFERENCES)
		self.app_prefs = PrefsNode(_('Application'), gtk.STOCK_LEAVE_FULLSCREEN)
		self.model.childs.append(self.app_prefs)
		self.doc_prefs = PrefsNode(_('New document'), gtk.STOCK_NEW)
		self.model.childs.append(self.doc_prefs)
		for item in PLUGINS:
			plg = item(self.app, self.dlg, self.fmt_config)
			if plg.cid == const.PREFS_APP_PLUGIN:
				self.app_prefs.childs.append(plg)
			else:
				self.doc_prefs.childs.append(plg)
			self.plugins.append(plg)

	def load_plugin(self, plg):
		if not plg.leaf: return
		if not self.current_plg is None: self.remove(self.current_plg)
		if not plg.built:
			plg.build()
		self.pack2(plg, True, False)
		plg.show_all()
		self.current_plg = plg

	def apply_changes(self):
		for item in self.plugins:
			if item.built:
				item.apply_changes()

	def restore_defaults(self, *args):
		self.current_plg.restore_defaults()
Ejemplo n.º 5
0
 def __init__(self, appdata, cnf={}, filepath=None):
     self.config = PDXF_Config()
     config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
     self.config.load(config_file)
     self.config.update(cnf)
     self.appdata = appdata
     self.doc_id = generate_id()
     self.loader = PDXF_Loader()
     self.saver = PDXF_Saver()
     self.methods = PDXF_Methods(self)
     self.rm = ResourceManager(self)
     self.create_cache_structure()
     if filepath is None:
         self.new()
     else:
         self.load(filepath)
Ejemplo n.º 6
0
	def __init__(self, app, dlg):
		self.app = app
		self.dlg = dlg
		self.fmt_config = PDXF_Config()
		config_dir = self.app.appdata.app_config_dir
		config_file = os.path.join(config_dir, 'pdxf_config.xml')
		self.fmt_config.load(config_file)
		gtk.HPaned.__init__(self)
		self.set_size_request(700, 400)
		self.build_model()
		self.viewer = PluginViewer(self)
		self.pack1(self.viewer, False, False)
		self.show_all()
Ejemplo n.º 7
0
	def __init__(self, appdata, cnf={}, filepath=None):
		self.config = PDXF_Config()
		config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
		self.config.load(config_file)
		self.config.update(cnf)
		self.appdata = appdata
		self.doc_id = generate_id()
		self.loader = PDXF_Loader()
		self.saver = PDXF_Saver()
		self.methods = PDXF_Methods(self)
		self.rm = ResourceManager(self)
		self.create_cache_structure()
		if filepath is None:
			self.new()
		else:
			self.load(filepath)