Beispiel #1
0
    def __init__(self, user, password, id, status, set_default):
        super(Varify, self).__init__()
        self.__status = status
        self.set_title('Verification')
        self.set_icon_from_file(ICON_PATH + '/validate.png')
        self.__set_default = set_default
        self.set_modal(True)
        self.set_resizable(False)
        self.set_border_width(20)
        vbox = gtk.VBox(False, 10)
        label = gtk.Label()
        label.set_markup('<span font_desc="belgrano">    Enter the <b>\
Activation Code</b> sent\nto your mobile <span foreground="#FF0000"><b>%s</b>\
</span> below</span>' % user)
        vbox.pack_start(label)
        hbox = gtk.HBox(False, 10)
        re_send = Button(ICON_PATH + '/resend.png', 'Re Send Code', 20, 20)
        re_send.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#000000'))
        re_send.connect('clicked', self.__resend, user, id)
        entry = gtk.Entry()
        entry.modify_font(pango.FontDescription('CrashNumberingGothic'))
        def clear_background(entry, unused):
            entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFFFFF'))
            if entry.get_text() == 'Incorrect Code' or\
               entry.get_text() == 'Re Send Code':
                entry.set_text('')
            return False
        entry.connect('focus-in-event', clear_background)
        entry.set_alignment(0.5)
        hbox.pack_start(entry, True, True)
        hbox.pack_start(re_send, False, False)
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.add(hbox)
        vbox.pack_start(alignment)
        activate = Button(ICON_PATH + '/activate.png', 'Activate Account', 60,
                          30)
        activate.connect('clicked', self.__activate, entry, user, password, id)
        alignment = gtk.Alignment(0.86, 0, 0, 0)
        alignment.add(activate)
        vbox.pack_start(alignment)
        alignment = gtk.Alignment(0, 0, 0, 1)
        alignment.add(vbox)
        self.add(alignment)
        self.connect('destroy', gtk.main_quit)
        self.show_all()
Beispiel #2
0
    def __init__(self):
        super(AccountManager, self).__init__()
        self.set_size_request(260, 220)
        self.set_modal(True)
        self.set_title('Account Manager')
        self.set_icon_from_file(ICON_PATH + '/admin.png')
        vbox = gtk.VBox(True, 4)
        scroll = gtk.ScrolledWindow()
        scroll.set_size_request(140, -1)
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_border_width(8)
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.set_border_width(8)
        from database import DataBase
        database = DataBase()
        users = database.get_user()
        def mark_default(radio):
            'mark the default user bold faced'

            for radio in radio.get_group():
                if radio.get_active():
                    number = radio.get_label()
                    radio.get_child().set_markup('<span font_desc="CrashNumberingGothic">\
<b>' + number + '</b></span>')
                    continue
                radio.get_child().set_markup('<span font_desc="CrashNumberingGothic">' +
                                             radio.get_label() + '</span>')
            return
        radio = gtk.RadioButton(None, str(users[0][0]))
        radio.connect('toggled', mark_default)
        vbox.pack_start(radio)
        for user in users[1:]:
            vbox.pack_start(gtk.RadioButton(radio, str(user[0])))
        default_user = str(database.get_default()[0])
        database.close()
        for radio in radio.get_group():
            if radio.get_label() == default_user:
                radio.set_active(True)
                break
        mark_default(radio)
        alignment.add(vbox)
        scroll.add_with_viewport(alignment)
        scroll.get_child().modify_bg(gtk.STATE_NORMAL,
                                     gtk.gdk.color_parse('#ffffff'))
        vbox = gtk.VBox(False, 4)
        vbox.pack_start(scroll, True, True)
        hbox = gtk.HBox(True, 10)
        add = Button(ICON_PATH + '/add-account.png', 'Add New Account', 30, 30)
        add.connect('clicked', self.__add_user, radio, vbox)
        remove = Button(ICON_PATH + '/remove-account.png', 'Remove Account',
                        30, 30)
        remove.connect('clicked', self.__remove_user, radio, vbox)
        save = Button(ICON_PATH + '/save.png', 'Save Account\n Information',
                      30, 30)
        save.connect('clicked', self.__save, radio)
        hbox.pack_start(add)
        hbox.pack_start(remove)
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.add(hbox)
        vbox.pack_start(alignment, False, False)
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.add(save)
        vbox.pack_start(alignment, False, False)
        self.add(vbox)
        self.connect('destroy', self.__save, radio)
        self.show_all()
