Package traylib :: Module tray_applet
[frames] | no frames]

Source Code for Module traylib.tray_applet

 1  from rox import applet 
 2  from rox.applet import Applet 
 3   
 4  from traylib import * 
 5  from traylib.tray_container import TrayContainer 
 6   
 7   
8 -class TrayApplet(Applet, TrayContainer):
9 """ 10 An applet showing a L{Tray}. 11 """ 12
13 - def __init__(self, 14 xid, 15 min_size, 16 max_size, 17 tray_class, 18 icon_config, 19 tray_config, 20 *tray_args):
21 """ 22 Creates a new TrayApplet. 23 24 @param xid: The XID of a gtk.Socket widget. 25 """ 26 Applet.__init__(self, xid) 27 orientation = self.get_panel_orientation() 28 if orientation == 'Top': 29 edge = TOP 30 elif orientation == 'Bottom': 31 edge = BOTTOM 32 elif orientation == 'Left': 33 edge = LEFT 34 elif orientation == 'Right': 35 edge = RIGHT 36 icon_config.edge = edge 37 icon_config.pos_func = self.position_menu 38 vertical = orientation in ('Left', 'Right') 39 if vertical: 40 self.set_size_request(8, -1) 41 else: 42 self.set_size_request(-1, 8) 43 TrayContainer.__init__(self, 44 min_size, 45 max_size, 46 vertical, 47 tray_class, 48 icon_config, 49 tray_config, 50 *tray_args)
51
52 - def get_icon_size(self):
53 """ 54 @return: 0.75 times the width (if vertical) or height of the panel. 55 """ 56 size = TrayContainer.get_icon_size(self) 57 size *= 0.75 58 size -= 2 59 return int(size)
60
61 - def get_panel_orientation(self):
62 """ 63 @return: The panel orientation ('Top', 'Bottom', 'Left', 'Right') 64 """ 65 pos = self.socket.property_get('_ROX_PANEL_MENU_POS', 'STRING', False) 66 if pos: pos = pos[2] 67 if pos: 68 side = pos.split(',')[0] 69 else: 70 side = None 71 return side
72