notification area icon (trayicon) is back for windows!
This commit is contained in:
parent
4aaa36fbae
commit
08a7c45c08
2 changed files with 21 additions and 18 deletions
15
src/gajim.py
15
src/gajim.py
|
@ -1133,15 +1133,14 @@ class Interface:
|
||||||
self.systray_enabled = False
|
self.systray_enabled = False
|
||||||
self.systray_capabilities = False
|
self.systray_capabilities = False
|
||||||
|
|
||||||
if False: #os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
try:
|
||||||
|
import systraywin32
|
||||||
|
except: # user doesn't have trayicon capabilities
|
||||||
pass
|
pass
|
||||||
#try:
|
else:
|
||||||
# import systraywin32
|
self.systray_capabilities = True
|
||||||
#except: # user doesn't have trayicon capabilities
|
self.systray = systraywin32.SystrayWin32(self)
|
||||||
# pass
|
|
||||||
#else:
|
|
||||||
# self.systray_capabilities = True
|
|
||||||
# self.systray = systraywin32.SystrayWin32(self)
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
import egg.trayicon # use gnomepythonextras trayicon
|
import egg.trayicon # use gnomepythonextras trayicon
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
##
|
##
|
||||||
## code initially based on
|
## code initially based on
|
||||||
## http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334779
|
## http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334779
|
||||||
|
## with some ideas/help from pysystray.sf.net
|
||||||
##
|
##
|
||||||
## Copyright (C) 2003-2005 Gajim Team
|
## Copyright (C) 2003-2005 Gajim Team
|
||||||
##
|
##
|
||||||
|
@ -52,8 +53,6 @@ class SystrayWINAPI:
|
||||||
self._oldwndproc = win32gui.SetWindowLong(self._hwnd, win32con.GWL_WNDPROC,
|
self._oldwndproc = win32gui.SetWindowLong(self._hwnd, win32con.GWL_WNDPROC,
|
||||||
self._wndproc)
|
self._wndproc)
|
||||||
|
|
||||||
gtk_window.connect('unrealize', self.remove)
|
|
||||||
|
|
||||||
|
|
||||||
def add_notify_icon(self, menu, hicon=None, tooltip=None):
|
def add_notify_icon(self, menu, hicon=None, tooltip=None):
|
||||||
""" Creates a notify icon for the gtk window. """
|
""" Creates a notify icon for the gtk window. """
|
||||||
|
@ -152,9 +151,7 @@ class NotifyIcon:
|
||||||
|
|
||||||
def _get_nid(self):
|
def _get_nid(self):
|
||||||
""" Function to initialise & retrieve the NOTIFYICONDATA Structure. """
|
""" Function to initialise & retrieve the NOTIFYICONDATA Structure. """
|
||||||
nid = (self._hwnd, self._id, self._flags, self._callbackmessage,
|
nid = [self._hwnd, self._id, self._flags, self._callbackmessage, self._hicon]
|
||||||
self._hicon)
|
|
||||||
nid = list(nid)
|
|
||||||
|
|
||||||
if not hasattr(self, '_tip'): self._tip = ''
|
if not hasattr(self, '_tip'): self._tip = ''
|
||||||
nid.append(self._tip)
|
nid.append(self._tip)
|
||||||
|
@ -173,7 +170,6 @@ class NotifyIcon:
|
||||||
|
|
||||||
return tuple(nid)
|
return tuple(nid)
|
||||||
|
|
||||||
|
|
||||||
def remove(self):
|
def remove(self):
|
||||||
""" Removes the tray icon. """
|
""" Removes the tray icon. """
|
||||||
try:
|
try:
|
||||||
|
@ -200,7 +196,7 @@ class NotifyIcon:
|
||||||
|
|
||||||
def _redraw(self, *args):
|
def _redraw(self, *args):
|
||||||
""" Redraws the tray icon. """
|
""" Redraws the tray icon. """
|
||||||
self.remove
|
self.remove()
|
||||||
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,7 +212,15 @@ class SystrayWin32(systray.Systray):
|
||||||
|
|
||||||
self.tray_ico_imgs = self.load_icos()
|
self.tray_ico_imgs = self.load_icos()
|
||||||
|
|
||||||
self.systray_winapi = SystrayWINAPI(self.plugin.roster.window)
|
#self.plugin.roster.window.realize()
|
||||||
|
#self.plugin.roster.window.show_all()
|
||||||
|
w = gtk.Window() # just a window to pass
|
||||||
|
w.realize() # realize it so gtk window exists
|
||||||
|
self.systray_winapi = SystrayWINAPI(w)
|
||||||
|
|
||||||
|
# this fails if you move the window
|
||||||
|
#self.systray_winapi = SystrayWINAPI(self.plugin.roster.window)
|
||||||
|
|
||||||
|
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
|
|
||||||
|
@ -233,7 +237,7 @@ class SystrayWin32(systray.Systray):
|
||||||
self.set_img()
|
self.set_img()
|
||||||
|
|
||||||
def hide_icon(self):
|
def hide_icon(self):
|
||||||
self.systray_winapi.remove_notify_icon()
|
self.systray_winapi.remove()
|
||||||
|
|
||||||
def on_clicked(self, hwnd, message, wparam, lparam):
|
def on_clicked(self, hwnd, message, wparam, lparam):
|
||||||
if lparam == win32con.WM_RBUTTONUP: # Right click
|
if lparam == win32con.WM_RBUTTONUP: # Right click
|
||||||
|
|
Loading…
Add table
Reference in a new issue