MakeIcon.module

Post Reply
User avatar
BruceSteers
Posts: 156
Joined: Thursday 23rd July 2020 5:20pm

MakeIcon.module

Post by BruceSteers » Saturday 19th September 2020 12:36pm

Want your apps to make their own launcher?

MakeIcon.module written by Bruce Steers
Have your gambas application create it's own launcher icon as either a desktop launcher or
a menu entry.

Simply add (Import) the MakeIcon.module to your app then you can use the following command...
# MakeIcon.MakeMe(Name, Icon Image, Comment, MenuCats, Prefix, UseRoot)

'Name' is the desktop icon name or the menu entry text and is optional,
Defaults to Application.Name

'Icon Image' is the icon 'Image' to use, must be a loaded Image object not just a filepath.
Defaults to the Applications main form icon.

'Comment' is the tooltip shown. Defaults to Application.Name

'MenuCats' Semicolon separated list of categories that define where the menu entry appears
Eg. Application;AudioVideo;Video
This property acts as a switch, if supplied it makes a menu entry, if ommited it makes
a desktop launcher.
Use the word 'choose' to pop a requester to ask the user to choose categories.

'Prefix' any text to prefix your launcher command, Ie 'pkexec gbr3'
Defaults to 'gbr3'

'UseRoot', Boolean toggle , If True and your app is running as root the launcher will be added to 'roots'
desktop or menu. By default the launcher will add to default Users home not root.

Example Usage...

Code: Select all

MakeIcon.MakeMe(File.BaseName(Application.Name), FMain.Icon.Image, "MediaPlay TVShow Player")
Creates a Desktop Icon with apps name (without extension) and icon and sets the descriptive "comment"

Code: Select all

MakeIcon.MakeMe(,, "MediaPlay TVShow Player", "Application;GNOME;AudioVideo;Video")
Creates a Menu item using app name and app icon with descriptive "comment" in the audio/video section

Code: Select all

MakeIcon.MakeMe(,, "MediaPlay TVShow Player", "choose")
Makes menu entry with app name, sets comment and asks user to select menu categories

Code: Select all

MakeIcon.MakeMe(, Image.Load("./FunkyIcon.png"))
Makes Desktop launcher with App name, an image from the app dir (comment will be app name)

Code: Select all

MakeIcon.MakeMe()
Makes a Desktop launcher with App name, Apps main form icon (comment is App name)

Tested on latest Debian / Ubuntu / Mint
If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 156
Joined: Thursday 23rd July 2020 5:20pm

Re: MakeIcon.module

Post by BruceSteers » Sunday 20th September 2020 9:21am

I found a bug i'd missed after adding some arguments (Prefix and UseRoot)
When using the "choose" option it stored the calling args but i hadn't updated the call to include the additional parameters.

Have fixed it now..
Attachments
MakeIcon.mod.zip
(2.96 KiB) Downloaded 22 times
If at first you don't succeed , try it differently.

Post Reply