Exemple #1
0
	def set_mode(self, mode=modes.SELECT_MODE):
		if not mode == self.mode:
			self.mode = mode
#			self.set_canvas_cursor(mode)
			self.controller = self.ctrls[mode]
			self.controller.set_cursor()
			events.emit(events.MODE_CHANGED, mode)
    def save_as(self):
        doc_file = '' + self.current_doc.doc_file
        if not doc_file:
            doc_file = '' + self.current_doc.doc_name
        if not os.path.splitext(doc_file)[1] == sk1doc.DOC_EXTENSION:
            doc_file = os.path.splitext(doc_file)[0] + sk1doc.DOC_EXTENSION
        if not os.path.lexists(os.path.dirname(doc_file)):
            doc_file = os.path.join(config.save_dir,
                                    os.path.basename(doc_file))
        doc_file = dialogs.get_save_file_name(self.mw, self, doc_file)
        if doc_file:
            old_file = self.current_doc.doc_file
            old_name = self.current_doc.doc_name
            self.current_doc.set_doc_file(doc_file)
            try:
                self.current_doc.save()
            except IOError:
                self.current_doc.set_doc_file(old_file, old_name)

                first = _('Cannot save document')
                sec = _('Please check file name and write permissions')
                msg = ("%s '%s'.") % (first, self.current_doc.doc_name)

                dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec)

                return False
            config.save_dir = os.path.dirname(doc_file)
            events.emit(events.APP_STATUS, _('Document saved'))
            return True
        else:
            return False
Exemple #3
0
 def update(self):
     if not self.objs:
         self.center_offset = [0.0, 0.0]
     self.update_bbox()
     eventloop = self.presenter.eventloop
     eventloop.emit(eventloop.SELECTION_CHANGED)
     msg = _('object(s) in selection')
     msg = '%i %s' % (len(self.objs), msg)
     events.emit(events.APP_STATUS, msg)
     events.emit(events.SELECTION_CHANGED, self.presenter)
Exemple #4
0
	def update(self):
		if not self.objs:
			self.center_offset = [0.0, 0.0]
		self.update_bbox()
		eventloop = self.presenter.eventloop
		eventloop.emit(eventloop.SELECTION_CHANGED)
		msg = _('object(s) in selection')
		msg = '%i %s' % (len(self.objs), msg)
		events.emit(events.APP_STATUS, msg)
		events.emit(events.SELECTION_CHANGED, self.presenter)
 def open(self):
     doc_file = dialogs.get_open_file_name(self.mw, self, config.open_dir)
     if os.path.lexists(doc_file):
         try:
             doc = DocPresenter(self, doc_file)
         except:
             msg = _('Cannot open file')
             msg = "%s '%s'" % (msg, doc_file)
             sec = _('The file may be corrupted or not supported format')
             dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec)
             return
         self.docs.append(doc)
         self.set_current_doc(doc)
         config.open_dir = os.path.dirname(doc_file)
         events.emit(events.APP_STATUS, _('Document opened'))
    def save(self, doc=''):
        if not doc:
            doc = self.current_doc
        if not doc.doc_file:
            return self.save_as()
        ext = os.path.splitext(self.current_doc.doc_file)[1]
        if not ext == sk1doc.DOC_EXTENSION:
            return self.save_as()
        if not os.path.lexists(os.path.dirname(self.current_doc.doc_file)):
            return self.save_as()

        try:
            doc.save()
            events.emit(events.DOC_SAVED, doc)
        except:
            return False
        events.emit(events.APP_STATUS, _('Document saved'))
        return True
    def close(self, doc=None):
        if not self.docs:
            return
        if doc is None:
            doc = self.current_doc

        if not self.mw.nb.page_num(
                doc.docarea) == self.mw.nb.get_current_page():
            self.mw.set_active_tab(doc.docarea)

        if self.inspector.is_doc_not_saved(doc):
            first = _("Document '%s' has been modified.") % (doc.doc_name)
            second = _('Do you want to save your changes?')
            ret = dialogs.warning_dialog(
                self.mw, self.appdata.app_name, first, second,
                [(
                    _("Don't save"),
                    gtk.RESPONSE_NO,
                ), (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
                 (gtk.STOCK_SAVE, gtk.RESPONSE_OK)])

            if ret == gtk.RESPONSE_OK:
                if not self.save(): return False
            elif ret == gtk.RESPONSE_NO: pass
            else: return False

        if doc in self.docs:
            self.docs.remove(doc)
            doc.close()
            gc.collect()
            events.emit(events.DOC_CLOSED)
            if not len(self.docs):
                self.current_doc = None
                events.emit(events.NO_DOCS)
                msg = _('To start create new or open existing document')
                events.emit(events.APP_STATUS, msg)
        return True
Exemple #8
0
	def reflect_saving(self):
		self.saved = True
		self.set_title()
		self.api.save_mark()
		events.emit(events.DOC_SAVED, self)
Exemple #9
0
	def set(self, objs):
		self.contents = []
		for obj in objs:
			self.contents.append(obj.copy())
		events.emit(events.CLIPBOARD)
Exemple #10
0
	def change_doc(self, *args):
		da = self.nb.get_nth_page(args[2])
		self.app.current_doc = da.presenter
		self.set_win_title(da.caption)
		events.emit(events.DOC_CHANGED, self)
Exemple #11
0
	def modified(self, *args):
		self.saved = False
		self.set_title()
		events.emit(events.DOC_MODIFIED, self)
 def change_doc(self, *args):
     da = self.nb.get_nth_page(args[2])
     self.app.current_doc = da.presenter
     self.set_win_title(da.caption)
     events.emit(events.DOC_CHANGED, self)
Exemple #13
0
 def set(self, objs):
     self.contents = []
     for obj in objs:
         self.contents.append(obj.copy())
     events.emit(events.CLIPBOARD)
Exemple #14
0
 def reflect_saving(self):
     self.saved = True
     self.set_title()
     self.api.save_mark()
     events.emit(events.DOC_SAVED, self)
Exemple #15
0
	def clear_history(self):
		self.undo = []
		self.redo = []
		events.emit(events.DOC_MODIFIED, self.presenter)
		self.presenter.reflect_saving()
Exemple #16
0
 def modified(self, *args):
     self.saved = False
     self.set_title()
     events.emit(events.DOC_MODIFIED, self)
 def run(self):
     events.emit(events.NO_DOCS)
     events.emit(events.APP_STATUS,
                 _('To start create new or open existing document'))
     gtk.main()
Exemple #18
0
	def __setattr__(self, attr, value):
		if not hasattr(self, attr) or getattr(self, attr) != value:
			self.__dict__[attr] = value
			events.emit(events.CONFIG_MODIFIED, attr, value)
 def set_current_doc(self, doc):
     self.current_doc = doc
     events.emit(events.DOC_CHANGED, doc)
 def new(self):
     doc = DocPresenter(self)
     self.docs.append(doc)
     self.set_current_doc(doc)
     events.emit(events.APP_STATUS, _('New document created'))