Esempio n. 1
0
    def __init__(self, path, **kw):
        assert not os.path.isfile(path), "No directory given!"

        Loadable.__init__(self, None, None)
        Accumulator.__init__(self)
        FileSystemObject.__init__(self, path, **kw)

        self.marked_items = list()

        for opt in ('sort_directories_first', 'sort', 'sort_reverse',
                    'sort_case_insensitive'):
            self.settings.signal_bind('setopt.' + opt,
                                      self.request_resort,
                                      weak=True,
                                      autosort=False)

        for opt in ('hidden_filter', 'show_hidden'):
            self.settings.signal_bind('setopt.' + opt,
                                      self.refilter,
                                      weak=True,
                                      autosort=False)

        self.settings = LocalSettings(path, self.settings)

        self.use()
Esempio n. 2
0
    def __init__(self, path, **kw):
        assert not os.path.isfile(path), "No directory given!"

        Loadable.__init__(self, None, None)
        Accumulator.__init__(self)
        FileSystemObject.__init__(self, path, **kw)

        self.marked_items = []

        self.filter_stack = []

        self._signal_functions = []
        func = self.signal_function_factory(self.sort)
        self._signal_functions += [func]
        for opt in ('sort_directories_first', 'sort', 'sort_reverse',
                    'sort_case_insensitive'):
            self.settings.signal_bind('setopt.' + opt,
                                      func,
                                      weak=True,
                                      autosort=False)
        func = self.signal_function_factory(self.refilter)
        self._signal_functions += [func]
        for opt in ('hidden_filter', 'show_hidden'):
            self.settings.signal_bind('setopt.' + opt,
                                      func,
                                      weak=True,
                                      autosort=False)

        self.settings = LocalSettings(path, self.settings)

        self.use()
Esempio n. 3
0
    def execute(self):
        try:
            line = int(self.arg(1))
        except ValueError:
            line = 1

        path = self.rest(2)

        if not path and self.fm.client:
            path = self.fm.client.get_cb()

        if os.path.isdir(path):
            dirname = path
        elif os.path.isfile(path):
            self.fm.attached_file = path
            dirname = os.path.dirname(path)
        else:
            return

        if self.fm.thisdir.path == dirname or self.fm.enter_dir(dirname):
            if os.path.isfile(path):
                self.fm.thisdir.refilter()
                self.fm.thisdir.move_to_obj(path)

                if hasattr(self.fm.thisfile, 'has_preview') and self.fm.thisfile.has_preview():
                    descr = 'Scroll the line for preview file'
                    loadable = Loadable(self.scroll_preview(line - 1), descr)
                    self.fm.loader.add(loadable, append=True)

            descr = 'Redraw manually after attach event'
            loadable = Loadable(self.redraw_status(), descr)
            self.fm.loader.add(loadable, append=True)
Esempio n. 4
0
    def __init__(self, copy_buffer, new_name, do_cut=False):
	self.copy_buffer = tuple(copy_buffer)
	self.do_cut = do_cut
	self.overwrite = False
	self.original_copy_buffer = copy_buffer
	self.original_path = os.path.join(self.fm.thistab.path, new_name)
	self.percent = 0
	if self.copy_buffer:
	    self.one_file = self.copy_buffer[0]
	Loadable.__init__(self, self.generate(), 'Calculating size...')
Esempio n. 5
0
 def __init__(self, copy_buffer, new_name, do_cut=False):
     self.copy_buffer = tuple(copy_buffer)
     self.do_cut = do_cut
     self.overwrite = False
     self.original_copy_buffer = copy_buffer
     self.original_path = os.path.join(self.fm.thistab.path, new_name)
     self.percent = 0
     if self.copy_buffer:
         self.one_file = self.copy_buffer[0]
     Loadable.__init__(self, self.generate(), 'Calculating size...')
