the Gambas desktop icon actions (Run with..)

Post

Posted
Rating:
#1 (In Topic #1864)
Guru
BruceSteers is in the usergroup ‘Guru’
I made a little script to make the "Run with …" actions of the desktop icon only show the available installed toolkits and not all of them.

Code

#!/usr/bin/env bash

LIBS=$(gbx3 -e 'Component.Path')

for gui in GTK3 QT4 QT5 QT6; do [ -e "$LIBS/gb.${gui,,}.component" ] && AGUIS="$AGUIS$gui;"; done
AGUIS=${AGUIS%;*}

ENTRY="[Desktop Entry]
Name=Gambas 3
Exec=gambas3
GenericName=Gambas 3 IDE
GenericName[fr]=EDI Gambas 3
GenericName[ru]=Gambas 3 IDE(ИСР)
GenericName[nl]=Gambas 3 IDE
Comment=Gambas3 Integrated Development Environment
Comment[fr]=Environnement de développement intégré Gambas3
Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic
Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving
Icon=gambas3
Terminal=false
Type=Application
Categories=Development;IDE;
StartupNotify=true
Actions=$AGUIS
"
OIFS=$IFS
IFS=';'
for gui in $AGUIS; do
ACTIONS="$ACTIONS
[Desktop Action $gui]
Name=Run with $gui
Name[fr]=Exécuter avec $gui
Name[nl]=Uitvoeren met $gui
Name[it]=Esegui con $gui
Exec=env GB_GUI=gb.${gui,,} gambas3
"
done
IFS=$OIFS

#echo "$ENTRY$ACTIONS"
echo "$ENTRY$ACTIONS" >/tmp/gambas3.desktop
xdg-desktop-menu uninstall /tmp/gambas3.desktop # remove old before installing new.
xdg-desktop-menu install --novendor /tmp/gambas3.desktop


If you run this script as it is it will update the ~/.local/share/applications/gambas3.desktop file Actions

To only test it, comment out the last 2 xdg-desktop-menu lines and inspect /tmp/gambas3.desktop after running it

I have used this script in my bruces-patched fork makefile.am so it now does it automatically during make install.
make desktop icon show installed gui toolkits not all of them. (4b838ef8) · Commits · Bruce Steers / gambas · GitLab
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
Update.

I removed thew bash reliant code that conveted text to lower case and used tr command instead.
tr is a POSIX command so it makes the script more compatible than relying on bash being installed.

Code


LIBS=$(gbx3 -e 'Component.Path')

for gui in GTK3 QT4 QT5 QT6
do
LCASE=$(echo -n $gui | tr '[:upper:]' '[:lower:]')
[ -e "$LIBS/gb.$LCASE.component" ] && AGUIS="$AGUIS$gui;"
done
AGUIS=${AGUIS%;*}

ENTRY="[Desktop Entry]
Name=Gambas 3
Exec=gambas3
GenericName=Gambas 3 IDE
GenericName[fr]=EDI Gambas 3
GenericName[ru]=Gambas 3 IDE(ИСР)
GenericName[nl]=Gambas 3 IDE
Comment=Gambas3 Integrated Development Environment
Comment[fr]=Environnement de développement intégré Gambas3
Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic
Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving
Icon=gambas3
Terminal=false
Type=Application
Categories=Development;IDE;
StartupNotify=true
Actions=$AGUIS
"
OIFS=$IFS
IFS=';'
for gui in $AGUIS; do
LCASE=$(echo -n $gui | tr '[:upper:]' '[:lower:]')
ACTIONS="$ACTIONS
[Desktop Action $gui]
Name=Run with $gui
Name[fr]=Exécuter avec $gui
Name[nl]=Uitvoeren met $gui
Name[it]=Esegui con $gui
Exec=env GB_GUI=gb.$LCASE gambas3
"
done
IFS=$OIFS

#echo "$ENTRY$ACTIONS"

echo "$ENTRY$ACTIONS" >/tmp/gambas3.desktop

# UNCOMMENT THE LINE BELOW TO FORCE RE-INSTALL OF ALREADY EXISTING ICON.
#xdg-desktop-menu uninstall /tmp/gambas3.desktop # remove old before installing new.

