scrolling over the tray icon switches among devices; fixes #101
It now works for the standard systray as well, not just the appindicator.
This commit is contained in:
parent
c0874220d2
commit
6a66370ffe
|
|
@ -67,15 +67,14 @@ def _create_menu(quit_handler):
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
# raise ImportError
|
|
||||||
from gi.repository import AppIndicator3
|
|
||||||
|
|
||||||
if _log.isEnabledFor(_DEBUG):
|
|
||||||
_log.debug("using AppIndicator3")
|
|
||||||
|
|
||||||
_last_scroll = 0
|
_last_scroll = 0
|
||||||
def _scroll(ind, _ignore, direction):
|
def _scroll(tray_icon, event, direction=None):
|
||||||
|
if direction is None:
|
||||||
|
direction = event.direction
|
||||||
|
now = event.time / 1000.0
|
||||||
|
else:
|
||||||
|
now = None
|
||||||
|
|
||||||
if direction != ScrollDirection.UP and direction != ScrollDirection.DOWN:
|
if direction != ScrollDirection.UP and direction != ScrollDirection.DOWN:
|
||||||
# ignore all other directions
|
# ignore all other directions
|
||||||
return
|
return
|
||||||
|
|
@ -88,7 +87,7 @@ try:
|
||||||
# scroll events come way too fast (at least 5-6 at once)
|
# scroll events come way too fast (at least 5-6 at once)
|
||||||
# so take a little break between them
|
# so take a little break between them
|
||||||
global _last_scroll
|
global _last_scroll
|
||||||
now = _timestamp()
|
now = now or _timestamp()
|
||||||
if now - _last_scroll < 0.33: # seconds
|
if now - _last_scroll < 0.33: # seconds
|
||||||
return
|
return
|
||||||
_last_scroll = now
|
_last_scroll = now
|
||||||
|
|
@ -144,6 +143,13 @@ try:
|
||||||
_update_tray_icon()
|
_update_tray_icon()
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
# raise ImportError
|
||||||
|
from gi.repository import AppIndicator3
|
||||||
|
|
||||||
|
if _log.isEnabledFor(_DEBUG):
|
||||||
|
_log.debug("using AppIndicator3")
|
||||||
|
|
||||||
def _create(menu):
|
def _create(menu):
|
||||||
theme_paths = Gtk.IconTheme.get_default().get_search_path()
|
theme_paths = Gtk.IconTheme.get_default().get_search_path()
|
||||||
|
|
||||||
|
|
@ -210,10 +216,9 @@ except ImportError:
|
||||||
icon.set_title(NAME)
|
icon.set_title(NAME)
|
||||||
icon.set_tooltip_text(NAME)
|
icon.set_tooltip_text(NAME)
|
||||||
icon.connect('activate', _window_toggle)
|
icon.connect('activate', _window_toggle)
|
||||||
|
icon.connect('scroll-event', _scroll)
|
||||||
icon.connect('popup_menu',
|
icon.connect('popup-menu',
|
||||||
lambda icon, button, time:
|
lambda icon, button, time: menu.popup(None, None, icon.position_menu, icon, button, time))
|
||||||
menu.popup(None, None, icon.position_menu, icon, button, time))
|
|
||||||
|
|
||||||
return icon
|
return icon
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue