Skip to content

Commit

Permalink
Linux: Add Mimetype support for maps
Browse files Browse the repository at this point in the history
This allows to open map files from the filemanager by clicking at them.

2nd, hidden *.desktop file needed to associate the mimetype with the wesnoth command
icons in mimetype/ are used as file icon
icons in apps/ are shown when the user want to change the default program for the mimetype
(In Dolphin this place can be reached after opening the file properties)
  • Loading branch information
sevu committed Oct 9, 2019
1 parent 091a5e3 commit 6bee4e7
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Expand Up @@ -595,8 +595,10 @@ endif(ENABLE_CAMPAIGN_SERVER AND NOT ENABLE_GAME)
# Install desktop file so wesnoth appears in the application start menu with an icon
#
if(ENABLE_DESKTOP_ENTRY AND ENABLE_GAME)
install(FILES packaging/org.wesnoth.Wesnoth.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications )
install(DIRECTORY packaging/icons/hicolor DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons )
install(FILES packaging/org.wesnoth.Wesnoth.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications )
install(FILES packaging/org.wesnoth.Wesnoth_Editor.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications )
install(FILES packaging/org.wesnoth.Wesnoth.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/mime/packages )
endif(ENABLE_DESKTOP_ENTRY AND ENABLE_GAME)

if(ENABLE_APPDATA_FILE AND ENABLE_GAME)
Expand Down
3 changes: 3 additions & 0 deletions SConstruct
Expand Up @@ -73,6 +73,7 @@ opts.AddVariables(
PathVariable('datadirname', 'sets the name of data directory', "wesnoth$version_suffix", PathVariable.PathAccept),
PathVariable('desktopdir', 'sets the desktop entry directory to a non-default location', "$datarootdir/applications", PathVariable.PathAccept),
PathVariable('icondir', 'sets the icons directory to a non-default location', "$datarootdir/icons", PathVariable.PathAccept),
PathVariable('mimedir', 'sets the mimetype directory to a non-default location', "$datarootdir/mime/packages", PathVariable.PathAccept),
PathVariable('appdatadir', 'sets the appdata directory to a non-default location', "$datarootdir/metainfo", PathVariable.PathAccept),
BoolVariable('internal_data', 'Set to put data in Mac OS X application fork', False),
PathVariable('localedirname', 'sets the locale data directory to a non-default location', "translations", PathVariable.PathAccept),
Expand Down Expand Up @@ -745,6 +746,8 @@ InstallManpages(env, "wesnoth")
if have_client_prereqs and have_X and env["desktop_entry"]:
env.InstallData("icondir", "wesnoth", "packaging/icons")
env.InstallData("desktopdir", "wesnoth", "packaging/org.wesnoth.Wesnoth.desktop")
env.InstallData("desktopdir", "wesnoth", "packaging/org.wesnoth.Wesnoth_Editor.desktop")
env.InstallData("mimedir", "wesnoth", "packaging/org.wesnoth.Wesnoth.xml")
if have_client_prereqs and "linux" in sys.platform and env["appdata_file"]:
env.InstallData("appdatadir", "wesnoth", "packaging/org.wesnoth.Wesnoth.appdata.xml")

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packaging/org.wesnoth.Wesnoth.desktop
Expand Up @@ -93,4 +93,4 @@ Name[sr@ijekavian]=Уређивач мапа
Name[sr@ijekavianlatin]=Uređivač mapa
Name[sr@latin]=Uređivač mapa
Name[tr]=Harita Düzenleyici
Exec=sh -c "wesnoth -e >/dev/null 2>&1"
Exec=sh -c "wesnoth -e >/dev/null 2>&1"
17 changes: 17 additions & 0 deletions packaging/org.wesnoth.Wesnoth.xml
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-wesnoth-map">
<sub-class-of type="text/plain"/>
<comment>Wesnoth Map</comment>
<comment xml:lang="de">Wesnoth Karte</comment>
<glob pattern="*.map"/>
<icon name="wesnoth-map"/>
</mime-type>
<mime-type type="application/x-wesnoth-map">
<sub-class-of type="text/plain"/>
<comment>Wesnoth Map</comment>
<comment xml:lang="de">Wesnoth Karte</comment>
<glob pattern="*.mask"/>
<icon name="wesnoth-map"/>
</mime-type>
</mime-info>
12 changes: 12 additions & 0 deletions packaging/org.wesnoth.Wesnoth_Editor.desktop
@@ -0,0 +1,12 @@
[Desktop Entry]
NoDisplay=True
Version=1.0
Type=Application
Name=Battle for Wesnoth (Map Editor)
GenericName=Map editor of a strategy game
GenericName[de]=Karteneditor eines Strategiespiels
Comment=Map Editor of a turn-based strategy game
Comment[de]=Karteneditor eines rundenbasierten Strategiespiels
Icon=wesnoth_editor-icon
Exec=sh -c "wesnoth -e -l %u >/dev/null 2>&1"
MimeType=application/x-wesnoth-map;

0 comments on commit 6bee4e7

Please sign in to comment.