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

Post

Posted
Rating:
#1 (In Topic #1195)
Trainee
When trying to open a file or folder with the following code:

Code

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
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
I guess desktop portal in debian testing is not complete,
or not installed
Debian -- Details of package xdg-desktop-portal in trixie

sudo apt-get install xdg-desktop-portal


Or try this to stop gb.desktop using portal

Code (gambas)

  1. Desktop.UsePortal = False
  2.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
 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 ?
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’

ask4nix said

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…

Code (gambas)

  1. Public sub Form_Open()
  2.  
  3.  Desktop.Open("computer:///")
  4.  
  5.   Message("next try without portal")
  6.  
  7.   Desktop.UsePortal = False
  8.   Desktop.Open("computer:///")
  9.  
  10.  
  11.  

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
Online now: No Back to the top

Post

Posted
Rating:
#5
Trainee
 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
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
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

Code (gambas)

  1.  
  2. Try Desktop.UsePortal = False
  3.  
  4.  

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 :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.