================================
desktop-file-utils:source=0.10-1
cvc rdiff desktop-file-utils -1 /[EMAIL PROTECTED]:1-devel/0.10-1
================================
0.10-1 Ken VanDine ([EMAIL PROTECTED]) Fri Jul 28 23:23:20 2006
    Merged from fl:desktop
    
desktop-file.tagdescription: new
--- /dev/null
+++ desktop-file.tagdescription
@@ -0,0 +5 @@
+file         %(taghandlerdir)s/desktop-file
+implements   files update
+implements   files remove
+implements   handler update
+include      %(datadir)s/applications/

desktop-file-utils.recipe: new
--- /dev/null
+++ desktop-file-utils.recipe
@@ -0,0 +30 @@
+#
+# Copyright (c) 2004-2005 rpath, Inc.
+# All rights reserved
+#
+
+class DesktopFileUtils(CPackageRecipe):
+    name = 'desktop-file-utils'
+    version = '0.10'
+ 
+    buildRequires = [ 'glib:devel', 'popt:devel', 'pkgconfig:devel' ]
+
+    def setup(r):
+        
r.addArchive('http://www.freedesktop.org/software/%(name)s/releases/%(name)s-%(version)s.tar.gz')
+        r.addSource('desktop-file.tagdescription', macros=True)
+        r.addSource('desktop-file.taghandler', macros=True)
+
+        r.Configure()
+        r.Make()
+        r.MakeInstall()
+
+        # zero-length config file to help verify along...
+        r.Create('%(datadir)s/applications/defaults.list')
+        
+        # Don't overwrite this file on update...
+        r.InitialContents('%(datadir)s/applications/defaults.list')
+
+        r.Install('desktop-file.tagdescription',
+                  '%(tagdescriptiondir)s/desktop-file')
+        r.Install('desktop-file.taghandler',
+                  '%(taghandlerdir)s/desktop-file', mode=0755)

desktop-file-utils-0.10.tar.gz: new
desktop-file.taghandler: new
--- /dev/null
+++ desktop-file.taghandler
@@ -0,0 +87 @@
+#!/bin/bash
+
+if [ $# -lt 2 ]; then
+    echo "not enough arguments: $0 $*" >&2
+    exit 1
+fi
+
+type="$1"
+shift
+action="$1"
+shift
+
+# GNOME currently does not automatically prefer entries that include
+# GNOME in their category list.  Instead, it uses a "defaults.list"
+# file that needs to be modified whenever desktop files are added or
+# removed.
+DEFAULTS_LIST=%(datadir)s/applications/defaults.list
+
+# KNOWN BUG:  If a MimeType entry is *removed* for an application's
+# desktop file, this script will not remove it.  This was an intentional
+# tradeoff to make the script run faster, because we doubt that many
+# applications will loose functionality, and it would make an already
+# slow process slower.
+
+update_database ()
+{
+    %(bindir)s/update-desktop-database %(datadir)s/applications > /dev/null
+}
+
+add_to_defaults_list ()
+{
+    # Check for an empty or nonexisting defaults.list, and create it
+    # with the header if required.
+    if ! [ -s $DEFAULTS_LIST ] ; then 
+        echo "[Default Applications]" > $DEFAULTS_LIST
+    fi
+
+    # add appropriate references to gnome apps to the defaults.list file
+    for GNOME_DESKTOP_FILE in $(grep -l 'Categories.*GNOME' "$@") ; do
+        MIME_TYPES=$(grep '^MimeType=' $GNOME_DESKTOP_FILE |
+                       sed 's/MimeType=//;s/;/ /g')
+        if [ -n "$MIME_TYPES" ] ; then
+            # the defaults.list file is not supposed to have complete paths
+            BASE_GNOME_DESKTOP_FILE=$(basename $GNOME_DESKTOP_FILE)
+        fi
+        for MIME_TYPE in $MIME_TYPES ; do
+            if ! grep -qs $MIME_TYPE $DEFAULTS_LIST ; then
+                echo "$MIME_TYPE=$BASE_GNOME_DESKTOP_FILE" >> $DEFAULTS_LIST
+            fi
+        done
+    done
+}
+
+remove_from_defaults_list ()
+{
+    # the first sed subexpression is the equivalent of basename on
+    # each filename, and the second subexpression just adds the \|
+    # between filenames
+    FILES="$(echo $@| sed 's,\(^\| \)[^ ]*/, ,g;s, ,\\|,g')"
+    # this sed removes any reference to any removed file from the list
+    sed -i -e "/=\\(${FILES}\\)$/d" $DEFAULTS_LIST
+}
+
+case $type in 
+    files)
+       case $action in
+           update)
+                add_to_defaults_list "$@"
+                update_database
+               ;;
+            remove)
+                remove_from_defaults_list "$@"
+                update_database
+               ;;
+       esac
+    ;;
+    handler)
+       case $action in
+           update)
+                # things might have changed, start over
+                add_to_defaults_list "$@"
+               ;;
+       esac
+    ;;
+esac
+
+exit 0


Committed by: krv
_______________________________________________
Desktop-commits mailing list
[email protected]
http://lists.bizrace.com/mailman/listinfo/desktop-commits

Reply via email to