Пример #1
0
def foldername(words, idx, view):

    prefix = os.path.dirname(words[idx])
    partial = os.path.expanduser(words[idx])

    root = pp_core.get_core(view.get_toplevel()).get_path()

    if not os.path.isabs(partial):
        partial = os.path.join(root, partial)

    dirname = os.path.dirname(partial)

    try:
        files = os.listdir(dirname)
    except OSError:
        return None

    base = os.path.basename(partial)
    ret = []
    real = []

    for f in files:
        directory = os.path.join(dirname, f)
        if f.startswith(base) and (
                base or not f.startswith('.')) and os.path.isdir(directory):
            real.append(directory)
            ret.append(os.path.join(prefix, f))

    _sort_nicely(real)

    if len(ret) == 1:
        return ret, ret[0], '/'
    else:
        return map(lambda x: os.path.basename(x), real), common_prefix(ret)
Пример #2
0
	def save(self, name, window):
		files = [doc.get_uri()
					for doc in window.get_documents()
					if doc.get_uri() is not None]

		path = get_core(window).get_path()
		self.plugin.sessions.add(Session(name, files, path))
		self.plugin.sessions.save()
		self.plugin.update_session_menu()
Пример #3
0
    def save(self, name, window):
        files = [
            doc.get_uri() for doc in window.get_documents()
            if doc.get_uri() is not None
        ]

        path = get_core(window).get_path()
        self.plugin.sessions.add(Session(name, files, path))
        self.plugin.sessions.save()
        self.plugin.update_session_menu()
Пример #4
0
    def load(self, name, window=None):
        session = self.plugin.sessions.get_by_name(name)

        if session is None:
            return

        app = gedit.app_get_default()

        if window is None:
            window = app.get_active_window()

        tab = window.get_active_tab()
        if tab is not None and \
          not (tab.get_document().is_untouched() and \
          tab.get_state() == gedit.TAB_STATE_NORMAL):
            window = app.create_window()
            window.show()

        window.set_data(self.CURRENT_SESSION_NAME_KEY, name)
        get_core(window).set_path(session.get_path())
        gedit.commands.load_uris(window, session.files, None, 0)
Пример #5
0
	def load(self, name, window = None):
		session = self.plugin.sessions.get_by_name(name)
		
		if session is None:
			return

		app = gedit.app_get_default()

		if window is None:
			window = app.get_active_window()

		tab = window.get_active_tab()
		if tab is not None and \
			 not (tab.get_document().is_untouched() and \
				tab.get_state() == gedit.TAB_STATE_NORMAL):
			window = app.create_window()
			window.show()

		window.set_data(self.CURRENT_SESSION_NAME_KEY, name)
		get_core(window).set_path(session.get_path())
		gedit.commands.load_uris(window, session.files, None, 0)
def foldername(words, idx, view):

	prefix = os.path.dirname(words[idx])
	partial = os.path.expanduser(words[idx])

	root = pp_core.get_core(view.get_toplevel()).get_path()

	if not os.path.isabs(partial):
		partial = os.path.join(root, partial)

	
	dirname = os.path.dirname(partial)
	
	try:
		files = os.listdir(dirname)
	except OSError:
		return None


	base = os.path.basename(partial)
	ret = []
	real = []


	for f in files:
		directory = os.path.join(dirname, f)
		if f.startswith(base) and (base or not f.startswith('.')) and os.path.isdir(directory):
			real.append(directory)
			ret.append(os.path.join(prefix, f))

	_sort_nicely(real)

	if len(ret) == 1:
		return ret, ret[0], '/'
	else:
		return map(lambda x: os.path.basename(x), real), common_prefix(ret)
Пример #7
0
def T(view):
    window = view.get_toplevel()
    path = get_core(window).get_path()
    subprocess.Popen(['gnome-terminal', "--working-directory=%s" % path])
    return 'opening project terminal'
Пример #8
0
def T (view):
	window = view.get_toplevel()
	path = get_core(window).get_path()
	subprocess.Popen(['gnome-terminal', "--working-directory=%s" % path])
	return 'opening project terminal'
 def on_result(self, path):
     path = os.path.join(get_core(self._window).get_path(), path)
     uri = gio.File(path).get_uri()
     gedit.commands.load_uri(self._window, uri, None, -1)
     return True
Пример #10
0
def pwd(entry, window):
	"""Get working directory"""

	row = get_core(window).get_path()
	entry.info_show(row, True)
	return commands.result.HIDE
Пример #11
0
def __default__(folder, window):
	"""Set working directory"""

	get_core(window).set_path(folder)
	return commands.result.HIDE
Пример #12
0
def flush(window):
    path = get_core(window).get_path()
    Finder().flush(path)
Пример #13
0
def search(text, window):
    path = get_core(window).get_path()
    return Finder().search(path, text)
Пример #14
0
def pwd(entry, window):
    """Get working directory"""

    row = get_core(window).get_path()
    entry.info_show(row, True)
    return commands.result.HIDE
Пример #15
0
def __default__(folder, window):
    """Set working directory"""

    get_core(window).set_path(folder)
    return commands.result.HIDE
 def on_result(self, path):
     path = os.path.join(get_core(self._window).get_path(), path)
     uri = gio.File(path).get_uri()
     gedit.commands.load_uri(self._window, uri, None, -1)
     return True