[Gambas-devel] Gambas 1.9.46 Help
Benoit Minisini
gambas at ...1...
Wed Nov 15 11:48:51 CET 2006
On Tuesday 14 November 2006 22:35, Fabien Bodard wrote:
> this is the corrected Functions.
>
> There were three errors
> First one is the env variable name (it miss _DESKTOP_)
> Second one: ubuntu and some other distrib not have epiphany so i've added
> firefox in second case in the gnomedesktop select.
>
> Third one was That the which program don't return anything when the
> required program not exist in debian like distribs.
>
> I've done some cleaning on the data receipt (use of the TO key with SHELL
>
>
> PUBLIC FUNCTION CheckProgram(sProg AS String) AS Boolean
>
> DIM bError AS Boolean
> DIM iPos AS Integer
> DIM sVal AS String
>
> iPos = InStr(sProg, " ")
> IF iPos THEN sProg = Left(sProg, iPos - 1)
>
> SHELL "which " & sProg TO sVal
>
> bError = sVal LIKE "which: *" OR IsNull(sVal)
>
> RETURN bError
>
> END
>
>
> PUBLIC SUB OpenWebPage(sLink AS String)
>
> DIM sExec AS String
> DIM aTest AS String[]
> DIM bCheck AS Boolean
>
> IF NOT Browser THEN
>
> SELECT CASE Settings["/Browser"]
>
> CASE "konqueror"
> aTest = ["konqueror"]
>
> CASE "epiphany"
> aTest = ["epiphany"]
>
> CASE "firefox"
> aTest = ["firefox", "mozilla-firefox"]
>
> CASE "seamonkey"
> aTest = ["seamonkey"]
>
> CASE ELSE
>
> aTest = [Application.Env["BROWSER"]]
>
> IF Application.Env["KDE_FULL_SESSION"] THEN
> aTest.Add("konqueror")
> ELSE IF Application.Env["GNOME_DESKTOP_SESSION_ID"] THEN
> aTest.Add("epiphany")
> aTest.Add("firefox")
> ENDIF
>
> END SELECT
>
> aTest.Add("konqueror")
> aTest.Add("mozilla-firefox")
> aTest.Add("firefox")
> aTest.Add("mozilla")
> aTest.Add("seamonkey")
> aTest.Add("opera")
>
> FOR EACH sExec IN aTest
> bCheck = NOT CheckProgram(sExec)
> IF bCheck THEN BREAK
> NEXT
>
> IF NOT bCheck THEN RETURN
>
> Browser = sExec
>
> ENDIF
>
> IF Left(sLink) = "/" THEN
> sLink = "file://" & Replace(sLink, "?", "%3F")
> ENDIF
>
> SHELL Browser & " " & Chr$(34) & sLink & Chr$(34)
>
> CATCH
>
> Message.Error(Error.Text)
>
> END
>
> Regards,
>
> Fabien Bodard
Merci Fabien!
--
Benoit Minisini
More information about the Devel
mailing list