Beispiel #3
0
    def __init__(self, contact = None):
        super(PhoneBook, self).__init__()
        self.set_size_request(444, 300)
        self.set_border_width(10)
        self.set_title('Contact Information')
        self.set_icon_from_file(ICON_PATH + '/contact.png')
        self.set_decorated(True)
        self.set_modal(True)
        self.set_position(gtk.WIN_POS_MOUSE)
        self.entry_list = []
        label = gtk.Label()
        label.set_markup('<span font_desc="belgrano 11">Name : </span>')
        label.set_justify(gtk.JUSTIFY_LEFT)
        self.entry_list.append(gtk.Entry())
        def left_strip_name(entry):
            entry.set_text(entry.get_text().lstrip())
        self.entry_list[0].connect("changed", left_strip_name)
        self.entry_list[0].modify_font(pango.FontDescription('belgrano'))
        h_box = gtk.HBox()
        h_box.pack_start(label)
        h_box.pack_start(self.entry_list[-1])
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.add(h_box)
        v_box = gtk.VBox(False, 4)
        v_box.pack_start(alignment)
        self.__add_button = Button(ICON_PATH + '/add.png', 'add contact', 20,
                                   20)
        self.__remove_button = Button(ICON_PATH + '/remove.png',
                                      'remove contact', 20, 20)
        self.__default_button = Button(ICON_PATH + '/default.png',
                                       'set default', 20, 20)
        h_box = gtk.HBox(False, 10)
        label = gtk.Label()
        label.set_markup('<span font_desc="belgrano 10" foreground="#ffffff">\
<b>Default No</b> :</span>')
        h_box.pack_start(label)
        self.entry_list.append(gtk.Entry())
        self.entry_list[-1].connect("changed", self.__check_num)
        self.entry_list[-1].modify_font(pango.FontDescription('CrashNumberingGothic'))
        self.entry_list[-1].set_max_length(10)
        h_box.pack_start(self.entry_list[-1])
        h_box.pack_start(self.__add_button)
        alignment = gtk.Alignment(0, 0, 0, 0)
        alignment.add(h_box)
        vbox = gtk.VBox(True, 4)
        vbox.pack_start(alignment)
        alignment = gtk.Alignment(0, 0, 0, 0)
        alignment.add(vbox)
        alignment.set_border_width(8)
        scroll = gtk.ScrolledWindow()
        scroll.set_size_request(420, 180)
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.add_with_viewport(alignment)
        scroll.set_border_width(8)
        self.__add_button.connect("clicked", self.__add_entry, vbox)
        self.__remove_button.connect("clicked", self.__remove_entry, vbox)
        self.__default_button.connect("clicked", self.__change_default)
        frame = gtk.Frame('Contact Numbers')
        frame.get_label_widget().modify_font(pango.FontDescription('belgrano'))
        frame.set_label_align(0.5, 0.5)
        frame.set_shadow_type(gtk.SHADOW_IN)
        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
        frame.get_label_widget().set_sensitive(False)
        frame.add(scroll)
        scroll.get_child().modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(
                                                                  '#000000'))
        v_box.pack_start(frame)
        save = Button(ICON_PATH + '/save.png', 'Save')
        cancel = Button(ICON_PATH + '/cancel.png', 'Cancel')
        save.connect("clicked", self.__save)
        cancel.connect("clicked", self.__cancel)
        h_box = gtk.HBox(True, 8)
        h_box.pack_start(cancel)
        h_box.pack_start(save)
        alignment = gtk.Alignment(1, 0.5, 0, 1)
        alignment.add(h_box)
        v_box.pack_start(alignment)
        self.__count = 1
        self.add(v_box)
        self.connect('destroy', gtk.main_quit)
        self.set_resizable(False)
        if contact:
            for text in contact[2:]:
                if text:
                    self.__add_button.emit('clicked')
            for index in range(len(contact)):
                if contact[index]:
                    self.entry_list[index].set_text(contact[index])
        self.show_all()
