diff options
author | Patrick Monnerat <[email protected]> | 2019-02-11 19:50:38 +0100 |
---|---|---|
committer | monsta <[email protected]> | 2019-02-20 17:11:10 +0300 |
commit | 7842b86e8deac7b6cae3bea3d27b26ae7a399db0 (patch) | |
tree | 3c98d5854e72567dc58252340d484686d3bd13df /examples/open-terminal.py | |
parent | 05c5dd58ebf03b1366a43cbcfd135079e6d4455d (diff) | |
download | python-caja-7842b86e8deac7b6cae3bea3d27b26ae7a399db0.tar.bz2 python-caja-7842b86e8deac7b6cae3bea3d27b26ae7a399db0.tar.xz |
Examples: remove use of Python 2/3 incompatible urllib/urlparse.
Plus some other rewriting to improve lisibility.
Diffstat (limited to 'examples/open-terminal.py')
-rw-r--r-- | examples/open-terminal.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/examples/open-terminal.py b/examples/open-terminal.py index c80552a..935d894 100644 --- a/examples/open-terminal.py +++ b/examples/open-terminal.py @@ -1,13 +1,6 @@ # This example is contributed by Martin Enlund import os -try: - # Python 3. - from urllib.parse import unquote -except: - # Python 2. - from urllib import unquote - from gi.repository import Caja, GObject, Gio TERMINAL_SCHEMA = 'org.mate.applications-terminal' @@ -18,7 +11,7 @@ class OpenTerminalExtension(Caja.MenuProvider, GObject.GObject): self.gsettings = Gio.Settings.new(TERMINAL_SCHEMA) def _open_terminal(self, file): - filename = unquote(file.get_uri()[7:]) + filename = file.get_location().get_path() terminal = self.gsettings[TERMINAL_KEY] os.chdir(filename) @@ -42,11 +35,11 @@ class OpenTerminalExtension(Caja.MenuProvider, GObject.GObject): label='Open Terminal' , tip='Open Terminal In %s' % file.get_name()) item.connect('activate', self.menu_activate_cb, file) - return item, + return [item] def get_background_items(self, window, file): item = Caja.MenuItem(name='CajaPython::openterminal_item', label='Open Terminal Here', tip='Open Terminal In This Directory') item.connect('activate', self.menu_background_activate_cb, file) - return item, + return [item] |