summaryrefslogtreecommitdiff
path: root/Mozo/MainWindow.py
diff options
context:
space:
mode:
authorJasper St. Pierre <[email protected]>2012-05-01 16:45:24 -0400
committerAlexei Sorokin <[email protected]>2016-08-22 23:03:31 +0300
commit06fecaeae7e1b706ccc6afd5ee071c9c6cf78556 (patch)
treedd1f0781e9862a76bffcbf359eab55ad02fa4fce /Mozo/MainWindow.py
parent2d90080dcec1decf459c8e7d676b987f33aea316 (diff)
downloadmozo-06fecaeae7e1b706ccc6afd5ee071c9c6cf78556.tar.bz2
mozo-06fecaeae7e1b706ccc6afd5ee071c9c6cf78556.tar.xz
util: replace our own DesktopParser with GKeyFile
Diffstat (limited to 'Mozo/MainWindow.py')
-rw-r--r--Mozo/MainWindow.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/Mozo/MainWindow.py b/Mozo/MainWindow.py
index b7c1ab6..5ce6d0b 100644
--- a/Mozo/MainWindow.py
+++ b/Mozo/MainWindow.py
@@ -370,15 +370,7 @@ class MainWindow:
file_path = os.path.join(util.getUserItemPath(), item.get_desktop_file_id())
file_type = 'Item'
elif item.get_type() == matemenu.TYPE_DIRECTORY:
- if item.get_desktop_file_path() == None:
- file_path = util.getUniqueFileId('mozo-made', '.directory')
- parser = util.DesktopParser(file_path, 'Directory')
- parser.set('Name', item.get_name())
- parser.set('Comment', item.get_comment())
- parser.set('Icon', item.get_icon())
- parser.write(open(file_path))
- else:
- file_path = os.path.join(util.getUserDirectoryPath(), os.path.split(item.get_desktop_file_path())[1])
+ file_path = os.path.join(util.getUserDirectoryPath(), os.path.split(item.get_desktop_file_path())[1])
file_type = 'Menu'
if not os.path.isfile(file_path):
@@ -571,13 +563,14 @@ class MainWindow:
content_type = file_info.get_content_type()
if content_type == 'application/x-desktop':
input_stream = myfile.read()
- (fd, tmppath) = tempfile.mkstemp(prefix='mozo-dnd', suffix='.desktop')
- with open(fd, "w") as f:
- f.write(input_stream.read())
- parser = util.DesktopParser(tmppath)
- self.editor.createItem(parent, parser.get('Icon'), parser.get('Name', self.editor.locale), parser.get('Comment', self.editor.locale), parser.get('Exec'), parser.get('Terminal'), before, after)
+ keyfile = GLib.KeyFile()
+ keyfile.load_from_data(input_stream.read())
+ self.editor.createItem(parent, before, after, KeyFile=keyfile)
elif content_type in ('application/x-shellscript', 'application/x-executable'):
- self.editor.createItem(parent, None, os.path.split(file_path)[1].strip(), None, file_path.replace('file://', '').strip(), False, before, after)
+ self.editor.createItem(parent, before, after,
+ Name=os.path.split(file_path)[1].strip(),
+ Exec=file_path.replace('file://', '').strip(),
+ Terminal=False)
self.drag_data = None
def on_item_tree_key_press_event(self, item_tree, event):