def create_popup(status): cb = lambda result, ids=ids: _do_set_torrent_options(ids, result) option_popup = InputPopup(mode,"Set torrent options (Esc to cancel)",close_cb=cb, height_req=22) for (field, field_type) in torrent_options: caption = "{!info!}" + torrent_options_to_names[field] value = options[field] if field_type == str: if not isinstance(value, basestring): value = str(value) option_popup.add_text_input(caption, field, value) elif field_type == bool: if options[field] == "multiple": choices = ( ["Yes", "No", "Mixed"], [True, False, None], 2 ) else: choices = ( ["Yes", "No"], [True, False], [True, False].index(options[field]) ) option_popup.add_select_input(caption, field, choices[0], choices[1], choices[2]) elif field_type == float: option_popup.add_float_spin_input(caption, field, value, min_val = -1) elif field_type == int: option_popup.add_int_spin_input(caption, field, value, min_val = -1) mode.set_popup(option_popup) mode.refresh()
def _show_rename_popup(self): #Perhaps in the future: Renaming multiple files if self.marked: title = "Error (Enter to close)" text = "Sorry, you can't rename multiple files, please clear selection with {!info!}'c'{!normal!} key" self.popup = MessagePopup(self, title, text) else: _file = self.__get_file_by_num(self.current_file_idx, self.file_list) old_filename = _file[0] idx = self._selection_to_file_idx() tid = self.torrentid if _file[3]: def do_rename(result): if not result["new_foldername"]: return old_fname = self._get_full_folder_path( self.current_file_idx) new_fname = "%s/%s/" % (old_fname.strip("/").rpartition( "/")[0], result["new_foldername"]) self._do_rename_folder(tid, old_fname, new_fname) popup = InputPopup(self, "Rename folder (Esc to cancel)", close_cb=do_rename) popup.add_text("{!info!}Renaming folder:{!input!}") popup.add_text(" * %s\n" % old_filename) popup.add_text_input("Enter new folder name:", "new_foldername", old_filename.strip("/")) self.popup = popup else: def do_rename(result): fname = "%s/%s" % (self.full_names[idx].rpartition("/")[0], result["new_filename"]) self._do_rename_file(tid, idx, fname) popup = InputPopup(self, "Rename file (Esc to cancel)", close_cb=do_rename) popup.add_text("{!info!}Renaming file:{!input!}") popup.add_text(" * %s\n" % old_filename) popup.add_text_input("Enter new filename:", "new_filename", old_filename) self.popup = popup
def _show_rename_popup(self): #Perhaps in the future: Renaming multiple files if self.marked: title = "Error (Enter to close)" text = "Sorry, you can't rename multiple files, please clear selection with {!info!}'c'{!normal!} key" self.popup = MessagePopup(self, title, text) else: _file = self.__get_file_by_num(self.current_file_idx, self.file_list) old_filename = _file[0] idx = self._selection_to_file_idx() tid = self.torrentid if _file[3]: def do_rename(result): if not result["new_foldername"]: return old_fname = self._get_full_folder_path(self.current_file_idx) new_fname = "%s/%s/" % (old_fname.strip("/").rpartition("/")[0], result["new_foldername"]) self._do_rename_folder(tid, old_fname, new_fname) popup = InputPopup(self,"Rename folder (Esc to cancel)",close_cb=do_rename) popup.add_text("{!info!}Renaming folder:{!input!}") popup.add_text(" * %s\n" % old_filename) popup.add_text_input("Enter new folder name:", "new_foldername", old_filename.strip("/")) self.popup = popup else: def do_rename(result): fname = "%s/%s" % (self.full_names[idx].rpartition("/")[0], result["new_filename"]) self._do_rename_file(tid, idx, fname) popup = InputPopup(self,"Rename file (Esc to cancel)",close_cb=do_rename) popup.add_text("{!info!}Renaming file:{!input!}") popup.add_text(" * %s\n" % old_filename) popup.add_text_input("Enter new filename:", "new_filename", old_filename) self.popup = popup
def create_popup(status): cb = lambda result, ids=ids: _do_set_torrent_options( ids, result) option_popup = InputPopup( mode, "Set torrent options (Esc to cancel)", close_cb=cb, height_req=22) for (field, field_type) in torrent_options: caption = "{!info!}" + torrent_options_to_names[field] value = options[field] if field_type == str: if not isinstance(value, basestring): value = str(value) option_popup.add_text_input(caption, field, value) elif field_type == bool: if options[field] == "multiple": choices = (["Yes", "No", "Mixed"], [True, False, None], 2) else: choices = (["Yes", "No"], [True, False], [True, False].index(options[field])) option_popup.add_select_input(caption, field, choices[0], choices[1], choices[2]) elif field_type == float: option_popup.add_float_spin_input(caption, field, value, min_val=-1) elif field_type == int: option_popup.add_int_spin_input(caption, field, value, min_val=-1) mode.set_popup(option_popup) mode.refresh()