xdg-desktop-menu install --novendor /tmp/gambas3.desktop

Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
If you want to use a script as part of the Gambas3 packages for Debian/Ubuntu you can simply use bash.
I can make it run after Gambas3 is installed, so all checks and balances can be done and changes applied.

I posted you some links on mailing list to see what debian requires.

If you have a script, that you think complies to debian rules, I'm willing to add it to my recipe for running some package and installation tests in vm to see if it works. 
After that, it's a matter of me adapting the recipe for OSB in master branch, do a merge request and Debian Ubuntu will be done, at least if Benoit thinks it's a good idea ;)

No idea on how it works for the other distro's but it is possible there as well.

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#4
Guru
BruceSteers is in the usergroup ‘Guru’
Cheers Willy.

I wonder if the use of xdg-desktop-menu or gbx3 breaks it's compliance?

All other commands are POSIX.

I re-added the #!shebang line i'd previously removed and added 'set -e' command.  that seemed to be all the vitals the page you pointed me to said was needed.

So i'm fairly sure it's all good (apart from the use of xdg-utils and gbx3)
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

BruceSteers said

Cheers Willy.

I wonder if the use of xdg-desktop-menu or gbx3 breaks it's compliance?

All other commands are POSIX.

I re-added the #!shebang line i'd previously removed and added 'set -e' command.  that seemed to be all the vitals the page you pointed me to said was needed.

So i'm fairly sure it's all good (apart from the use of xdg-utils and gbx3)


xdg-utils is a dependency that will be installed when installing gambas3 (the complete IDE that is).
Only then the desktop entry for gambas3 is created.

Now, I suppose that once installed and at the moment the postinst script is run, the system will be aware of both xdg-utils and gbx3.
If not, it is probably easily solved by a full path reference to gbx3 (for example) in the script.

So, what script do you want me to use for testing and what distro you prefer debian13/12/11 OR/AND Ubuntu 24.04/22.04/20.04.
I will do one or two simultanious builds, all amd64 for testing, so make your pick.
I'll publish a working result if I get one, for you to test as well.
 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
Okay well lets see if it works then :)  And thank you, i couldn't get my head around creating my own repository :(

Attachment

make.gambas3desktop.tar.gz


I have commented out the line that uninstalls the icon first.
This means it will probably only do it's job if the icon does not already exist (I think xdg-desktop-menu does not reinstall over existing)

added code to remove the temp file from /tmp/ and check it does not exist before attempting writing it.

I guess before thinking of submitting a merge to Ben We should think about naming?
maybe make.gambas3desktop is not the best name?

something more like…
MakeDesktopIcon.sh

BTW in my branch the script lives in gambas-source/app/desktop/ folder and the app/Makefile.am has a line to run it from there.
app/desktop/ is where all the other .desktop related files reside so it made sense to put it there.
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’
Re: distro, just do whatever you prefer m8
I'm fairly sure if it works on one of them it should work on them all as they are all deb based packagers.
Online now: No Back to the top

Post

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

BruceSteers said


I have commented out the line that uninstalls the icon first.
This means it will probably only do it's job if the icon does not already exist (I think xdg-desktop-menu does not reinstall over existing)


Hmm thinking about it you may have to un-comment that line so it works.

I'm thinking if the installer installs it's own icon and then the script is run after that then it probably won't overwrite it.

Unless you can stop the packager trying to install the static gambas3.desktop file and leave it to the script.
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
We got a winner

winner.png

I packaged your bruces-patched for debian 12 and 13 and Ubuntu 24.04 (all amd64).Tested on Linux Mint 22 VM. Made sure no gambas was installed, so it's a virgin install and the desktop file is as should be (no more QT4 ;))
I will be testing some more later, first gonna create me some dinner…


 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

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

gbWilly said

We got a winner

I packaged your bruces-patched for debian 12 and 13 and Ubuntu 24.04 (all amd64).Tested on Linux Mint 22 VM. Made sure no gambas was installed, so it's a virgin install and the desktop file is as should be (no more QT4 )
I will be testing some more later, first gonna create me some dinner…


 

Awesome stuff :)

