1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
5 Contact and phone number select dialogs
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright (c) 2003 - 2007 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 Wammu
.Locales
import StrConv
31 return cmp(i1
['Name'], i2
['Name'])
33 def SelectContact(parent
, list, index
= False):
38 choices
.append(StrConv(e
['Number']))
40 choices
.append(StrConv(e
['Name']))
42 dlg
= wx
.SingleChoiceDialog(parent
, _('Select contact from bellow list'), _('Select contact'),
43 choices
, wx
.CHOICEDLG_STYLE | wx
.RESIZE_BORDER
)
44 if dlg
.ShowModal() == wx
.ID_OK
and len(choices
) > 0:
45 rs
= dlg
.GetSelection()
47 rs
= list[rs
]['Location']
53 def SelectNumber(parent
, list):
54 i
= SelectContact(parent
, list, True)
57 return SelectContactNumber(parent
, list[i
])
59 def SelectContactNumber(parent
, item
):
62 for x
in range(len(item
['Entries'])):
63 if Wammu
.Utils
.GetItemType(item
['Entries'][x
]['Type']) == 'phone':
64 numbers
.append(item
['Entries'][x
]['Value'])
65 texts
.append(StrConv(item
['Entries'][x
]['Type'] + ' : ' + item
['Entries'][x
]['Value']))
69 elif len(numbers
) == 1:
71 dlg
= wx
.SingleChoiceDialog(parent
, _('Select number for selected contact'), _('Select phone number'),
72 texts
, wx
.CHOICEDLG_STYLE | wx
.RESIZE_BORDER
)
73 if dlg
.ShowModal() == wx
.ID_OK
:
74 rs
= numbers
[dlg
.GetSelection()]