Beispiel #4
0
class PhoneBook(gtk.Window):
    'the contact widget holding all contacts'

    def __init__(self, contact = None):
        super(PhoneBook, self).__init__()
        self.set_size_request(444, 300)
        self.set_border_width(10)
        self.set_title('Contact Information')
        self.set_icon_from_file(ICON_PATH + '/contact.png')
        self.set_decorated(True)
        self.set_modal(True)
        self.set_position(gtk.WIN_POS_MOUSE)
        self.entry_list = []
        label = gtk.Label()
        label.set_markup('<span font_desc="belgrano 11">Name : </span>')
        label.set_justify(gtk.JUSTIFY_LEFT)
        self.entry_list.append(gtk.Entry())
        def left_strip_name(entry):
            entry.set_text(entry.get_text().lstrip())
        self.entry_list[0].connect("changed", left_strip_name)
        self.entry_list[0].modify_font(pango.FontDescription('belgrano'))
        h_box = gtk.HBox()
        h_box.pack_start(label)
        h_box.pack_start(self.entry_list[-1])
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.add(h_box)
        v_box = gtk.VBox(False, 4)
        v_box.pack_start(alignment)
        self.__add_button = Button(ICON_PATH + '/add.png', 'add contact', 20,
                                   20)
        self.__remove_button = Button(ICON_PATH + '/remove.png',
                                      'remove contact', 20, 20)
        self.__default_button = Button(ICON_PATH + '/default.png',
                                       'set default', 20, 20)
        h_box = gtk.HBox(False, 10)
        label = gtk.Label()
        label.set_markup('<span font_desc="belgrano 10" foreground="#ffffff">\
<b>Default No</b> :</span>')
        h_box.pack_start(label)
        self.entry_list.append(gtk.Entry())
        self.entry_list[-1].connect("changed", self.__check_num)
        self.entry_list[-1].modify_font(pango.FontDescription('CrashNumberingGothic'))
        self.entry_list[-1].set_max_length(10)
        h_box.pack_start(self.entry_list[-1])
        h_box.pack_start(self.__add_button)
        alignment = gtk.Alignment(0, 0, 0, 0)
        alignment.add(h_box)
        vbox = gtk.VBox(True, 4)
        vbox.pack_start(alignment)
        alignment = gtk.Alignment(0, 0, 0, 0)
        alignment.add(vbox)
        alignment.set_border_width(8)
        scroll = gtk.ScrolledWindow()
        scroll.set_size_request(420, 180)
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.add_with_viewport(alignment)
        scroll.set_border_width(8)
        self.__add_button.connect("clicked", self.__add_entry, vbox)
        self.__remove_button.connect("clicked", self.__remove_entry, vbox)
        self.__default_button.connect("clicked", self.__change_default)
        frame = gtk.Frame('Contact Numbers')
        frame.get_label_widget().modify_font(pango.FontDescription('belgrano'))
        frame.set_label_align(0.5, 0.5)
        frame.set_shadow_type(gtk.SHADOW_IN)
        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
        frame.get_label_widget().set_sensitive(False)
        frame.add(scroll)
        scroll.get_child().modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(
                                                                  '#000000'))
        v_box.pack_start(frame)
        save = Button(ICON_PATH + '/save.png', 'Save')
        cancel = Button(ICON_PATH + '/cancel.png', 'Cancel')
        save.connect("clicked", self.__save)
        cancel.connect("clicked", self.__cancel)
        h_box = gtk.HBox(True, 8)
        h_box.pack_start(cancel)
        h_box.pack_start(save)
        alignment = gtk.Alignment(1, 0.5, 0, 1)
        alignment.add(h_box)
        v_box.pack_start(alignment)
        self.__count = 1
        self.add(v_box)
        self.connect('destroy', gtk.main_quit)
        self.set_resizable(False)
        if contact:
            for text in contact[2:]:
                if text:
                    self.__add_button.emit('clicked')
            for index in range(len(contact)):
                if contact[index]:
                    self.entry_list[index].set_text(contact[index])
        self.show_all()

    def __save(self, unused):
        'saves the contact details'

        def show_message(msg_type, msg_format, text, button =
                         gtk.BUTTONS_CLOSE):
            '''
            shows warning/error messages if
            anything goes wrong in contact info
            '''

            def set_flag(unused_button):
                '''
                sets the flag to overwrite same
                contact name with newer details
                '''

                self.__over_write = True
                return False
            self.__over_write = False
            message = gtk.MessageDialog(type = msg_type, message_format =
                                        msg_format, buttons = button)
            message.format_secondary_markup(text)
            message.set_icon_from_file(ICON_PATH + '/contact.png')
            if button == gtk.BUTTONS_YES_NO:
                message.get_child().get_children()[-1].get_children()[0].\
                                            connect('clicked', set_flag)
            message.run()
            message.destroy()
        if not self.entry_list[0].get_text():
            show_message(gtk.MESSAGE_ERROR, 'ERROR', '<span font_desc=\
"belgrano 12">Name can not be empty</span>')
            return False
        elif not self.entry_list[1].get_text():
            show_message(gtk.MESSAGE_ERROR, 'ERROR', '<span font_desc="primitiv\
e 12"><span foreground="#3EA9DC"><b>' + self.entry_list[0].get_text() + \
'</b></span> must have a default number</span>')
            return False
        else:
            faulty = []
            for entry in range(1, len(self.entry_list)):
                if len(self.entry_list[entry].get_text()) < 10:
                    faulty.append(entry)
            if faulty:
                text = '<span font_desc="belgrano 12">The following contact(s)\
 has(have) less than 10 digits :\n'
                for index in faulty:
                    if index == 1:
                        text += '<b>default</b>\n'
                    else:
                        text += '#<b>' + str(index) + '</b>\n'
                text += '</span>'
                show_message(gtk.MESSAGE_ERROR, 'ERROR', text)
                return False
        values = [self.entry_list[1].get_text(), self.entry_list[0].get_text()]
        for entry in self.entry_list[2:]:
            values.append(entry.get_text())
        values = tuple(values)
        from database import DataBase
        database = DataBase()
        if database.row_count('contacts', self.entry_list[1].get_text()):
            show_message(gtk.MESSAGE_WARNING, 'WARNING', '<span font_desc="belgrano 12">Number <span foreground="#0000FF"><b>' + \
self.entry_list[1].get_text() + '</b></span> is already in use for <span foreground="#FF0000"><b>%s</b></span>\n\nOverwrite the \
details for <span foreground="#077E11"><b>%s</b></span> ?</span>' % (database.select('contacts', self.entry_list[1].get_text())[0][0],
self.entry_list[0].get_text()), gtk.BUTTONS_YES_NO)
            if self.__over_write:
                database.update('contacts', values)
                database.close()
                self.destroy()
        else:
            database.update('contacts', values)
            database.close()
            self.destroy()

    def __cancel(self, unused_button):
        'cancels all the informations for a contact'

        self.destroy()

    def __check_num(self, entry):
        'forces the characters in the entry field to be digits only'

        text = entry.get_text().strip()
        entry.set_text(''.join([i for i in text if i in '0123456789']))

    def __remove_entry(self, unused, vbox):
        'removes a contact number field'

        self.__count -= 1
        hbox = self.__remove_button.parent
        alignment = hbox.parent
        remove_list = self.__remove_button.parent.get_children()
        for item in remove_list:
            item.hide()
            hbox.remove(item)
        remove_list[0].destroy()
        remove_list[1].destroy()
        self.entry_list.pop()
        alignment.remove(hbox)
        hbox.destroy()
        alignment.destroy()
        hbox = vbox.get_children()[-1].get_children()[0]
        hbox.pack_start(self.__add_button)
        if self.__count > 1:
            hbox.pack_start(self.__remove_button)
        hbox.show_all()

    def __add_entry(self, unused, vbox):
        'adds a new field for a new contact number'

        def cursor_enter(unused_entry, unused_event, hbox):
            'places the default button next to the field whenever cursor enters the field'

            if self.__default_button.parent:
                self.__default_button.parent.remove(self.__default_button)
            hbox.pack_start(self.__default_button)
            self.__default_button.show()
        if self.__count > 1:
            self.__remove_button.hide()
            self.__remove_button.parent.remove(self.__remove_button)
        h_box = gtk.HBox(False, 10)
        self.entry_list.append(gtk.Entry())
        self.entry_list[-1].connect("changed", self.__check_num)
        self.entry_list[-1].modify_font(pango.FontDescription('CrashNumberingGothic'))
        self.entry_list[-1].connect("enter-notify-event", cursor_enter, h_box)
        self.entry_list[-1].set_max_length(10)
        self.__add_button.hide()
        self.__add_button.parent.remove(self.__add_button)
        label = gtk.Label()
        label.set_markup('<span font_desc="belgrano 11"foreground = "#ffffff">\
Contact #%02d :</span>' % (self.__count + 1))
        h_box.pack_start(label)
        h_box.pack_start(self.entry_list[-1])
        h_box.pack_start(self.__add_button)
        h_box.pack_start(self.__remove_button)
        alignment = gtk.Alignment(0, 0, 0, 0)
        alignment.add(h_box)
        vbox.pack_start(alignment)
        alignment.show_all()
        self.__count += 1

    def __change_default(self, unused):
        'swaps the focused contact number with the default number'

        entry = self.__default_button.parent.get_children()[1]
        temp = entry.get_text()
        entry.set_text(self.entry_list[1].get_text())
        self.entry_list[1].set_text(temp)
        return False
