/usr/share/pyshared/pyhoca/wxgui/taskbar.py is in pyhoca-gui 0.4.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | # -*- coding: utf-8 -*-
# Copyright (C) 2010-2013 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
# Copyright (C) 2010-2013 by Dick Kniep <dick.kniep@lindix.nl>
#
# PyHoca GUI is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# PyHoca GUI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
modules ={}
try:
import wxversion
wxversion.select('2.9')
except: pass
try:
import wxversion
wxversion.select('2.8')
except: pass
# Python X2Go
import x2go
import gevent
import gevent.monkey
gevent.monkey.patch_all()
import wx
if x2go.X2GOCLIENT_OS == 'Windows':
import win32gui
import os
# PyHoca-GUI modules
import menus_taskbar
import basepath
_icons_location = basepath.icons_basepath
def MakeIcon(icon_name, fallback_name='pyhoca-trayicon'):
"""\
The various platforms have different requirements for the
icon size...
@param icon_name: rel. file name of the icon image
@type icon_name: C{str}
@param fallback_name: a fallback icon file name in case C{icon_name} cannot be found
@type fallback_name: C{str}
"""
if "wxMSW" in wx.PlatformInfo:
icon_size = '16x16'
elif "wxGTK" in wx.PlatformInfo:
icon_size = '22x22'
elif "wxMAC" in wx.PlatformInfo:
icon_size = '128x128'
if icon_name is None:
icon_name = fallback_name
icon_file = '%s/PyHoca/%s/%s.png' % (_icons_location, icon_size, icon_name)
if not (os.path.isfile(str(icon_file)) or os.path.islink(str(icon_file))):
icon_file = '%s/PyHoca/%s/%s.png' % (_icons_location, icon_size, fallback_name)
img = wx.Image(icon_file)
icon = wx.IconFromBitmap(img.ConvertToBitmap())
return icon
class PyHocaGUI_TaskBarIcon(wx.TaskBarIcon):
"""\
Class for the L{PyHocaGUI} taskbar icon.
"""
def __init__(self, about):
"""\
Initialize the systray icon. The main application window is
the about window, so this one has to be passed in as mandatory
argument.
@param about: instance of the About wx.Frame
@type about: C{obj}
"""
wx.TaskBarIcon.__init__(self)
self._PyHocaGUI = about._PyHocaGUI
self._pyhoca_logger = self._PyHocaGUI._pyhoca_logger
self._pyhoca_logger('start TaskBarIcon of type: %s' % (wx.PlatformInfo, ), loglevel=x2go.loglevel_INFO)
self.SetIconIdle()
self.imgidx = 1
self.tooltip = ""
def SetIconConnecting(self, profile_name):
"""\
When connecting show the default icon and some informational text on mouse hover events
that gives some information what remote X2Go server the client is connecting to.
@param profile_name: the name of the session profile the application currently is connecting to
@type profile_name: C{str}
"""
if x2go.X2GOCLIENT_OS == 'Windows':
icon_name = self._PyHocaGUI.tray_icon_connecting or self._PyHocaGUI.tray_icon
self.icon = MakeIcon(icon_name=icon_name, fallback_name='pyhoca-trayicon')
self.SetIcon(self.icon, _(u"PyHoca-GUI\nConnecting you to ,,%s\'\'") % profile_name)
else:
icon_name = self._PyHocaGUI.tray_icon_connecting or self._PyHocaGUI.tray_icon
self.icon = MakeIcon(icon_name=icon_name, fallback_name='pyhoca-trayicon')
self.SetIcon(self.icon, _(u"PyHoca-GUI (Python X2Go Client)\nCurrently connecting you to remote X2Go server ,,%s\'\'") % profile_name)
def SetIconIdle(self):
"""\
When idle show the default icon and some default informational text on mouse hover events.
"""
if x2go.X2GOCLIENT_OS == 'Windows':
icon_name = self._PyHocaGUI.tray_icon
self.icon = MakeIcon(icon_name=icon_name, fallback_name='pyhoca-trayicon')
self.SetIcon(self.icon, _(u"PyHoca-GUI\nConnecting you to X2Go..."))
else:
icon_name = self._PyHocaGUI.tray_icon
self.icon = MakeIcon(icon_name=icon_name, fallback_name='pyhoca-trayicon')
self.SetIcon(self.icon, _(u"PyHoca-GUI (Python X2Go Client)\nClient for connecting you to a remote X2Go server"))
def CreateSessionManagerPopupMenu(self, evt):
"""\
This method is called by the L{PyHocaGUI} base class when it needs to popup
the menu for the default EVT_LEFT_DOWN event.
@param evt: event
@type evt: C{obj}
@return: a wx-based popup menu object (containing the session and connection manager)
@rtype: C{obj}
"""
if self._PyHocaGUI.args.single_session_profile:
self.menu_sessionmanager = self.PopupMenu(menus_taskbar.PyHocaGUI_Menu_TaskbarSessionProfile(self._PyHocaGUI, caller=self, profile_name=self._PyHocaGUI.args.session_profile))
else:
self.menu_sessionmanager = self.PopupMenu(menus_taskbar.PyHocaGUI_Menu_TaskbarSessionManager(self._PyHocaGUI, caller=self,))
return self.menu_sessionmanager
def CreatePopupMenu(self):
"""\
This method is called by the L{PyHocaGUI} base class when it needs to popup
the menu for the default EVT_RIGHT_DOWN event.
This method wraps around L{CreateProfileManagerPopupMenu()}.
@return: a wx-based popup menu object (containing the session profile manager, amongst others)
@rtype: C{obj}
"""
return self.CreateProfileManagerPopupMenu()
def CreateProfileManagerPopupMenu(self):
"""\
Create the profile manager / client mangager popup menu (i.e. on right-click of the mouse).
@return: a wx-based popup menu object (containing the session profile manager, amongst others)
@rtype: C{obj}
"""
self.menu_optionsmanager = self.PopupMenu(menus_taskbar.PyHocaGUI_Menu_TaskbarOptionsManager(self._PyHocaGUI, caller=self,))
return self.menu_optionsmanager
def Close(self):
"""\
Remove the applet icon from the system tray.
"""
self.RemoveIcon()
|