diff --git a/toolkit/system/gnome/nsGnomeVFSService.cpp b/toolkit/system/gnome/nsGnomeVFSService.cpp index 097be0c712b6..c06b38e26566 100644 --- a/toolkit/system/gnome/nsGnomeVFSService.cpp +++ b/toolkit/system/gnome/nsGnomeVFSService.cpp @@ -50,6 +50,7 @@ extern "C" { #include #include #include +#include #include } @@ -245,6 +246,20 @@ nsGnomeVFSService::ShowURI(nsIURI *aURI) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsGnomeVFSService::ShowURIForInput(const nsACString &aUri) +{ + char* spec = gnome_vfs_make_uri_from_input(PromiseFlatCString(aUri).get()); + nsresult rv = NS_ERROR_FAILURE; + + if (gnome_url_show(spec, NULL)) + rv = NS_OK; + + if (spec) + g_free(spec); + return rv; +} + NS_IMETHODIMP nsGnomeVFSService::SetAppStringKey(const nsACString &aID, PRInt32 aKey, diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 795a2b8349e2..f1ec275e50ff 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -83,6 +83,10 @@ #include "nsITimelineService.h" #include "nsIProgrammingLanguage.h" +#ifdef MOZ_WIDGET_GTK2 +#include "nsIGnomeVFSService.h" +#endif + #include "nsNativeCharsetUtils.h" #include "nsTraceRefcntImpl.h" @@ -1663,13 +1667,44 @@ nsLocalFile::Launch() NS_IMETHODIMP nsLocalFile::Reveal() { +#ifdef MOZ_WIDGET_GTK2 + nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); + if (!vfs) + return NS_ERROR_FAILURE; + + PRBool isDirectory; + if (NS_FAILED(IsDirectory(&isDirectory))) + return NS_ERROR_FAILURE; + + if (isDirectory) { + return vfs->ShowURIForInput(mPath); + } else { + nsCOMPtr parentDir; + nsCAutoString dirPath; + if (NS_FAILED(GetParent(getter_AddRefs(parentDir)))) + return NS_ERROR_FAILURE; + if (NS_FAILED(parentDir->GetNativePath(dirPath))) + return NS_ERROR_FAILURE; + + return vfs->ShowURIForInput(dirPath); + } +#else return NS_ERROR_FAILURE; +#endif } NS_IMETHODIMP nsLocalFile::Launch() { +#ifdef MOZ_WIDGET_GTK2 + nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); + if (!vfs) + return NS_ERROR_FAILURE; + + return vfs->ShowURIForInput(mPath); +#else return NS_ERROR_FAILURE; +#endif } #endif diff --git a/xpcom/system/nsIGnomeVFSService.idl b/xpcom/system/nsIGnomeVFSService.idl index 68df39781388..5f54d93a6f5d 100644 --- a/xpcom/system/nsIGnomeVFSService.idl +++ b/xpcom/system/nsIGnomeVFSService.idl @@ -44,7 +44,7 @@ interface nsIURI; /* nsIGnomeVFSMimeApp holds information about an application that is looked up with nsIGnomeVFSService::GetAppForMimeType. */ -[scriptable, uuid(99ae024f-e869-4973-958b-54768a84295a)] +[scriptable, uuid(57b1ef41-35cd-48e9-a248-2030c8365067)] interface nsIGnomeVFSMimeApp : nsISupports { const long EXPECTS_URIS = 0; @@ -143,6 +143,7 @@ interface nsIGnomeVFSService : nsISupports /* Open the given URI in the default application */ void showURI(in nsIURI uri); + [noscript] void showURIForInput(in ACString uri); }; %{C++