1
2
3
4
5
6 from libxyz.core.plugins import BasePlugin
7 from libxyz.core import UserData
8
10 "Plugin where"
11
12 NAME = u"where"
13 AUTHOR = u"Max E. Kuznecov <syhpoon@syhpoon.name>"
14 VERSION = u"0.1"
15 BRIEF_DESCRIPTION = _(u"Save panels locations")
16 FULL_DESCRIPTION = _(u"When starting load previously saved locations")
17 NAMESPACE = u"misc"
18 MIN_XYZ_VERSION = 2
19 DOC = None
20 HOMEPAGE = "http://xyzcmd.syhpoon.name/"
21 EVENTS = None
22
33
34
35
37 """
38 Restore locations on startup
39 """
40
41 f = None
42 try:
43 f = self._ud.openfile(self._wfile, "r", "data")
44 data = f.readlines()
45 act = data[0].strip()
46 inact = data[1].strip()
47
48 chdir = self.xyz.pm.from_load(":sys:panel", "chdir")
49 chdir(act)
50 chdir(inact, active=False)
51 except Exception:
52 pass
53
54 if f:
55 f.close()
56
57
58
60 """
61 Save locations on shutdown
62 """
63
64 cwdf = self.xyz.pm.from_load(":sys:panel", "cwd")
65 act = cwdf()
66 inact = cwdf(active=False)
67
68 f = None
69 try:
70 f = self._ud.openfile(self._wfile, "w", "data")
71 f.write("\n".join([act, inact]))
72 except XYZRuntimeError, e:
73 xyzlog.info(_(u"Unable to open where data file: %s")
74 % ustring(str(e)))
75 if f:
76 f.close()
77