Beispiel #5
0
 def __init__(self, set_default = False):
     from spinner import Spinner
     super(Auth, self).__init__()
     self.set_border_width(10)
     self.set_title('Authentication')
     self.set_icon_from_file(ICON_PATH + '/authenticate.png')
     self.set_resizable(False)
     self.set_modal(True)
     self.set_position(gtk.WIN_POS_MOUSE)
     self.__set_default = set_default
     v_box = gtk.VBox(False, 4)
     label = gtk.Label()
     label.set_markup('<span font_desc="belgrano 12">Your Phone Number : </span>')
     label.set_justify(gtk.JUSTIFY_LEFT)
     self.__user = gtk.Entry()
     self.__user.modify_font(pango.FontDescription('CrashNumberingGothic'))
     self.__user.set_max_length(10)
     self.__user.set_alignment(0.5)
     def check_user_name(entry):
         text = entry.get_text().strip()
         entry.set_text(''.join([i for i in text if i in '0123456789']))
         if len(entry.get_text()) == 10:
             self.set_focus(self.__password)
     def clear_background(entry, unused):
         entry.modify_base(gtk.STATE_NORMAL,
                                  gtk.gdk.color_parse('#FFFFFF'))
     self.__user.connect('changed', check_user_name)
     h_box = gtk.HBox()
     h_box.pack_start(label)
     h_box.pack_start(self.__user)
     alignment = gtk.Alignment(1, 0, 0, 0)
     alignment.add(h_box)
     v_box.pack_start(alignment)
     h_box = gtk.HBox()
     label = gtk.Label()
     label.set_markup('<span font_desc="belgrano 12">Way2Sms Password : </span>')
     h_box.pack_start(label)
     self.__password = gtk.Entry()
     def change_focus(unused, event, button):
         if event.keyval == gtk.keysyms.Return:
             button.emit('clicked')
     h_box.pack_start(self.__password)
     self.__password.set_visibility(False)
     alignment = gtk.Alignment(1, 0, 0, 0)
     alignment.add(h_box)
     v_box.pack_start(alignment)
     self.__user.connect('focus-in-event', clear_background)
     self.__password.connect('focus-in-event', clear_background)
     cancel = Button(ICON_PATH + '/cancel.png', 'Cancel', 40, 30)
     def __destroy(unused, self):
         self.emit('destroy')
     cancel.connect('clicked', __destroy, self)
     login = Button(ICON_PATH + '/login.png', 'Login', 40, 30)
     login.connect('clicked', self.__validate)
     self.__password.connect('key-release-event', change_focus, login)
     h_box = gtk.HBox(True, 10)
     h_box.pack_start(cancel)
     h_box.pack_start(login)
     alignment = gtk.Alignment(1, 0, 0, 0)
     alignment.add(h_box)
     v_box.pack_start(alignment)
     alignment = gtk.Alignment(0, 0, 0, 0)
     alignment.add(v_box)
     self.add(alignment)
     self.__spinner = Spinner('logging in ...')
     self.connect('destroy', gtk.main_quit)
     self.show_all()
     self.__spinner.hide_all()
