New FREEDESKTOP scons option installs desktop MIME entry and .desktop file. Also...
authorNick Mainsbridge <beatroute@iprimus.com.au>
Mon, 25 Feb 2008 17:37:55 +0000 (17:37 +0000)
committerNick Mainsbridge <beatroute@iprimus.com.au>
Mon, 25 Feb 2008 17:37:55 +0000 (17:37 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3121 d708f5d6-7413-0410-9779-e7cbd77b26cf

SConstruct
gtk2_ardour/SConscript
gtk2_ardour/ardour2.desktop.in [new file with mode: 0644]
gtk2_ardour/ardour2.xml [new file with mode: 0644]

index 520bcdd058b4f5b3e3ba4e89d0cee94db08bad1c..462fea93e8556382c4f370eedabd06a14fd1f060 100644 (file)
@@ -50,6 +50,7 @@ opts.AddOptions(
     BoolOption('VST', 'Compile with support for VST', 0),
     BoolOption('LV2', 'Compile with support for LV2 (if slv2 is available)', 1),
     BoolOption('GPROFILE', 'Compile with support for gprofile (Developers only)', 0),
+    BoolOption('FREEDESKTOP', 'Install MIME type, icons and .desktop file as per the freedesktop.org spec (requires xdg-utils and shared-mime-info). "scons uninstall" removes associations in desktop database', 0),
     BoolOption('TRANZPORT', 'Compile with support for Frontier Designs (if libusb is available)', 1)
 )
 
@@ -926,6 +927,26 @@ else:
 
 libraries['dmalloc'] = conf.Finish ()
 
+#
+# ensure FREEDESKTOP target is doable..
+#
+
+conf = env.Configure ()
+if env['FREEDESKTOP']:
+       have_update_mime_database = conf.TryAction (Action ('update-mime-database -v'))
+       if have_update_mime_database[0] != 1:
+               print "Warning. You have no update-mime-database command in your PATH. FREEDESKTOP is now disabled."
+               env['FREEDESKTOP'] = 0
+       have_gtk_update_icon_cache = conf.TryAction (Action ('gtk-update-icon-cache -?'))
+       if have_gtk_update_icon_cache[0] != 1:
+               print "Warning. You have no gtk-update-icon-cache command in your PATH. FREEDESKTOP is now disabled."
+               env['FREEDESKTOP'] = 0
+       have_update_desktop_database = conf.TryAction (Action ('update-desktop-database -?'))
+       if have_update_desktop_database[0] != 1:
+               print "Warning. You have no update-desktop-database command in your PATH. FREEDESKTOP is now disabled."
+               env['FREEDESKTOP'] = 0
+env = conf.Finish()
+
 #
 # Audio/MIDI library (needed for MIDI, since audio is all handled via JACK)
 #
index 56a96336832e3fcdb99653c5a9b056d229be2da8..0b3da94e0655d115475c701187e962a4a56f3605 100644 (file)
@@ -471,10 +471,43 @@ env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'SAE-de
 # data files
 env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'ardour2'), 'splash.png'))
 env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'ardour2', 'pixmaps'), pixmap_files))
-env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'ardour2', 'icons'), icon_files))
-
+if not env['FREEDESKTOP']:
+       env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'ardour2', 'icons'), icon_files))
 env.Alias ('version', gtkardour.VersionBuild(['version.cc','version.h'], []))
