From 9b7a920e0d73fa140faf3e285808f46c42e63d98 Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Fri, 18 Jan 2013 17:18:35 +0200 Subject: [PATCH] fix for systray visibility (gihub #14) --- lib/solaar/gtk.py | 2 ++ lib/solaar/ui/main_window.py | 1 + lib/solaar/ui/status_icon.py | 12 +++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py index dd0405e0..82427104 100644 --- a/lib/solaar/gtk.py +++ b/lib/solaar/gtk.py @@ -108,6 +108,8 @@ def _run(args): GObject.timeout_add(3000, check_for_listener) GObject.timeout_add(10, check_for_listener, True) + if icon: + GObject.timeout_add(1000, ui.status_icon.check_systray, icon, window) Gtk.main() if listener[0]: diff --git a/lib/solaar/ui/main_window.py b/lib/solaar/ui/main_window.py index a8f5f5f9..35a7ce91 100644 --- a/lib/solaar/ui/main_window.py +++ b/lib/solaar/ui/main_window.py @@ -283,6 +283,7 @@ def create(title, name, max_devices, systray=False): return True def _set_has_systray(w, systray): + # print ("set has systray", systray, w._has_systray) if systray != w._has_systray: w._has_systray = systray if systray: diff --git a/lib/solaar/ui/status_icon.py b/lib/solaar/ui/status_icon.py index 6d730909..e02502a3 100644 --- a/lib/solaar/ui/status_icon.py +++ b/lib/solaar/ui/status_icon.py @@ -38,18 +38,24 @@ def create(window, menu_actions=None): lambda icon, button, time, menu: menu.popup(None, None, icon.position_menu, icon, button, time), menu) + return icon + +def check_systray(icon, window): # use size-changed to detect if the systray is available or not def _size_changed(i, size, w): + import logging + logging.info("size-chagend %s %s", size, w) def _check_systray(i2, w2): + logging.info("check_systray %s %s", i2.is_embedded(), i2.get_visible()) w2.set_has_systray(i2.is_embedded() and i2.get_visible()) # first guess GObject.timeout_add(250, _check_systray, i, w) # just to make sure... - GObject.timeout_add(1000, _check_systray, i, w) - icon.connect('size-changed', _size_changed, window) + # GObject.timeout_add(1000, _check_systray, i, w) - return icon + _size_changed(icon, None, window) + icon.connect('size-changed', _size_changed, window) _PIXMAPS = {}