community icon indicating copy to clipboard operation
community copied to clipboard

Icon View Filechooser - No possibility to go a directory up

Open Wessix opened this issue 13 years ago • 4 comments

The filechooser Icon View misses a icon for going directories upwards. took a picture of a folder that is not my root folder,

bildschirmfotovom2013087f251

I found out that it's only occuring when you set a root Dir. If you enter e subdir of that root you cannot go back

Wessix avatar Aug 30 '13 14:08 Wessix

ok i have a workaround for me, but someone who is better should implement a clean and nice solution:

Problem i that the case if you have set a rootpath is not catched in current version, i wrote about that on irc.

now what i did, i used an extra variable to determine if rootpath was set by the user and added that to the if check. all lines i inserter are marked with ###von mir eingenfuegt

def _generate_file_entries(self, _args, *_kwargs): # Generator that will create all the files entries. # the generator is used via _update_files() and _create_files_entries() # don't use it directly. is_root = True path = kwargs.get('path', self.path) have_parent = kwargs.get('parent', None) is not None
# Add the components that are always needed
if self.rootpath:
    rootpath = realpath(self.rootpath)
    path = realpath(path)
    rootpath_set = True                                                                 ###von mir eingefuegt
    if not path.startswith(rootpath):
        self.path = rootpath
        return
    elif path == rootpath:

        is_root = True
else:
    rootpath_set = False                                                                     ###von mir eingefuegt
    if platform == 'win':
        is_root = splitdrive(path)[1] in (sep, altsep)
    elif platform in ('macosx', 'linux', 'android', 'ios'):
        is_root = normpath(expanduser(path)) == sep
    else:
        # Unknown fs, just always add the .. entry but also log
        Logger.warning('Filechooser: Unsupported OS: %r' % platform)
        is_root = False
# generate an entries to go back to previous
if not is_root and not have_parent:
    back = '..' + sep
    pardir = Builder.template(self._ENTRY_TEMPLATE, **dict(
        name=back, size='', path=back, controller=ref(self),
        isdir=True, parent=None, sep=sep, get_nice_size=lambda: ''))
    yield 0, 1, pardir

elif is_root and not have_parent and rootpath_set == True :                ### von mir eingefuegt
    back = '..' + sep ###von mir eingefuegt
    pardir = Builder.template(self._ENTRY_TEMPLATE, **dict(                  ###von mir eingefuegt
        name=back, size='', path=back, controller=ref(self),                         ###von mir eingefuegt
        isdir=True, parent=None, sep=sep, get_nice_size=lambda: ''))          ###on mir eingefuegt
    yield 0, 1, pardir                                                                                ###von mir eingefuegt

now the "../" appear when the root path is set. But they appear also in the set root dir, so someone better must change to code so it gets hidden there or not created. cheers

Wessix avatar Aug 30 '13 17:08 Wessix

It happens when you set a root directory. This is not a bug, it is a feature. http://kivy.org/docs/api-kivy.uix.filechooser.html#kivy.uix.filechooser.FileChooserController

Use "path" instead.

depau avatar Aug 31 '13 17:08 depau

You we're right it is a bug. If you set rootpath and open a subdirectory, you cannot get back to the parent.

depau avatar Aug 31 '13 17:08 depau

Fixed by the PR #1476. :)

tito avatar Sep 16 '13 13:09 tito