[Gambas-user] Making an app gtk/qt switchable
Bruce Steers
bsteers4 at gmail.com
Sun Nov 15 23:15:45 CET 2020
> Aah cool :)
> > It's great , i've set a number of my app launchers on my panel like it
> > now, working a treat :)
> > thanks again
> > BruceS
> >
>
>
I have come up with my own solution too now if anyone wants to see it...
Maybe i'm doing it badly? i do not know but this works for me...
It changes (for me) the "no, cannot make an app choose it's gui on launch"
to , "Yes, this way...."
I've used it on this "under-construction" git managing app i'm making.
https://gitlab.com/bsteers4/gitman
The reason is clicking text in the TextArea in QT and GTK3 will auto select
the filename clicked.
But on GTK2 it does not work.
So if GTK2 is detected it offers a choice on launch without me presetting
an env GB_GUI prefix.
To try it out just run the GitMan.gambas app with GTK2 and test the click a
filename feature with different gui's.
To test the file auto-select-filename feature it wants to be given a git
folder with unadded commits then the "status" page will list them under
"modified: filename". click a filename in gtk2 and nothing happens, but
works in the other GUI environments.
Perhaps there's a better way you experts can make the following code an
optimal solution for us all?
Thanks :)
(there's always a way :)
Here's the code (condensed version)..
(comments removed (or bunched up to same line) to shorten for this email,
the version on gitlab has full comments)
*Public Sub Form_Open()*
*If Not Component.IsLoaded("gb.gtk") Then Goto SkipGtkCheck ' gtk2 not
being used so skip.Dim iVal As Integer = Message.Question("Warning GTK2
detected!\nSome functions like clicking a file to select\nthe whole
filename do not work on GTK2.\nReload a diferent GUI base?", "Run with
GTK3", "Run with QT5", "Use GTK2") *
*If iVal = 3 Then Goto SkipGtkCheck ' User Selected continue with gtk2
loaded so skip reload.*
*Dim sArgs As String[] = Args.All.Copy() ' Copy args to String[]*
*If File.Ext(sArgs[0]) <> "gambas" Then sArgs[0] &= ".gambas" ' only needed
if running from IDE*
* If Left(sArgs[0], 2) = "./" Then ' Make sure path of launched app is full
not relative. sArgs[0] = Application.Path &/ Right(sArgs[0], -2) Else If
InStr(sArgs[0], "/") = 0 Then sArgs[0] = Application.Path &/
sArgs[0] EndifsArgs.Add("env", 0) ' Add GB_GUI=gb.<chosen> env prifix to
commandsArgs.Add("GB_GUI=gb." & ["", "gtk3", "qt5"][iVal], 1)Wait 0.1 '
above question window will not close if not Wait 0.1*
* Exec sArgs Wait ' Relaunch Application with args and GUI prefix and
wait hidden, then quit after relaunched app quits.*
* Stop Event Quit 'Return SkipGtkCheck:*
*' Rest of Form_Open() and normal running of app from here*
*'*
*End*
Any thoughts / Improvements on that anyone ?
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201115/73bd4807/attachment.htm>
More information about the User
mailing list