Logo Search packages:      
Sourcecode: scenic version File versions  Download package

def scenic::gui::Gui::on_edit_contact_save_clicked (   self,
  unused_args 
)
The save button in the "edit_contact" window has been clicked.
Hides the edit_contact window and saves the changes. (new or modified contact)

Definition at line 687 of file gui.py.

                                                        :
        """
        The save button in the "edit_contact" window has been clicked.
        Hides the edit_contact window and saves the changes. (new or modified contact)
        """
        def _when_valid_save():
            # Saves contact info after it's been validated and then closes the window
            # THIS IS WHERE WE CREATE THE CONTACTS IN THE ADDRESSBOOK
            # TODO: move to a dedicated function in save.py or so.
            contact = {
                "name": self.contact_name_widget.get_text().strip(),
                "address": addr,
                "auto_accept": self.contact_auto_accept_widget.get_active(),
                }
            contact_markup = format_contact_markup(contact)
            if self.app.address_book.current_contact_is_new:
                self.contact_tree.append([contact_markup]) # add it to the tree list
                self.app.address_book.contact_list.append(contact) # and the internal address book
                self.selection.select_path(len(self.app.address_book.contact_list) - 1) # select it ...?
                self.app.address_book.selected_contact = self.app.address_book.contact_list[len(self.app.address_book.contact_list) - 1] #FIXME: we should not copy a dict like that
                self.app.address_book.current_contact_is_new = False # FIXME: what does that mean?
            else:
                self.contact_tree.set_value(self.selected_contact_row, 0, contact_markup)
                self.app.address_book.contact_list[self.selected_contact_index] = contact # FIXME: this is flaky. make some functions to handle this
            self.app.address_book.selected_contact = contact
            self.edit_contact_window.hide()

        # Validate the address
        addr = self.contact_addr_widget.get_text().strip()
        if not network.validate_address(addr):
            self.show_error_dialog(_("The address is not valid\n\nEnter a valid address\nExample: 192.0.32.10 or example.org"))
            return
        # save it.
        _when_valid_save()


Generated by  Doxygen 1.6.0   Back to index