[Gtk-sharp-list] Drag and drop path

Christian Rudh lists-christian@rudh.se
Thu, 06 Jan 2005 22:13:59 +0100


Hi

The code from muine worked good. But not with international and special
characters. I solved it by using this C gnome-vfs function instead:

	[DllImport ("libgnomevfs-2.dll")]
	private static extern IntPtr gnome_vfs_format_uri_for_display (string
str);

	public static string FormatUriForDisplay (string uri)
	{
		IntPtr p = gnome_vfs_format_uri_for_display (uri);

		if (p == IntPtr.Zero)
			return null;
		else
		return GLib.Marshaller.PtrToStringGFree (p);
	}

This works fine with importing the files and showing them in the
application, but gstreamer doesn't accept the filenames :(

But I solved that by sending the URI instead of the filename. GStreamer
accepts them if you add the song to the pipeline with:

	filesrc = ElementFactory.Make ("gnomevfssrc", "disk_source");
	filesrc.SetProperty ("location", songURI);

So gnomevfssrc instead of filesrc. Now all files I have tried to add so
far works beutifully! :)

Hope it is to some help if you haven't solved it yet (saw that is was
still an issue in bluefunk cvs).

/Christian


On Mon, 2004-11-29 at 22:01 +0000, Mike Rhodes wrote:
> I use this code:
> 
> 	[DllImport ("libgnomevfs-2.dll")]
> 	private static extern IntPtr gnome_vfs_get_local_path_from_uri (string str);
> 
> 	public static string LocalPathFromUri (string uri)
> 	{
> 		IntPtr p = gnome_vfs_get_local_path_from_uri (uri);
> 
> 		if (p == IntPtr.Zero)
> 			return null;
> 		else
> 			return GLib.Marshaller.PtrToStringGFree (p);
> 	}
> 
> (All credit goes to the Muine code where I found it =) ) I believe
> gnome-vfs isn't part of gtk-sharp as of yet, so I'm not sure of
> another way to do it.
> 
> Mike.
> 
> p.s. btw, if you are thinking of writing a C# music player, I'm also
> writing one; perhaps we could team up -- or at least solve some of the
> issues that come up -- drop me a line off-list if you are interested!
> 
> 
> On Mon, 29 Nov 2004 19:08:26 +0100, Christian Rudh
> <lists-christian@rudh.se> wrote:
> > Hi
> > 
> > When drop a file on my application i get the URL in the following
> > format:
> > 
> > file:///home/user/song%20X.mp3
> > 
> > To be able to pass it on to Gst# (for example) I have to remove the
> > file:// part and replace %20 with spaces (that goes for other special
> > characters to). Is there any simple way to decode the string to a normal
> > Unix path? Like the System.Web.HttpUtility.HTMLDecode that MS .NET has?
> 
> 
-- 
Christian Rudh <lists-christian@rudh.se>