1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import wx
17 from i18n import ChandlerMessageFactory as _
18 from osaf import sharing
19
20 """
21 Note: need to migrate translation logic to a base wx dialog class that can handle all the work for sub classes
22 """
23
36
37
39 - def __init__(self, title, view, size=wx.DefaultSize,
40 pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE):
41
42
43
44
45
46 pre = wx.PreDialog()
47 pre.Create(None, -1, title, pos, size, style)
48
49
50
51
52 self.this = pre.this
53
54
55
56 sizer = wx.BoxSizer(wx.VERTICAL)
57
58 box = wx.BoxSizer(wx.HORIZONTAL)
59 label = wx.StaticText(self, -1, _(u"&Synchronize"))
60 box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
61 choice = wx.Choice(self, -1, choices=[])
62
63 interval = sharing.getAutoSyncInterval(view)
64
65 choices = [
66 (_(u"Manually"), None),
67 (_(u"Every 30 minutes"), 30),
68 (_(u"Every hour"), 60),
69 (_(u"Every 2 hours"), 120),
70 (_(u"Every 6 hours"), 360),
71 (_(u"Every day"), 1440),
72 ]
73 for (text, minutes) in choices:
74 newIndex = choice.Append(text)
75 choice.SetClientData(newIndex, minutes)
76 if interval == minutes:
77 choice.SetSelection(newIndex)
78
79 box.Add(choice, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
80
81 sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
82
83 line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
84 sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
85
86 box = wx.BoxSizer(wx.HORIZONTAL)
87
88 btn = wx.Button(self, wx.ID_OK)
89 btn.SetDefault()
90 box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
91
92 btn = wx.Button(self, wx.ID_CANCEL)
93 box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
94
95 sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
96
97 self.SetSizer(sizer)
98 self.SetAutoLayout(True)
99 sizer.Fit(self)
100
101
102
103 self.view = view
104 self.choice = choice
105
107 index = self.choice.GetSelection()
108 minutes = self.choice.GetClientData(index)
109 sharing.setAutoSyncInterval(self.view, minutes)
110 self.view.commit()
111