(self, _widget, Terminal)
Handle menu item callback by saving text to a file
Handle menu item callback by saving text to a file
Handle menu item callback by saving text to a file
def start_logger(self, _widget, Terminal):
        """ Handle menu item callback by saving text to a file"""
        savedialog = Gtk.FileChooserDialog(title=_("Save Log File As"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_transient_for(_widget.get_toplevel())
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)
        savedialog.show_all()
        response = savedialog.run()
        if response == Gtk.ResponseType.OK:
            try:
                logfile = os.path.join(savedialog.get_current_folder(),
                                       savedialog.get_filename())
                fd = open(logfile, 'w+')
                # Save log file path, 
                # associated file descriptor, signal handler id
                # and last saved col,row positions respectively.
                vte_terminal = Terminal.get_vte()
                (col, row) = vte_terminal.get_cursor_position()

                self.loggers[vte_terminal] = {"filepath":logfile,
                                              "handler_id":0, "fd":fd,
                                              "col":col, "row":row}
                # Add contents-changed callback
                self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
            except:
                e = sys.exc_info()[1]
                error = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
                                          Gtk.ButtonsType.OK, e.strerror)
                error.set_transient_for(savedialog)
                error.run()
                error.destroy()
        savedialog.destroy()
def start_logger ( self , _widget , Terminal ) : savedialog = Gtk . FileChooserDialog ( title = _ ( "Save Log File As" ) , action = self . dialog_action , buttons = self . dialog_buttons ) savedialog . set_transient_for ( _widget . get_toplevel ( ) ) savedialog . set_do_overwrite_confirmation ( True ) savedialog . set_local_only ( True ) savedialog . show_all ( ) response = savedialog . run ( ) if response == Gtk . ResponseType . OK : try : logfile = os . path . join ( savedialog . get_current_folder ( ) , savedialog . get_filename ( ) ) fd = open ( logfile , 'w+' ) # Save log file path,  # associated file descriptor, signal handler id # and last saved col,row positions respectively. vte_terminal = Terminal . get_vte ( ) ( col , row ) = vte_terminal . get_cursor_position ( ) self . loggers [ vte_terminal ] = { "filepath" : logfile , "handler_id" : 0 , "fd" : fd , "col" : col , "row" : row } # Add contents-changed callback self . loggers [ vte_terminal ] [ "handler_id" ] = vte_terminal . connect ( 'contents-changed' , self . save ) except : e = sys . exc_info ( ) [ 1 ] error = Gtk . MessageDialog ( None , Gtk . DialogFlags . MODAL , Gtk . MessageType . ERROR , Gtk . ButtonsType . OK , e . strerror ) error . set_transient_for ( savedialog ) error . run ( ) error . destroy ( ) savedialog . destroy ( )