Пример #1
0
    def on_edit(self, *a):
        custom, default = self.view.get_selected()
        if custom is None:
            return  # Should not have been sensitive

        if not custom.exists():
            # Copy default
            default.copyto(custom)

        edit_file(self, custom, istextfile=True)
        self.view.refresh()
Пример #2
0
    def edit_page_source(self, page=None):
        '''Menu action to edit the page source in an external editor.
		See L{edit_file} for details.

		@param page: the L{Page} object, or C{None} for te current page
		'''
        # This could also be defined as a custom tool, but we want to determine
        # the editor dynamically because we assume that the default app for a
        # text file is a editor and not e.g. a viewer or a browser.
        # Of course users can still define a custom tool for other editors.
        page = page or self.page

        edit_file(self.widget, self.page.source, istextfile=True)
        page.check_source_changed()