Beispiel #6
0
    def __init__(self, login_thread_list):
        super(Interface, self).__init__()
        self.set_size_request(460, 400)
        self.set_border_width(4)
        self.set_title('SMS')
        self.set_icon_from_file(ICON_PATH + '/logo.png')
        self.set_decorated(True)
        self.set_position(gtk.WIN_POS_MOUSE)
        text_field = gtk.TextView()
        text_field.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
        text_field.set_border_width(10)
        text_field.modify_font(pango.FontDescription('belgrano'))
        text_buffer = gtk.TextBuffer()
        text_field.set_buffer(text_buffer)
        text_field.set_wrap_mode(gtk.WRAP_WORD_CHAR)
        text_field.set_tooltip_markup('   Type in your\n<b>MESSAGE</b> here')
        text_field.set_sensitive(False)
        def _enable_text_view_widget(field, thread_list):
            for thread in thread_list:
                if thread.isAlive():
                    return True
            status = True
            for thread in thread_list:
                status = status and thread.getStatus()
            field.set_sensitive(status)
            if not status:
                self.__push_status_message('<span font_desc="belgrano 10"><b>  Login Failed - Network Error</b></span>')
            return False
        gobject.timeout_add(200, _enable_text_view_widget, text_field, login_thread_list)
        self.spell_check_enable = False
        spell_correction = None
        size_tag = text_buffer.create_tag("size", size_points = 11)
        error_tag = text_buffer.create_tag("error", underline = pango.UNDERLINE_ERROR)
        frame = gtk.Frame('Message Body')
        frame.get_label_widget().modify_font(pango.FontDescription('belgrano'))
        frame.set_label_align(0.5, 0.5)
        frame.set_shadow_type(gtk.SHADOW_IN)
        frame.get_label_widget().set_sensitive(False)
        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_border_width(4)
        scroll.add_with_viewport(text_field)
        scroll.get_child().modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
        frame.add(scroll)
        frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#70EDF7'))
        vbox = gtk.VBox(False, 4)
        hbox = gtk.HBox(False, 20)
        alignment = gtk.Alignment(1, 0.5, 1, 1)
        send = Button(ICON_PATH + '/send.png', 'Send Message')
        clear = Button(ICON_PATH + '/clear.png', 'Clear Field')
        send.connect("clicked", self.__send, text_buffer)
        clear.connect("clicked", self.__clear, text_buffer)
        def check_number(entry):
            'enforces only digits in the entry field'

            text = entry.get_active_text().strip()
            entry.child.set_text(''.join([i for i in text if i in '0123456789']))
            if not len(entry.child.get_text()):
                if self._receiver_index != -1:
                    index = self._receiver_index
                    self._receiver_index = -1
                    del self._receiver[index]
                    self._receiver_widget.remove_text(index)
            if len(entry.child.get_text()) == 10:
                if entry.get_active() != -1:
                    self._receiver_index = entry.get_active()
                if entry.child.get_text() not in self._receiver:
                    if self._receiver_index != -1:
                        self._receiver[self._receiver_index] = entry.child.get_text()
                        self._receiver_widget.remove_text(self._receiver_index)
                        self._receiver_widget.insert_text(self._receiver_index, entry.child.get_text())
                        self._receiver_index = -1
                    else:
                        entry.append_text(entry.child.get_text())
                        self._receiver.append(entry.child.get_text())
                    entry.child.set_text('')
            return False
        receiver_box = gtk.VBox(False, 4)
        label = gtk.Label()
        label.set_markup('<span font_desc="belgrano 10"><b>Receivers</b></span>')
        self._receiver = []
        self._receiver_index = -1
        self._receiver_widget = gtk.combo_box_entry_new_text()
        self._receiver_widget.child.modify_font(pango.FontDescription('CrashNumberingGothic'))
        self._receiver_widget.child.set_max_length(10)
        self._receiver_widget.child.set_tooltip_text("Enter Receivers'\n Numbers Here")
        self._receiver_widget.set_size_request(120, -1)
        self._receiver_widget.child.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse('#0000ff'))
        self._receiver_widget.connect('changed', check_number)
        receiver_box.pack_start(label)
        receiver_box.pack_start(self._receiver_widget)
        hbox.pack_start(receiver_box, True, False)
        hbox.pack_start(clear, False, False)
        hbox.pack_start(send, False, False)
        alignment.add(hbox)
        vbox.pack_start(frame, True, True)
        vbox.pack_start(alignment, False, False)
        paned = gtk.HPaned()
        v_box = gtk.VBox(False, 8)
        paned.pack1(vbox, True, False)
        frame = gtk.Frame('Phone Book')
        frame.get_label_widget().modify_font(pango.FontDescription('belgrano'))
        frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#70EDF7'))
        frame.set_label_align(0.5, 0.5)
        frame.set_shadow_type(gtk.SHADOW_IN)
        frame.get_label_widget().set_sensitive(False)
        self.__contact_box = gtk.VBox(False, 10)
        alignment = gtk.Alignment(0, 0, 0, 0)
        alignment.set_border_width(4)
        alignment.add(self.__contact_box)
        self.add_contacts()
        scroll = gtk.ScrolledWindow()
        scroll.set_size_request(140, -1)
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_border_width(4)
        scroll.add_with_viewport(alignment)
        scroll.get_child().modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
        vbox = gtk.VBox(False, 2)
        hbox = gtk.HBox(True, 0)
        add = Button(ICON_PATH + '/add-user.png', 'Add Contact')
        add.set_border_width(2)
        add.connect('clicked', self.__add_user)
        edit = Button(ICON_PATH + '/edit-user.png', 'Edit Contact\nInformation')
        edit.connect('clicked', self.__edit_user)
        delete = Button(ICON_PATH + '/remove-user.png', 'Remove Contact')
        delete.set_border_width(2)
        delete.connect('clicked', self.__delete_user)
        vbox.pack_start(scroll, True, True)
        hbox.pack_start(add, True, True)
        hbox.pack_start(delete, True, True)
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.add(hbox)
        vbox.pack_start(alignment, False, False)
        alignment = gtk.Alignment(0.5, 0, 0, 0)
        alignment.add(edit)
        vbox.pack_start(alignment, False, False)
        frame.add(vbox)
        paned.pack2(frame, False, False)
        def manage_account(unused):
            from account import AccountManager
            AccountManager()
            gtk.main()
        def show_about(unused):
            About()
        def show_history(unused):
            from history import HistoryManager
            HistoryManager()
            gtk.main()
        def load_from_file(unused):
            from path import HOME_PATH
            loader = gtk.FileChooserDialog(title = 'Open ...', action = gtk.FILE_CHOOSER_ACTION_OPEN, buttons = (gtk.STOCK_CANCEL,
                                                                            gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
            loader.set_icon_from_file(ICON_PATH + '/logo.png')
            loader.set_current_folder(HOME_PATH + '/Desktop')
            loader.set_default_response(gtk.RESPONSE_OK)
            filter = gtk.FileFilter()
            filter.set_name("Text")
            filter.add_pattern("*.txt")
            loader.add_filter(filter)
            filter = gtk.FileFilter()
            filter.set_name("All files")
            filter.add_pattern("*")
            loader.add_filter(filter)
            response = loader.run()
            if response == gtk.RESPONSE_OK:
                text_buffer.set_text(open(loader.get_filename()).read())
            loader.destroy()
            return
        def save_to_file(unused):
            from path import HOME_PATH
            import os
            if not os.path.exists(HOME_PATH + '/.sms/saved messages/'):
                os.makedirs(HOME_PATH + '/.sms/saved messages/')
            files = len([name for name in os.listdir(HOME_PATH + '/.sms/saved messages/')])
            loader = gtk.FileChooserDialog(title = "Save ...", action = gtk.FILE_CHOOSER_ACTION_SAVE, buttons = (gtk.STOCK_CANCEL,
                                                                            gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
            loader.set_icon_from_file(ICON_PATH + '/logo.png')
            loader.set_current_folder(HOME_PATH + '/.sms/saved messages/')
            loader.set_default_response(gtk.RESPONSE_OK)
            loader.set_current_name('message %s.txt' % str(files + 1))
            text = text_buffer.get_text(text_buffer.get_start_iter(), text_buffer.get_end_iter())
            response = loader.run()
            if response == gtk.RESPONSE_OK and text:
                filename = loader.get_filename()
                file = open(filename, 'w')
                file.write(text)
                file.close()
            loader.destroy()
            return
        def check_spell(unused):
            from SpellCheck import spell_check
            global spell_correction
            spell_correction = {}
            thread.start_new(spell_check, (text_buffer.get_text(text_buffer.get_start_iter(), text_buffer.get_end_iter()), spell_correction))
            text_buffer.remove_tag(error_tag, text_buffer.get_start_iter(), text_buffer.get_end_iter())
            text_buffer.apply_tag(size_tag, text_buffer.get_start_iter(), text_buffer.get_end_iter())
            gtk.main()
            if spell_correction:
                self.spell_check_enable = True
                for key in spell_correction.keys():
                    text_buffer.apply_tag(error_tag, text_buffer.get_iter_at_offset(key[0] - 1), text_buffer.get_iter_at_offset(key[0] + key[1] - 1))
        menu_bar = gtk.MenuBar()
        menu_bar.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ff0000'))
        menu = gtk.Menu()
        menu.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ff8800'))
        menu_item = gtk.MenuItem("Load")
        menu.append(menu_item)
        menu_item.connect('activate', load_from_file)
        menu_item = gtk.MenuItem("Save")
        menu.append(menu_item)
        menu_item.connect('activate', save_to_file)
        menu_item = gtk.MenuItem("User Account")
        menu.append(menu_item)
        menu_item.connect('activate', manage_account)
        menu_item = gtk.SeparatorMenuItem()
        menu.append(menu_item)
        menu_item = gtk.MenuItem("Quit")
        menu.append(menu_item)
        menu_item.connect('activate', gtk.main_quit)
        action_menu = gtk.MenuItem("_Action")
        action_menu.set_submenu(menu)
        menu_bar.append(action_menu)
        menu = gtk.Menu()
        menu.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ff8800'))
        menu_item = gtk.MenuItem("History")
        menu.append(menu_item)
        message_menu = gtk.MenuItem("_Message")
        menu_item.connect('activate', show_history)
        menu_item = gtk.MenuItem("Spell Check")
        menu.append(menu_item)
        menu_item.connect('activate', check_spell)
        message_menu.set_submenu(menu)
        menu_bar.append(message_menu)
        menu = gtk.Menu()
        menu.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ff8800'))
        menu_item = gtk.MenuItem("About")
        menu.append(menu_item)
        help_menu = gtk.MenuItem("_Help")
        menu_item.connect('activate', show_about)
        help_menu.set_submenu(menu)
        menu_bar.append(help_menu)
        self.status_bar = gtk.Statusbar()
        self.status_bar.set_size_request(-1, 28)
        self.status_bar.set_has_resize_grip(True)
        hbox = gtk.HBox(False, 2)
        hbox.pack_start(menu_bar, True, True)
        v_box.pack_start(hbox, False, False)
        v_box.pack_start(paned, True, True)
        v_box.pack_start(self.status_bar, False, False)
        self.add(v_box)
        text_buffer.connect("changed", self.__current_char, size_tag, error_tag)
        def spell_check_context_menu(unused, menu):
            global spell_correction
            cursor_pos = text_buffer.props.cursor_position
            if not self.spell_check_enable:
                return
            def replace_rectified(unused, word, key):
                del(spell_correction[key])
                start = text_buffer.get_iter_at_offset(key[0] - 1)
                end = text_buffer.get_iter_at_offset(key[0] + key[1] - 1)
                replaced = text_buffer.get_text(start, end)
                text_buffer.delete(start, end)
                text_buffer.insert(start, word)
                diff = len(replaced) - len(word)
                if diff:
                    for (k, v) in spell_correction.items()[:]:
                        del(spell_correction[k])
                        if key[0] < k[0]:
                            spell_correction[(k[0] - diff, k[1])] = v
                        else:
                            spell_correction[(k[0], k[1])] = v
                for key in spell_correction.keys():
                    text_buffer.apply_tag(error_tag,
                                    text_buffer.get_iter_at_offset(key[0] - 1),
                           text_buffer.get_iter_at_offset(key[0] + key[1] - 1))
                self.spell_check_enable = True
                return
            for key in spell_correction.keys():
                if cursor_pos >= key[0] - 1 and cursor_pos <= key[0] + key[1] - 1:
                    correct = spell_correction[key][:]
                    correct.reverse()
                    for word in correct:
                        menu_item = gtk.MenuItem(word)
                        menu.prepend(menu_item)
                        menu_item.connect('activate', replace_rectified, word, key)
                    menu.show_all()
                    break
            return
        text_field.connect('populate-popup', spell_check_context_menu)
        def destroy(unused):
            gtk.main_quit()
            return
        self.connect("destroy", destroy)
        self.set_focus(text_field)
        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
        self.show_all()