def cell_toggled(self, cell, path, text): iterator = self.store.get_iter(path) section = self.store.get(self.store.iter_parent(iterator), 0)[0] option = self.store.get(iterator, 0)[0] self.store.set_value(iterator, 1, text) configuration.set_conf(section, option, text) if section == "keybindings": self.binder.get_keybindings() self.binder.bind_keys() if option == "show_places": self.parent.parent.file_chooser__.file_chooser_places_show_hide() if section == "eq": self.player.eq_set(int(option[4]), int(text)) if option == "show_console": self.parent.parent.console.show_hide() if option == "show_infobar": self.parent.parent.infobar.show_hide()
def evaluate(self, text): tokens = self.get_tokens(text) if tokens[0] == ":set": if tokens[1] == "repeat": state = tokens[2] in ["true", "True", "TRUE", "1", "t"] configuration.set_conf("player", "repeat", bool(state)) return False if tokens[1] == "repeat_all": state = tokens[2] in ["true", "True", "TRUE", "1", "t"] configuration.set_conf("player", "repeat_all", bool(state)) return False if tokens[1] == "show_places": if configuration.get_conf("player", "show_explorer", "bool"): state = tokens[2] in ["true", "True", "TRUE", "1", "t"] configuration.set_conf("file_chooser", "show_places", state) self.parent.file_chooser__.file_chooser_places_show_hide() return False if tokens[1] == "show_explorer": state = tokens[2] in ["true", "True", "TRUE", "1", "t"] configuration.set_conf("player", "show_explorer", state) self.parent.show_hide_filechooser() return False if tokens[1] == "vol": self.parent.player.volume_track(float(tokens[2])) return False elif tokens[0] == ":r": configuration.set_conf("player", "repeat", not configuration.get_conf("player", "repeat", "bool")) return False elif tokens[0] == ":ra": configuration.set_conf("player", "repeat_all", not configuration.get_conf("player", "repeat_all", "bool")) return False elif tokens[0] == ":e": state = configuration.get_conf("player", "show_explorer", "bool") configuration.set_conf("player", "show_explorer", not state) self.parent.show_hide_filechooser() return False elif tokens[0] == ":i": state = configuration.get_conf("player", "show_infobar", "bool") configuration.set_conf("player", "show_infobar", not state) self.parent.infobar.show_hide() return False elif tokens[0] == ":s" or tokens[0] == ":settings": self.parent.player_controls__.settings.show_settings_window() elif tokens[0] == ":vol" or tokens[0] == ":v": if len(tokens) == 3: if tokens[1] == "up" or tokens[1] == "u": self.parent.player.volume_track_by(int(tokens[2]), "up") if tokens[2] == "down" or tokens[1] == "d": self.parent.player.volume_track_by(int(tokens[2]), "down") elif len(tokens) == 2: self.parent.player.volume_track(float(tokens[1])) return False elif tokens[0] == ":pause" or tokens[0] == ":pa": self.parent.player.pause_track() return False elif tokens[0] == ":play" or tokens[0] == ":pl" or tokens[0] == ":p": if len(tokens) == 1: self.parent.player_controls__.play_button_pressed() else: if int(tokens[1]) < len(self.parent.playlist__.store): self.parent.playlist__.playlist_selection_change(int(tokens[1])) self.parent.player_controls__.play_button_pressed() return False elif len(tokens) == 1 and (tokens[0][1:].isdigit()): if int(tokens[0][1:]) < len(self.parent.playlist__.store): self.parent.playlist__.playlist_selection_change(int(tokens[0][1:])) self.parent.player_controls__.play_button_pressed() return False elif tokens[0] == ":next" or tokens[0] == ":ne": self.parent.player.start_next_track_from_playlist() return False elif tokens[0] == ":prev" or tokens[0] == ":pr": self.parent.player.start_previous_track_from_playlist() return False elif tokens[0] == ":q": self.parent.destroy(None) return False elif tokens[0] == ":que": for x in range(1, len(tokens)): self.parent.player.enque(int(tokens[x])) self.parent.playlist__.update_queue() return False elif tokens[0] == ":qe": self.parent.player.empty_queue() self.parent.playlist__.update_queue() return False elif tokens[0] == ":d": if len(tokens) == 1: self.parent.playlist__.remove_selected(None, self.parent.playlist__.treeView) return False elif tokens[0] == ":da": self.parent.playlist__.select_all(None, self.parent.playlist__.treeView) self.parent.playlist__.remove_selected(None, self.parent.playlist__.treeView) return False return True
def repeat_button_callback(self, button): state = button.get_active() configuration.set_conf("player", "repeat", str(not bool(state)))
def cmd_input(self): while 1: self.cmdInput = input(self.color.OKBLUE + ":." + self.color.ENDC) if self.cmdInput == "load": load_path = input(" <path:") self._player.load_track(load_path) elif self.cmdInput == "load-from-playlist": # Display the playlist items = self.pp.get_items_from_playlist(self.pp.playlist, "") x = 1 print(self.color.OKGREEN + "\n <Playlist:\n" + self.color.ENDC) for item in items: print( " <" + str(x) + ". " + self.color.OKBLUE + self.mediaInfo.track_get_title(item) + self.color.ENDC + " - " + self.mediaInfo.track_get_artist(item) + "\n path: " + item[0:30] + "..." ) x = x + 1 print("\n") num = input(" <index of the track to load: ") if num > 0: self._player.load_track_from_playlist(self.pp.playlist, int(num)) else: print(self.color.FAIL + " <ERROR: index doesn't exist!" + self.color.ENDC) elif self.cmdInput == "load-into-playlist": path = input(" <path: ") self.pp.put_item_into_playlist(self.pp.playlist, path) elif self.cmdInput == "copy-into-internal-playlist": if self.pp.playlist == self.pp.internal_playlist: print(self.color.ERROR + " <do you really want to duplicate?!" + self.color.ENDC) else: self.pp.load_external_playlist_into_internal(self.pp.playlist, "a") self._player.load_track_from_playlist(self.pp.playlist, 1) elif self.cmdInput == "load-playlist": path = input(" <path:") self.pp.load_external_playlist(path) elif self.cmdInput == "load-internal-playlist": self.pp.load_internal_playlist() elif self.cmdInput == "playlist-search": input_ = input(" <query:") result_items = self.pp.search_playlist(input_) if len(result_items) == 0: print(" <no match") else: x = 1 print(self.color.OKGREEN + "\n <Search Reults:\n" + self.color.ENDC) for item in result_items: print( " <" + str(x) + ". " + self.color.OKBLUE + self.mediaInfo.track_get_title(item[0]) + self.color.ENDC + " - " + self.mediaInfo.track_get_artist(item[0]) + "\n path: " + item[0][0:30] + "..." ) x = x + 1 print("\n") num = input(" <do you want to load a track? (index):") if num != "": if int(num) > 0: self._player.load_track_from_playlist( self.pp.playlist, int(result_items[int(num) - 1][1]) + 1 ) else: print(self.color.FAIL + " <ERROR: index doesn't exist!" + self.color.ENDC) elif self.cmdInput == "play": self._player.start_track() elif self.cmdInput == "play-next": self._player.start_next_track_from_playlist() elif self.cmdInput == "play-prev": self._player.start_previous_track_from_playlist() elif self.cmdInput == "stop": self._player.stop_track() elif self.cmdInput == "pause": self._player.pause_track() elif self.cmdInput == "volume-set": print( self.color.OKGREEN + "\n <current: " + str(int(self._player.volume_show_track())) + self.color.ENDC ) inp = input(" <set:") if inp != "": self._player.volume_track(float(inp)) print("\n") elif self.cmdInput == "info": print(self.color.OKGREEN + "\n <Track Info:\n" + self.color.ENDC) print( "\n < title: " + self.color.OKBLUE + self.mediaInfo.track_get_title(self._player._filepath) + self.color.ENDC ) print( " < artist: " + self.color.OKBLUE + self.mediaInfo.track_get_artist(self._player._filepath) + self.color.ENDC ) print( " < album: " + self.color.OKBLUE + self.mediaInfo.track_get_album(self._player._filepath) + self.color.ENDC ) print( " < year: " + self.color.OKBLUE + self.mediaInfo.track_get_year(self._player._filepath) + self.color.ENDC ) print( " < track: " + self.color.OKBLUE + self.mediaInfo.track_get_track(self._player._filepath) + self.color.ENDC ) print( " < genre: " + self.color.OKBLUE + self.mediaInfo.track_get_genre(self._player._filepath) + self.color.ENDC ) print( " < duration: " + self.color.OKBLUE + timeConverter.convert_time(self.mediaInfo.track_get_duration(self._player._filepath) * 1000000000) + self.color.ENDC ) print( " < bitrate: " + self.color.OKBLUE + self.mediaInfo.track_get_bitrate(self._player._filepath) + "\n" + self.color.ENDC ) elif self.cmdInput == "position-get": print( self.color.OKGREEN + "\n <current position: " + self.color.ENDC + str(self._player.get_current_position_track()) + "\n" ) elif self.cmdInput == "position-set": print("\n <input format: hh:mm:ss") inp = input(" <set:") if inp != "": self._player.set_position_track(timeConverter.convert_time_back(inp)) print("\n") elif self.cmdInput == "config": input_ = input(" <") if input_ == "repeat": print( " <" + self.color.OKBLUE + str(configuration.get_conf("player", "repeat")) + self.color.ENDC ) input_ = input(" <") if input_ != "": configuration.set_conf("player", "repeat", input_) elif input_ == "fade": print( " <" + self.color.OKBLUE + str(configuration.get_conf("effects", "pause_fade")) + self.color.ENDC ) input_ = input(" <") if input_ != "": configuration.set_conf("effects", "pause_fade", input_) elif input_ == "remember on exit": print( " <" + self.color.OKBLUE + str(configuration.get_conf("player", "remember_last_track")) + self.color.ENDC ) input_ = input(" <") if input_ != "": configuration.set_conf("player", "remember_last_track", input_) elif input_ == "load on startup": print( " <" + self.color.OKBLUE + str(configuration.get_conf("player", "load_from_playlist_on_startup")) + self.color.ENDC ) input_ = input(" <") if input_ != "": configuration.set_conf("player", "load_from_playlist_on_startup", input_) elif self.cmdInput == "path-get": print(" <path: " + self._player.filepath) elif self.cmdInput == "playlist-erase-all": self.pp.empty_playlist(self.pp.playlist) elif self.cmdInput == "playlist-erase": items = self.pp.get_items_from_playlist(self.pp.playlist, "") x = 1 for item in items: print( " <" + str(x) + ". " + self.color.OKBLUE + self.mediaInfo.track_get_title(item) + self.color.ENDC + " - " + self.mediaInfo.track_get_artist(item) + "\n path: " + item[0:30] + "..." ) x = x + 1 num = input(" <erase item with index: ") if num.isdigit(): if num > 0: if int(num) > int(len(items)): print(self.color.FAIL + " <ERROR: index is out of bound" + self.color.ENDC) else: self.pp.delete_item_by_number(self.pp.playlist, int(num)) else: print(self.color.FAIL + " <ERORR: index can't be < 0" + self.color.ENDC) else: print(self.color.FAIL + " <ERROR: invalid input!" + self.color.ENDC) elif self.cmdInput == "playlist-get": items = self.pp.get_items_from_playlist(self.pp.playlist, "") x = 1 print(self.color.OKGREEN + "\n <Playlist:\n" + self.color.ENDC) for item in items: print( " <" + str(x) + ". " + self.color.OKBLUE + self.mediaInfo.track_get_title(item) + self.color.ENDC + " - " + self.mediaInfo.track_get_artist(item) + "\n path: " + item[0:25] + "..." ) x = x + 1 print("\n") elif self.cmdInput == "eq-get": eq_values = self._player.eq_get() for x in range(1, 11): print(" <" + str(x) + ". band" + str(x - 1) + ": " + str(eq_values[x - 1])) elif self.cmdInput == "eq-set": print(self._player.eq_get()) input_band = input(" <band(1-10):") input_value = input(" <value(-24 - 12):") self._player.eq_set(input_band, int(input_value)) configuration.set_conf("eq", "band" + str(int(input_band) - 1), str(int(input_value))) elif self.cmdInput == "clear": os.system("clear") elif self.cmdInput == "exit": if bool(configuration.get_conf("player", "remember_last_track")): self.pp.empty_playlist("last_track_and_playlist") self.pp.put_item_into_playlist("last_track_and_playlist", self._player._filepath) self.pp.put_item_into_playlist("last_track_and_playlist", self.pp.playlist) self.pp.put_item_into_playlist("last_track_and_playlist", self._player.current_track_playlist_index) self.exit_cmd() elif not self.cmdInput == "exit": print(self.color.FAIL + " <ERROR: unknown command" + self.color.ENDC)