Esempio n. 6
0
    def __init__(self, path, **kw):
        assert not os.path.isfile(path), "No directory given!"

        Loadable.__init__(self, None, None)
        Accumulator.__init__(self)
        FileSystemObject.__init__(self, path, **kw)

        self.marked_items = list()

        for opt in ('sort_directories_first', 'sort', 'sort_reverse', 'sort_case_insensitive'):
            self.settings.signal_bind('setopt.' + opt, self.sort, weak=True, autosort=False)

        for opt in ('hidden_filter', 'show_hidden'):
            self.settings.signal_bind('setopt.' + opt, self.refilter, weak=True, autosort=False)

        self.settings = LocalSettings(path, self.settings)

        if self.settings.vcs_aware:
            self.vcs = Vcs(self)

        self.use()
Esempio n. 7
0
    def __init__(self, path, **kw):
        assert not os.path.isfile(path), "No directory given!"

        Loadable.__init__(self, None, None)
        Accumulator.__init__(self)
        FileSystemObject.__init__(self, path, **kw)

        self.marked_items = []

        self._signal_functions = []
        func = self.signal_function_factory(self.sort)
        self._signal_functions += [func]
        for opt in ('sort_directories_first', 'sort', 'sort_reverse', 'sort_case_insensitive'):
            self.settings.signal_bind('setopt.' + opt, func, weak=True, autosort=False)
        func = self.signal_function_factory(self.refilter)
        self._signal_functions += [func]
        for opt in ('hidden_filter', 'show_hidden'):
            self.settings.signal_bind('setopt.' + opt, func, weak=True, autosort=False)

        self.settings = LocalSettings(path, self.settings)

        self.use()
Esempio n. 8
0
    def fix_vcs(self):
        """
        Vcs in ranger is a bad design. It will produce a death lock with
        --cmd='set column_ratios 1,1' caused by 'ui.redraw'.

        """
        def enable_vcs_aware():
            """
            Use a queue loader to enable vcs_aware to avoid a death lock.

            """
            self.fm.execute_console('set vcs_aware True')
            self.fm.thisdir.load_content(schedule=False)
            yield

        if self.fm.settings.vcs_aware:
            self.fm.execute_console('set vcs_aware False')
            descr = "Restore user's setting of vcs_aware"
            loadable = Loadable(enable_vcs_aware(), descr)
            self.fm.loader.add(loadable)
Esempio n. 9
0
    def execute(self):
        path = self.rest(1)

        if not path and self.fm.client:
            path = self.fm.client.get_cb()

        if os.path.isdir(path):
            dirname = path
        elif os.path.isfile(path):
            self.fm.attached_file = path
            dirname = os.path.dirname(path)
        else:
            return

        if self.fm.thisdir.path == dirname or self.fm.enter_dir(dirname):
            if os.path.isfile(path):
                self.fm.thisdir.refilter()
                self.fm.thisdir.move_to_obj(path)

            descr = 'Redraw manually after attach event'
            loadable = Loadable(self.redraw_status(), descr)
            self.fm.loader.add(loadable, append=True)
Esempio n. 10
0
 def __init__(self, descr, event, args):
     Loadable.__init__(self, self.generate(), descr)
     ServiceRunner.__init__(self, event, args)
Esempio n. 11
0
 def __init__(self, proc, path):
     self.proc = proc
     self.path = path
     Loadable.__init__(self, self.generate(),
                       'Asynchronous callback from gitignore process.')
Esempio n. 12
0
 def __init__(self, path):
     SignalDispatcher.__init__(self)
     descr = "Waiting for dir '" + path + "' to be mounted"
     Loadable.__init__(self, self.generate(), descr)
     self.path = path
Esempio n. 13
0
 def __init__(self, path):
     SignalDispatcher.__init__(self)
     descr = "Waiting for dir '" + path + "' to be mounted"
     Loadable.__init__(self, self.generate(), descr)
     self.path = path
Esempio n. 14
0
 def __init__(self, proc, path):
     self.proc = proc
     self.path = path
     self.seconds_of_work_time = 0.01
     Loadable.__init__(self, self.generate(), 'Asynchronous callback from gitignore process.')
Esempio n. 15
0
 def __init__(self, descr, event, args):
     Loadable.__init__(self, self.generate(), descr)
     self.event = event
     self.args = args