def tableview_did_select(self, tableview, section, row): # Called when the user selects a row if section == 0: if self.type == 0: # actions for folders if row == 0: # Go Here in Shellista nav.close() print("Launching Shellista...") try: from Shellista import Shell except ImportError as err: print("Failed to import Shellista: " + err.message) print("See note on Shellista integration at the top of filenav.py.") print("> logout") return shell = Shell() shell.prompt = '> ' shell.onecmd("cd " + self.path) print("> cd " + self.path) shell.cmdloop() elif self.type == 1: # actions for files if row == 0: # Quick Look nav.close() time.sleep(1) # ui thread will hang otherwise console.quicklook(self.path) elif row == 1: # Open in Editor open_path(self.path) nav.close() elif row == 2: # Copy & Open destdir = full_path(os.path.join(SCRIPT_ROOT, "temp")) if not os.path.exists(destdir): os.mkdir(destdir) destfile = full_path(os.path.join(destdir, os.path.basename(self.path).lstrip("."))) shutil.copy(self.path, destfile) editor.reload_files() open_path(destfile) nav.close() elif row == 3: # Copy & Open as Text destdir = full_path(os.path.join(SCRIPT_ROOT, "temp")) if not os.path.exists(destdir): os.mkdir(destdir) destfile = full_path(os.path.join(destdir, os.path.basename(self.path).lstrip(".") + ".txt")) shutil.copy(self.path, destfile) editor.reload_files() open_path(destfile) nav.close() elif row == 4: # Open In if console.open_in(self.path): nav.close() else: console.hud_alert("Failed to Open", "error")
def tableview_did_select(self, tableview, section, row): # Called when the user selects a row key = self.lists[section][1][row][0] if key == "shellista-cd": # Go Here - Shellista nav.close() print("Launching Shellista...") try: from Shellista import Shell except ImportError as err: print("Failed to import Shellista: " + err.message) print("See note on Shellista integration at the top of filenav.py.") print("> logout") return shell = Shell() shell.prompt = "> " shell.onecmd("cd " + self.fi.path) print("> cd " + self.fi.path) shell.cmdloop() elif key == "ios-qlook": # Preview - Quick Look nav.close() time.sleep(1) # ui thread will hang otherwise console.quicklook(self.fi.path) elif key == "pysta-edit": # Open in Editor - Pythonista open_path(self.fi.path) nav.close() elif key == "pysta-cpedit": # Copy & Open - Pythonista destdir = full_path(os.path.join(SCRIPT_ROOT, "temp")) if not os.path.exists(destdir): os.mkdir(destdir) destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip("."))) shutil.copy(self.fi.path, destfile) editor.reload_files() open_path(destfile) nav.close() elif key == "pysta-cptxt": # Copy & Open as Text - Pythonista destdir = full_path(os.path.join(SCRIPT_ROOT, "temp")) if not os.path.exists(destdir): os.mkdir(destdir) destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(".") + ".txt")) shutil.copy(self.fi.path, destfile) editor.reload_files() open_path(destfile) nav.close() elif key == "console-printimg": # Show in Console - console console.show_image(self.fi.path) elif key == "sound-playsound": # Play Sound - sound spath = rel_to_app(self.fi.path.rsplit(".", 1)[0]) sound.load_effect(spath) sound.play_effect(spath) elif key == "webbrowser-open": # Open Website - webbrowser webbrowser.open("file://" + self.fi.path) nav.close() elif key == "ios-openin": # Open In - External Apps if console.open_in(self.fi.path): nav.close() else: console.hud_alert("Failed to Open", "error")
def tableview_did_select(self, tableview, section, row): # Called when the user selects a row key = self.lists[section][1][row][0] if key == "shellista-cd": # Go Here - Shellista nav.close() print("Launching Shellista...") try: from Shellista import Shell except ImportError as err: print("Failed to import Shellista: " + err.message) print("See note on Shellista integration at the top of filenav.py.") print("> logout") return shell = Shell() shell.prompt = '> ' shell.onecmd("cd " + self.fi.path) print("> cd " + self.fi.path) shell.cmdloop() elif key == "ios-qlook": # Preview - Quick Look nav.close() time.sleep(1) # ui thread will hang otherwise console.quicklook(self.fi.path) elif key == "pysta-edit": # Open in Editor - Pythonista open_path(self.fi.path) nav.close() elif key == "pysta-cpedit": # Copy & Open - Pythonista destdir = full_path(os.path.join(SCRIPT_ROOT, "temp")) if not os.path.exists(destdir): os.mkdir(destdir) destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip("."))) shutil.copy(self.fi.path, destfile) editor.reload_files() open_path(destfile) nav.close() elif key == "pysta-cptxt": # Copy & Open as Text - Pythonista destdir = full_path(os.path.join(SCRIPT_ROOT, "temp")) if not os.path.exists(destdir): os.mkdir(destdir) destfile = full_path(os.path.join(destdir, self.fi.basename().lstrip(".") + ".txt")) shutil.copy(self.fi.path, destfile) editor.reload_files() open_path(destfile) nav.close() elif key == "console-printimg": # Show in Console - console console.show_image(self.fi.path) elif key == "sound-playsound": # Play Sound - sound spath = rel_to_app(self.fi.path.rsplit(".", 1)[0]) sound.load_effect(spath) sound.play_effect(spath) elif key == "webbrowser-open": # Open Website - webbrowser webbrowser.open("file://" + self.fi.path) nav.close() elif key == "ios-openin": # Open In - External Apps if console.open_in(self.fi.path): nav.close() else: console.hud_alert("Failed to Open", "error")