Thread: [Gambas-user] Desktop.Open [,Wait], what does it do?
Brought to you by:
gambas
|
From: T L. D. <t.l...@gm...> - 2014-11-22 19:49:37
|
Hi, Desktop.Open is quite a handy utility. Thank you for that, Benoît. But now can anyone help me understand what Desktop.Open, with Wait=True, does? The Gambas documentation does not say, and the 'xdg-open' documentation gives no mention of it. I thought perhaps it might cause Desktop.Open to wait until the opened application terminates. But it does not. I have tested it with Wait set to True and False, and with image and text files. And, the only difference I see is that Wait=True causes only a slight delay before Desktop.Open returns. In both cases (True or False), Desktop.Open returns before the application fully launches and becomes the active window. One more thing to clarify. Am I correct in assuming that since it is optional, the default would be False? -- Lee __________ "Artificial Intelligence is no match for natural stupidity." |
|
From: Tobias B. <ta...@gm...> - 2014-11-22 20:07:28
|
On Sat, 22 Nov 2014, T Lee Davidson wrote: > Hi, > > Desktop.Open is quite a handy utility. Thank you for that, Beno??t. > > > But now can anyone help me understand what Desktop.Open, with Wait=True, > does? > > The Gambas documentation does not say, and the 'xdg-open' documentation > gives no mention of it. > > I thought perhaps it might cause Desktop.Open to wait until the opened > application terminates. But it does not. > > I have tested it with Wait set to True and False, and with image and > text files. And, the only difference I see is that Wait=True causes only > a slight delay before Desktop.Open returns. > > In both cases (True or False), Desktop.Open returns before the > application fully launches and becomes the active window. > > > One more thing to clarify. Am I correct in assuming that since it is > optional, the default would be False? > Apparently it waits for the xdg script to terminate. There is no relation to the actually launched application -- the xdg script can a priori terminate before the application window emerges, or it can terminate even after the launched application did (if it's very short-lived), or everything between these extremes. But when Wait = True, Desktop.Open() tries to report errors that happened during running the xdg script. You can answer these questions yourself, too, if you care to do that, by looking at the source code. gb.desktop is written in Gambas. The particular sources I got these answers from are [0] and [1]. Regards, Tobi [0] http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.desktop/.src/Desktop.class [1] http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.desktop/.src/Main.module -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk |
|
From: T L. D. <t.l...@gm...> - 2014-11-23 05:39:03
|
On 11/22/2014 03:04 PM, Tobias Boege wrote: > Apparently it waits for the xdg script to terminate. There is no relation to > the actually launched application -- the xdg script can a priori terminate > before the application window emerges, or it can terminate even after the > launched application did (if it's very short-lived), or everything between > these extremes. > > But when Wait = True, Desktop.Open() tries to report errors that happened > during running the xdg script. You can answer these questions yourself, too, > if you care to do that, by looking at the source code. gb.desktop is written > in Gambas. The particular sources I got these answers from are [0] and [1]. > > Regards, > Tobi > > [0]http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.desktop/.src/Desktop.class > [1]http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.desktop/.src/Main.module Thank you, Tobi. Those links helped me get right to it. I can now see the difference clearly. I have updated the documentation (http://gambaswiki.org/wiki/comp/gb.desktop/desktop/open) based on your response. However, Desktop.Open with Wait=True does not Error.Raise("The action has failed") when it should. On the command-line, `xdg-open doesnotexist.txt` causes an error message box to pop up and exits with a status code of 4, which is "The action failed." (It sure would be nice if xdg-open provided a --quiet option.) The following code in a form, when executed, prints no errors: Public Sub Button1_Click() Try Desktop.Open("doesnotexist.txt", True) If Error Then Print Error.Text Catch Print Error.Text End So, perhaps the documentation revision I just made is not entirely correct in practice. -- Lee __________ "Artificial Intelligence is no match for natural stupidity." |
|
From: Benoît M. <ga...@us...> - 2014-11-23 12:17:51
|
Le 23/11/2014 06:38, T Lee Davidson a écrit : > On 11/22/2014 03:04 PM, Tobias Boege wrote: >> Apparently it waits for the xdg script to terminate. There is no relation to >> the actually launched application -- the xdg script can a priori terminate >> before the application window emerges, or it can terminate even after the >> launched application did (if it's very short-lived), or everything between >> these extremes. >> >> But when Wait = True, Desktop.Open() tries to report errors that happened >> during running the xdg script. You can answer these questions yourself, too, >> if you care to do that, by looking at the source code. gb.desktop is written >> in Gambas. The particular sources I got these answers from are [0] and [1]. >> >> Regards, >> Tobi >> >> [0]http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.desktop/.src/Desktop.class >> [1]http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.desktop/.src/Main.module > > Thank you, Tobi. Those links helped me get right to it. I can now see > the difference clearly. > > I have updated the documentation > (http://gambaswiki.org/wiki/comp/gb.desktop/desktop/open) based on your > response. > > > However, Desktop.Open with Wait=True does not Error.Raise("The action > has failed") when it should. > > On the command-line, `xdg-open doesnotexist.txt` causes an error message > box to pop up and exits with a status code of 4, which is "The action > failed." (It sure would be nice if xdg-open provided a --quiet option.) > > The following code in a form, when executed, prints no errors: > > Public Sub Button1_Click() > > Try Desktop.Open("doesnotexist.txt", True) > If Error Then Print Error.Text > > Catch > Print Error.Text > > End > > > So, perhaps the documentation revision I just made is not entirely > correct in practice. > > I guess it's not my fault: the 'kde-open' executable (which is used by xdg-open on KDE) returns "0" inside the script, whereas it returns "1" when run from the shell. So 'xdg-open' thinks it has been successfull. And I have no idea how it could be possible... Regards, -- Benoît Minisini |
|
From: Benoît M. <ga...@us...> - 2014-11-23 13:04:13
|
Le 23/11/2014 13:17, Benoît Minisini a écrit : > > I guess it's not my fault: the 'kde-open' executable (which is used by > xdg-open on KDE) returns "0" inside the script, whereas it returns "1" > when run from the shell. So 'xdg-open' thinks it has been successfull. > And I have no idea how it could be possible... > > Regards, > I found a workaround in revision #6670. Now Desktop.Open() should behave as expected, at least on KDE desktops. I didn't test the others. Regards, -- Benoît Minisini |