Error with Desktop.Open() in Debian Testing (Gambas 3.19) [SOLVED]

Post your Gambas programming questions here.
Post Reply
ask4nix
Posts: 7
Joined: Thursday 3rd August 2023 3:24pm

Error with Desktop.Open() in Debian Testing (Gambas 3.19) [SOLVED]

Post by ask4nix »

When trying to open a file or folder with the following code:

Code: Select all

Public Sub btnOpen_Click()
    Desktop.Open(Path_to_file_or_folder)
End
I get this error message in Debian Testing (Gambas 3.19):
This application has raised an unexpected error and must abort.

org.freedesktop.DBus.ErrorServiceUnknown: The
name org.freedesktop.portal.Desktop was not
provided by any service files

[gb.dbus].DBusProxy._Invoke.357
This procedure runs just fine in Debian 12 (Gambas 3.18) and Debian 11.

Can anyone offer an explanation and suggest a solution
Last edited by ask4nix on Friday 1st March 2024 1:17pm, edited 1 time in total.
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Error with Desktop.Open() in Debian Testing (Gambas 3.19)

Post by BruceSteers »

I guess desktop portal in debian testing is not complete,
or not installed
https://packages.debian.org/trixie/xdg-desktop-portal

sudo apt-get install xdg-desktop-portal


Or try this to stop gb.desktop using portal
Desktop.UsePortal = False
If at first you don't succeed , try doing something differently.
BruceS
ask4nix
Posts: 7
Joined: Thursday 3rd August 2023 3:24pm

Re: Error with Desktop.Open() in Debian Testing (Gambas 3.19)

Post by ask4nix »

Thanks, Bruce. I'm a bit busy with work atm, so will try both when I have a bit more free time, and then report back.
As for your second suggestion, where would I set Desktop.UsePortal = False ?
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Error with Desktop.Open() in Debian Testing (Gambas 3.19)

Post by BruceSteers »

ask4nix wrote: Friday 1st March 2024 6:30am Thanks, Bruce. I'm a bit busy with work atm, so will try both when I have a bit more free time, and then report back.
As for your second suggestion, where would I set Desktop.UsePortal = False ?
Just anywhere in the code before you use Desktop.Open()

Desktop.Open will not use desktop portal if Desktop.UsePortal is false

consider this code...

Public sub Form_Open()

 Desktop.Open("computer:///")

  Message("next try without portal")

  Desktop.UsePortal = False
  Desktop.Open("computer:///")

End



The first instance will use the portal and fail to open computer:/// as portal does not support that address.

after setting UsePortal to False it will then use xdg-open and that in turn will use "gio open computer:///" successfully
If at first you don't succeed , try doing something differently.
BruceS
ask4nix
Posts: 7
Joined: Thursday 3rd August 2023 3:24pm

Re: Error with Desktop.Open() in Debian Testing (Gambas 3.19)

Post by ask4nix »

Ok, so I've had a chance to check it out. It turns out that xdg-desktop-portal was already installed in my Debian Testing Vm, so maybe Debian still has to do more work on it.
But setting Desktop.UsePortal=False in Form_Open did the trick and I no longer get the error I originally described, so thank you for the solution, Bruce.

Interestingly, xdg-desktop-portal was not installed on either of my laptops running Debian 12 (MX23 or SparkyLinux 7), so setting Desktop.UsePortal=False threw an error in Gambas 3.18.0.4 running on those systems. I guess gb.Desktop uses gio by default to open files in Gambas 3.18.04
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Error with Desktop.Open() in Debian Testing (Gambas 3.19) [SOLVED]

Post by BruceSteers »

not quite.
gb.desktop has it's own copy of xdg-utils and uses that if xdg-utils is not installed.
it's xdg-open that uses gio

I think this is the reason Benoit is going the portal way as he wants to remove the xdg-utils files from the mix altogether.

if you want compatibility across different systems use Try


Try Desktop.UsePortal = False



Then it will not throw an error in a previous gambas version so it should work all round as if the Desktop.UsePortal property does not exist then the gambas version does not use it and will use xdg-utils anyway :)
If at first you don't succeed , try doing something differently.
BruceS
Post Reply