Page 1 of 1

Desktop.Open() question

Posted: Sunday 12th December 2021 8:24pm
by Diverod
Seems I don't understand the proper usage for this. When I try the below

Code: Select all

Public Sub Button1_Click()

  Desktop.Open("https://startpage.com/", True)

End
I get nothing.
If I put https://startpage.com/ as the text of a UrlLabel and click on it, it functions properly.
I did check my Components and noticed that gb.desktop is only partially green. (Is that significant?)

I've tried throwing peanut butter at the wall for 2 days and can't get anything to stick! I must be doing something wrong. :?:

Re: Desktop.Open() question

Posted: Monday 13th December 2021 1:10am
by BruceSteers
It works as expected for me with that url.

do you get a result if you use xdg-open in a terminal?

xdg-open https://startpage.com/

Desktop.Open() uses xdg-open

Re: Desktop.Open() question

Posted: Monday 13th December 2021 3:07am
by Diverod
BruceSteers wrote: Monday 13th December 2021 1:10am It works as expected for me with that url.

do you get a result if you use xdg-open in a terminal?

xdg-open https://startpage.com/

Desktop.Open() uses xdg-open
Yes, works fine in terminal with xdg-open https://startpage.com/.
I have this in the notes of my UrlLabel

Code: Select all

Public Sub ulbStartPage_Click()

  '' If you add the 'gb.desktop' component you can use (this worked with 3.14.3)
  '' After updating to 3.16.3 this crashes and needed the component gb.pcre
  '' sudo apt-get install gambas3-gb-pcre
  '' This now works but opens 2 of the same web page < add Wait = True to correct
   Desktop.Open("https://startpage.com/", True)
    
End
But then I realized that the UrlLabel ignores the Desktop.Open("https://startpage.com/", True) and uses whatever is in the text of the label.
I also didn't understand what the gb.pcre had to do with anything and it's not checked in Project > Components, but it did stop the crashing.

I was just wanting to open a couple different web pages programmatically. If it works for you it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?

Thanks for your response.

Re: Desktop.Open() question

Posted: Monday 13th December 2021 3:18am
by Diverod
I just saw this in my terminal window if it helps.

Code: Select all

rodg@rodg-ubuntu:~$ xdg-open https://startpage.com/
rodg@rodg-ubuntu:~$ Gtk-Message: Failed to load module "canberra-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"
/usr/share/libdrm/amdgpu.ids: No such file or directory
Opening in existing browser session.
[7518:7518:0100/000000.902768:ERROR:sandbox_linux.cc(376)] InitializeSandbox() called with multiple threads in process gpu-process.
It did open the browser properly and switched to it, causing me to miss the above.

Re: Desktop.Open() question

Posted: Monday 13th December 2021 2:51pm
by BruceSteers
Diverod wrote: Monday 13th December 2021 3:07am
BruceSteers wrote: Monday 13th December 2021 1:10am It works as expected for me with that url.

do you get a result if you use xdg-open in a terminal?

xdg-open https://startpage.com/

Desktop.Open() uses xdg-open
Yes, works fine in terminal with xdg-open https://startpage.com/.
I have this in the notes of my UrlLabel

Code: Select all

Public Sub ulbStartPage_Click()

  '' If you add the 'gb.desktop' component you can use (this worked with 3.14.3)
  '' After updating to 3.16.3 this crashes and needed the component gb.pcre
  '' sudo apt-get install gambas3-gb-pcre
  '' This now works but opens 2 of the same web page < add Wait = True to correct
   Desktop.Open("https://startpage.com/", True)
    
End
But then I realized that the UrlLabel ignores the Desktop.Open("https://startpage.com/", True) and uses whatever is in the text of the label.
I also didn't understand what the gb.pcre had to do with anything and it's not checked in Project > Components, but it did stop the crashing.

I was just wanting to open a couple different web pages programmatically. If it works for you it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?

Thanks for your response.
Aah yes, you are doing something twice there.
UrlLabel is a clickable link, it's already doing what you are doing. the link is set in the Link field not the Text field (possibly it uses the text field if the link field has not been filled).

your Click event function would make sense for a normal label but not for UrlLabel.
To override the UrlLabel function use Stop Event

Code: Select all

Public Sub ulbStartPage_Click()

   Desktop.Open("https://startpage.com/", True)
   Stop Event  ' cancel the standard function of urlLabel
       
End
Or you could just use the shell
Exec ["xdg-open", "https://startpage.com/"]

Re: Desktop.Open() question

Posted: Monday 13th December 2021 3:20pm
by Diverod
BruceSteers wrote: Monday 13th December 2021 2:51pm
Or you could just use the shell
Exec ["xdg-open", "https://startpage.com/"]
I think I'll just sidestep the Desktop.Open for now. I think I run a little behind the curve on Gambas updates due to the use of Ubuntu 20.04.3. but I don't really know enough to be sure of that

The above will work great for me, so my problem is Solved. :D Thanks Bruce.

Re: Desktop.Open() question

Posted: Monday 13th December 2021 3:28pm
by BruceSteers
Diverod wrote: Monday 13th December 2021 3:20pm
BruceSteers wrote: Monday 13th December 2021 2:51pm
Or you could just use the shell
Exec ["xdg-open", "https://startpage.com/"]
I think I'll just sidestep the Desktop.Open for now. I think I run a little behind the curve on Gambas updates due to the use of Ubuntu 20.04.3. but I don't really know enough to be sure of that

The above will work great for me, so my problem is Solved. :D Thanks Bruce.
You're welcome.

If you want to keep updated i made some utilities to help update to latest gambas versions..

the easiest way on an ubuntu system is to use the PPA method..

see the apt repository PPA latest gambas install info here..
http://gambaswiki.org/wiki/install/ubuntu
There's instructions for adding either the gambas stable release or the latest development branch


Gambas compile and install info...
http://gambaswiki.org/wiki/install

Some utilities to simplify auto-tools install method..
http://gambaswiki.org/wiki/installtools

Re: Desktop.Open() question

Posted: Monday 13th December 2021 4:25pm
by stevedee
Diverod wrote: Monday 13th December 2021 3:07am ...it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?
It means "not finished, but stable"

Fully green means "stable"

Fully white/hollow means "experimental"

Re: Desktop.Open() question

Posted: Monday 13th December 2021 8:39pm
by Diverod
stevedee wrote: Monday 13th December 2021 4:25pm
Diverod wrote: Monday 13th December 2021 3:07am ...it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?
It means "not finished, but stable"

Fully green means "stable"

Fully white/hollow means "experimental"
Thanks stevedee, that's great info. I had truly been wondering the meaning of the half filled circle.
I see now that if I'd left my mouse over that green circle it would have told me a bit more. :shock:
BruceSteers wrote: Monday 13th December 2021 3:28pm Some utilities to simplify auto-tools install method..
http://gambaswiki.org/wiki/installtools
Thanks Bruce, I used one of your auto-tools(very,very nice) Simple Upgrade so Gambas should be correct now. Desktop.Open still doesn't work for me so it must be something with Ubuntu. No worries though as "xdg-open" works great.

Thanks to All, RodG