MakeIcon.module
Posted: 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...
Creates a Desktop Icon with apps name (without extension) and icon and sets the descriptive "comment"
Creates a Menu item using app name and app icon with descriptive "comment" in the audio/video section
Makes menu entry with app name, sets comment and asks user to select menu categories
Makes Desktop launcher with App name, an image from the app dir (comment will be app name)
Makes a Desktop launcher with App name, Apps main form icon (comment is App name)
Tested on latest Debian / Ubuntu / Mint
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")
Code: Select all
MakeIcon.MakeMe(,, "MediaPlay TVShow Player", "Application;GNOME;AudioVideo;Video")
Code: Select all
MakeIcon.MakeMe(,, "MediaPlay TVShow Player", "choose")
Code: Select all
MakeIcon.MakeMe(, Image.Load("./FunkyIcon.png"))
Code: Select all
MakeIcon.MakeMe()
Tested on latest Debian / Ubuntu / Mint