Пример #1
0
    def view_confirm_close(self, view):
        buff = view.get_file_ops()
        
        # If buffer was not modified you can safely close it
        if not buff.get_modified():
            return True
        
        # When the buffer is new then we need to show the save dialog instead
        # of a save changes dialog:
        if buff.get_is_new():
            # XXX: this is utterly broken but there's no support for new files
            # either
            # well, there is now
            return True
        
        parent = self.get_window()
        files, response = hig.save_changes(
            [buff.get_filename()],
            parent=parent
        )
        
        if response == gtk.RESPONSE_OK:
            if not self._file_ops(buff, "save", "save"):
                return False

        return response in (gtk.RESPONSE_OK, gtk.RESPONSE_CLOSE)
Пример #2
0
 def cmd_can_close(self):
     buffs = [view.buffer for view in self.__files.values() if view.buffer.get_modified()]
     # If we have no buffers to save, go on
     if len(buffs) == 0:
         return True
         
     filenames = dict(map(lambda buff: (buff.filename, buff), buffs))
     parent = self.get_window()
     files, response = hig.save_changes(filenames.keys(), parent=parent)
     # Save the files that need to be saved
     for filename in files:
         # XXX: handle new files
         filenames[filename].save()
     return response in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_OK)
Пример #3
0
 def cmd_can_close(self):
     buffs = [view.buffer for view in self.__files.values() if view.buffer.get_modified()]
     # If we have no buffers to save, go on
     if len(buffs) == 0:
         return True
         
     filenames = dict(map(lambda buff: (buff.filename, buff), buffs))
     parent = self.boss.get_main_window()
     files, response = hig.save_changes(filenames.keys(), parent=parent)
     # Save the files that need to be saved
     for filename in files:
         # XXX: handle new files
         filenames[filename].save()
     return response in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_OK)
Пример #4
0
    def cmd_can_close(self):
        buffs = map(lambda val: val.get_file_ops(), self.__views.values())
        buffs = filter(lambda val: val.get_modified(), buffs)

        # If we have no buffers to save, go on
        if len(buffs) == 0:
            return True

        filenames = dict(map(lambda buff: (buff.get_filename(), buff), buffs))
        parent = self.get_window()
        files, response = hig.save_changes(filenames.keys(), parent=parent)
        # Save the files that need to be saved
        errors = []
        for filename in files:
            # XXX: handle new files
            try:
                filenames[filename].save()
            except IOError, err:
                errors.append(filename)
Пример #5
0
    def cmd_can_close(self):
        buffs = map(lambda val: val.get_file_ops(), self.__views.values())
        buffs = filter(lambda val: val.get_modified(), buffs)

        # If we have no buffers to save, go on
        if len(buffs) == 0:
            return True
            
        filenames = dict(map(lambda buff: (buff.get_filename(), buff), buffs))
        parent = self.get_window()
        files, response = hig.save_changes(filenames.keys(), parent=parent)
        # Save the files that need to be saved
        errors = []
        for filename in files:
            # XXX: handle new files
            try:
                filenames[filename].save()
            except IOError, err:
                errors.append(filename)
Пример #6
0
    def confirm_multi_view_controlbar_clicked_close(self, view):
        buff = view.buffer

        # If buffer was not modified you can safely close it
        if not buff.get_modified():
            return True

        # When the buffer is new then we need to show the save dialog instead
        # of a save changes dialog:
        if buff.is_new:
            # XXX: this is utterly broken but there's no support for new files
            # either
            return False

        parent = self.get_window()
        files, response = hig.save_changes([buff.filename], parent=parent)

        if response == gtk.RESPONSE_OK:
            buff.save()

        return response in (gtk.RESPONSE_OK, gtk.RESPONSE_CLOSE)
Пример #7
0
    def confirm_multi_view_controlbar_clicked_close(self, view):
        buff = view.buffer

        # If buffer was not modified you can safely close it
        if not buff.get_modified():
            return True

        # When the buffer is new then we need to show the save dialog instead
        # of a save changes dialog:
        if buff.is_new:
            # XXX: this is utterly broken but there's no support for new files
            # either
            return False

        parent = self.get_window()
        files, response = hig.save_changes([buff.filename], parent=parent)

        if response == gtk.RESPONSE_OK:
            buff.save()

        return response in (gtk.RESPONSE_OK, gtk.RESPONSE_CLOSE)
Пример #8
0
    def view_confirm_close(self, view):
        buff = view.get_file_ops()

        # If buffer was not modified you can safely close it
        if not buff.get_modified():
            return True

        # When the buffer is new then we need to show the save dialog instead
        # of a save changes dialog:
        if buff.get_is_new():
            # XXX: this is utterly broken but there's no support for new files
            # either
            # well, there is now
            return True

        parent = self.get_window()
        files, response = hig.save_changes([buff.get_filename()],
                                           parent=parent)

        if response == gtk.RESPONSE_OK:
            if not self._file_ops(buff, "save", "save"):
                return False

        return response in (gtk.RESPONSE_OK, gtk.RESPONSE_CLOSE)