1 """To create a panel applet for ROX-Filer, you should add a file called
2 AppletRun to your application. This is run when your applet it dragged onto
3 a panel. It works like the usual AppRun, except that it is passed the XID of
4 the GtkSocket widget that ROX-Filer creates for you on the panel.
6 A sample AppletRun might look like this:
9 import findrox; findrox.version(1, 9, 12)
12 from rox import applet, g
14 plug = applet.Applet(sys.argv[1])
16 label = g.Label('Hello\\nWorld!')
26 _root_window
= g
.gdk
.get_default_root_window()
29 """When your AppletRun file is used, create an Applet widget with
30 the argument passed to AppletRun. Show the widget to make it appear
31 in the panel. toplevel_* functions are called automatically."""
32 def __init__(self
, xid
):
33 """xid is the sys.argv[1] passed to AppletRun."""
35 g
.Plug
.__init
__(self
, xid
)
36 self
.socket
= g
.gdk
.window_foreign_new(xid
)
38 self
.connect('destroy', rox
.toplevel_unref
)
40 def position_menu(self
, menu
):
41 """Use this as the third argument to Menu.popup()."""
42 x
, y
, mods
= _root_window
.get_pointer()
43 pos
= self
.socket
.property_get('_ROX_PANEL_MENU_POS',
47 side
, margin
= pos
.split(',')
50 side
, margin
= None, 2
52 width
, height
= g
.gdk
.screen_width(), g
.gdk
.screen_height()
54 req
= menu
.size_request()
59 elif side
== 'Bottom':
60 y
= height
- margin
- req
[1]
66 x
= width
- margin
- req
[0]
72 def limit(v
, min, max):
73 if v
< min: return min
74 if v
> max: return max
77 x
= limit(x
, 4, width
- 4 - req
[0])
78 y
= limit(y
, 4, height
- 4 - req
[1])