I have attached a patch that adds a wrapper script to Wine for
starting files from Linux file managers such as nautilus and modifies
wine.desktop to use the script for exe, msi, lnk, chm, and hlp files.

The wrapper sets the working directory to the directory containing the
file and starts it using wine start with the full windows path. If
wine start fails, it displays an error dialog. As I understand it,
this is very close to the behavior when double-clicking a file in
windows explorer.

Please comment.


These issues worry me in particular:

I cannot double-click on exe files to open them myself because of
http://bugs.winehq.org/show_bug.cgi?id=8386 (nautilus is getting
confused about file types). As I understand it, this is a separate
problem (and should be fixed?), but I wonder if I can do anything
about it.

Nautilus is not using Wine to start hlp files. I put in every mime
type I could come up with for hlp, including
application/x-extension-hlp.

Wine does not show in the "Open With" list in nautilus. This makes the
wrapper a little bit harder to use for applications installed in wine
to handle specific filetypes.

Is the list of file extensions I decided to use reasonable?

Is the list of MIME types I decided to use for those extensions
reasonable? Is there some way Wine could help the system recognize
some of these types? I don't know much about this topic,
unfortunately, and I'm not very confident about my list.

I cannot test the kdialog command in the script myself because kdialog
consistently fails to display things here.

-- 
Vincent Povirk
diff --git a/tools/Makefile.in b/tools/Makefile.in
index d771c51..3fcc2ad 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -76,6 +76,7 @@ wineprefixcreate: wineprefixcreate.in relpath$(EXEEXT)
 
 install install-lib:: wineprefixcreate $(INSTALLDIRS)
 	$(INSTALL_SCRIPT) wineprefixcreate $(DESTDIR)$(bindir)/wineprefixcreate
+	$(INSTALL_SCRIPT) winestartfile $(DESTDIR)$(bindir)/winestartfile
 	$(INSTALL_DATA) $(SRCDIR)/wine.inf $(DESTDIR)$(datadir)/wine/wine.inf
 	$(INSTALL_DATA) $(SRCDIR)/wine.desktop $(DESTDIR)$(datadir)/applications/wine.desktop
 	$(INSTALL_DATA) wineprefixcreate.man $(DESTDIR)$(mandir)/man$(prog_manext)/wineprefixcreate.$(prog_manext)
diff --git a/tools/wine.desktop b/tools/wine.desktop
index c57b844..4814d3f 100644
--- a/tools/wine.desktop
+++ b/tools/wine.desktop
@@ -5,6 +5,6 @@ Name[de]=Wine Windows-Emulator
 Name[sv]=Windows-emulatorn Wine
 Name[ru]=Wine Эмулятор Windows
 Name[fr]=Émulateur Windows Wine
-Exec=wine %f
-MimeType=application/x-ms-dos-executable;application/x-msdos-program;application/x-msdownload;application/exe;application/x-exe;application/dos-exe;vms/exe;application/x-winexe;application/msdos-windows;application/x-zip-compressed;application/x-executable;
+Exec=winestartfile %f
+MimeType=application/x-ms-dos-executable;application/x-msdos-program;application/x-msdownload;application/exe;application/x-exe;application/dos-exe;vms/exe;application/x-winexe;application/msdos-windows;application/x-zip-compressed;application/x-executable;application/x-ole-storage;application/msi;application/x-msi;application/x-extension-msi;application/x-ms-shortcut;application/x-lnk;application/x-extension-lnk;application/x-chm;application/x-extension-chm;application/winhlp;application/x-helpfile;application/x-winhelp;application/x-hlp;application/x-extension-hlp;
 NoDisplay=true
diff --git a/tools/winestartfile b/tools/winestartfile
new file mode 100755
index 0000000..ff1ffcf
--- /dev/null
+++ b/tools/winestartfile
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Start a file as if it were double-clicked in windows explorer.
+#
+# This is intended as a wrapper for linux file managers, and it expects
+# a unix path.
+#
+# Copyright 2007 Vincent Povirk
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+#
+
+usage()
+{
+    cat <<EOF
+usage: winestartfile FILENAME
+EOF
+    exit 2
+}
+
+if test $# -ne 1 ; then
+    usage
+fi
+
+# Change to the path containing the file.
+cd "$(dirname "$1")"
+
+# Determine the full windows path of the file.
+windowspath="$(winepath --windows "$(basename "$1")")"
+
+# Start the file with its full windows path.
+wine start "${windowspath}"
+
+# If wine start failed, show its error message to the user.
+if test $? -ne 0; then
+    if type zenity &>/dev/null; then
+        wine start "${windowspath}"|xargs --null zenity --error --title Wine --text
+    elif type kdialog &>/dev/null; then
+        wine start "${windowspath}"|xargs --null kdialog --title Wine --error
+    elif type xmessage &>/dev/null; then
+        wine start "${windowspath}"|xmessage -file -
+    fi
+fi
+


Reply via email to