1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2008 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 from wx
.lib
.filebrowsebutton
import FileBrowseButton
29 from wx
.lib
.masked
.timectrl
import TimeCtrl
33 import Wammu
.GammuSettings
34 import Wammu
.PhoneWizard
36 class Settings(wx
.Dialog
):
37 def __init__(self
, parent
, config
):
38 wx
.Dialog
.__init
__(self
, parent
, -1, _('Settings'), style
= wx
.DEFAULT_DIALOG_STYLE | wx
.RESIZE_BORDER
)
41 self
.notebook
= wx
.Notebook(self
, -1)
42 self
.notebook_gammu
= wx
.Panel(self
.notebook
, -1)
43 self
.notebook_connection
= wx
.Panel(self
.notebook
, -1)
44 self
.notebook_messages
= wx
.Panel(self
.notebook
, -1)
45 self
.notebook_view
= wx
.Panel(self
.notebook
, -1)
46 self
.notebook_other
= wx
.Panel(self
.notebook
, -1)
47 self
.notebook_hacks
= wx
.Panel(self
.notebook
, -1)
50 self
.sizer
= wx
.lib
.rcsizer
.RowColSizer()
52 self
.sizer
.AddGrowableCol(2)
53 self
.sizer
.AddGrowableRow(1)
55 self
.sizer
.AddSpacer(1, 1, pos
= (0, 0))
56 self
.sizer
.AddSpacer(1, 1, pos
= (0, 4))
58 self
.sizer
.Add(self
.notebook
, pos
= (1, 1), colspan
= 3, flag
= wx
.EXPAND
)
60 self
.sizer
.Add(wx
.StaticLine(self
, -1), pos
= (2, 1), colspan
= 3, flag
= wx
.EXPAND
)
62 self
.button_sizer
= wx
.StdDialogButtonSizer()
63 self
.button_sizer
.AddButton(wx
.Button(self
, wx
.ID_OK
))
64 self
.button_sizer
.AddButton(wx
.Button(self
, wx
.ID_CANCEL
))
65 self
.button_sizer
.Realize()
67 self
.sizer
.Add(self
.button_sizer
, pos
= (3, 1), colspan
= 3, flag
= wx
.ALIGN_RIGHT
)
69 self
.sizer
.AddSpacer(1, 1, pos
= (4, 0), colspan
= 5)
72 self
.gammu_config
= config
.gammu
75 self
.sizer_gammu
= wx
.lib
.rcsizer
.RowColSizer()
77 self
.sizer_gammu
.AddGrowableCol(1)
79 self
.sizer_gammu
.AddSpacer(1, 1, pos
= (0, 0))
82 self
.editcfgpath
= wx
.lib
.filebrowsebutton
.FileBrowseButton(self
.notebook_gammu
,
85 initialValue
= config
.Read('/Gammu/Gammurc', False),
86 toolTip
= _('Please enter here path to gammu configuration file you want to use.'),
87 changeCallback
= self
.OnConfigChange
,
89 self
.sizer_gammu
.Add(wx
.StaticText(self
.notebook_gammu
, -1, _('Gammurc path')), pos
= (r
, 1), flag
= wx
.ALIGN_CENTER_VERTICAL
)
90 self
.sizer_gammu
.Add(self
.editcfgpath
, pos
= (r
, 2), flag
= wx
.EXPAND
)
93 self
.sizer_gammu
.Add(wx
.StaticText(self
.notebook_gammu
, -1, _('You can configure connection parameters on Connection tab.')), pos
= (r
, 1), colspan
= 2)
96 self
.sizer_gammu
.AddSpacer(1, 1, pos
= (r
, 3))
99 self
.editauto
= wx
.CheckBox(self
.notebook_gammu
, -1, _('Automatically connect to phone on startup'))
100 self
.editauto
.SetToolTipString(_('Whether you want application automatically connect to phone when it is started.'))
101 self
.editauto
.SetValue(config
.Read('/Wammu/AutoConnect') == 'yes')
102 self
.sizer_gammu
.Add(self
.editauto
, pos
= (r
, 1), colspan
= 2)
105 self
.editdebug
= wx
.CheckBox(self
.notebook_gammu
, -1, _('Show debug log'))
106 self
.editdebug
.SetToolTipString(_('Show debug information on error output.'))
107 self
.editdebug
.SetValue(config
.Read('/Debug/Show') == 'yes')
108 self
.sizer_gammu
.Add(self
.editdebug
, pos
= (r
, 1), colspan
= 2)
111 self
.editsync
= wx
.CheckBox(self
.notebook_gammu
, -1, _('Synchronize time'))
112 self
.editsync
.SetToolTipString(_('Synchronise time in phone with computer time while connecting.'))
113 self
.editsync
.SetValue(config
.Read('/Gammu/SyncTime') == 'yes')
114 self
.sizer_gammu
.Add(self
.editsync
, pos
= (r
, 1), colspan
= 2)
117 self
.editinfo
= wx
.CheckBox(self
.notebook_gammu
, -1, _('Startup information'))
118 self
.editinfo
.SetToolTipString(_('Display startup on phone (not supported by all models).'))
119 self
.editinfo
.SetValue(config
.Read('/Gammu/StartInfo') == 'yes')
120 self
.sizer_gammu
.Add(self
.editinfo
, pos
= (r
, 1), colspan
= 2)
123 if sys
.platform
!= 'win32':
124 # locking not available on windoze
125 self
.editlock
= wx
.CheckBox(self
.notebook_gammu
, -1, _('Lock device'))
126 self
.editlock
.SetToolTipString(_('Whether to lock device in /var/lock. On some systems you might lack privileges to do so.'))
127 self
.editlock
.SetValue(config
.Read('/Gammu/LockDevice') == 'yes')
128 self
.sizer_gammu
.Add(self
.editlock
, pos
= (r
, 1), colspan
= 2)
131 self
.sizer_gammu
.AddSpacer(1, 1, pos
= (r
, 3))
134 self
.notebook_gammu
.SetAutoLayout(True)
135 self
.notebook_gammu
.SetSizer(self
.sizer_gammu
)
136 self
.sizer_gammu
.Fit(self
.notebook_gammu
)
137 self
.sizer_gammu
.SetSizeHints(self
.notebook_gammu
)
140 self
.sizer_connection
= wx
.lib
.rcsizer
.RowColSizer()
142 self
.sizer_connection
.AddGrowableCol(1)
144 self
.sizer_connection
.AddSpacer(1, 1, pos
= (0, 0))
147 lst
, choices
= config
.gammu
.GetConfigList()
148 self
.editsection
= wx
.Choice(self
.notebook_connection
, choices
= choices
, size
= (250, -1))
149 section
= config
.ReadInt('/Gammu/Section')
150 for i
in range(len(lst
)):
151 if lst
[i
]['Id'] == section
:
152 self
.editsection
.SetSelection(i
)
154 self
.sizer_connection
.Add(wx
.StaticText(self
.notebook_connection
, -1, _('Phone connection')), pos
= (r
, 1), rowspan
= 2, flag
= wx
.ALIGN_CENTER_VERTICAL
)
155 self
.sizer_connection
.Add(self
.editsection
, pos
= (r
, 2))
156 self
.Bind(wx
.EVT_CHOICE
, self
.OnConnectionChange
, self
.editsection
)
159 self
.addsection
= wx
.Button(self
.notebook_connection
, wx
.ID_ADD
)
160 self
.sizer_connection
.Add(self
.addsection
, pos
= (r
, 2), flag
= wx
.EXPAND
)
163 self
.sizer_connection
.AddSpacer(1, 1, pos
= (r
, 3))
166 self
.editname
= wx
.TextCtrl(self
.notebook_connection
, -1, '', size
= (250, -1))
167 self
.editname
.SetToolTipString(_('Name for this configuration.'))
168 self
.sizer_connection
.Add(wx
.StaticText(self
.notebook_connection
, -1, _('Name')), pos
= (r
, 1), flag
= wx
.ALIGN_CENTER_VERTICAL
)
169 self
.sizer_connection
.Add(self
.editname
, pos
= (r
, 2))
172 self
.editdev
= wx
.ComboBox(self
.notebook_connection
, -1, '', choices
= Wammu
.Data
.Devices
, size
= (150, -1))
173 self
.editdev
.SetToolTipString(_('Device, where your phone is connected.'))
174 self
.sizer_connection
.Add(wx
.StaticText(self
.notebook_connection
, -1, _('Device')), pos
= (r
, 1), flag
= wx
.ALIGN_CENTER_VERTICAL
)
175 self
.sizer_connection
.Add(self
.editdev
, pos
= (r
, 2), flag
= wx
.ALIGN_RIGHT | wx
.EXPAND
)
178 self
.editconn
= wx
.ComboBox(self
.notebook_connection
, -1, '', choices
= Wammu
.Data
.Connections
, size
= (150, -1))
179 self
.editconn
.SetToolTipString(_('Connection which your phone understands, check Gammu documentation for connection details.'))
180 self
.sizer_connection
.Add(wx
.StaticText(self
.notebook_connection
, -1, _('Connection')), pos
= (r
, 1), flag
= wx
.ALIGN_CENTER_VERTICAL
)
181 self
.sizer_connection
.Add(self
.editconn
, pos
= (r
, 2), flag
= wx
.ALIGN_RIGHT | wx
.EXPAND
)
184 self
.editmodel
= wx
.ComboBox(self
.notebook_connection
, -1, '', choices
= Wammu
.Data
.Models
, size
= (150, -1))
185 self
.editmodel
.SetToolTipString(_('Phone model, you can usually keep here auto unless you have any problems.'))
186 if self
.editmodel
.GetValue() == '':
187 self
.editmodel
.SetValue('auto')
188 self
.sizer_connection
.Add(wx
.StaticText(self
.notebook_connection
, -1, _('Model')), pos
= (r
, 1), flag
= wx
.ALIGN_CENTER_VERTICAL
)
189 self
.sizer_connection
.Add(self
.editmodel
, pos
= (r
, 2), flag
= wx
.ALIGN_RIGHT | wx
.EXPAND
)
192 # Initialise above fields
193 self
.OnConnectionChange()
195 self
.sizer_connection
.AddSpacer(1, 1, pos
= (r
, 3))
197 # size connection tab
198 self
.notebook_connection
.SetAutoLayout(True)
199 self
.notebook_connection
.SetSizer(self
.sizer_connection
)
200 self
.sizer_connection
.Fit(self
.notebook_connection
)
201 self
.sizer_connection
.SetSizeHints(self
.notebook_connection
)
204 self
.sizer_messages
= wx
.lib
.rcsizer
.RowColSizer()
206 self
.sizer_messages
.AddGrowableCol(1)
208 self
.sizer_messages
.AddSpacer(1, 1, pos
= (0, 0))
211 v
= config
.ReadInt('/Message/ScaleImage')
212 self
.editscale
= wx
.SpinCtrl(self
.notebook_messages
, -1, str(v
), style
= wx
.SP_WRAP|wx
.SP_ARROW_KEYS
, min = 1, max = 20, initial
= v
, size
= (150, -1))
213 self
.editscale
.SetToolTipString(_('Whether images in messages should be scaled when displayed. This is usually good idea as they are pretty small.'))
214 self
.sizer_messages
.Add(wx
.StaticText(self
.notebook_messages
, -1, _('Scale images')), pos
= (r
, 1))
215 self
.sizer_messages
.Add(self
.editscale
, pos
= (r
, 2))
218 self
.editformat
= wx
.CheckBox(self
.notebook_messages
, -1, _('Attempt to reformat text'))
219 self
.editformat
.SetToolTipString(_('If you get sometimes "compressed" messages likeTHIStext, you should be interested in this choice.'))
220 self
.editformat
.SetValue(config
.Read('/Message/Format') == 'yes')
221 self
.sizer_messages
.Add(self
.editformat
, pos
= (r
, 1), colspan
= 2)
224 # options for new message
225 self
.new_message_panel
= wx
.Panel(self
.notebook_messages
, -1)
226 self
.sizer_messages
.Add(self
.new_message_panel
, pos
= (r
, 1), colspan
= 2, flag
= wx
.EXPAND
)
229 self
.sizer_message_new
= wx
.StaticBoxSizer(wx
.StaticBox(self
.new_message_panel
, -1, 'Default options for new message'), wx
.HORIZONTAL
)
230 self
.new_message_panel_2
= wx
.Panel(self
.new_message_panel
, -1)
231 self
.sizer_message_new
.Add(self
.new_message_panel_2
, 1, wx
.EXPAND
, 0)
233 self
.sizer_message_new_2
= wx
.lib
.rcsizer
.RowColSizer()
235 self
.sizer_message_new_2
.AddGrowableCol(1)
239 self
.editconcat
= wx
.CheckBox(self
.new_message_panel_2
, -1, _('Concatenated'))
240 self
.editconcat
.SetToolTipString(_('Create concatenated message, what allows to send longer messages.'))
241 self
.editconcat
.SetValue(config
.Read('/Message/Concatenated') == 'yes')
242 self
.sizer_message_new_2
.Add(self
.editconcat
, pos
= (r2
, 0), colspan
= 2)
245 self
.editunicode
= wx
.CheckBox(self
.new_message_panel_2
, -1, _('Create unicode message'))
246 self
.editunicode
.SetToolTipString(_('Unicode messages can contain national and other special characters, check this if you use non latin-1 characters. Your messages will require more space, so you can write less characters into single message.'))
247 self
.editunicode
.SetValue(config
.Read('/Message/Unicode') == 'yes')
248 self
.sizer_message_new_2
.Add(self
.editunicode
, pos
= (r2
, 0), colspan
= 2)
251 self
.editreport
= wx
.CheckBox(self
.new_message_panel_2
, -1, _('Request delivery report by default'))
252 self
.editreport
.SetToolTipString(_('Check to request delivery report for message.'))
253 self
.editreport
.SetValue(config
.Read('/Message/DeliveryReport') == 'yes')
254 self
.sizer_message_new_2
.Add(self
.editreport
, pos
= (r2
, 0), colspan
= 2)
257 self
.edit16bit
= wx
.CheckBox(self
.new_message_panel_2
, -1, _('Use 16bit Id'))
258 self
.edit16bit
.SetToolTipString(_('Use 16 bit Id inside message. This is safe for most cases.'))
259 self
.edit16bit
.SetValue(config
.Read('/Message/16bitId') == 'yes')
260 self
.sizer_message_new_2
.Add(self
.edit16bit
, pos
= (r2
, 0), colspan
= 2)
263 self
.new_message_panel_2
.SetAutoLayout(True)
264 self
.new_message_panel_2
.SetSizer(self
.sizer_message_new_2
)
265 self
.sizer_message_new_2
.Fit(self
.new_message_panel_2
)
266 self
.sizer_message_new_2
.SetSizeHints(self
.new_message_panel_2
)
268 self
.new_message_panel
.SetAutoLayout(True)
269 self
.new_message_panel
.SetSizer(self
.sizer_message_new
)
270 self
.sizer_message_new
.Fit(self
.new_message_panel
)
271 self
.sizer_message_new
.SetSizeHints(self
.new_message_panel
)
273 self
.sizer_messages
.AddSpacer(1, 1, pos
= (r
, 3))
276 self
.notebook_messages
.SetAutoLayout(True)
277 self
.notebook_messages
.SetSizer(self
.sizer_messages
)
278 self
.sizer_messages
.Fit(self
.notebook_messages
)
279 self
.sizer_messages
.SetSizeHints(self
.notebook_messages
)
282 self
.sizer_view
= wx
.lib
.rcsizer
.RowColSizer()
284 self
.sizer_view
.AddGrowableCol(1)
286 self
.sizer_view
.AddSpacer(1, 1, pos
= (0, 0))
289 v
= config
.Read('/Wammu/NameFormat')
290 self
.editnameformat
= wx
.Choice(self
.notebook_view
, choices
= [
292 _('Automatic starting with first name'),
293 _('Automatic starting with last name'),
294 _('Custom, use format string bellow')
297 self
.editnameformat
.SetSelection(0)
298 elif v
== 'auto-first-last':
299 self
.editnameformat
.SetSelection(1)
300 elif v
== 'auto-last-first':
301 self
.editnameformat
.SetSelection(2)
303 self
.editnameformat
.SetSelection(3)
304 self
.sizer_view
.Add(wx
.StaticText(self
.notebook_view
, -1, _('Name display format')), pos
= (r
, 1))
305 self
.sizer_view
.Add(self
.editnameformat
, pos
= (r
, 2), flag
= wx
.EXPAND
)
306 self
.Bind(wx
.EVT_CHOICE
, self
.OnNameFormatChange
, self
.editnameformat
)
309 v
= config
.Read('/Wammu/NameFormatString')
310 self
.editnamestring
= wx
.ComboBox(self
.notebook_view
, -1, v
, choices
= [
312 '%(FirstName)s %(LastName)s (%(Company)s)',
313 '%(LastName)s, %(FirstName)s (%(Company)s)',
314 '%(LastName)s, %(FirstName)s (%(NickName)s)',
316 # l10n: The %s will be replaced by list of currently supported tags, %%(value)s should be kept intact (you can translate word value).
317 self
.editnamestring
.SetToolTipString(_('Format string for name displaying. You can use %%(value)s format marks. Currently available values are: %s.') %
318 'Name, FirstName, LastName, NickName, FormalName, Company')
319 self
.sizer_view
.Add(wx
.StaticText(self
.notebook_view
, -1, _('Name format string')), pos
= (r
, 1), flag
= wx
.ALIGN_CENTER_VERTICAL
)
320 self
.sizer_view
.Add(self
.editnamestring
, pos
= (r
, 2), flag
= wx
.ALIGN_RIGHT | wx
.EXPAND
)
323 self
.sizer_view
.AddSpacer(1, 1, pos
= (r
, 3))
326 self
.notebook_view
.SetAutoLayout(True)
327 self
.notebook_view
.SetSizer(self
.sizer_view
)
328 self
.sizer_view
.Fit(self
.notebook_view
)
329 self
.sizer_view
.SetSizeHints(self
.notebook_view
)
332 self
.sizer_other
= wx
.lib
.rcsizer
.RowColSizer()
334 self
.sizer_other
.AddGrowableCol(1)
336 self
.sizer_other
.AddSpacer(1, 1, pos
= (0, 0))
339 v
= config
.ReadInt('/Wammu/RefreshState')
340 self
.editrefresh
= wx
.SpinCtrl(self
.notebook_other
, -1, str(v
), style
= wx
.SP_WRAP|wx
.SP_ARROW_KEYS
, min = 0, max = 10000000, initial
= v
, size
= (150, -1))
341 self
.editrefresh
.SetToolTipString(_('How often refresh phone state in application status bar. Enter value in miliseconds, 0 to disable.'))
342 self
.sizer_other
.Add(wx
.StaticText(self
.notebook_other
, -1, _('Refresh phone state')), pos
= (r
, 1))
343 self
.sizer_other
.Add(self
.editrefresh
, pos
= (r
, 2))
346 self
.editconfirm
= wx
.CheckBox(self
.notebook_other
, -1, _('Confirm deleting'))
347 self
.editconfirm
.SetToolTipString(_('Whether to ask for confirmation when deleting entries.'))
348 self
.editconfirm
.SetValue(config
.Read('/Wammu/ConfirmDelete') == 'yes')
349 self
.sizer_other
.Add(self
.editconfirm
, pos
= (r
, 1), colspan
= 2)
352 self
.taskbaricon
= wx
.CheckBox(self
.notebook_other
, -1, _('Task bar icon'))
353 self
.taskbaricon
.SetToolTipString(_('Show icon in task bar.'))
354 self
.taskbaricon
.SetValue(config
.Read('/Wammu/TaskBarIcon') == 'yes')
355 self
.sizer_other
.Add(self
.taskbaricon
, pos
= (r
, 1), colspan
= 2)
358 dtime
= config
.Read('/Wammu/DefaultTime')
360 times
= dtime
.split(':')
368 self
.edittime
= TimeCtrl(self
.notebook_other
, -1, fmt24hr
= True)
369 Wammu
.Utils
.FixupMaskedEdit(self
.edittime
)
370 self
.edittime
.SetValue(wx
.DateTimeFromHMS(th
, tm
, ts
))
371 self
.edittime
.SetToolTipString(_('Default time to be used for newly created time fields.'))
372 self
.sizer_other
.Add(wx
.StaticText(self
.notebook_other
, -1, _('Default time')), pos
= (r
, 1))
373 self
.sizer_other
.Add(self
.edittime
, pos
= (r
, 2))
376 v
= config
.ReadInt('/Wammu/DefaultDateOffset')
377 self
.editdate
= wx
.SpinCtrl(self
.notebook_other
, -1, str(v
), style
= wx
.SP_WRAP|wx
.SP_ARROW_KEYS
, min = -10000000, max = 10000000, initial
= v
, size
= (150, -1))
378 self
.editdate
.SetToolTipString(_('Default date to be used for newly created time fields. Enter amount of days from today (1 = tommorow).'))
379 self
.sizer_other
.Add(wx
.StaticText(self
.notebook_other
, -1, _('Default date = now + x days')), pos
= (r
, 1))
380 self
.sizer_other
.Add(self
.editdate
, pos
= (r
, 2))
383 v
= config
.ReadInt('/Wammu/DefaultEntries')
384 self
.editentries
= wx
.SpinCtrl(self
.notebook_other
, -1, str(v
), style
= wx
.SP_WRAP|wx
.SP_ARROW_KEYS
, min = 0, max = 20, initial
= v
, size
= (150, -1))
385 self
.editentries
.SetToolTipString(_('How many entries will be shown in newly created item.'))
386 self
.sizer_other
.Add(wx
.StaticText(self
.notebook_other
, -1, _('Entries for new item')), pos
= (r
, 1))
387 self
.sizer_other
.Add(self
.editentries
, pos
= (r
, 2))
391 lst
+= Wammu
.Data
.InternationalPrefixes
392 self
.editprefix
= wx
.ComboBox(self
.notebook_other
, -1, config
.Read('/Wammu/PhonePrefix'), choices
= lst
, size
= (150, -1))
393 self
.editprefix
.SetToolTipString(_('Prefix for non international phone numbers.'))
394 self
.sizer_other
.Add(wx
.StaticText(self
.notebook_other
, -1, _('Number prefix')), pos
= (r
, 1))
395 self
.sizer_other
.Add(self
.editprefix
, pos
= (r
, 2))
398 self
.sizer_other
.AddSpacer(1, 1, pos
= (r
, 3))
401 self
.notebook_other
.SetAutoLayout(True)
402 self
.notebook_other
.SetSizer(self
.sizer_other
)
403 self
.sizer_other
.Fit(self
.notebook_other
)
404 self
.sizer_other
.SetSizeHints(self
.notebook_other
)
407 self
.sizer_hacks
= wx
.lib
.rcsizer
.RowColSizer()
409 self
.sizer_hacks
.AddGrowableCol(1)
411 self
.sizer_hacks
.AddSpacer(1, 1, pos
= (0, 0))
414 v
= config
.ReadInt('/Hacks/MaxEmptyGuess')
415 self
.editmaxemptyguess
= wx
.SpinCtrl(self
.notebook_hacks
, -1, str(v
), style
= wx
.SP_WRAP|wx
.SP_ARROW_KEYS
, min = 0, max = 10000000, initial
= v
, size
= (150, -1))
416 self
.editmaxemptyguess
.SetToolTipString(_('When Wammu encounters continuous this count of empty entries when reading items from phone where total count was guessed, it assumes that rest is empty.'))
417 self
.sizer_hacks
.Add(wx
.StaticText(self
.notebook_hacks
, -1, _('Maximal empty entries if total is guessed')), pos
= (r
, 1))
418 self
.sizer_hacks
.Add(self
.editmaxemptyguess
, pos
= (r
, 2))
421 v
= config
.ReadInt('/Hacks/MaxEmptyKnown')
422 self
.editmaxemptyknown
= wx
.SpinCtrl(self
.notebook_hacks
, -1, str(v
), style
= wx
.SP_WRAP|wx
.SP_ARROW_KEYS
, min = 0, max = 10000000, initial
= v
, size
= (150, -1))
423 self
.editmaxemptyknown
.SetToolTipString(_('When Wammu encounters continuous this count of empty entries when reading items from phone which have known total count, it assumes that rest is empty.'))
424 self
.sizer_hacks
.Add(wx
.StaticText(self
.notebook_hacks
, -1, _('Maximal empty entries if total is known')), pos
= (r
, 1))
425 self
.sizer_hacks
.Add(self
.editmaxemptyknown
, pos
= (r
, 2))
428 self
.sizer_hacks
.AddSpacer(1, 1, pos
= (r
, 3))
431 self
.notebook_hacks
.SetAutoLayout(True)
432 self
.notebook_hacks
.SetSizer(self
.sizer_hacks
)
433 self
.sizer_hacks
.Fit(self
.notebook_hacks
)
434 self
.sizer_hacks
.SetSizeHints(self
.notebook_hacks
)
436 # add pages to notebook
437 self
.notebook
.AddPage(self
.notebook_gammu
, _('Gammu'))
438 self
.notebook
.AddPage(self
.notebook_connection
, _('Connection'))
439 self
.notebook
.AddPage(self
.notebook_messages
, _('Messages'))
440 self
.notebook
.AddPage(self
.notebook_view
, _('View'))
441 self
.notebook
.AddPage(self
.notebook_other
, _('Other'))
442 self
.notebook
.AddPage(self
.notebook_hacks
, _('Hacks'))
445 self
.SetAutoLayout(True)
446 self
.SetSizer(self
.sizer
)
448 self
.sizer
.SetSizeHints(self
)
450 # workaround, when sizers don't set correct size
453 self
.SetSize((400, 400))
456 self
.OnNameFormatChange()
459 self
.Bind(wx
.EVT_BUTTON
, self
.Okay
, id = wx
.ID_OK
)
460 self
.Bind(wx
.EVT_BUTTON
, self
.AddPhone
, id = wx
.ID_ADD
)
462 def OnNameFormatChange(self
, evt
= None):
463 selection
= self
.editnameformat
.GetSelection()
467 self
.editnamestring
.Enable(True)
469 self
.editnamestring
.Enable(False)
471 def OnConnectionChange(self
, evt
= None):
472 selection
= self
.editsection
.GetSelection()
475 lst
, choices
= self
.gammu_config
.GetConfigList()
477 self
.editdev
.Enable(False)
478 self
.editmodel
.Enable(False)
479 self
.editname
.Enable(False)
480 self
.editconn
.Enable(False)
483 self
.editdev
.Enable(True)
484 self
.editmodel
.Enable(True)
485 self
.editname
.Enable(True)
486 self
.editconn
.Enable(True)
487 current
= lst
[selection
]
488 gammu
= self
.gammu_config
.GetConfig(current
['Id'])
489 self
.editdev
.SetValue(gammu
['Device'])
490 self
.editmodel
.SetValue(gammu
['Model'])
491 self
.editname
.SetValue(gammu
['Name'])
492 self
.editconn
.SetValue(gammu
['Connection'])
494 def OnConfigChange(self
, evt
= None):
495 # temporarily change gammu config data
496 newpath
= self
.editcfgpath
.GetValue()
497 self
.gammu_config
= Wammu
.GammuSettings
.GammuSettings(self
.config
, os
.path
.expanduser(newpath
))
500 def RereadConfig(self
):
501 lst
, choices
= self
.gammu_config
.GetConfigList()
502 self
.editsection
.Clear()
504 self
.editsection
.Append(x
)
506 self
.editsection
.SetSelection(0)
507 self
.OnConnectionChange()
509 def AddPhone(self
, evt
= None):
510 index
= self
.gammu_config
.FirstFree()
511 result
= Wammu
.PhoneWizard
.RunConfigureWizard(self
, index
)
512 if result
is not None:
513 self
.gammu_config
.SetConfig(result
['Position'], result
['Device'], result
['Connection'], result
['Name'])
515 lst
, choices
= self
.gammu_config
.GetConfigList()
516 self
.editsection
.SetSelection(len(lst
) - 1)
517 self
.OnConnectionChange()
520 lst
, choices
= self
.config
.gammu
.GetConfigList()
522 # Check whether we have some configuration
524 wx
.MessageDialog(self
,
525 _('You don\'t have any phone connection configured. Wammu will not be able to conect to your phone!'),
526 _('No phone configured!'),
527 wx
.OK | wx
.ICON_ERROR
).ShowModal()
529 current
= lst
[self
.editsection
.GetSelection()]
530 self
.config
.gammu
= self
.gammu_config
531 self
.config
.gammu
.SetConfig(current
['Id'],
532 self
.editdev
.GetValue(),
533 self
.editconn
.GetValue(),
534 self
.editname
.GetValue(),
535 self
.editmodel
.GetValue())
536 self
.config
.Write('/Gammu/Gammurc', self
.editcfgpath
.GetValue())
537 self
.config
.WriteInt('/Gammu/Section', current
['Id'])
539 if self
.editsync
.GetValue():
543 self
.config
.Write('/Gammu/SyncTime', value
)
544 if sys
.platform
!= 'win32':
545 if self
.editlock
.GetValue():
549 self
.config
.Write('/Gammu/LockDevice', value
)
550 if self
.editinfo
.GetValue():
554 self
.config
.Write('/Gammu/StartInfo', value
)
555 if self
.editdebug
.GetValue():
559 self
.config
.Write('/Debug/Show', value
)
560 if self
.editauto
.GetValue():
564 self
.config
.Write('/Wammu/AutoConnect', value
)
565 if self
.editformat
.GetValue():
569 self
.config
.Write('/Message/Format', value
)
570 if self
.editconcat
.GetValue():
574 self
.config
.Write('/Message/Concatenated', value
)
575 if self
.editunicode
.GetValue():
579 self
.config
.Write('/Message/Unicode', value
)
580 if self
.editreport
.GetValue():
584 self
.config
.Write('/Message/DeliveryReport', value
)
585 if self
.edit16bit
.GetValue():
589 self
.config
.Write('/Message/16bitId', value
)
590 self
.config
.WriteInt('/Message/ScaleImage', self
.editscale
.GetValue())
591 self
.config
.WriteInt('/Wammu/RefreshState', self
.editrefresh
.GetValue())
592 if self
.editconfirm
.GetValue():
596 self
.config
.Write('Wammu/ConfirmDelete', value
)
597 if self
.taskbaricon
.GetValue():
601 self
.config
.Write('/Wammu/TaskBarIcon', value
)
602 self
.config
.Write('Wammu/DefaultTime', self
.edittime
.GetValue())
603 self
.config
.WriteInt('/Wammu/DefaultDateOffset', self
.editdate
.GetValue())
604 self
.config
.WriteInt('/Wammu/DefaultEntries', self
.editentries
.GetValue())
605 self
.config
.Write('/Wammu/PhonePrefix', self
.editprefix
.GetValue())
606 self
.config
.Write('/Wammu/NameFormat', self
.editnamestring
.GetValue())
607 ind
= self
.editnameformat
.GetSelection()
611 val
= 'auto-first-last'
613 val
= 'auto-last-first'
617 raise Exception('Invalid NameFormatString id: %d' % ind
)
618 self
.config
.Write('/Wammu/NameFormat', val
)
620 self
.config
.WriteInt('/Hacks/MaxEmptyGuess', self
.editmaxemptyguess
.GetValue())
621 self
.config
.WriteInt('/Hacks/MaxEmptyKnown', self
.editmaxemptyknown
.GetValue())
622 self
.EndModal(wx
.ID_OK
)