trackma icon indicating copy to clipboard operation
trackma copied to clipboard

Unification of 'open-folder' function, should fix 'xdg-open' path error

Open BigBoyBarney opened this issue 1 year ago • 1 comments

Should fix #726 as long as xdg-open is in $PATH, which can be assumed for every distro. I tested it for GTK, Qt and CLI on Fedora 39.

[!CAUTION] As my other PR (#722), this requires python 3.10. Do not merge before #722 or without updating python dep.

Changes

Code

  • Unified all 'open folder' functions in utils.py. Can take an error_callback param so error reporting can still be done uniquely for every UI.
  • Fixed OSError not being raised when the folder was in the library, but was changed after scanning. I.e:
    1. Start trackma
    2. 'Show X' gets scanned and found
    3. Rename folder of 'show X'
    4. Open folder
    5. Error is raised correctly

BigBoyBarney avatar Jan 12 '24 14:01 BigBoyBarney

Thanks for the changes.

Which part of this PR requires Python 3.10? I'm not seeing it …

match sys.platform:
            case 'darwin':
                command = ["open", os.path.dirname(filename)]
            case 'win32':
                command = ["explorer", os.path.dirname(filename)]
            case _:
                command = ["xdg-open", os.path.dirname(filename)]

Match was introduced in Python 3.10

BigBoyBarney avatar Feb 09 '24 12:02 BigBoyBarney