-               
+
+# This will install icons and MIME type as per freedesktop.org specs. #
+if env['FREEDESKTOP']:
+       desktop_icon_install_prefix = install_prefix + '/share/icons/hicolor'
+       # Install the desktop icons to the default locations #
+       env.Alias('install', env.InstallAs(os.path.join(desktop_icon_install_prefix, '16x16', 'apps', 'ardour2.png'), 'icons/ardour_icon_16px.png'))
+       env.Alias('install', env.InstallAs(os.path.join(desktop_icon_install_prefix, '22x22', 'apps', 'ardour2.png'), 'icons/ardour_icon_22px.png'))
+       env.Alias('install', env.InstallAs(os.path.join(desktop_icon_install_prefix, '32x32', 'apps', 'ardour2.png'), 'icons/ardour_icon_32px.png'))
+       env.Alias('install', env.InstallAs(os.path.join(desktop_icon_install_prefix, '48x48', 'apps', 'ardour2.png'), 'icons/ardour_icon_48px.png'))
+       # Install the mime type xml file and its icon #
+        env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'mime', 'packages'), 'ardour2.xml'))
+       env.Alias('install', env.InstallAs(os.path.join(desktop_icon_install_prefix, '48x48', 'mimetypes','application-x-ardour2.png'), 'icons/ardour_icon_48px.png'))
+       env.Alias('install', env.Command (os.path.join(install_prefix, 'share', 'mime'), [], 'update-mime-database $TARGET'))
+       # Update the icon cache #
+       env.Alias('install', env.Command (desktop_icon_install_prefix, [], 'touch --no-create $TARGET'))
+       env.Alias('install', env.Command (desktop_icon_install_prefix, [], 'gtk-update-icon-cache $TARGET'))
+       # Make the ardour2.desktop file and install it #
+       env.Alias('install', env.Command ('ardour2.desktop', 'ardour2.desktop.in', 'cat $SOURCES  > $TARGET'))
+       env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'applications'), 'ardour2.desktop'))
+       env.Alias('install', env.Command (os.path.join(install_prefix, 'share', 'applications'), [], 'update-desktop-database $TARGET'))
+       # uninstall target.. needed to run  update-mime-database and update-desktop-database after removal. #`
+       remove_desktop_files = env.Command ('another_frobnicatory_decoy', [],
+                             [ Delete (install_prefix + '/share/mime/packages/ardour2.xml'),
+                              Delete (install_prefix + '/share/applications/ardour2.desktop'),
+                              Delete (desktop_icon_install_prefix + '/16x16/apps/ardour2.png'),
+                              Delete (desktop_icon_install_prefix + '/22x22/apps/ardour2.png'),
+                              Delete (desktop_icon_install_prefix + '/32x32/apps/ardour2.png'),
+                              Delete (desktop_icon_install_prefix + '/48x48/apps/ardour2.png'),
+                              Delete (desktop_icon_install_prefix + '/48x48/mimetypes/application-x-ardour2.png'),
+                               Action ('update-mime-database ' + install_prefix + '/share/mime'),
+                               Action ('gtk-update-icon-cache ' + desktop_icon_install_prefix),
+                               Action ('update-desktop-database ' + install_prefix + '/share/applications')])
+       env.Alias('uninstall', remove_desktop_files)
+
 #dist
 env.Alias ('tarball', env.Distribute (env['DISTTREE'],
                                       [ 'SConscript',
@@ -488,7 +521,9 @@ env.Alias ('tarball', env.Distribute (env['DISTTREE'],
                                        'ardour-sae-ansi.bindings.in', 
                                        'ardour-sae-de.bindings.in', 
                                        'ardour2_ui_default.conf',
-                                       'editor_xpms'
+                                       'editor_xpms',
+                                       'ardour2.xml',
+                                       'ardour2.desktop.in'
                                         ] +
                                       gtkardour_files +
                                      vst_files +
diff --git a/gtk2_ardour/ardour2.desktop.in b/gtk2_ardour/ardour2.desktop.in
new file mode 100644 (file)
index 0000000..b5911e8
--- /dev/null
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Ardour
+Comment=Ardour Digital Audio Workstation
+Exec=ardour2
+Icon=ardour2
+Terminal=false
+MimeType=application/x-ardour2;
+Type=Application
+Categories=AudioVideo;Audio;X-Recorders;X-Multitrack;X-Jack;
diff --git a/gtk2_ardour/ardour2.xml b/gtk2_ardour/ardour2.xml
new file mode 100644 (file)
index 0000000..dd1c46e
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+  <mime-type type="application/x-ardour2">
+  <sub-class-of type="application/xml"/>
+  <comment>Ardour session file</comment>
+  <glob pattern="*.ardour"/>
+  </mime-type>
+</mime-info>