Skip to content

Commit

Permalink
More desktop menu item fixes, and updated duke3d example...appears to…
Browse files Browse the repository at this point in the history
… work now!
  • Loading branch information
icculus committed Feb 13, 2008
1 parent a31d230 commit 5057e36
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs.txt
Expand Up @@ -781,6 +781,8 @@ Here are the elements, and the attributes they can possess.
!!! FIXME: Things that collect mime info themselves, like web browsers
!!! FIXME: and email clients, can use new apps this way, however.

!!! FIXME: there is currently no way for an installer to add submenus.



Add any localized strings:
Expand Down
Binary file added examples/duke3d/data/duke3d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 17 additions & 2 deletions examples/duke3d/scripts/config.lua
Expand Up @@ -69,6 +69,19 @@ Setup.Package
uniquefile = "atominst/duke3d.grp"
},

-- Install a desktop menu item with all install types.
Setup.DesktopMenuItem
{
disabled = false,
name = "Duke Nukem 3D",
genericname = "Duke Nukem 3D",
tooltip = "Always bet on Duke!",
builtin_icon = false,
icon = "duke3d.png", -- relative to the dest; you must install it!
commandline = "/home/icculus/duke3d/duke3d",
category = "Game",
},

Setup.OptionGroup
{
description = _("Installation type"),
Expand All @@ -87,7 +100,8 @@ Setup.Package

Setup.File
{
wildcards = "*.txt"; -- catch all the EULAs and READMEs.
-- catch all the EULAs and READMEs, and the desktop menu icon.
wildcards = { "*.txt", "duke3d.png" }
},
Setup.File
{
Expand All @@ -114,7 +128,8 @@ Setup.Package

Setup.File
{
wildcards = "*.txt"; -- catch all the EULAs and READMEs.
-- catch all the EULAs and READMEs, and the desktop menu icon.
wildcards = { "*.txt", "duke3d.png" }
},

Setup.File
Expand Down
4 changes: 2 additions & 2 deletions platform_unix.c
Expand Up @@ -1070,7 +1070,7 @@ static boolean unix_launchXdgUtil(const char *util, const char **argv)

if (path != NULL) // it's installed on the system; use that.
{
char *cmd = path;
char *cmd = xstrdup(util);
char *tmp = NULL;
int i;
for (i = 0; argv[i]; i++)
Expand All @@ -1082,7 +1082,7 @@ static boolean unix_launchXdgUtil(const char *util, const char **argv)
cmd = tmp;
} // for

tmp = format("%0 >/dev/null 2>&1", cmd);
tmp = format("%0/%1 >/dev/null 2>&1", path, cmd);
free(cmd);
cmd = tmp;
retval = (system(cmd) == 0);
Expand Down
2 changes: 1 addition & 1 deletion scripts/config.lua
Expand Up @@ -106,7 +106,7 @@ Setup.Package
builtin_icon = false,
icon = "icon.png", -- relative to the dest; you must install it!
commandline = "command-line",
categories = "Game",
category = "Game",
mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' },
},

Expand Down
14 changes: 9 additions & 5 deletions scripts/mojosetup_mainline.lua
Expand Up @@ -820,7 +820,7 @@ local function serialize(obj)
local objtype = type(obj)
if objtype == "nil" then
retval = "nil"
elseif objtype == "number" then
elseif (objtype == "number") or (objtype == "boolean") then
retval = tostring(obj)
elseif objtype == "string" then
retval = string.format("%q", obj)
Expand Down Expand Up @@ -988,8 +988,8 @@ end


local function freedesktop_menuitem_filename(pkg, idx) -- only for Unix.
local vendor = string.gsub(pkg.vendor, "%..*$", "", 1) -- chop off TLD.
local fname = vendor .. "-" .. pkg.id .. idx .. ".desktop"
local vendor = string.gsub(pkg.vendor, "%.", "_")
local fname = vendor .. "-" .. pkg.id .. "_" .. idx .. ".desktop"
return MojoSetup.metadatadir .. "/" .. fname
end

Expand All @@ -1005,7 +1005,7 @@ local function uninstall_desktop_menu_items(pkg)
elseif MojoSetup.info.platform == "beos" then
MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me.
else -- freedesktop, we hope.
local fname = freedesktop_menuitem_filename(pkg, idx)
local fname = freedesktop_menuitem_filename(pkg, i)
if not MojoSetup.platform.uninstalldesktopmenuitem(fname) then
MojoSetup.fatal(_("Failed to uninstall desktop menu item"))
end
Expand All @@ -1032,7 +1032,7 @@ local function install_freedesktop_menuitem(pkg, idx, item) -- only for Unix.
"Comment=" .. item.tooltip .. "\n" ..
"Icon=" .. icon .. "\n" ..
"Exec=" .. item.commandline .. "\n" ..
"Categories=" .. flatten_list(item.categories) .. "\n"
"Categories=" .. flatten_list(item.category) .. "\n"

if item.mimetype ~= nil then
str = str .. "MimeType=" .. flatten_list(item.mimetype) .. "\n"
Expand All @@ -1044,6 +1044,10 @@ local function install_freedesktop_menuitem(pkg, idx, item) -- only for Unix.
local perms = "0644" -- !!! FIXME
local key = MojoSetup.metadatakey
local desc = MojoSetup.metadatadesc

--MojoSetup.logdebug("Install FreeDesktop file")
--MojoSetup.logdebug(dest)
--MojoSetup.logdebug(str)
install_file_from_string(dest, str, perms, desc, key)
if not MojoSetup.platform.installdesktopmenuitem(dest) then
MojoSetup.fatal(_("Failed to install desktop menu item"))
Expand Down

0 comments on commit 5057e36

Please sign in to comment.