def on_category_right_press(self, widget, x, y, item, cloumn): menu_items = [ (None, "新建试听列表", self.new_listen_list), (None, "新建在线歌单", self.new_online_list), ] if not item: Menu(menu_items, True).show((x, y)) return if item.list_type == MusicListItem.COLLECT_TYPE: if bplayer.is_login: menu_items = [ (None, "刷新", item.refrush), (None, "新建歌单", self.new_online_list), ] else: menu_items = None elif item.list_type == MusicListItem.PLAYLIST_TYPE: menu_items = [ (None, "新建歌单", self.new_online_list), (None, "删除歌单", lambda: self.del_online_list(item)), (None, "重命名", lambda: self.rename_online_list(item)), (None, "刷新", item.refrush), ] elif item.list_type == MusicListItem.LOCAL_TYPE: menu_items.extend([ (None, "删除列表", lambda: self.del_listen_list(item)), (None, "重命名", lambda: self.rename_online_list(item, is_online=False)) ]) if menu_items: Menu(menu_items, True).show((x, y))
def on_music_view_right_press_items(self, widget, x, y, current_item, select_items): if current_item and select_items: selected_songs_id = [ item.get_song()['id'] for item in select_items ] # 子菜单 - 添加到创建的歌单 addto_submenu = [ (None, _(gobject.markup_escape_text(key)), self.add_to_list, selected_songs_id, self.CREATED_LISTS_DICT[key]) for key in self.CREATED_LISTS_DICT.keys() ] addto_submenu.insert( 0, (None, _('播放列表'), self.add_to_list, selected_songs_id, 0)) addto_submenu = Menu(addto_submenu) if len(select_items) > 1: items = [ (None, _("播放"), lambda: self.add_play_emit( [item.get_song()['id'] for item in select_items])), ] else: items = [ (None, _("播放"), lambda: self.add_play_emit( [current_item.get_song()['id']])), ] items.insert(0, (None, _("添加到"), addto_submenu)) Menu(items, True).show((int(x), int(y)))
def right_press_items(self, widget, x, y, current_item, select_items): if current_item and select_items and nplayer.is_login: subscribe_submenu = [ (None, _('**确定收藏**'), self.subscribe_playlist, current_item), (None, _(current_item.get_playlist['name']), self.subscribe_playlist, current_item), (None, _('**确定收藏**'), self.subscribe_playlist, current_item), ] menu_items = [ (None, _('收藏歌单'), Menu(subscribe_submenu)), ] Menu(menu_items, True).show((x, y))
def popup_detail_menu(self, widget, x, y, item, select_items): if self.detail_menu != None: self.detail_menu.destroy() play_mode_menu = self.current_item.song_view.get_playmode_menu( align=True) sort_dict = OrderedDict() sort_dict["file"] = _("By Filename") sort_dict["title"] = _("By Title") sort_dict["artist"] = _("By Artist") sort_dict["album"] = _("By Album") sort_dict["genre"] = _("By Genre") sort_dict["#track"] = _("By Track") sort_dict["#playcount"] = _("By Play Count") sort_dict["#added"] = _("By Date Added") sort_items = [(None, value, self.current_item.song_view.set_sort_keyword, key) for key, value in sort_dict.iteritems()] sort_items.append(None) sort_items.append( (None, _("Randomize"), self.current_item.song_view.random_reorder)) sub_sort_menu = Menu(sort_items) add_to_list_menu = self.get_edit_sub_menu(select_items) move_to_list_menu = self.get_edit_sub_menu(select_items, True) self.detail_menu = Menu([ (None, _("Play"), self.current_item.song_view.play_select_item), (None, _("Add to List"), add_to_list_menu), (None, _("move to List"), move_to_list_menu), None, (None, _("Remove Track"), self.current_item.song_view.remove_select_items), (None, _("Move to Trash"), self.current_item.song_view.try_move_trash), (None, _("Clear List"), self.current_item.song_view.erase_items), None, (None, _("Playback Order"), play_mode_menu), (None, _("Sort"), sub_sort_menu), (None, _("Convert"), self.current_item.song_view.songs_convert), (None, _("Open directory"), self.current_item.song_view.open_song_dir), (None, _("Properties"), self.current_item.song_view.open_song_editor), ], True) if item and item.song.get_type() == "cue": self.detail_menu.set_menu_item_sensitive_by_index(5, False) self.detail_menu.set_menu_item_sensitive_by_index(10, False) self.detail_menu.show((int(x), int(y)))
def get_add_menu(self): menu_items = [ (None, _("File"), self.add_file), (None, _("Directory(include subdirectories)"), self.recursion_add_dir), (None, _("Directory"), self.add_dir), ] return Menu(menu_items)
def get_convert_sub_menu(self): menu_items = [ (None, _("Convert"), self.choose_file_and_convert), (None, _("Task Manager"), lambda: convert_task_manager.visible_it()), ] return Menu(menu_items)
def _list_menu_show(self, button, x, y, offset_x, offset_y): '''the combo button clicked callback. show combo_buton list menu''' menu_item = [(None, _("save automatically"), self._list_menu_click, SAVE_OP_AUTO, button), (None, _("save as"), self._list_menu_click, SAVE_OP_AS, button), (None, _("save to clipboard"), self._list_menu_click, SAVE_OP_CLIP, button), (None, _("save automatically to file and clipboard"), self._list_menu_click, SAVE_OP_AUTO_AND_CLIP, button)] # set current operate icon current_item = menu_item[self.screenshot.save_op_index] menu_pixbuf = (app_theme.get_pixbuf("action/selected.png"), app_theme.get_pixbuf("action/selected_hover.png"), app_theme.get_pixbuf("action/selected.png")) menu_item[self.screenshot.save_op_index] = (menu_pixbuf, current_item[1], current_item[2], current_item[3]) self.combo_menu = Menu( menu_item, is_root_menu=True, menu_item_select_color=app_theme.get_shadow_color( "menu_item_select").get_color_info()) self.set_all_inactive() self.combo_menu.show((x, y), (offset_x, offset_y))
def show_instance_menu(self, obj, x, y): curren_view = self.playlist_ui.get_selected_song_view() menu_items = [ (None, _("Add"), curren_view.get_add_menu()), (None, _("Controls"), self.get_play_control_menu()), (self.get_pixbuf_group("playmode"), _("Playback Order"), curren_view.get_playmode_menu()), None, (None, _("Equalizer"), lambda: self.equalizer_win.run()), (None, _("Convert"), self.get_convert_sub_menu()), None, self.get_app_mode_menu(), None, self.get_lyrics_menu_items(), self.get_locked_menu_items(), None, (None, _("View New Features"), self.show_wizard_win), (self.get_pixbuf_group("setting"), _("Preferences"), lambda: self.preference_dialog.show_all()), None, (self.get_pixbuf_group("close"), _("Quit"), self.force_quit), ] if config.getboolean("lyrics", "status"): menu_items.insert(10, (None, _("Search Lyrics"), lambda: Dispatcher.emit("search-lyrics"))) Menu(menu_items, True).show((x, y))
def popup_desktop_right_menu(self, widget, event): if event.button == 3 and Player.song: adjust_menu_item = [(None, _("Forward 0.5 seconds"), lambda: self.after_offset(None)), (None, _("Rewind 0.5 seconds"), lambda: self.before_offset(None))] menu_items = [ (None, _("Search"), lambda: self.open_search_window(None)), (None, _("Adjust lyrics"), Menu(adjust_menu_item)), None, (None, _("Choose local lrc"), self.allocation_lrc), (None, _("Open directory"), self.open_lrc_dir), None, (None, _("Settings"), lambda: self.open_setting_window(None)), (None, _("Switch to window mode"), lambda: self.switch_to_scroll_lyrics(None)) ] Menu(menu_items, True).show((int(event.x_root), int(event.y_root)))
def get_volume_menu(self): menu_items = [ (None, _("Volume Up"), Player.increase_volume), (None, _("Volume Down"), Player.decrease_volume), (None, _("Mute"), Player.mute_volume), ] return Menu(menu_items)
def popup_delete_menu(self, x, y): items = [ (None, _("Remove Track from this List"), self.remove_select_items), (None, _("Remove Unavailable Tracks"), self.delete_error_items), (None, _("Move to Trash"), lambda: self.try_move_trash()), (None, _("Clear List"), self.erase_items) ] Menu(items, True).show((int(x), int(y)))
def popup_list_menu(self, widget, event): menu_items = [(None, _("New List"), self.new_list), (None, _("Import List"), self.leading_in_list), (None, _("Open List"), self.add_to_list), (None, _("Export List"), self.leading_out_list), (None, _("Remove List"), self.delete_item_list), None, (None, _("Save all Lists"), self.save_all_list)] Menu(menu_items, True).show((int(event.x_root), int(event.y_root)))
def popup_add_menu(self, x, y): menu_items = [ (None, _("URL") , self.add_unknow_uri), (None, _("File"), self.add_file), (None, _("Directory (include subdirectories)"), self.recursion_add_dir), (None, _("Directory"), self.add_dir), ] Menu(menu_items, True).show((x, y))
def popup_right_menu(self, widget, x, y, item, select_items): menu_items = [ # (None, _("优先转换"), self.set_job_priority, item), (None, _("Open directory"), lambda : utils.open_file_directory(item.output_path)), None, (None, _("Delete task"), self.delete_job, item), (None, _("Clear finished tasks"), self.delete_finish_jobs) ] Menu(menu_items, True).show((int(x), int(y)))
def __on_right_click_item(self, widget, item, x, y): menu_items = [(None, _("Pair"), lambda: item.do_pair())] if item.is_paired: menu_items = [] menu_items.extend(item.menu_items) menu_items.append(None) menu_items.append((None, _("Remove Device"), lambda: self.__do_remove_item(item))) Menu(menu_items, True).show((int(x), int(y)))
def show_right_menu(self, widget, event): menu_items = [ (self.get_menu_pixbuf_group("artist"), _("By Artist"), self.update_widget_icon, "artist", _("By Artist")), (self.get_menu_pixbuf_group("genre"), _("By Genre"), self.update_widget_icon, "genre", _("By Genre")), (self.get_menu_pixbuf_group("album"), _("By Album"), self.update_widget_icon, "album", _("By Album")), ] Menu(menu_items, True).show( (int(event.x_root) - 10, int(event.y_root)))
def get_edit_sub_menu(self, select_items, move=False): sub_menu_items = [] if len(self.category_list.get_items()) > 1: other_category_items = self.get_categroy_other_items() sub_menu_items = [(None, category_item.get_title(), self.edit_list_item, category_item, select_items ,move) for category_item in other_category_items] if sub_menu_items: sub_menu_items.extend([None, ((app_theme.get_pixbuf("toolbar/add_normal.png"), None, None), _("New List"), self.edit_new_list_item, select_items, move)]) else: sub_menu_items.extend([((app_theme.get_pixbuf("toolbar/add_normal.png"), None, None), _("New List"), self.edit_new_list_item, select_items, move)]) return Menu(sub_menu_items)
def on_right_press_items(self, widget, x, y, current_item, select_items): if current_item and select_items: if len(select_items) > 1: items = [(None, _("Delete"), lambda: self.delete_items(select_items)), (None, _("Clear List"), lambda: self.clear_items())] else: items = [(None, _("Play"), lambda: self.play_item(current_item)), (None, _("Delete"), lambda: self.delete_items([current_item])), (None, _("Clear List"), lambda: self.clear_items())] Menu(items, True).show((int(x), int(y)))
def on_category_right_press(self, widget, x, y, item, column): if not item: menu_items = [(None, _("New List"), self.new_list), (None, _("Import List"), self.leading_in_list), None, (None, _("Save all Lists"), self.save_all_list)] else: menu_items = [ (None, _("Rename"), lambda: self.rename_item_list(item)), (None, _("Remove List"), lambda: self.delete_item_list(item)), (None, _("Open List"), lambda: self.add_to_list(item)), None, (None, _("Save all Lists"), self.save_all_list) ] Menu(menu_items, True).show((x, y))
def get_playmode_menu(self, pos=[], align=False): mode_dict = OrderedDict() mode_dict["single_mode"] = _("Repeat (single)") mode_dict["order_mode"] = _("Order play") mode_dict["list_mode"] = _("Repeat (list)") mode_dict["random_mode"] = _("Randomize") mode_items = [] for key, value in mode_dict.iteritems(): if self.get_loop_mode() == key: tick = (app_theme.get_pixbuf("menu/tick.png"), app_theme.get_pixbuf("menu/tick_press.png"), app_theme.get_pixbuf("menu/tick_disable.png")) mode_items.append((tick, value, self.set_loop_mode, key)) else: tick = None mode_items.append((None, value, self.set_loop_mode, key)) if pos: Menu(mode_items, True).show((pos[0], pos[1])) else: return Menu(mode_items)
def get_add_online_list_menu(self, select_items): category_items = [item for item in self.category_view.items if item.list_type == self.PLAYLIST_TYPE] if len(category_items) <= 0: return None songs = [ item.song for item in select_items ] sids = self.get_sids(select_items) def add_song_to_list(item, songs, sids): item.add_songs(songs, pos=0) pid = item.list_id bplayer.add_list_song(pid, sids) menu_items = [(None, item.title, add_song_to_list, item, songs, sids) for item in category_items ] return Menu(menu_items)
def popup_right_menu(self, widget, x, y, item, select_items): menu_items = [ (None, _("Play"), self.play_song), (None, _("Add to Playlist"), self.emit_to_playlist), None, (None, _("Remove from Library"), self.remove_songs), (None, _("Move to Trash"), lambda: self.try_move_trash()), None, (None, _("Open Directory"), self.open_song_dir), (None, _("Converter"), self.songs_convert), (None, _("Properties"), self.open_song_editor) ] right_menu = Menu(menu_items, True) if item.song.get_type() == "cue": right_menu.set_menu_item_sensitive_by_index(4, False) right_menu.set_menu_item_sensitive_by_index(7, False) right_menu.show((int(x), int(y)))
def scroll_right_press_cb(self, widget, event): menu_items = [ (self.get_scroll_menu_pixbufs("lrc"), _("Switch to desktop mode"), self.switch_to_desktop_lyrics), None, (self.get_scroll_menu_pixbufs("before"), _("Lyrics rewind"), lambda: self.before_offset(None)), (self.get_scroll_menu_pixbufs("after"), _("Lyrics forward"), lambda: self.after_offset(None)), None, (self.get_scroll_menu_pixbufs("search"), _("Search"), lambda: self.open_search_window(None)), (self.get_scroll_menu_pixbufs("setting"), _("Settings"), lambda: Dispatcher.show_scroll_page()), ] Menu(menu_items, True).show((int(event.x_root), int(event.y_root)))
def get_play_control_menu(self): menu_items = [] if Player.is_paused(): state_label = _("Play") state_pixbuf = self.get_pixbuf_group("play") else: state_label = _("Pause") state_pixbuf = self.get_pixbuf_group("pause") menu_items.append((state_pixbuf, state_label, Player.playpause)) control_items = [ (self.get_pixbuf_group("forward"), _("Forward"), Player.forward), (self.get_pixbuf_group("rewind"), _("Rewind"), Player.rewind), (self.get_pixbuf_group("previous"), _("Previous"), Player.previous), (self.get_pixbuf_group("next"), _("Next"), Player.next), ] menu_items.extend(control_items) return Menu(menu_items)
def __on_right_click_item(self, widget, item, x, y): if not item: return menu_items = [ (None, _("Play All"), lambda : self.play_item(item)), (None, _("Add to List"), lambda : self.emit_to_list(item)), None, (None, _("Remove from Library"), lambda : self.real_remove_item(item)), (None, _("Move to Trash"), lambda : self.try_move_trash(item)), None, ] if item.tag == "folder": menu_items.append((None, _("Open Directory"), lambda : utils.open_directory(item.value_name))) elif item.tag in ["artist", "album"] and item.key_name != "deepin-all-songs": menu_items.append((None, _("Change Cover"), lambda : self.change_item_cover(item))) else: menu_items.pop() Menu(menu_items, True).show((int(x), int(y)))
def __on_right_press_items(self, widget, x, y, current_item, select_items): if current_item and select_items: if len(select_items) > 1: items = [ (None, _("Add to Playlist"), lambda: self.emit_to_playlist(select_items)), # (None, _("Delete"), None), ] else: items = [ (None, _("Play"), lambda: Dispatcher.play_webcast(current_item.webcast)), (None, _("Add to Playlist"), lambda: self.emit_to_playlist([current_item])), self.get_favorite_menu_item(current_item), # None, # (None, _("Clear List"), None), ] Menu(items, True).show((int(x), int(y)))
def update_menu(self): menu_items = [] if Player.is_paused(): pixbuf_group = self.get_pixbuf_group("play") status_label = _("Play") else: pixbuf_group = self.get_pixbuf_group("pause") status_label = _("Pause") menu_items.append((pixbuf_group, status_label, Player.playpause)) menu_items.append((self.get_pixbuf_group("previous"), _("Previous"), Player.previous)) menu_items.append( (self.get_pixbuf_group("next"), _("Next"), Player.next)) menu_items.append(None) menu_items.append((self.get_pixbuf_group("volume"), _("Volume"), self.get_volume_menu())) menu_items.append(None) if config.getboolean("lyrics", "status"): menu_items.append( (None, _("Close Lyrics"), lambda: Dispatcher.close_lyrics())) menu_items.append((None, _("Search Lyrics"), lambda: Dispatcher.emit("search-lyrics"))) else: menu_items.append( (None, _("Show Lyrics"), lambda: Dispatcher.show_lyrics())) if config.getboolean("lyrics", "locked"): menu_items.append( (self.get_pixbuf_group("unlock"), _("Unlock Lyrics"), lambda: Dispatcher.unlock_lyrics())) else: menu_items.append((self.get_pixbuf_group("lock"), _("Lock Lyrics"), lambda: Dispatcher.lock_lyrics())) menu_items.append(None) menu_items.append((self.get_pixbuf_group("setting"), _("Preferences"), lambda: Dispatcher.show_setting())) menu_items.append((self.get_pixbuf_group("close"), _("Quit"), lambda: Dispatcher.quit())) if self.menu is not None: del self.menu self.menu = Menu(menu_items, True)
def popup_predefine_menu(self, widget, event): menu_dict = OrderedDict() menu_dict["vitality_yellow"] = _("Vitality yellow") menu_dict["fresh_green"] = _("Fresh green") menu_dict["playful_pink"] = _("Playful pink") menu_dict["cool_blue"] = _("Cool blue") menu_items = [] save_predefine_color = config.get("lyrics", "predefine_color", "vitality_yellow") for key, value in menu_dict.iteritems(): item_pixbuf = None if key == save_predefine_color: item_pixbuf = (app_theme.get_pixbuf("menu/tick.png"), app_theme.get_pixbuf("menu/tick_press.png"), app_theme.get_pixbuf("menu/tick_disable.png")) if item_pixbuf is None: menu_items.append((None, value, self.set_predefine_color, key)) else: menu_items.append( (item_pixbuf, value, self.set_predefine_color, key)) predefine_menu = Menu(menu_items, True) predefine_menu.show((int(event.x_root), int(event.y_root)))
def on_music_view_right_press_items(self, widget, x, y, current_item, select_items): if current_item and select_items: if len(select_items) > 1: items = [ (None, _("Delete"), lambda : self.delete_items(select_items)), (None, _("Clear List"), lambda : self.clear_items()) ] else: items = [ (None, _("Play"), lambda : self.request_song(current_item.get_song())), (None, _("Delete"), lambda : self.delete_items([current_item])), (None, _("Clear List"), lambda : self.clear_items()) ] if self.view_type != self.PLAYLIST_TYPE and bplayer.is_login: sub_menu = self.get_add_online_list_menu(select_items) if sub_menu: items.insert(1, (None, "添加到歌单", sub_menu)) if self.view_type != self.COLLECT_TYPE: collect_items = filter(lambda item: item.list_type == self.COLLECT_TYPE, self.category_view.items) if len(collect_items) > 0: collect_item = collect_items[0] songs = [ item.song for item in select_items ] sids = self.get_sids(select_items) def add_to_collect(item, songs, sids): item.add_songs(songs, pos=0) bplayer.add_collect_song(sids) items.insert(1, (None, "收藏", add_to_collect, collect_item, songs, sids)) Menu(items, True).show((int(x), int(y)))
def init_root_menu(self): # Init file menu. file_menu = Menu([ (None, "新建", lambda: self.code_edit.clear()), # 清空代码编辑器. (None, "打开", lambda: self.open_file_dialog_window()), (None), (None, "我的程序...", None), (None), (None, "保存", lambda: self.code_edit.save()), (None, "另存为", None), (None), (None, "退出", lambda: gtk.main_quit()) ]) # Init edit menu. edit_menu = Menu([(None, "剪切", None), (None, "复制", None), (None, "粘帖", None), (None, "全选", None), (None), (None, "注释", lambda: self.notes_line()), (None, "取消注释", lambda: self.notes_line()), (None), (None, "撤销", None), (None, "恢复", None), (None), (None, "查找", None), (None, "替换", None), (None, "定位到行", None)]) # Init run menu. run_menu = Menu([(None, "编译成目标文件", None), (None, "生成可执行文件", None), (None, "生成动态链接库文件", None), (None, "运行", None), (None, "多模块链接", None), (None, "调试", None), (None, "运行LINUX控制台程序", None)]) # Init tool menu. tool_menu = Menu([(None, "选项", None), (None, "计算器", lambda: open_gcalctool())]) # Init help menu. help_menu = Menu([ (None, "帮助主题", None), (None, "关于", None), ]) # Init root menu. self.root_menu = Menu([ (None, "文件", file_menu), (None, "编辑", edit_menu), (None, "运行", run_menu), (None, "工具", tool_menu), (None, "帮助", help_menu), ], True)