Skip to content

Commit

Permalink
More menu item work.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 13, 2008
1 parent 0b92f06 commit a31d230
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 17 deletions.
77 changes: 77 additions & 0 deletions docs.txt
Expand Up @@ -706,6 +706,83 @@ Here are the elements, and the attributes they can possess.
non-nil permission, the filter takes precedence.


Setup.DesktopMenuItem:

This element specifies a menu item that will be installed in the system
desktop menu: this might be the "Applications" dropdown in the Gnome panel,
or the "Start" bar on Windows, for example. This can be a child of
Setup.Option (in which case it is only considered for installation if the
option itself is too), or Setup.Package (in which case it is always
considered for installation). Some of this element's properties are ignored
on some operating systems, but they are still required both for
cross-platform safety and future expansion.

Setup.DesktopMenuItem attributes:

disabled (no default, mustBeBool)

If this is true, the menu item will be skipped by the installer. You
probably want this to be true, but you might need to programmatically shut
off specific menu items.


name (no default, mustExist, mustBeString, cantBeEmpty)

This is the proper name of the item to be installed ("Firefox").


genericname (no default, mustExist, mustBeString, cantBeEmpty)

This is a generic name for the item to be installed ("Web Browser").


tooltip (no default, mustExist, mustBeString, cantBeEmpty)

This is used as a tooltip for the item by the OS when the user hovers
the mouse pointer over it.

builtin_icon (no default, mustBeBool)

If this is true, then "icon" refers to a platform-dependent standard
icon. Currently, this only makes sense on Unix systems that follow
the freedesktop.org standards. If this is false, then "icon" refers
to a file, relative to the installation's destination directory, which
the must be installed through a Setup.File. Most installers should set
this to false (the default) unless they know what they are doing.

icon (no default, mustExist, mustBeString, cantBeEmpty)

The icon to use with this menu item. Please see builtin_icon for info
on what this string means. The format of files that may be used as icons
varies from platform to platform; you may need to install a different
file programmatically, based on the value of MojoSetup.info.platform.

commandline (no default, mustExist, mustBeString, cantBeEmpty)

This is the command line that will be used to launch the application
when the end user clicks on the desktop menu item.

category (no default, mustExist, mustBeStringOrTableOfStrings)

This is a category (or array of categories) that the menu item applies
to. You can choose several, but one is usually less confusing. Valid
choices are currently: AudioVideo, Development, Education, Game, Graphics, Network,
Office, Settings, System, Utility.

mimetype (no default, mustBeStringOrTableOfStrings)

This is a MIME type (or array of MIME types) that the menu item can handle.
For example, if you are installing an image viewer, you might specify:
mimetype={"image/jpeg", "image/png"}; ... this is optional, you don't
have to specify any mimetypes at all.

!!! FIXME: there is currently no way for an installer to inform the system
!!! FIXME: of associations between new file extensions and mimetypes.
!!! FIXME: Things that collect mime info themselves, like web browsers
!!! FIXME: and email clients, can use new apps this way, however.



Add any localized strings:

If you added strings to the installer or your config file that you want
Expand Down
31 changes: 16 additions & 15 deletions scripts/config.lua
Expand Up @@ -96,7 +96,21 @@ Setup.Package
bytes = megabytes(600),
description = "Base Install",

-- File(s) to install.
-- Install a desktop menu item with the base install.
Setup.DesktopMenuItem
{
disabled = false,
name = "My Game",
genericname = "Shoot-em up",
tooltip = "A game of alien hunting.",
builtin_icon = false,
icon = "icon.png", -- relative to the dest; you must install it!
commandline = "command-line",
categories = "Game",
mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' },
},

-- File(s) to install with this option.
Setup.File
{
-- source can be a directory, an archive, or a supported URL.
Expand Down Expand Up @@ -132,20 +146,7 @@ Setup.Package
end
},

Setup.DesktopMenuItem
{
disabled = false,
name = "My Game",
genericname = "Shoot-em up",
comment = "A game for shooting aliens.",
builtin_icon = false,
icon = "icon.png", -- relative to the dest; you must install it!
commandline = "command-line",
categories = "Game",
mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' },
},

-- Here's an option that has it's own EULA.
-- Here's a suboption that has it's own EULA.
Setup.Option
{
value = true,
Expand Down
2 changes: 1 addition & 1 deletion scripts/mojosetup_init.lua
Expand Up @@ -413,7 +413,7 @@ function Setup.DesktopMenuItem(tab)
{ "disabled", nil, mustBeBool },
{ "name", nil, mustExist, mustBeString, cantBeEmpty },
{ "genericname", nil, mustExist, mustBeString, cantBeEmpty },
{ "comment", nil, mustExist, mustBeString, cantBeEmpty },
{ "tooltip", nil, mustExist, mustBeString, cantBeEmpty },
{ "builtin_icon", nil, mustBeBool },
{ "icon", nil, mustExist, mustBeString, cantBeEmpty },
{ "commandline", nil, mustExist, mustBeString, cantBeEmpty },
Expand Down
12 changes: 11 additions & 1 deletion scripts/mojosetup_mainline.lua
Expand Up @@ -1029,7 +1029,7 @@ local function install_freedesktop_menuitem(pkg, idx, item) -- only for Unix.
"Type=Application\n" ..
"Name=" .. item.name .. "\n" ..
"GenericName=" .. item.genericname .. "\n" ..
"Comment=" .. item.comment .. "\n" ..
"Comment=" .. item.tooltip .. "\n" ..
"Icon=" .. icon .. "\n" ..
"Exec=" .. item.commandline .. "\n" ..
"Categories=" .. flatten_list(item.categories) .. "\n"
Expand Down Expand Up @@ -1114,6 +1114,7 @@ local function do_install(install)

-- Desktop icons should probably require uninstall so we don't clutter
-- the system with no option for reversal later.
-- !!! FIXME: will miss menu items that are Setup.Option children...
if (install.desktopmenuitems ~= nil) and (not install.support_uninstall) then
MojoSetup.fatal(_("BUG: Setup.DesktopMenuItem requires support_uninstall"))
end
Expand Down Expand Up @@ -1349,6 +1350,15 @@ local function do_install(install)
process_file(option, v)
end
end

if option.desktopmenuitems ~= nil then
for i,item in ipairs(option.desktopmenuitems) do
if install.desktopmenuitems == nil then
install.desktopmenuitems = {}
end
install.desktopmenuitems[#install.desktopmenuitems] = item
end
end
end

local function build_source_tables(opts)
Expand Down

0 comments on commit a31d230

Please sign in to comment.