From c6f19e56bdfae545ff49c80fa8cf1a1f068ad753 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Sat, 9 Mar 2013 15:37:17 -0500 Subject: [PATCH] Disable keybinding temporarily, not working yet --- usr/lib/linuxmint/mintMenu/keybinding.py | 29 +++++++------------ usr/lib/linuxmint/mintMenu/mintMenu.py | 17 +++++++---- .../mintMenu/plugins/applications.py | 2 -- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/keybinding.py b/usr/lib/linuxmint/mintMenu/keybinding.py index 3cd9afa..a83653d 100644 --- a/usr/lib/linuxmint/mintMenu/keybinding.py +++ b/usr/lib/linuxmint/mintMenu/keybinding.py @@ -35,15 +35,9 @@ import capi gdk = CDLL("libgdk-x11-2.0.so.0") -class GlobalKeyBinding(GObject.GObject, threading.Thread): - __gsignals__ = { - 'activate':(GObject.SIGNAL_RUN_LAST, None,()), - } +class GlobalKeyBinding(): def __init__(self): - GObject.GObject.__init__(self) - threading.Thread.__init__(self) - self.setDaemon(True) self.keymap = capi.get_widget (gdk.gdk_keymap_get_default()) self.display = Display() @@ -62,9 +56,7 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread): self.known_modifiers_mask |= modifier def grab(self, key): - Gdk.threads_enter() accelerator = key - Gdk.threads_leave() keyval, modifiers = Gtk.accelerator_parse(accelerator) print keyval, modifiers # if not accelerator or (not keyval and not modifiers): @@ -73,16 +65,17 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread): # print "what" # return count = c_int() - keys = KeymapKey * 10 + array = (KeymapKey * 10)() + keys = cast(array, POINTER(KeymapKey)) self.keycode = gdk.gdk_keymap_get_entries_for_keyval(hash(self.keymap), keyval, byref(keys), byref(count)) #self.keycode= self.keymap.get_entries_for_keyval(keyval)[0].keycode - print keys + print keys[0].keycode self.modifiers = int(modifiers) catch = error.CatchError(error.BadAccess) for ignored_mask in self.ignored_masks: mod = modifiers | ignored_mask - result = self.root.grab_key(self.keycode, mod, True, X.GrabModeAsync, X.GrabModeSync, onerror=catch) + result = self.root.grab_key(keys[0].keycode, mod, True, X.GrabModeAsync, X.GrabModeSync, onerror=catch) self.display.sync() if catch.get_error(): return False @@ -97,15 +90,17 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread): def idle(self): print "caught" - Gdk.threads_enter() self.emit("activate") - Gdk.threads_leave() return False + def activate(self): + GObject.idle_add(self.run) + def run(self): self.running = True wait_for_release = False while self.running: + print "running" event = self.display.next_event() self.current_event_time = event.time if event.detail == self.keycode and event.type == X.KeyPress and not wait_for_release: @@ -118,11 +113,12 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread): elif event.detail == self.keycode and wait_for_release: if event.type == X.KeyRelease: wait_for_release = False - GLib.idle_add(self.idle) + GObject.idle_add(self.idle) self.display.allow_events(X.AsyncKeyboard, event.time) else: self.display.allow_events(X.ReplayKeyboard, event.time) + def stop(self): self.running = False self.ungrab() @@ -132,6 +128,3 @@ class KeymapKey(Structure): _fields_ = [("keycode", c_uint), ("group", c_int), ("level", c_int)] - -class KeymapKeyMany(Structure): - _fields_ = [("keymap", KeymapKey*10)] \ No newline at end of file diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index 5957251..3ebd4b4 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -3,7 +3,7 @@ import gi gi.require_version("Gtk", "2.0") -from gi.repository import Gtk, GdkPixbuf, Gdk +from gi.repository import Gtk, GdkPixbuf, Gdk, GObject from gi.repository import MatePanelApplet from gi.repository import Gio @@ -25,6 +25,12 @@ except Exception, e: print e sys.exit( 1 ) +from keybinding import GlobalKeyBinding + +GObject.threads_init() + +keybinder = GlobalKeyBinding() + gtk = CDLL("libgtk-x11-2.0.so.0") gdk = CDLL("libgdk-x11-2.0.so.0") @@ -124,6 +130,7 @@ class MainWindow( object ): self.settings.connect( "changed::border-width", self.toggleBorderWidth ) self.settings.connect( "changed::opacity", self.toggleOpacity ) + def on_window1_destroy (self, widget, data=None): Gtk.main_quit() sys.exit(0) @@ -370,7 +377,6 @@ class MainWindow( object ): self.paneholder.pack_start( ImageBox, False, False, 0 ) self.paneholder.pack_start( PluginPane, False, False, 0 ) self.tooltips.disable() - #print u"Loading", (time.time() - start), "s" def SetPaneColors( self, items ): @@ -544,6 +550,7 @@ class MenuWin( object ): self.bind_hot_key() def onBindingPress(self): + print "press" try: if self.mainwin.window.flags() & Gtk.VISIBLE: self.mainwin.window.hide() @@ -687,10 +694,10 @@ class MenuWin( object ): self.sizeButton() def bind_hot_key (self): + return try: - self.binder = keybinding.GlobalKeyBinding() - self.binder.grab( self.hotkeyText ) - self.binder.connect("activate", self.onBindingPress) + keybinder.grab( self.hotkeyText ) + keybinder.connect("activate", self.onBindingPress) # Binding menu to hotkey print "Binding to Hot Key: " + self.hotkeyText diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 469a958..4761d2f 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -33,8 +33,6 @@ import matemenu from user import home -GObject.threads_init() - # i18n gettext.install("mintmenu", "/usr/share/linuxmint/locale")