Cleanup
[rox-menu.git] / panel.py
blob4ba579f407a866de102d7b8bce0937267971d4bd
1 import gtk
3 def find_panel_window():
4 root = gtk.gdk.get_default_root_window()
5 wids = root.property_get('_NET_CLIENT_LIST')[2]
6 wl = [gtk.gdk.window_foreign_new(long(w)) for w in wids]
7 for w in wl:
8 if w is not None:
9 wclass = w.property_get('WM_CLASS')[2].split('\0')[:2]
10 if wclass[0] == 'ROX-Panel':
11 return w
12 else:
13 return None
15 def get_panel_orientation():
16 panel = find_panel_window()
17 if panel:
18 panelx, panely = panel.get_root_origin()
19 rect = panel.get_frame_extents()
20 panelw, panelh = rect.width, rect.height
21 if panelx == 0:
22 if panelw > panelh:
23 if panely == 0:
24 return "Top"
25 else:
26 return "Bottom"
27 return "Left"
28 if panelw < panelh:
29 return "Right"