I've tested the autotools method so far on debian/trixie ubuntu/noble fedora42 and manjaro.  all working as expected :)

did you have to add it to the postinst or did it just work from the makefile?
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

BruceSteers said

did you have to add it to the postinst or did it just work from the makefile?


I renamed your script to postinst, did some minor modification and language additions, added it to the recipe and packaged it for bookworm, trixie and noble.
Next I created a repository (see my mail to you) and installed from repo. Works as a charm and has nothing to do with the Gambas source.

script.png

I switch to using bash and added a comment with a short description, autor and copyright. I hope you can agree with the content and license, if not just let me know.
In this form it can be part of the recipe for debian/ubuntu package creation (also for previous Gambas versions).
I will be using it in my recipes as I very much like the solution being tailored to the sytem, good job :thumbs:

Below the content of the Gambas3.deb package and it now has a script named postinst that will run at the end of the gambas3 install (post install :lol:)


gambas3.deb.png  

You can open .deb packages with an archive manager as that is what they are. :thumbs:

 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

Posted
Rating:
#12
Guru
BruceSteers is in the usergroup ‘Guru’
Excellent  :)

You could also tailor yours a bit more to add some other actions (GambOS related)

Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#13
Guru
BruceSteers is in the usergroup ‘Guru’
So we change this line…

[ -e "$LIBS/gb.$LCASE.component" ] && AGUIS="$AGUIS$gui;"

To be this…
[ -e "$LIBS/gb.$LCASE.webview.component" ] && AGUIS="$AGUIS$gui;"

Then as Benoit stated it more accurately checks that webview exists as the toolkit can be present but missing webkit so the ide won't use that toolkit.

Updated version..
Attachment

make.gambas3desktop.tar.gz


Last edit: by BruceSteers

Online now: No Back to the top

Post

Posted
Rating:
#14
Guru
BruceSteers is in the usergroup ‘Guru’
Well my fork of gambas now makes the icon dynamically on install and I also added an option in the preferences to update the desktop menu icon.

Untitled.jpg
That'll do nicely for me :)
Online now: No Back to the top

Post

Posted
Rating:
#15
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
That is probably a way better solution as the packaging solution is not sinking in with Benoit somehow, no matter the amount of post I spend on explain the matter  O_o

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

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

gbWilly said

That is probably a way better solution as the packaging solution is not sinking in with Benoit somehow, no matter the amount of post I spend on explain the matter  

Yep he can be hard to convince sometimes.
I think his view is if they are all there then none are missing.

that's why i like compiling my own fork/branch. If I want it and Ben does not then that's fine, I can still have it :)

I've just updated my function to load the existing file (if exists) and use DesktopFile.class to ensure any additional user added Actions are preserved :)
app/src/gambas3/.src/Options/FOption.class · e7dc14a4f695e9b464338fc33cfe14d142d16478 · Bruce Steers / gambas · GitLab
Online now: No Back to the top

Post

Posted
Rating:
#17
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

BruceSteers said

Yep he can be hard to convince sometimes.
I think his view is if they are all there then none are missing.

that's why i like compiling my own fork/branch. If I want it and Ben does not then that's fine, I can still have it :)

I've just updated my function to load the existing file (if exists) and use DesktopFile.class to ensure any additional user added Actions are preserved :)
app/src/gambas3/.src/Options/FOption.class · e7dc14a4f695e9b464338fc33cfe14d142d16478 · Bruce Steers / gambas · GitLab

Yes, I had a look at it (saw mailing list first) and I like the implementation  :thumbs:
That would solve it for all circumstances and the package solution wouldn't be needed.

Hope Benoit likes your solution  ;)

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

Posted
Rating:
#18
Guru
BruceSteers is in the usergroup ‘Guru’
Here is the updated function from the IDE as a gbs gambas script file

The advantages of the gbs script are as follows..
It uses DesktopFile.class and DesktopActions.class to make the file.

it checks for an existing icon and pre-loads it before adding missing toolkit Actions or removing superfluous ones. thus preserving any existing other Actions you may have set.

It works outside of the IDE like the other script. Just run it to update your desktop menu icon toolkits.

