conduit r1807 - in trunk: . conduit/modules
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1807 - in trunk: . conduit/modules
- Date: Mon, 19 Jan 2009 12:55:14 +0000 (UTC)
Author: jstowers
Date: Mon Jan 19 12:55:14 2009
New Revision: 1807
URL: http://svn.gnome.org/viewvc/conduit?rev=1807&view=rev
Log:
2009-01-20 John Stowers <john stowers gmail com>
* conduit/modules/ConverterModule.py: Bookmarks should
convert to desktop files.
Fixes #568293 (Andrew Stormont)
Modified:
trunk/ChangeLog
trunk/conduit/modules/ConverterModule.py
Modified: trunk/conduit/modules/ConverterModule.py
==============================================================================
--- trunk/conduit/modules/ConverterModule.py (original)
+++ trunk/conduit/modules/ConverterModule.py Mon Jan 19 12:55:14 2009
@@ -307,22 +307,32 @@
return bookmark
def bookmark_to_file(self, bookmark):
- f = File.TempFile(self._to_text(bookmark))
- f.force_new_filename(bookmark.title.replace("/","_"))
- f.force_new_file_extension(".txt")
- return f
+ # Now actually creates a useful filetype
+ if bookmark.get_title() != None and bookmark.get_uri() != None:
+ desktop = "[Desktop Entry]\n"
+ desktop += "Version=1.0\n"
+ desktop += "Encoding=UTF-8\n"
+ desktop += "Name=%s\n" % bookmark.get_title()
+ desktop += "Type=Link\n"
+ desktop += "URL=%s\n" % bookmark.get_uri()
+ desktop += "Icon=gnome-fs-bookmark\n"
+ f = File.TempFile(desktop)
+ f.force_new_filename(bookmark.get_title().replace("/","_") + ".desktop" )
+ return f
def file_to_bookmark(self, f):
- bookmark = None
+ # This too. Now parses .desktop files... badly
if f.get_mimetype().startswith("text"):
txt = f.get_contents_as_text()
- k,v = self._to_key_value(txt)
- if k != None and v != None:
- bookmark = Bookmark.Bookmark(
- title=k,
- uri=v
- )
- return bookmark
+ title = None
+ uri = None
+ for line in txt.split("\n"):
+ if line.startswith( "Name" ):
+ title = line.split( "=" )[1]
+ elif line.startswith( "URL" ):
+ uri = line.split( "=" )[1]
+ if uri != None and title != None:
+ return Bookmark.Bookmark( title, uri )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]