Пример #1
0
def __default__(filename, view):
    """Edit file: edit <filename>"""

    doc = view.get_buffer()
    cwd = os.getcwd()

    if not doc.is_untitled():
        cwd = doc.get_location().get_parent().get_path()
    else:
        cwd = os.path.expanduser('~/')

    if not os.path.isabs(filename):
        filename = os.path.join(cwd, filename)

    matches = glob.glob(filename)
    files = []

    if matches:
        for match in matches:
            files.append(Gio.file_new_for_path(match))
    else:
        files.append(Gio.file_new_for_path(filename))

    if files:
        window = view.get_toplevel()
        Gedit.commands_load_locations(window, files, None, 0, 0)

    return commander.commands.result.HIDE
Пример #2
0
def __default__(filename, view):
    """Edit file: edit <filename>"""

    doc = view.get_buffer()
    cwd = os.getcwd()

    if not doc.is_untitled():
        cwd = doc.get_file().get_location().get_parent().get_path()
    else:
        cwd = os.path.expanduser('~/')

    if not os.path.isabs(filename):
        filename = os.path.join(cwd, filename)

    matches = glob.glob(filename)
    files = []

    if matches:
        for match in matches:
            files.append(Gio.file_new_for_path(match))
    else:
        files.append(Gio.file_new_for_path(filename))

    if files:
        window = view.get_toplevel()
        Gedit.commands_load_locations(window, files, None, 0, 0)

    return commander.commands.result.HIDE
Пример #3
0
    def apply_uris(self, window):
        if log.query(log.INFO):
            Gedit.debug_plugin_message(log.format("%s", window))

        uris = self._restore_uris

        if log.query(log.DEBUG):
            Gedit.debug_plugin_message(log.format("applying uris=%s", uris))

        if uris:
            documents = window.get_documents()
            create_notebook = False

            if documents:
                window.set_active_tab(
                    Gedit.Tab.get_from_document(documents[-1]))

            for notebook_uris in uris:
                if create_notebook:
                    window.activate_action('new-tab-group')

                locations = [
                    Gio.File.new_for_uri(uri) for uri in notebook_uris
                ]

                Gedit.commands_load_locations(window, locations, None, 0, 0)

                create_notebook = True
Пример #4
0
    def _load_session(self, session, window):
        # Note: a session has to stand on its own window.
        tab = window.get_active_tab()
        if tab is not None and \
           not (tab.get_document().is_untouched() and \
                tab.get_state() == Gedit.TabState.STATE_NORMAL):
            # Create a new gedit window
            window = Gedit.App.get_default().create_window(None)
            window.show()

        Gedit.commands_load_locations(window, session.files, None, 0, 0)