I'm not so sure it's any good to use during an install like the other script because gambas scripting (gbs3) might not be installed.
Attachment

makegambas3desktop.gbs.tar.gz

Online now: No Back to the top

Post

Posted
Rating:
#19
Guru
BruceSteers is in the usergroup ‘Guru’
There is also this option I came up with after one of my replies to Benoit.

regarding having a GUI selector.

here is a script that asks what GUI to load for a program…
Attachment

gb-gui.tar.gz


It's very basic and probably needs refining but it works.  it's a bash/gbs hybrid

example usage.
gb-gui gambas3
gb-gui /path/to/myprog.gambas

If there was a way to make gambas do this it would be awesome.
for example
env GB_GUI=ASK gambas3

That would solve everything because the gambas3 icon could then just have the one Action to pop up a requester to ask what toolkit to load.
Online now: No Back to the top

Post

Posted
Rating:
#20
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

BruceSteers said

Here is the updated function from the IDE as a gbs gambas script file

The advantages of the gbs script are as follows..
It uses DesktopFile.class and DesktopActions.class to make the file.

it checks for an existing icon and pre-loads it before adding missing toolkit Actions or removing superfluous ones. thus preserving any existing other Actions you may have set.

It works outside of the IDE like the other script. Just run it to update your desktop menu icon toolkits.

I'm not so sure it's any good to use during an install like the other script because gambas scripting (gbs3) might not be installed.
Gambas script running from the installer might be problematic, unless gbs3 is installed. Safer to use bash scripts.
But in theory it should be possible, a matter of trying I guess.

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: Yes Back to the top

Post

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

I guess there's this solution.

The function is now a small program (8.8kb compressed)
I made it detect if being run from a GUI environment or terminal and use either Message() or Print respectively.

the script can just unpack the archive to /tmp and use gbx3 to run the project dir , gbx3 WILL be installed :)

With the attached archive in the app/desktop folder the script can be just this…

Code

#!/usr/bin/env bash
echo ${0}
tar -xf "${0%/*}/GambasDesktop.tar.gz" -C /tmp >/dev/null
[ $? -ne 0 ] && exit
cd /tmp/GambasDesktop
gbc3 -ax ./ >/dev/null
gbx3 ./
rm -rf /tmp/GambasDesktop

EDIT: Archive updated as it worked on everything except OpenSuse with wayland.
Attachment

GambasDesktop.tar.gz

Last edit: by BruceSteers

Online now: No Back to the top

Post

Posted
Rating:
#22
Guru
BruceSteers is in the usergroup ‘Guru’
Here is my final solution to this..
Attachment

MakeDesktopMenu.tar.gz


How it works…
In the attached archive is a bash script and a gambas module source.

The bash script is this…

Code

#!/usr/bin/env bash

[ -d "/tmp/GambasDesktop" ] && rm -rf /tmp/GambasDesktop
mkdir /tmp/GambasDesktop
mkdir /tmp/GambasDesktop/.src

