def test_index(self): self.assertEqual( browsers.browsers[browsers.index("SearchBar")], browsers.search.SearchBar) self.assertEqual( browsers.browsers[browsers.index("FileSystem")], browsers.filesystem.FileSystem)
def test_index(self): self.assertEqual( browsers.browsers[browsers.index("EmptyBar")], browsers.empty.EmptyBar) self.assertEqual( browsers.browsers[browsers.index("FileSystem")], browsers.filesystem.FileSystem)
def __create_menu(self, player, library): ag = Gtk.ActionGroup.new('QuodLibetWindowActions') actions = [ ('Music', None, _("_Music")), ('AddFolders', Gtk.STOCK_ADD, _(u'_Add a Folder…'), "<control>O", None, self.open_chooser), ('AddFiles', Gtk.STOCK_ADD, _(u'_Add a File…'), None, None, self.open_chooser), ('AddLocation', Gtk.STOCK_ADD, _(u'_Add a Location…'), None, None, self.open_location), ('BrowseLibrary', Gtk.STOCK_FIND, _('Open _Browser'), ""), ("Preferences", Gtk.STOCK_PREFERENCES, None, None, None, self.__preferences), ("Plugins", Gtk.STOCK_EXECUTE, _("_Plugins"), None, None, self.__plugins), ("Quit", Gtk.STOCK_QUIT, None, None, None, lambda *x: self.destroy()), ("Control", None, _("_Control")), ("EditTags", Gtk.STOCK_PROPERTIES, _("Edit _Tags"), "", None, self.__current_song_prop), ("Information", Gtk.STOCK_INFO, None, None, None, self.__current_song_info), ("Jump", Gtk.STOCK_JUMP_TO, _("_Jump to Playing Song"), "<control>J", None, self.__jump_to_current), ("View", None, _("_View")), ("Help", None, _("_Help")), ] actions.append(("Previous", Gtk.STOCK_MEDIA_PREVIOUS, None, "<control>comma", None, self.__previous_song)) actions.append(("PlayPause", Gtk.STOCK_MEDIA_PLAY, None, "<control>space", None, self.__play_pause)) actions.append(("Next", Gtk.STOCK_MEDIA_NEXT, None, "<control>period", None, self.__next_song)) ag.add_actions(actions) act = Gtk.ToggleAction.new("StopAfter", _("Stop After This Song"), None, "") ag.add_action_with_accel(act, "<shift>space") # access point for the tray icon self.stop_after = act act = Gtk.Action.new("AddBookmark", _("Add Bookmark"), None, Gtk.STOCK_ADD) connect_obj(act, 'activate', self.__add_bookmark, library.librarian, player) ag.add_action_with_accel(act, "<ctrl>D") act = Gtk.Action.new("EditBookmarks", _(u"Edit Bookmarks…"), None, "") connect_obj(act, 'activate', self.__edit_bookmarks, library.librarian, player) ag.add_action_with_accel(act, "<ctrl>B") act = Gtk.Action.new("About", None, None, Gtk.STOCK_ABOUT) connect_obj(act, 'activate', self.__show_about, player) ag.add_action_with_accel(act, None) act = Gtk.Action.new("OnlineHelp", _("Online Help"), None, Gtk.STOCK_HELP) def website_handler(*args): util.website(const.ONLINE_HELP) act.connect('activate', website_handler) ag.add_action_with_accel(act, "F1") act = Gtk.Action.new("SearchHelp", _("Search Help"), None, "") def search_help_handler(*args): util.website(const.SEARCH_HELP) act.connect('activate', search_help_handler) ag.add_action_with_accel(act, None) act = Gtk.Action.new("RefreshLibrary", _("Re_fresh Library"), None, Gtk.STOCK_REFRESH) act.connect('activate', self.__rebuild, False) ag.add_action_with_accel(act, None) ag.add_toggle_actions([("SongList", None, _("Song _List"), None, None, self.showhide_playlist, config.getboolean("memory", "songlist"))]) ag.add_toggle_actions([("Queue", None, _("_Queue"), None, None, self.showhide_playqueue, config.getboolean("memory", "queue"))]) view_actions = [] for i, Kind in enumerate(browsers.browsers): action = "View" + Kind.__name__ label = Kind.accelerated_name view_actions.append((action, None, label, None, None, i)) current = browsers.index(config.get("memory", "browser")) def action_callback(view_action, current): self.select_browser(view_action, current, library, player) ag.add_radio_actions(view_actions, current, action_callback, None) for Kind in browsers.browsers: if not Kind.in_menu: continue action = "Browser" + Kind.__name__ label = Kind.accelerated_name act = Gtk.Action.new(action, label, None, None) def browser_activate(action, Kind): LibraryBrowser.open(Kind, library, player) act.connect('activate', browser_activate, Kind) ag.add_action_with_accel(act, None) ui = Gtk.UIManager() ui.insert_action_group(ag, -1) ui.add_ui_from_string(MAIN_MENU % {"browsers": browsers.BrowseLibrary()}) self._filter_menu = FilterMenu(library, player, ui) menustr = MENU % { "views": browsers.ViewBrowser(), } ui.add_ui_from_string(menustr) # Cute. So. UIManager lets you attach tooltips, but when they're # for menu items, they just get ignored. So here I get to actually # attach them. ui.get_widget("/Menu/Music/RefreshLibrary").set_tooltip_text( _("Check for changes in your library")) return ui
def __create_menu(self, player, library): def add_view_items(ag): act = Action(name="Information", label=_('_Information'), icon_name=Icons.DIALOG_INFORMATION) act.connect('activate', self.__current_song_info) ag.add_action(act) act = Action(name="Jump", label=_('_Jump to Playing Song'), icon_name=Icons.GO_JUMP) self.__jump_to_current(True, None, True) act.connect('activate', self.__jump_to_current) ag.add_action_with_accel(act, "<Primary>J") def add_top_level_items(ag): ag.add_action(Action(name="File", label=_("_File"))) ag.add_action(Action(name="Song", label=_("_Song"))) ag.add_action(Action(name="View", label=_('_View'))) ag.add_action(Action(name="Browse", label=_("_Browse"))) ag.add_action(Action(name="Control", label=_('_Control'))) ag.add_action(Action(name="Help", label=_('_Help'))) ag = Gtk.ActionGroup.new('QuodLibetWindowActions') add_top_level_items(ag) add_view_items(ag) act = Action(name="AddFolders", label=_(u'_Add a Folder…'), icon_name=Icons.LIST_ADD) act.connect('activate', self.open_chooser) ag.add_action_with_accel(act, "<Primary>O") act = Action(name="AddFiles", label=_(u'_Add a File…'), icon_name=Icons.LIST_ADD) act.connect('activate', self.open_chooser) ag.add_action(act) act = Action(name="AddLocation", label=_(u'_Add a Location…'), icon_name=Icons.LIST_ADD) act.connect('activate', self.open_location) ag.add_action(act) act = Action(name="BrowseLibrary", label=_('Open _Browser'), icon_name=Icons.EDIT_FIND) ag.add_action(act) act = Action(name="Preferences", label=_('_Preferences'), icon_name=Icons.PREFERENCES_SYSTEM) act.connect('activate', self.__preferences) ag.add_action(act) act = Action(name="Plugins", label=_('_Plugins'), icon_name=Icons.SYSTEM_RUN) act.connect('activate', self.__plugins) ag.add_action(act) act = Action(name="Quit", label=_('_Quit'), icon_name=Icons.APPLICATION_EXIT) act.connect('activate', lambda *x: self.destroy()) ag.add_action_with_accel(act, "<Primary>Q") act = Action(name="EditTags", label=_('Edit _Tags'), icon_name=Icons.DOCUMENT_PROPERTIES) act.connect('activate', self.__current_song_prop) ag.add_action(act) act = Action(name="EditBookmarks", label=_(u"Edit Bookmarks…")) connect_obj(act, 'activate', self.__edit_bookmarks, library.librarian, player) ag.add_action_with_accel(act, "<Primary>B") act = Action(name="Previous", label=_('Pre_vious'), icon_name=Icons.MEDIA_SKIP_BACKWARD) act.connect('activate', self.__previous_song) ag.add_action_with_accel(act, "<Primary>comma") act = Action(name="PlayPause", label=_('_Play'), icon_name=Icons.MEDIA_PLAYBACK_START) act.connect('activate', self.__play_pause) ag.add_action_with_accel(act, "<Primary>space") act = Action(name="Next", label=_('_Next'), icon_name=Icons.MEDIA_SKIP_FORWARD) act.connect('activate', self.__next_song) ag.add_action_with_accel(act, "<Primary>period") act = ToggleAction(name="StopAfter", label=_("Stop After This Song")) ag.add_action_with_accel(act, "<shift>space") # access point for the tray icon self.stop_after = act act = Action(name="Shortcuts", label=_("_Keyboard Shortcuts")) act.connect('activate', self.__keyboard_shortcuts) ag.add_action_with_accel(act, "<Primary>question") act = Action(name="About", label=_("_About"), icon_name=Icons.HELP_ABOUT) act.connect('activate', self.__show_about) ag.add_action_with_accel(act, None) act = Action(name="OnlineHelp", label=_("Online Help"), icon_name=Icons.HELP_BROWSER) def website_handler(*args): util.website(const.ONLINE_HELP) act.connect('activate', website_handler) ag.add_action_with_accel(act, "F1") act = Action(name="SearchHelp", label=_("Search Help")) def search_help_handler(*args): util.website(const.SEARCH_HELP) act.connect('activate', search_help_handler) ag.add_action_with_accel(act, None) act = Action(name="CheckUpdates", label=_("_Check for Updates…"), icon_name=Icons.NETWORK_SERVER) def check_updates_handler(*args): d = UpdateDialog(self) d.run() d.destroy() act.connect('activate', check_updates_handler) ag.add_action_with_accel(act, None) act = Action(name="RefreshLibrary", label=_("_Scan Library"), icon_name=Icons.VIEW_REFRESH) act.connect('activate', self.__rebuild, False) ag.add_action(act) current = config.get("memory", "browser") try: browsers.get(current) except ValueError: current = browsers.name(browsers.default) first_action = None for Kind in browsers.browsers: name = browsers.name(Kind) index = browsers.index(name) action_name = "View" + Kind.__name__ act = RadioAction(name=action_name, label=Kind.accelerated_name, value=index) act.join_group(first_action) first_action = first_action or act if name == current: act.set_active(True) ag.add_action_with_accel(act, "<Primary>%d" % ((index + 1) % 10, )) assert first_action self._browser_action = first_action def action_callback(view_action, current_action): current = browsers.name( browsers.get(current_action.get_current_value())) self._select_browser(view_action, current, library, player) first_action.connect("changed", action_callback) for Kind in browsers.browsers: action = "Browser" + Kind.__name__ label = Kind.accelerated_name name = browsers.name(Kind) index = browsers.index(name) act = Action(name=action, label=label) def browser_activate(action, Kind): LibraryBrowser.open(Kind, library, player) act.connect('activate', browser_activate, Kind) ag.add_action_with_accel(act, "<Primary><alt>%d" % ((index + 1) % 10, )) ui = Gtk.UIManager() ui.insert_action_group(ag, -1) menustr = MENU % { "views": browser_menu_items(), "browsers": secondary_browser_menu_items(), "filters_menu": FilterMenu.MENU } ui.add_ui_from_string(menustr) self._filter_menu = FilterMenu(library, player, ui) # Cute. So. UIManager lets you attach tooltips, but when they're # for menu items, they just get ignored. So here I get to actually # attach them. ui.get_widget("/Menu/File/RefreshLibrary").set_tooltip_text( _("Check for changes in your library")) return ui
def __create_menu(self, player, library): ag = gtk.ActionGroup('QuodLibetWindowActions') actions = [ ('Music', None, _("_Music")), ('SwitchAudioOutputs', gtk.STOCK_FIND, _('_Audio Outputs'), ""), ('BrowseLibrary', gtk.STOCK_FIND, _('_Browse Library'), ""), ("Preferences", gtk.STOCK_PREFERENCES, None, None, None, self.__preferences), ("Quit", gtk.STOCK_QUIT, None, None, None, self.destroy), ('Filters', None, _("_Filters")), ("PlayedRecently", gtk.STOCK_FIND, _("Recently _Played"), "", None, self.__filter_menu_actions), ("AddedRecently", gtk.STOCK_FIND, _("Recently _Added"), "", None, self.__filter_menu_actions), ("TopRated", gtk.STOCK_FIND, _("_Top 40"), "", None, self.__filter_menu_actions), ("Control", None, _("_Control")), ("EditTags", gtk.STOCK_PROPERTIES, _("Edit _Tags"), "", None, self.__current_song_prop), ("Information", gtk.STOCK_INFO, None, None, None, self.__current_song_info), ("Jump", gtk.STOCK_JUMP_TO, _("_Jump to Playing Song"), "<control>J", None, self.__jump_to_current), ("View", None, _("_View")), ("Help", None, _("_Help")), ("OutputLog", gtk.STOCK_EDIT, _("_Output Log"), None, None, lambda *args: LoggingWindow(self)), ] if const.DEBUG: from quodlibet.debug import cause_error, enc actions.append(("DebugReload", gtk.STOCK_DIALOG_WARNING, _("_Edit and Continue"), None, None, lambda *args: enc.reload())) actions.append(("DebugCauseError", gtk.STOCK_DIALOG_ERROR, _("_Cause an Error"), None, None, cause_error)) actions.append(("Previous", gtk.STOCK_MEDIA_PREVIOUS, None, "<control>comma", None, self.__previous_song)) actions.append(("PlayPause", gtk.STOCK_MEDIA_PLAY, None, "<control>space", None, self.__play_pause)) actions.append(("Next", gtk.STOCK_MEDIA_NEXT, None, "<control>period", None, self.__next_song)) ag.add_actions(actions) act = gtk.Action("About", None, None, gtk.STOCK_ABOUT) act.connect_object('activate', self.__show_about, player) ag.add_action_with_accel(act, None) act = gtk.Action("OnlineHelp", _("Online Help"), None, gtk.STOCK_HELP) act.connect_object('activate', util.website, const.ONLINE_HELP) ag.add_action_with_accel(act, "F1") act = gtk.Action("SearchHelp", _("Search Help"), None, "") act.connect_object('activate', util.website, const.SEARCH_HELP) ag.add_action_with_accel(act, None) act = gtk.Action( "RefreshLibrary", _("Re_fresh Library"), None, gtk.STOCK_REFRESH) act.connect('activate', self.__rebuild, False) ag.add_action_with_accel(act, None) act = gtk.Action( "ConnectDisconnect", _("_Connect/Disconnect"), None, gtk.STOCK_REFRESH) act.connect('activate', self.__toggle_connected, True) ag.add_action_with_accel(act, None) for tag_, lab in [ ("genre", _("Filter on _Genre")), ("artist", _("Filter on _Artist")), ("album", _("Filter on Al_bum"))]: act = gtk.Action( "Filter%s" % util.capitalize(tag_), lab, None, gtk.STOCK_INDEX) act.connect_object('activate', self.__filter_on, tag_, None, player) ag.add_action_with_accel(act, None) for (tag_, accel, label) in [ ("genre", "G", _("Random _Genre")), ("artist", "T", _("Random _Artist")), ("album", "M", _("Random Al_bum"))]: act = gtk.Action("Random%s" % util.capitalize(tag_), label, None, gtk.STOCK_DIALOG_QUESTION) act.connect('activate', self.__random, tag_) ag.add_action_with_accel(act, "<control>" + accel) ag.add_toggle_actions([ ("SongList", None, _("Song _List"), None, None, self.showhide_playlist, config.getboolean("memory", "songlist"))]) ag.add_toggle_actions([ ("Queue", None, _("_Queue"), None, None, self.showhide_playqueue, config.getboolean("memory", "queue"))]) view_actions = [] for i, Kind in enumerate(browsers.browsers): action = "View" + Kind.__name__ label = Kind.accelerated_name view_actions.append((action, None, label, None, None, i)) current = browsers.index(config.get("memory", "browser")) ag.add_radio_actions( view_actions, current, self.select_browser, (library, player)) for Kind in browsers.browsers: if not Kind.in_menu: continue action = "Browser" + Kind.__name__ label = Kind.accelerated_name act = gtk.Action(action, label, None, None) act.connect_object('activate', LibraryBrowser, Kind, library) ag.add_action_with_accel(act, None) debug_menu = "" if const.DEBUG: debug_menu = ("<separator/>" "<menuitem action='OutputLog'/>" "<menuitem action='DebugReload'/>" "<menuitem action='DebugCauseError'/>") self.ui = gtk.UIManager() self.ui.insert_action_group(ag, -1) menustr = const.MENU % {"browsers": browsers.BrowseLibrary(), "views": browsers.ViewBrowser(), "mpd_audio_outputs": self._mpd.browse_audio_outputs(), "debug": debug_menu} self.ui.add_ui_from_string(menustr) # Cute. So. UIManager lets you attach tooltips, but when they're # for menu items, they just get ignored. So here I get to actually # attach them. self.ui.get_widget("/Menu/Music/RefreshLibrary").set_tooltip_text( _("Check for changes in your library")) self.ui.get_widget("/Menu/Filters/TopRated").set_tooltip_text( _("The 40 songs you've played most (more than 40 may " "be chosen if there are ties)"))
def __create_menu(self, player, library): ag = Gtk.ActionGroup.new('QuodLibetWindowActions') def logging_cb(*args): window = LoggingWindow(self) window.show() actions = [ ('Music', None, _("_Music")), ('AddFolders', Gtk.STOCK_ADD, _('_Add a Folder...'), "<control>O", None, self.open_chooser), ('AddFiles', Gtk.STOCK_ADD, _('_Add a File...'), None, None, self.open_chooser), ('AddLocation', Gtk.STOCK_ADD, _('_Add a Location...'), None, None, self.open_location), ('BrowseLibrary', Gtk.STOCK_FIND, _('Open _Browser'), ""), ("Preferences", Gtk.STOCK_PREFERENCES, None, None, None, self.__preferences), ("Plugins", Gtk.STOCK_EXECUTE, _("_Plugins"), None, None, self.__plugins), ("Quit", Gtk.STOCK_QUIT, None, None, None, self.destroy), ('Filters', None, _("_Filters")), ("PlayedRecently", Gtk.STOCK_FIND, _("Recently _Played"), "", None, self.__filter_menu_actions), ("AddedRecently", Gtk.STOCK_FIND, _("Recently _Added"), "", None, self.__filter_menu_actions), ("TopRated", Gtk.STOCK_FIND, _("_Top 40"), "", None, self.__filter_menu_actions), ("All", Gtk.STOCK_FIND, _("All _Songs"), "", None, self.__filter_menu_actions), ("Control", None, _("_Control")), ("EditTags", Gtk.STOCK_PROPERTIES, _("Edit _Tags"), "", None, self.__current_song_prop), ("Information", Gtk.STOCK_INFO, None, None, None, self.__current_song_info), ("Jump", Gtk.STOCK_JUMP_TO, _("_Jump to Playing Song"), "<control>J", None, self.__jump_to_current), ("View", None, _("_View")), ("Help", None, _("_Help")), ("OutputLog", Gtk.STOCK_EDIT, _("_Output Log"), None, None, logging_cb), ] actions.append(("Previous", Gtk.STOCK_MEDIA_PREVIOUS, None, "<control>comma", None, self.__previous_song)) actions.append(("PlayPause", Gtk.STOCK_MEDIA_PLAY, None, "<control>space", None, self.__play_pause)) actions.append(("Next", Gtk.STOCK_MEDIA_NEXT, None, "<control>period", None, self.__next_song)) ag.add_actions(actions) act = Gtk.ToggleAction.new("StopAfter", _("Stop After This Song"), None, "") ag.add_action_with_accel(act, "<shift>space") # access point for the tray icon self.stop_after = act act = Gtk.Action.new( "AddBookmark", _("Add Bookmark"), None, Gtk.STOCK_ADD) act.connect_object('activate', self.__add_bookmark, library.librarian, player) ag.add_action_with_accel(act, "<ctrl>D") act = Gtk.Action.new("EditBookmarks", _(u"Edit Bookmarks…"), None, "") act.connect_object('activate', self.__edit_bookmarks, library.librarian, player) ag.add_action_with_accel(act, "<ctrl>B") act = Gtk.Action.new("About", None, None, Gtk.STOCK_ABOUT) act.connect_object('activate', self.__show_about, player) ag.add_action_with_accel(act, None) act = Gtk.Action.new( "OnlineHelp", _("Online Help"), None, Gtk.STOCK_HELP) act.connect_object('activate', util.website, const.ONLINE_HELP) ag.add_action_with_accel(act, "F1") act = Gtk.Action.new("SearchHelp", _("Search Help"), None, "") act.connect_object('activate', util.website, const.SEARCH_HELP) ag.add_action_with_accel(act, None) act = Gtk.Action.new( "RefreshLibrary", _("Re_fresh Library"), None, Gtk.STOCK_REFRESH) act.connect('activate', self.__rebuild, False) ag.add_action_with_accel(act, None) for tag_, lab in [ ("genre", _("Filter on _Genre")), ("artist", _("Filter on _Artist")), ("album", _("Filter on Al_bum"))]: act = Gtk.Action.new( "Filter%s" % util.capitalize(tag_), lab, None, Gtk.STOCK_INDEX) act.connect_object('activate', self.__filter_on, tag_, None, player) ag.add_action_with_accel(act, None) for (tag_, accel, label) in [ ("genre", "G", _("Random _Genre")), ("artist", "T", _("Random _Artist")), ("album", "M", _("Random Al_bum"))]: act = Gtk.Action.new("Random%s" % util.capitalize(tag_), label, None, Gtk.STOCK_DIALOG_QUESTION) act.connect('activate', self.__random, tag_) ag.add_action_with_accel(act, "<control>" + accel) ag.add_toggle_actions([ ("SongList", None, _("Song _List"), None, None, self.showhide_playlist, config.getboolean("memory", "songlist"))]) ag.add_toggle_actions([ ("Queue", None, _("_Queue"), None, None, self.showhide_playqueue, config.getboolean("memory", "queue"))]) view_actions = [] for i, Kind in enumerate(browsers.browsers): action = "View" + Kind.__name__ label = Kind.accelerated_name view_actions.append((action, None, label, None, None, i)) current = browsers.index(config.get("memory", "browser")) def action_callback(view_action, current): self.select_browser(view_action, current, library, player) ag.add_radio_actions( view_actions, current, action_callback, None) for Kind in browsers.browsers: if not Kind.in_menu: continue action = "Browser" + Kind.__name__ label = Kind.accelerated_name act = Gtk.Action.new(action, label, None, None) act.connect_object('activate', LibraryBrowser.open, Kind, library) ag.add_action_with_accel(act, None) debug_menu = "" if const.DEBUG: debug_menu = ( "<separator/>" "<menuitem action='OutputLog' always-show-image='true'/>") ui = Gtk.UIManager() ui.insert_action_group(ag, -1) menustr = const.MENU % {"browsers": browsers.BrowseLibrary(), "views": browsers.ViewBrowser(), "debug": debug_menu} ui.add_ui_from_string(menustr) # Cute. So. UIManager lets you attach tooltips, but when they're # for menu items, they just get ignored. So here I get to actually # attach them. ui.get_widget("/Menu/Music/RefreshLibrary").set_tooltip_text( _("Check for changes in your library")) ui.get_widget("/Menu/Filters/TopRated").set_tooltip_text( _("The 40 songs you've played most (more than 40 may " "be chosen if there are ties)")) return ui
def __create_menu(self, player, library): ag = Gtk.ActionGroup.new('QuodLibetWindowActions') actions = [ ('Music', None, _("_Music")), ('AddFolders', Gtk.STOCK_ADD, _(u'_Add a Folder…'), "<control>O", None, self.open_chooser), ('AddFiles', Gtk.STOCK_ADD, _(u'_Add a File…'), None, None, self.open_chooser), ('AddLocation', Gtk.STOCK_ADD, _(u'_Add a Location…'), None, None, self.open_location), ('BrowseLibrary', Gtk.STOCK_FIND, _('Open _Browser'), ""), ("Preferences", Gtk.STOCK_PREFERENCES, None, None, None, self.__preferences), ("Plugins", Gtk.STOCK_EXECUTE, _("_Plugins"), None, None, self.__plugins), ("Quit", Gtk.STOCK_QUIT, None, None, None, lambda *x: self.destroy()), ("Control", None, _("_Control")), ("EditTags", Gtk.STOCK_PROPERTIES, _("Edit _Tags"), "", None, self.__current_song_prop), ("Information", Gtk.STOCK_INFO, None, None, None, self.__current_song_info), ("Jump", Gtk.STOCK_JUMP_TO, _("_Jump to Playing Song"), "<control>J", None, self.__jump_to_current), ("View", None, _("_View")), ("Help", None, _("_Help")), ] actions.append(("Previous", Gtk.STOCK_MEDIA_PREVIOUS, None, "<control>comma", None, self.__previous_song)) actions.append(("PlayPause", Gtk.STOCK_MEDIA_PLAY, None, "<control>space", None, self.__play_pause)) actions.append(("Next", Gtk.STOCK_MEDIA_NEXT, None, "<control>period", None, self.__next_song)) ag.add_actions(actions) act = Gtk.ToggleAction.new("StopAfter", _("Stop After This Song"), None, "") ag.add_action_with_accel(act, "<shift>space") # access point for the tray icon self.stop_after = act act = Gtk.Action.new( "AddBookmark", _("Add Bookmark"), None, Gtk.STOCK_ADD) connect_obj(act, 'activate', self.__add_bookmark, library.librarian, player) ag.add_action_with_accel(act, "<ctrl>D") act = Gtk.Action.new("EditBookmarks", _(u"Edit Bookmarks…"), None, "") connect_obj(act, 'activate', self.__edit_bookmarks, library.librarian, player) ag.add_action_with_accel(act, "<ctrl>B") act = Gtk.Action.new("About", None, None, Gtk.STOCK_ABOUT) connect_obj(act, 'activate', self.__show_about, player) ag.add_action_with_accel(act, None) act = Gtk.Action.new( "OnlineHelp", _("Online Help"), None, Gtk.STOCK_HELP) def website_handler(*args): util.website(const.ONLINE_HELP) act.connect('activate', website_handler) ag.add_action_with_accel(act, "F1") act = Gtk.Action.new("SearchHelp", _("Search Help"), None, "") def search_help_handler(*args): util.website(const.SEARCH_HELP) act.connect('activate', search_help_handler) ag.add_action_with_accel(act, None) act = Gtk.Action.new( "RefreshLibrary", _("Re_fresh Library"), None, Gtk.STOCK_REFRESH) act.connect('activate', self.__rebuild, False) ag.add_action_with_accel(act, None) ag.add_toggle_actions([ ("SongList", None, _("Song _List"), None, None, self.showhide_playlist, config.getboolean("memory", "songlist"))]) ag.add_toggle_actions([ ("Queue", None, _("_Queue"), None, None, self.showhide_playqueue, config.getboolean("memory", "queue"))]) view_actions = [] for i, Kind in enumerate(browsers.browsers): action = "View" + Kind.__name__ label = Kind.accelerated_name view_actions.append((action, None, label, None, None, i)) current = browsers.index(config.get("memory", "browser")) def action_callback(view_action, current): self.select_browser(view_action, current, library, player) ag.add_radio_actions( view_actions, current, action_callback, None) for Kind in browsers.browsers: if not Kind.in_menu: continue action = "Browser" + Kind.__name__ label = Kind.accelerated_name act = Gtk.Action.new(action, label, None, None) def browser_activate(action, Kind): LibraryBrowser.open(Kind, library, player) act.connect('activate', browser_activate, Kind) ag.add_action_with_accel(act, None) ui = Gtk.UIManager() ui.insert_action_group(ag, -1) ui.add_ui_from_string( MAIN_MENU % {"browsers": browsers.BrowseLibrary()}) self._filter_menu = FilterMenu(library, player, ui) menustr = MENU % { "views": browsers.ViewBrowser(), } ui.add_ui_from_string(menustr) # Cute. So. UIManager lets you attach tooltips, but when they're # for menu items, they just get ignored. So here I get to actually # attach them. ui.get_widget("/Menu/Music/RefreshLibrary").set_tooltip_text( _("Check for changes in your library")) return ui
def __create_menu(self, player, library): ag = Gtk.ActionGroup.new("QuodLibetWindowActions") act = Action(name="Music", label=_("_Music")) ag.add_action(act) act = Action(name="AddFolders", label=_(u"_Add a Folder…"), icon_name=Icons.LIST_ADD) act.connect("activate", self.open_chooser) ag.add_action_with_accel(act, "<Primary>O") act = Action(name="AddFiles", label=_(u"_Add a File…"), icon_name=Icons.LIST_ADD) act.connect("activate", self.open_chooser) ag.add_action(act) act = Action(name="AddLocation", label=_(u"_Add a Location…"), icon_name=Icons.LIST_ADD) act.connect("activate", self.open_location) ag.add_action(act) act = Action(name="BrowseLibrary", label=_("Open _Browser"), icon_name=Icons.EDIT_FIND) ag.add_action(act) act = Action(name="Preferences", label=_("_Preferences"), icon_name=Icons.PREFERENCES_SYSTEM) act.connect("activate", self.__preferences) ag.add_action(act) act = Action(name="Plugins", label=_("_Plugins"), icon_name=Icons.SYSTEM_RUN) act.connect("activate", self.__plugins) ag.add_action(act) act = Action(name="Quit", label=_("_Quit"), icon_name=Icons.APPLICATION_EXIT) act.connect("activate", lambda *x: self.destroy()) ag.add_action_with_accel(act, "<Primary>Q") act = Action(name="Control", label=_("_Control")) ag.add_action(act) act = Action(name="EditTags", label=_("Edit _Tags"), icon_name=Icons.DOCUMENT_PROPERTIES) act.connect("activate", self.__current_song_prop) ag.add_action(act) act = Action(name="Information", label=_("_Information"), icon_name=Icons.DIALOG_INFORMATION) act.connect("activate", self.__current_song_info) ag.add_action(act) act = Action(name="Jump", label=_("_Jump to Playing Song"), icon_name=Icons.GO_JUMP) act.connect("activate", self.__jump_to_current) ag.add_action_with_accel(act, "<Primary>J") act = Action(name="View", label=_("_View")) ag.add_action(act) act = Action(name="Help", label=_("_Help")) ag.add_action(act) act = Action(name="Previous", label=_("Pre_vious"), icon_name=Icons.MEDIA_SKIP_BACKWARD) act.connect("activate", self.__previous_song) ag.add_action_with_accel(act, "<Primary>comma") act = Action(name="PlayPause", label=_("_Play"), icon_name=Icons.MEDIA_PLAYBACK_START) act.connect("activate", self.__play_pause) ag.add_action_with_accel(act, "<Primary>space") act = Action(name="Next", label=_("_Next"), icon_name=Icons.MEDIA_SKIP_FORWARD) act.connect("activate", self.__next_song) ag.add_action_with_accel(act, "<Primary>period") act = ToggleAction(name="StopAfter", label=_("Stop After This Song")) ag.add_action_with_accel(act, "<shift>space") # access point for the tray icon self.stop_after = act act = Action(name="AddBookmark", label=_("Add Bookmark"), icon_name=Icons.LIST_ADD) connect_obj(act, "activate", self.__add_bookmark, library.librarian, player) ag.add_action_with_accel(act, "<Primary>D") act = Action(name="EditBookmarks", label=_(u"Edit Bookmarks…")) connect_obj(act, "activate", self.__edit_bookmarks, library.librarian, player) ag.add_action_with_accel(act, "<Primary>B") act = Action(name="About", label=_("_About"), icon_name=Icons.HELP_ABOUT) connect_obj(act, "activate", self.__show_about, player) ag.add_action_with_accel(act, None) act = Action(name="OnlineHelp", label=_("Online Help"), icon_name=Icons.HELP_BROWSER) def website_handler(*args): util.website(const.ONLINE_HELP) act.connect("activate", website_handler) ag.add_action_with_accel(act, "F1") act = Action(name="SearchHelp", label=_("Search Help")) def search_help_handler(*args): util.website(const.SEARCH_HELP) act.connect("activate", search_help_handler) ag.add_action_with_accel(act, None) act = Action(name="RefreshLibrary", label=_("Re_fresh Library"), icon_name=Icons.VIEW_REFRESH) act.connect("activate", self.__rebuild, False) ag.add_action(act) act = ToggleAction(name="SongList", label=_("Song _List")) act.set_active(config.getboolean("memory", "songlist")) act.connect("activate", self.showhide_playlist) ag.add_action(act) act = ToggleAction(name="Queue", label=_("_Queue")) act.set_active(config.getboolean("memory", "queue")) act.connect("activate", self.showhide_playqueue) ag.add_action(act) current = config.get("memory", "browser") try: browsers.get(current) except ValueError: current = browsers.name(browsers.default) first_action = None for Kind in browsers.browsers: name = browsers.name(Kind) index = browsers.index(name) action_name = "View" + Kind.__name__ label = Kind.accelerated_name act = RadioAction(name=action_name, label=Kind.accelerated_name, value=index) act.join_group(first_action) first_action = first_action or act if name == current: act.set_active(True) ag.add_action(act) assert first_action def action_callback(view_action, current_action): current = browsers.name(browsers.get(current_action.get_current_value())) self.select_browser(view_action, current, library, player) first_action.connect("changed", action_callback) for Kind in browsers.browsers: if Kind.is_empty: continue action = "Browser" + Kind.__name__ label = Kind.accelerated_name act = Action(name=action, label=label) def browser_activate(action, Kind): LibraryBrowser.open(Kind, library, player) act.connect("activate", browser_activate, Kind) ag.add_action_with_accel(act, None) ui = Gtk.UIManager() ui.insert_action_group(ag, -1) ui.add_ui_from_string(MAIN_MENU % {"browsers": BrowseLibrary()}) self._filter_menu = FilterMenu(library, player, ui) menustr = MENU % {"views": ViewBrowser()} ui.add_ui_from_string(menustr) # Cute. So. UIManager lets you attach tooltips, but when they're # for menu items, they just get ignored. So here I get to actually # attach them. ui.get_widget("/Menu/Music/RefreshLibrary").set_tooltip_text(_("Check for changes in your library")) return ui
def test_index(self): self.assertEqual(browsers.browsers[browsers.index("SearchBar")], browsers.tracks.TrackList) self.assertEqual(browsers.browsers[browsers.index("FileSystem")], browsers.filesystem.FileSystem)
def __create_menu(self, player, library): def add_view_items(ag): act = Action(name="Information", label=_('_Information'), icon_name=Icons.DIALOG_INFORMATION) act.connect('activate', self.__current_song_info) ag.add_action(act) act = Action(name="Jump", label=_('_Jump to Playing Song'), icon_name=Icons.GO_JUMP) self.__jump_to_current(True, None, True) act.connect('activate', self.__jump_to_current) ag.add_action_with_accel(act, "<Primary>J") def add_top_level_items(ag): ag.add_action(Action(name="File", label=_("_File"))) ag.add_action(Action(name="Song", label=_("_Song"))) ag.add_action(Action(name="View", label=_('_View'))) ag.add_action(Action(name="Browse", label=_("_Browse"))) ag.add_action(Action(name="Control", label=_('_Control'))) ag.add_action(Action(name="Help", label=_('_Help'))) ag = Gtk.ActionGroup.new('QuodLibetWindowActions') add_top_level_items(ag) add_view_items(ag) act = Action(name="AddFolders", label=_(u'_Add a Folder…'), icon_name=Icons.LIST_ADD) act.connect('activate', self.open_chooser) ag.add_action_with_accel(act, "<Primary>O") act = Action(name="AddFiles", label=_(u'_Add a File…'), icon_name=Icons.LIST_ADD) act.connect('activate', self.open_chooser) ag.add_action(act) act = Action(name="AddLocation", label=_(u'_Add a Location…'), icon_name=Icons.LIST_ADD) act.connect('activate', self.open_location) ag.add_action(act) act = Action(name="BrowseLibrary", label=_('Open _Browser'), icon_name=Icons.EDIT_FIND) ag.add_action(act) act = Action(name="Preferences", label=_('_Preferences'), icon_name=Icons.PREFERENCES_SYSTEM) act.connect('activate', self.__preferences) ag.add_action(act) act = Action(name="Plugins", label=_('_Plugins'), icon_name=Icons.SYSTEM_RUN) act.connect('activate', self.__plugins) ag.add_action(act) act = Action(name="Quit", label=_('_Quit'), icon_name=Icons.APPLICATION_EXIT) act.connect('activate', lambda *x: self.destroy()) ag.add_action_with_accel(act, "<Primary>Q") act = Action(name="EditTags", label=_('Edit _Tags'), icon_name=Icons.DOCUMENT_PROPERTIES) act.connect('activate', self.__current_song_prop) ag.add_action(act) act = Action(name="EditBookmarks", label=_(u"Edit Bookmarks…")) connect_obj(act, 'activate', self.__edit_bookmarks, library.librarian, player) ag.add_action_with_accel(act, "<Primary>B") act = Action(name="Previous", label=_('Pre_vious'), icon_name=Icons.MEDIA_SKIP_BACKWARD) act.connect('activate', self.__previous_song) ag.add_action_with_accel(act, "<Primary>comma") act = Action(name="PlayPause", label=_('_Play'), icon_name=Icons.MEDIA_PLAYBACK_START) act.connect('activate', self.__play_pause) ag.add_action_with_accel(act, "<Primary>space") act = Action(name="Next", label=_('_Next'), icon_name=Icons.MEDIA_SKIP_FORWARD) act.connect('activate', self.__next_song) ag.add_action_with_accel(act, "<Primary>period") act = ToggleAction(name="StopAfter", label=_("Stop After This Song")) ag.add_action_with_accel(act, "<shift>space") # access point for the tray icon self.stop_after = act act = Action(name="Shortcuts", label=_("_Keyboard Shortcuts")) act.connect('activate', self.__keyboard_shortcuts) ag.add_action_with_accel(act, "<Primary>question") act = Action(name="About", label=_("_About"), icon_name=Icons.HELP_ABOUT) act.connect('activate', self.__show_about) ag.add_action_with_accel(act, None) act = Action(name="OnlineHelp", label=_("Online Help"), icon_name=Icons.HELP_BROWSER) def website_handler(*args): util.website(const.ONLINE_HELP) act.connect('activate', website_handler) ag.add_action_with_accel(act, "F1") act = Action(name="SearchHelp", label=_("Search Help")) def search_help_handler(*args): util.website(const.SEARCH_HELP) act.connect('activate', search_help_handler) ag.add_action_with_accel(act, None) act = Action(name="CheckUpdates", label=_("_Check for Updates…"), icon_name=Icons.NETWORK_SERVER) def check_updates_handler(*args): d = UpdateDialog(self) d.run() d.destroy() act.connect('activate', check_updates_handler) ag.add_action_with_accel(act, None) act = Action( name="RefreshLibrary", label=_("_Scan Library"), icon_name=Icons.VIEW_REFRESH) act.connect('activate', self.__rebuild, False) ag.add_action(act) current = config.get("memory", "browser") try: browsers.get(current) except ValueError: current = browsers.name(browsers.default) first_action = None for Kind in browsers.browsers: name = browsers.name(Kind) index = browsers.index(name) action_name = "View" + Kind.__name__ act = RadioAction(name=action_name, label=Kind.accelerated_name, value=index) act.join_group(first_action) first_action = first_action or act if name == current: act.set_active(True) ag.add_action_with_accel(act, "<Primary>%d" % ((index + 1) % 10,)) assert first_action self._browser_action = first_action def action_callback(view_action, current_action): current = browsers.name( browsers.get(current_action.get_current_value())) self._select_browser(view_action, current, library, player) first_action.connect("changed", action_callback) for Kind in browsers.browsers: action = "Browser" + Kind.__name__ label = Kind.accelerated_name name = browsers.name(Kind) index = browsers.index(name) act = Action(name=action, label=label) def browser_activate(action, Kind): LibraryBrowser.open(Kind, library, player) act.connect('activate', browser_activate, Kind) ag.add_action_with_accel(act, "<Primary><alt>%d" % ((index + 1) % 10,)) ui = Gtk.UIManager() ui.insert_action_group(ag, -1) menustr = MENU % { "views": browser_menu_items(), "browsers": secondary_browser_menu_items(), "filters_menu": FilterMenu.MENU } ui.add_ui_from_string(menustr) self._filter_menu = FilterMenu(library, player, ui) # Cute. So. UIManager lets you attach tooltips, but when they're # for menu items, they just get ignored. So here I get to actually # attach them. ui.get_widget("/Menu/File/RefreshLibrary").set_tooltip_text( _("Check for changes in your library")) return ui
def test_index(self): self.assertEqual(browsers.browsers[browsers.index("EmptyBar")], browsers.empty.EmptyBar) self.assertEqual(browsers.browsers[browsers.index("FileSystem")], browsers.filesystem.FileSystem)