예제 #1
0
    def set_filename(self, filename):
        # gnomevfs doesnt seem to like unicode filenames
        filename = str(filename)
        oldname = str(self.get_filename())

        newInfo = gnomevfs.FileInfo()
        newInfo.name = filename

        olduri = self.get_text_uri()
        newuri = olduri.replace(oldname, filename)

        try:
            gnomevfs.set_file_info(self._URI, newInfo, gnomevfs.SET_FILE_INFO_NAME)
            # close so the file info is re-read
            self._URI = gnomevfs.URI(newuri)
            self.close()
        except gnomevfs.NotSupportedError:
            # dunno what this is
            return None
        except gnomevfs.AccessDeniedError:
            # file is on readonly filesystem
            return None
        except gnomevfs.NotPermittedError:
            # file is on readonly filesystem
            return None
        except gnomevfs.FileExistsError:
            # I think this is when you rename a file to its current name
            pass

        return newuri
예제 #2
0
    def finished(self):
        Pipeline.finished(self)

        if self.aborted:
            # remove partial file
            try:
                gnomevfs.unlink(self.output_filename)
            except:
                pass
            return

        # Copy file permissions
        try:
            info = gnomevfs.get_file_info(self.sound_file.uri,
                                        gnomevfs.FILE_INFO_FIELDS_PERMISSIONS)
            gnomevfs.set_file_info(self.output_filename, info,
                                            gnomevfs.SET_FILE_INFO_PERMISSIONS)
        except:
            log('Cannot set permission on \'%s\'' %
                        gnomevfs.format_uri_for_display(self.output_filename))

        if self.delete_original and self.processing and not self.error:
            log('deleting: \'%s\'' % self.sound_file.uri)
            try:
                gnomevfs.unlink(self.sound_file.uri)
            except:
                log('Cannot remove \'%s\'' %
                        gnomevfs.format_uri_for_display(self.output_filename))
예제 #3
0
    def edit_file_name(self, widget, path, new_text):
        current_dir = self.flist.get_current_dir()
        #root_iter = self.treestore.get_iter_first()
        file_iter = self.treestore.get_iter_from_string(path)
        tuple_path = self.treestore.get_path(file_iter)
        old_file_name = self.treestore.get_value(file_iter, 1)
        file_dir = current_dir
        
#        for i in tuple_path[1:-1]:
#            root_iter = self.treestore.iter_nth_child(root_iter, i)
#            file_dir += '/' + self.treestore.get_value(root_iter, 1)
        
        for i in range(1, len(tuple_path)):
            dir_iter = self.treestore.get_iter(tuple_path[0:i])
            file_dir = os.path.join(file_dir, self.treestore.get_value(dir_iter, 1))
            
        if new_text != old_file_name:

            old_file_uri = os.path.join(file_dir, old_file_name)
            new_file_uri = os.path.join(file_dir, new_text)

            if gnomevfs.exists(new_file_uri):
                secondary_text = _("A file with the same name already exists. Please use a different name.")
                main_text = _("<b>File already exists.</b>") 
                error = ErrorDialog(main_text, secondary_text)
                error_return = error.run()
                
                if error_return == gtk.RESPONSE_DELETE_EVENT:
                    error.destroy()
                    return
                elif error_return == 1:
                    error.destroy()
                    return
            
            old_file_info = gnomevfs.get_file_info(old_file_uri)
            old_file_info.name = new_text
            gnomevfs.set_file_info(old_file_uri, old_file_info,
                                   gnomevfs.SET_FILE_INFO_NAME)
            
            self.treestore.set_value(file_iter, 1, new_text)
        self.refresh()
        
        # Search for the row of the renamed file and select it
        def search_new_file(model, path, iter, new_text):
            file_name = model.get_value(iter, 1)
            
            if file_name == new_text:
                selection = self.treeview.get_selection()
                selection.select_iter(iter)
                return True
                
        self.treestore.foreach(search_new_file, new_text)            
예제 #4
0
    def finished(self):
        Pipeline.finished(self)

        # Copy file permissions
        try:
            info = gnomevfs.get_file_info(self.sound_file.uri, gnomevfs.FILE_INFO_FIELDS_PERMISSIONS)
            gnomevfs.set_file_info(self.output_filename, info, gnomevfs.SET_FILE_INFO_PERMISSIONS)
        except:
            log("Cannot set permission on '%s'" % gnomevfs.format_uri_for_display(self.output_filename))

        if self.delete_original and self.processing and not self.error:
            log("deleting: '%s'" % self.sound_file.uri)
            try:
                gnomevfs.unlink(self.sound_file.uri)
            except:
                log("Cannot remove '%s'" % gnomevfs.format_uri_for_display(self.output_filename))
예제 #5
0
    def set_mtime(self, timestamp=None, datetime=None):
        newInfo = gnomevfs.FileInfo()
        newInfo.mtime = timestamp

        try:
            gnomevfs.set_file_info(self._URI, newInfo, gnomevfs.SET_FILE_INFO_TIME)
            self.close()
            return timestamp
        except gnomevfs.NotSupportedError:
            # dunno what this is
            return None
        except gnomevfs.AccessDeniedError:
            # file is on readonly filesystem
            return None
        except gnomevfs.NotPermittedError:
            # file is on readonly filesystem
            return None
예제 #6
0
    def finished(self):
        Pipeline.finished(self)

        # Copy file permissions
        try:
            info = gnomevfs.get_file_info(
                self.sound_file.uri, gnomevfs.FILE_INFO_FIELDS_PERMISSIONS)
            gnomevfs.set_file_info(self.output_filename, info,
                                   gnomevfs.SET_FILE_INFO_PERMISSIONS)
        except:
            log('Cannot set permission on \'%s\'' %
                gnomevfs.format_uri_for_display(self.output_filename))

        if self.delete_original and self.processing and not self.error:
            log('deleting: \'%s\'' % self.sound_file.uri)
            try:
                vfs_unlink(self.sound_file.uri)
            except:
                log('Cannot remove \'%s\'' %
                    gnomevfs.format_uri_for_display(self.output_filename))