|
1
|
+From 38232679bf89add784cbadfa5196440b20115ae5 Mon Sep 17 00:00:00 2001
|
|
2
|
+From: Sam Tygier <sam.tygier@manchester.ac.uk>
|
|
3
|
+Date: Tue, 14 May 2019 19:34:34 +0100
|
|
4
|
+Subject: [PATCH] Fix drag and drop of .desktop file
|
|
5
|
+
|
|
6
|
+Update for gtk3 API changes in SelectionData, Gio.File, Gio.InputStream
|
|
7
|
+and urllib.
|
|
8
|
+---
|
|
9
|
+ Mozo/MainWindow.py | 12 ++++++------
|
|
10
|
+ 1 file changed, 6 insertions(+), 6 deletions(-)
|
|
11
|
+
|
|
12
|
+diff --git a/Mozo/MainWindow.py b/Mozo/MainWindow.py
|
|
13
|
+index 4ca5b84..01639b9 100644
|
|
14
|
+--- a/Mozo/MainWindow.py
|
|
15
|
++++ b/Mozo/MainWindow.py
|
|
16
|
+@@ -28,7 +28,7 @@
|
|
17
|
+ import gettext
|
|
18
|
+ import subprocess
|
|
19
|
+ import shutil
|
|
20
|
+-import urllib
|
|
21
|
++import urllib.parse
|
|
22
|
+ try:
|
|
23
|
+ from Mozo import config
|
|
24
|
+ gettext.bindtextdomain(config.GETTEXT_PACKAGE,config.localedir)
|
|
25
|
+@@ -543,7 +543,7 @@ def on_item_tree_drag_data_received(self, treeview, context, x, y, selection, in
|
|
26
|
+ self.editor.moveSeparator(item, destination, before, after)
|
|
27
|
+ context.finish(True, True, etime)
|
|
28
|
+ elif str(selection.get_target()) == 'text/plain':
|
|
29
|
+- if selection.data is None:
|
|
30
|
++ if selection.get_data() is None:
|
|
31
|
+ return False
|
|
32
|
+ menus, iter = self.tree.get_object('menu_tree').get_selection().get_selected()
|
|
33
|
+ parent = menus[iter][2]
|
|
34
|
+@@ -559,16 +559,16 @@ def on_item_tree_drag_data_received(self, treeview, context, x, y, selection, in
|
|
35
|
+ else:
|
|
36
|
+ path = (len(items) - 1,)
|
|
37
|
+ after = items[path][3]
|
|
38
|
+- file_path = urllib.unquote(selection.data).strip()
|
|
39
|
++ file_path = urllib.parse.unquote(selection.get_data().decode("utf-8")).strip()
|
|
40
|
+ if not file_path.startswith('file:'):
|
|
41
|
+ return
|
|
42
|
+- myfile = Gio.File(uri=file_path)
|
|
43
|
+- file_info = myfile.query_info(Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)
|
|
44
|
++ myfile = Gio.File.new_for_uri(uri=file_path)
|
|
45
|
++ file_info = myfile.query_info(Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, Gio.FileQueryInfoFlags.NONE)
|
|
46
|
+ content_type = file_info.get_content_type()
|
|
47
|
+ if content_type == 'application/x-desktop':
|
|
48
|
+ input_stream = myfile.read()
|
|
49
|
+ keyfile = GLib.KeyFile()
|
|
50
|
+- keyfile.load_from_data(input_stream.read())
|
|
51
|
++ keyfile.load_from_bytes(input_stream.read_bytes(1024*1024), GLib.KeyFileFlags.NONE)
|
|
52
|
+ self.editor.createItem(parent, before, after, KeyFile=keyfile)
|
|
53
|
+ elif content_type in ('application/x-shellscript', 'application/x-executable'):
|
|
54
|
+ self.editor.createItem(parent, before, after,
|
|
55
|
+
|