[nautilus-python: 1/2] Fix open-terminal example urllib import and terminal path



commit d14849670f834e81f2061afc1e6879c6a166379b
Author: Maximilian Schambach <maximilian schambach kit edu>
Date:   Thu Nov 22 11:54:39 2018 +0100

    Fix open-terminal example urllib import and terminal path

 examples/open-terminal.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/examples/open-terminal.py b/examples/open-terminal.py
index 46d793a..8d33733 100644
--- a/examples/open-terminal.py
+++ b/examples/open-terminal.py
@@ -1,23 +1,26 @@
 # This example is contributed by Martin Enlund
 import os
-import urllib
+
+# A way to get unquote working with python 2 and 3
+try:
+    from urllib import unquote
+except ImportError:
+    from urllib.parse import unquote
 
 import gi
 gi.require_version('GConf', '2.0')
 from gi.repository import Nautilus, GObject, GConf
 
-TERMINAL_KEY = '/desktop/gnome/applications/terminal/exec'
 
 class OpenTerminalExtension(Nautilus.MenuProvider, GObject.GObject):
     def __init__(self):
         self.client = GConf.Client.get_default()
         
     def _open_terminal(self, file):
-        filename = urllib.unquote(file.get_uri()[7:])
-        terminal = self.client.get_string(TERMINAL_KEY)
+        filename = unquote(file.get_uri()[7:])
 
         os.chdir(filename)
-        os.system('%s &' % terminal)
+        os.system('gnome-terminal')
         
     def menu_activate_cb(self, menu, file):
         self._open_terminal(file)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]