ppd / freecad-ppd

5 stars 1 forks source link

issues with older xdg-desktop-portal versions #15

Open ppd opened 2 years ago

ppd commented 2 years ago

Older portal versions proxy everything through the document portal.

Problems:

Possible solutions:

ppd commented 2 years ago

Realthunder's solution: https://github.com/realthunder/FreeCAD/commit/71adbe805a2315fc85f8e7fd80faf00386128765 https://github.com/realthunder/FreeCAD/commit/62d7d3f36d201c88faf2d6392d30f8f891217d09

@luzpaz Should we just switch to the internal file chooser by default? It's uglier, but it works for external links on all systems.

ppd commented 2 years ago

Idea: /etc/lsb-release is mounted from the host; we can parse it to get the host's OS & version. We could simply integrate a whitelist for known working hosts.

whitelist = [
  "Ubuntu 21.10"
]

def get_os_info():
  os_info = {}
  with open("/etc/lsb-release") as f:
    for line in f:
      [key, value] = line.split("=")
      os_info[key] = value.strip("\"'\n ")
  return os_info

def is_in_whitelist(distrib_id, distrib_release):
  return f"{distrib_id} {distrib_release}" in whitelist

def host_supports_unproxied_file_chooser():
  os_info = get_os_info()
  return is_in_whitelist(
    os_info["DISTRIB_ID"],
    os_info["DISTRIB_RELEASE"]
  )
ppd commented 2 years ago

Bug filed for default filename support in Qt's QXdgDesktopPortalFileDialog: https://bugreports.qt.io/browse/QTBUG-100297

luzpaz commented 2 years ago

CC @hfiguiere ☝️ (related to Flatpak as well)

ppd commented 2 years ago

Support for unproxied access to files was introduced in xdg-desktop-portal v1.8.1: https://github.com/flatpak/xdg-desktop-portal/commit/48a981ee3cc3fbfbb2474629ab6c2e8a81ba67a4

ppd commented 2 years ago

Internal dialog by default was introduced in revisions:

ppd commented 2 years ago

I found another problem with the portal: While it works really well for a lot of things in the user's home folder, it does not work properly for accessing things in $SNAP, i.e. in /snap/freecad-ppd/current. It kinda works, technically spoken, but not really from the average user's perspective. E.g. selecting patterns in TechDraw suffers from this.

ToniTen commented 2 years ago

Found yet another issue with portals in xubuntu 18.04 (Can't upgrade due to issues with GPU drivers, don't ask). Adding it here instead of creating a new issue. I will move this to a new issue if asked

I was trying to add a new directory for macro icons so I could have recognizable toolbar buttons for them, and the following happened:

On a pristine snap install, I go to Tools/Customize/Macros, click on the button next to Pixmap, click on the button "Icon folders...", and click on the button "+". A file chooser dialog opens, but it it doesn't let me select a directory, if I select a directory, it automatically opens it. If I click on an icon and select it, it proxies it through the document portal and I end with a path such as this "/run/user/1000/doc/97603f7e/dowel_pin_hole.svg". If I select the directory on the recents tab and click open, FreeCAD seems to lock up and I need to kill -9 it

The only way to get a custom directory for icons is to select a file in the file chooser, accept that it goes through the portal and gives me a path through /run/user/... and then open ~$/snap/freecad-ppd/common/user.cfg with your choice of text editor and replace the /run/user/... path with the correct path.

FreeCAD version info

OS: Ubuntu Core 20 (xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.28730 (Git)
Build type: Release
Branch: master
Hash: 4358a9ba7031a61f1ade26958b74f95ff8daf1cf
Python 3.8.10, Qt 5.15.3, Coin 4.0.0, OCC 7.6.1
Locale: Spanish/Spain (es_ES)
ppd commented 2 years ago

Yeah, the portals are like a loosely coupled dependency that is very unstable because it exists in different implementations (KDE, Gnome...) and many versions. Significant development efforts need to be spent to get FreeCAD to play along 100% with confinement and portals. I wonder if simply polishing the internal file dialog would be a very good interim step. We could special-case running inside flatpaks/snaps and add proper shortcuts to all relevant paths, so users don't even see the strange home directory of the snap.

ToniTen commented 2 years ago

Doesn't change the fact that it's not possible to properly set a directory for custom icons, even if the directory is in say ~$/images/freecad_icons without manually editing the XML user.cfg file

EDIT: Oh, this also happens on RealThunder's LinkBranch3, but I thought it would be best to post it here first and then link it on LinkBranch3

ppd commented 2 years ago

But portals are not the default any more. Not in this snap and especially not in realthunder's snap. He explicitly disabled the portal file choosers, whereas I merely set the internal file chooser as the default.

Edit: Seems like this part of FreeCAD does not use FreeCAD's file dialog, but always defaults to the native dialog. That's certainly an interesting find. Thank you.