# Path: Wammu/Locales.py
# def StrConv(txt):
#     """
#     This function coverts something (txt) to string form usable by wxPython. There
#     is problem that in default configuration in most distros (maybe all) default
#     encoding for unicode objects is ascii. This leads to exception when converting
#     something different than ascii. And this exception is not catched inside
#     wxPython and leads to segfault.
# 
#     So if wxPython supports unicode, we give it unicode, otherwise locale
#     dependant text.
#     """
#     try:
#         if isinstance(txt, unicode):
#             return txt
#         elif isinstance(txt, str):
#             return unicode(txt, LOCALE_CHARSET)
#         return str(txt)
#     except UnicodeEncodeError:
#         return '???'
# 
# Path: Wammu/Locales.py
# def ugettext(message):
#     if _TRANSLATION:
#         if six.PY2:
#             return _TRANSLATION.ugettext(message)
#         return _TRANSLATION.gettext(message)
#     return message


import os
import wx
import Wammu.Select
import Wammu.Utils
import Wammu.PhoneValidator
from Wammu.Locales import StrConv
from Wammu.Locales import ugettext as _
        # TODO: Load would be better
        self.load_button = wx.Button(self, wx.ID_OPEN)

        self.button_sizer = wx.StdDialogButtonSizer()
        self.button_sizer.AddButton(wx.Button(self, wx.ID_OK))
        self.button_sizer.AddButton(wx.Button(self, wx.ID_CANCEL))

        self.__set_properties()
        self.__do_layout()
        self.__bind_events()

    def __bind_events(self):
        self.Bind(wx.EVT_BUTTON, self.Add, self.add_button)
        self.Bind(wx.EVT_BUTTON, self.Delete, self.delete_button)
        self.Bind(wx.EVT_BUTTON, self.Save, self.save_button)
        self.Bind(wx.EVT_BUTTON, self.Load, self.load_button)

    def __init_data(self):
        self.numberlist = []
        self.optionslist = []

        for item in self.contacts:
            numbers = []
            texts = []
            prefix = ''
            if item['Name'] != '':
                prefix = '%s: ' % item['Name']
            for i in range(len(item['Entries'])):
                if Wammu.Utils.GetItemType(item['Entries'][i]['Type']) == 'phone':
                    numbers.append(item['Entries'][i]['Value'])

# Path: Wammu/Locales.py
# def StrConv(txt):
#     """
#     This function coverts something (txt) to string form usable by wxPython. There
#     is problem that in default configuration in most distros (maybe all) default
#     encoding for unicode objects is ascii. This leads to exception when converting
#     something different than ascii. And this exception is not catched inside
#     wxPython and leads to segfault.
# 
#     So if wxPython supports unicode, we give it unicode, otherwise locale
#     dependant text.
#     """
#     try:
#         if isinstance(txt, unicode):
#             return txt
#         elif isinstance(txt, str):
#             return unicode(txt, LOCALE_CHARSET)
#         return str(txt)
#     except UnicodeEncodeError:
#         return '???'
# 
# Path: Wammu/Locales.py
# def ugettext(message):
#     if _TRANSLATION:
#         if six.PY2:
#             return _TRANSLATION.ugettext(message)
#         return _TRANSLATION.gettext(message)
#     return message


# Path: Wammu/EditContactList.py
import os
import wx
import Wammu.Select
import Wammu.Utils
import Wammu.PhoneValidator
from Wammu.Locales import StrConv
from Wammu.Locales import ugettext as _

        # TODO: Load would be better
        self.load_button = wx.Button(self, wx.ID_OPEN)

        self.button_sizer = wx.StdDialogButtonSizer()
        self.button_sizer.AddButton(wx.Button(self, wx.ID_OK))
        self.button_sizer.AddButton(wx.Button(self, wx.ID_CANCEL))

        self.__set_properties()
        self.__do_layout()
        self.__bind_events()

    def __bind_events(self):
        self.Bind(wx.EVT_BUTTON, self.Add, self.add_button)
        self.Bind(wx.EVT_BUTTON, self.Delete, self.delete_button)
        self.Bind(wx.EVT_BUTTON, self.Save, self.save_button)
        self.Bind(wx.EVT_BUTTON, self.Load, self.load_button)

    def __init_data(self):
        self.numberlist = []
        self.optionslist = []

        for item in self.contacts:
            numbers = []
            texts = []
            prefix = ''
            if item['Name'] != '':
                prefix = '%s: ' % item['Name']
            for i in range(len(item['Entries'])):
                if Wammu.Utils.GetItemType(item['Entries'][i]['Type']) == 'phone':
                    numbers.append(item['Entries'][i]['Value'])

                    texts.append(StrConv('%s (%s)' % (item['Entries'][i]['Value'], item['Entries'][i]['Type'])))