Exemplo n.º 1
0
    def mkdir(self):
        dialog = InputDialog('New directory', self.widget.get_toplevel())
        dialog.entry.set_text('NewDirectory')

        if dialog.run() == gtk.RESPONSE_ACCEPT:
            name = dialog.entry.get_text()
            gfile = self.current_folder.get_child_for_display_name(name)
            try:
                gfile.make_directory()
            except Exception, e:
                self.feedback.show(str(e), 'error')
            else:
                self.feedback.show('Directory created', 'done')
Exemplo n.º 2
0
    def rename(self):
        if len(self.model.selection) == 1:
            dialog = InputDialog('Rename', self.widget.get_toplevel())

            fi = self.model[self.model.selection.keys()[0]][2]
            fname = fi.get_edit_name().decode('utf-8')

            dialog.entry.set_text(fname)

            fname_without_extension, sep, _ = fname.rpartition('.')
            if sep and fname_without_extension:
                idle(dialog.entry.select_region, 0, len(fname_without_extension))

            if dialog.run() == gtk.RESPONSE_ACCEPT:
                newname = dialog.entry.get_text()
                gfile = self.current_folder.get_child(fi.get_name())
                try:
                    gfile.set_display_name(newname)
                except Exception, e:
                    self.feedback.show(str(e), 'error')
                else:
                    self.feedback.show('Renamed', 'done')

            dialog.destroy()