cp ${0%/*}/GambasDesktop.module /tmp/GambasDesktop/.src/
echo -e "# Gambas Project File 3.0\nStartup=GambasDesktop\nVersion=0.0.1\nComponent=gb.image\nComponent=gb.desktop" >/tmp/GambasDesktop/.project

cd /tmp/GambasDesktop
gbc3 -ax ./ >/dev/null
gbx3 ./
rm -rf /tmp/GambasDesktop

So instead of using a compressed archive of the project it now creates a project on the fly by copying the source module and making a .project file.
that is much faster.

The source module is this…

Code


Public Sub Main()

  Component.Load("gb.desktop")
  Dim hExisting, hNew As DesktopFile
  Dim sTemp As String = File.SetExt(Temp("gambas3"), "desktop")
  Dim sGui, sExisting As String
  Dim aToolkits As String[] = ["GTK3", "GTK4", "QT4", "QT5", "QT6"]
  Dim aActions As String[]
  Dim iChanges As Integer
  Dim bCanWrite As Boolean

  If Exist(sTemp) Then Kill sTemp

  For Each sExisting In ["~/.local/share/applications/gambas3.desktop", "/usr/local/share/applications/gambas3.desktop", "/usr/share/applications/gambas3.desktop"]
    If Exist(sExisting) Then
      hExisting = New DesktopFile(sExisting)
      bCanWrite = Access(sExisting, gb.Write)
      Break
    Endif
    sExisting = ""
  Next

  If sExisting And If Not bCanWrite Then
    hExisting.Save(sTemp)
  Else If sExisting And If bCanWrite Then
    hNew = hExisting
  Else
    File.Save(sTemp,
      "[Desktop Entry]\n"
      "Name=Gambas 3\n"
      "Exec=gambas3\n"
      "GenericName=Gambas 3 IDE\n"
      "GenericName[fr]=EDI Gambas 3\n"
      "GenericName[ru]=Gambas 3 IDE(ИСР)\n"
      "GenericName[nl]=Gambas 3 IDE\n"
      "Comment=Gambas3 Integrated Development Environment\n"
      "Comment[fr]=Environnement de développement intégré Gambas3\n"
      "Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic\n"
      "Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving\n"
      "Icon=gambas3\n"
      "Terminal=false\n"
      "Type=Application\n"
      "Categories=Development;IDE;\n"
    "StartupNotify=true\n")
  Endif

  If Not bCanWrite Then hNew = New DesktopFile(sTemp)
  aActions = Split(hNew.Actions.Join("]"), "]", Null, True)
  If Not aActions Then aActions = []

  For c As Integer = aToolkits.Max DownTo 0
    sGui = aToolkits[c]

    If Exist(Component.Path &/ "gb." & LCase(sGui) & ".webview.component") Then

      If Not aActions.Exist(sGui) Then
        Inc iChanges
        aActions.Add(sGui, 0)
        hNew.DesktopActions.Add(sGui, "Run with " & sGui, "env GB_GUI=gb." & LCase(sGui) & " gambas3")
        hNew.DesktopActions[sGui]["Name[fr]"] = "Exécuter avec " & sGui
        hNew.DesktopActions[sGui]["Name[nl]"] = "Uitvoeren met " & sGui
        hNew.DesktopActions[sGui]["Name[it]"] = "Esegui con " & sGui
      Endif

    Else

      If aActions.Exist(sGui) Then
        Inc iChanges
        aActions.Remove(hNew.Actions.Find(sGui))
        hNew.DesktopActions[sGui].Delete
      Endif
      aToolkits.Remove(c)

    Endif
  Next

  If sExisting And If iChanges = 0 Then Error.Raise("No changes made to desktop menu icon")
  hNew.Actions = aActions
  hNew.Save
  If Not bCanWrite Then
    Shell "xdg-desktop-menu uninstall gambas3.desktop\nxdg-desktop-menu install --novendor " & Shell(sTemp) & "\nxdg-desktop-menu forceupdate" Wait
    Kill sTemp
  Else
    Shell "xdg-desktop-menu forceupdate" Wait
  Endif
  Print "gambas3.desktop menu " & If(bCanWrite, "reconfigured", "rebuilt") & " with toolkits: " & aToolkits.Join(", ")

Catch
  Print Error.Text
  If Exist(sTemp) Then Kill sTemp

End


Now if an existing icon is found and it is writable it will modify it instead of using xdg to re-install
also i use one Shell Wait command instead of multiple Exec Wait commands.

during install there is no lag now, the info text appears instantly.

the attached archive script can be run standalone but it no longer uses Message for results just Print.

tested working okay on debian / ubuntu / fedora / manjaro and opensuse
Online now: No Back to the top

Post

Posted
Rating:
#23
Guru
BruceSteers is in the usergroup ‘Guru’
sorry , THIS is my final solution.

I have now removed the need for the separate GambasDesktop.module file by importing it into the bash script to be written by an echo redirect.

So now it's all self contained in one script :)

Code

#!/usr/bin/env bash

[ -d "/tmp/GambasDesktop" ] && rm -rf /tmp/GambasDesktop
mkdir /tmp/GambasDesktop
mkdir /tmp/GambasDesktop/.src

echo '
Public Sub Main()

  Component.Load("gb.desktop")
  Dim hExisting, hNew As DesktopFile
  Dim sTemp As String = File.SetExt(Temp("gambas3"), "desktop")
  Dim sGui, sExisting As String
  Dim aToolkits As String[] = ["GTK3", "GTK4", "QT4", "QT5", "QT6"]
  Dim aActions As String[]
  Dim iChanges As Integer
  Dim bCanWrite As Boolean

  If Exist(sTemp) Then Kill sTemp

  For Each sExisting In ["~/.local/share/applications/gambas3.desktop", "/usr/local/share/applications/gambas3.desktop", "/usr/share/applications/gambas3.desktop"]
    If Exist(sExisting) Then
      hExisting = New DesktopFile(sExisting)
      bCanWrite = Access(sExisting, gb.Write)
      Break
    Endif
    sExisting = ""
  Next

  If sExisting And If Not bCanWrite Then
    hExisting.Save(sTemp)
  Else If sExisting And If bCanWrite Then
    hNew = hExisting
  Else
    File.Save(sTemp,
      "[Desktop Entry]\n"
      "Name=Gambas 3\n"
      "Exec=gambas3\n"
      "GenericName=Gambas 3 IDE\n"
      "GenericName[fr]=EDI Gambas 3\n"
      "GenericName[ru]=Gambas 3 IDE(ИСР)\n"
      "GenericName[nl]=Gambas 3 IDE\n"
      "Comment=Gambas3 Integrated Development Environment\n"
      "Comment[fr]=Environnement de développement intégré Gambas3\n"
      "Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic\n"
      "Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving\n"
      "Icon=gambas3\n"
      "Terminal=false\n"
      "Type=Application\n"
      "Categories=Development;IDE;\n"
    "StartupNotify=true\n")
  Endif

  If Not bCanWrite Then hNew = New DesktopFile(sTemp)
  aActions = Split(hNew.Actions.Join("]"), "]", Null, True)
  If Not aActions Then aActions = []

  For c As Integer = aToolkits.Max DownTo 0
    sGui = aToolkits[c]

    If Exist(Component.Path &/ "gb." & LCase(sGui) & ".webview.component") Then

      If Not aActions.Exist(sGui) Then
        Inc iChanges
        aActions.Add(sGui, 0)
        hNew.DesktopActions.Add(sGui, "Run with " & sGui, "env GB_GUI=gb." & LCase(sGui) & " gambas3")
        hNew.DesktopActions[sGui]["Name[fr]"] = "Exécuter avec " & sGui
        hNew.DesktopActions[sGui]["Name[nl]"] = "Uitvoeren met " & sGui
        hNew.DesktopActions[sGui]["Name[it]"] = "Esegui con " & sGui
      Endif

    Else

      If aActions.Exist(sGui) Then
        Inc iChanges
        aActions.Remove(hNew.Actions.Find(sGui))
        hNew.DesktopActions[sGui].Delete
      Endif
      aToolkits.Remove(c)

    Endif
  Next

  If sExisting And If iChanges = 0 Then Error.Raise("No changes made to desktop menu icon")
  hNew.Actions = aActions
  hNew.Save
  If Not bCanWrite Then
    Shell "xdg-desktop-menu uninstall gambas3.desktop\nxdg-desktop-menu install --novendor " & Shell(sTemp) & "\nxdg-desktop-menu forceupdate" Wait
    Kill sTemp
  Else
    Shell "xdg-desktop-menu forceupdate" Wait
  Endif
  Print "gambas3.desktop menu " & If(bCanWrite, "reconfigured", "rebuilt") & " with toolkits: " & aToolkits.Join(", ")

Catch
  Print Error.Text
  If Exist(sTemp) Then Kill sTemp

End
' >/tmp/GambasDesktop/.src/GambasDesktop.module

echo -e "# Gambas Project File 3.0\nStartup=GambasDesktop\nVersion=0.0.1\nComponent=gb.image\nComponent=gb.desktop" >/tmp/GambasDesktop/.project

cd /tmp/GambasDesktop
gbc3 -ax ./ >/dev/null
gbx3 ./
rm -rf /tmp/GambasDesktop

Attachment

make.gambas3desktop.tar.gz

Online now: No Back to the top
1 guest and 0 members have just viewed this.