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

def mago::application::gnome::GEdit::close (   self,
  save = False,
  filename = '' 
)

Given a gedit window, it tries to close the application.
By default, it closes without saving. This behaviour can be changed to save (or save as) on close.
 
@type save: boolean
@param save: If True, the edited file will be saved on close.

@type filename: string
@param filename: The file name to save the buffer to 

Definition at line 456 of file gnome.py.

00456                                             :
        """
        Given a gedit window, it tries to close the application.
        By default, it closes without saving. This behaviour can be changed to save (or save as) on close.
         
        @type save: boolean
        @param save: If True, the edited file will be saved on close.

        @type filename: string
        @param filename: The file name to save the buffer to 
        """

        # Exit using the Quit menu 
        try:
            gedit = ooldtp.context(self.name)
            try:
                quit_menu = gedit.getchild(self.MNU_QUIT)
            except ldtp.LdtpExecutionError:
                raise ldtp.LdtpExecutionError, "The quit menu was not found."
            quit_menu.selectmenuitem()
        except ldtp.LdtpExecutionError:
            raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."

        question_dialog = None
        count = 0
        while not gedit.waittillguinotexist(guiTimeOut=1) and \
                count < 10:
            try:
                question_dialog = ooldtp.context(self.QUESTION_DLG)
            except:
                count += 1
            else:
                break

        # If the text has changed, the save dialog will appear
        if question_dialog:
            # Test if the file needs to be saved
            if save:
                try:
                    question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE)
                    question_dlg_btn_save.click()
                except ldtp.LdtpExecutionError:
                    # If the Save button was not found, we will try to find the Save As
                    try:
                        question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE_AS)
                        question_dlg_btn_save.click()
                    except ldtp.LdtpExecutionError:
                        raise ldtp.LdtpExecutionError, "The save or save as buttons in Gedit question dialog were not found."

                    try:
                        ldtp.waittillguiexist(self.SAVE_DLG)
                        save_dialog = ooldtp.context(self.SAVE_DLG)
                    except ldtp.LdtpExecutionError:
                        raise ldtp.LdtpExecutionError, "The Gedit save dialog was not found."
                    try:
                        save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME)
                    except ldtp.LdtpExecutionError:
                        raise ldtp.LdtpExecutionError, "The filename txt field in Gedit save dialog was not found."
                    try:
                        ldtp.wait(2)
                        save_dlg_txt_filename.settextvalue(filename)
                    except ldtp.LdtpExecutionError:
                        raise ldtp.LdtpExecutionError, "There was an error when writing the text."

                    try:
                        save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE)
                    except ldtp.LdtpExecutionError:
                        raise ldtp.LdtpExecutionError, "The save button in Gedit save dialog was not found."
        
                    try:
                        save_dlg_btn_save.click()
                    except ldtp.LdtpExecutionError:
                        raise ldtp.LdtpExecutionError, "There was an error when pushing the Save button."

                    ldtp.waittillguinotexist(self.SAVE_DLG)
            
            else:
                try:
                    question_dlg_btn_close = question_dialog.getchild(self.QUESTION_DLG_BTN_CLOSE)
                    question_dlg_btn_close.click()
                except ldtp.LdtpExecutionError:
                    raise ldtp.LdtpExecutionError, "It was not possible to click the close button."

            gedit.waittillguinotexist(guiTimeOut=20)
 
class PolicyKit(Application):


Generated by  Doxygen 1.6.0   Back to index