MakeIcon.module

So you have written that new, must have program. Let us see it here.
Post Reply
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

MakeIcon.module

Post by BruceSteers »

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 doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: MakeIcon.module

Post by BruceSteers »

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..
If at first you don't succeed , try doing something differently.
BruceS
Post Reply