Getting nautilus to recognize a key press using the python-nautilus extension



Hi. I'm not subscribed to this list so I'd appreciate to be CC'd on a reply so that I can receive it. I have nautilus 3.18.5 running on an ubuntu 16.04.2 updated system. The reason I'm writing is to ask a question about the python-nautilus extension of nautilus. I'm trying to get nautilus to recognize a key combination on the keyboard to then have it run a script on the currently selected file(s)/folder(s). To ensure that this is possible, I searched on the web and found a site[1] that describes that this is possible, so I decided to use the script that it mentions was re-written for nautilus 3[2] and modify it just to test if nautilus at least recognizes the key press by opening a gnome-terminal if it does. Below is the brief modified code. Can anyone explain why the key press is not recognized for me? All I want is to get nautilus to recognize a key press and then run a script on the currently selected files. Any help would be appreciated. Thank you.

[1] http://zverovich.net/2011/02/18/user-defined-keyboard-shortcuts-in-nautilus.html [2] https://github.com/vitaut/captain-nemo/raw/master/misc/shortcut-nautilus3.py

import os, pipes, urllib
from gi.repository import Nautilus, GObject, Gtk, Gdk

class ShortcutProvider(GObject.GObject, Nautilus.LocationWidgetProvider):
    def __init__(self):
        self.accel_group = Gtk.AccelGroup()
self.accel_group.connect_group(ord('g'), Gdk.ModifierType.CONTROL_MASK,
            Gtk.AccelFlags.VISIBLE, self.run_copy_to_remote_google_drive)
        self.window = None

def run_copy_to_remote_google_drive(self, accel_group, acceleratable, keyval, modifier):
        filename = urllib.unquote(self.uri[7:])
        os.system('/usr/bin/gnome-terminal &')
        return True

    def get_widget(self, uri, window):
        self.uri = uri
        if self.window:
            self.window.remove_accel_group(self.accel_group)
        window.add_accel_group(self.accel_group)
        self.window = window
        return None


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