Beispiel #1
0
    def change_encode(self, document, encode):
        #TODO: this method isn't use the document passed argument
        #TODO: what happen if a invalid encoding is passed?
        """
        Change the text encode of a document.
        
        @param document: a document to change the encoding
        @type document: a Document.
        
        @param encode: encode name.
        @type encode: a String.
        """
        
        page_num = self.get_current_page()
        
        if page_num != -1:
            document = self.get_nth_page(page_num)

            if document.encode != encode:
                file_uri = document.file_uri
                
                if file_uri != "":
                    if not document.is_updated():
                        dialog = CloseAlertDialog()
                        dialog.set_markup(constants.MESSAGE_0014)

                        button_clicked = dialog.run()

                        if button_clicked == gtk.RESPONSE_DELETE_EVENT:
                            dialog.destroy()
                            return
                        elif button_clicked == 1:
                            dialog.destroy()
                        elif button_clicked == 2:
                            dialog.destroy()
                            return
                        elif button_clicked == 3:
                            self.save_active_tab(file_uri)
                           
                            dialog.destroy()
                                                       
                        self.__remove_tab(document)
                        self.open_tab(file_uri, encode)
                    else:
                        self.__remove_tab(document)
                        self.open_tab(file_uri, encode)
                        
                    new_page_num = self.get_current_page()
                    document = self.get_nth_page(new_page_num)
                    self.reorder_child(document, page_num)