Ejemplo n.º 1
0
    def __init__(self, library, player, ui=None):
        self._browser = None
        self._library = library
        self._player = player
        self._standalone = not ui

        ag = Gtk.ActionGroup.new('QuodLibetFilterActions')
        for name, icon_name, label, cb in [
                ('Filters', "", _("_Filters"), None),
                ("PlayedRecently", Icons.EDIT_FIND, _("Recently _Played"),
                 self.__filter_menu_actions),
                ("AddedRecently", Icons.EDIT_FIND, _("Recently _Added"),
                 self.__filter_menu_actions),
                ("TopRated", Icons.EDIT_FIND, _("_Top 40"),
                 self.__filter_menu_actions),
                ("All", Icons.EDIT_FIND, _("All _Songs"),
                 self.__filter_menu_actions)]:
            action = Action(name=name, icon_name=icon_name, label=label)
            if cb:
                action.connect('activate', cb)
            ag.add_action(action)

        for tag_, lab in [
            ("genre", _("On Current _Genre(s)")),
            ("artist", _("On Current _Artist(s)")),
            ("album", _("On Current Al_bum"))]:
            act = Action(
                name="Filter%s" % util.capitalize(tag_), label=lab,
                icon_name=Icons.EDIT_SELECT_ALL)
            act.connect('activate', self.__filter_on, tag_, None, player)
            ag.add_action(act)

        for (tag_, accel, label) in [
            ("genre", "G", _("Random _Genre")),
            ("artist", "T", _("Random _Artist")),
            ("album", "M", _("Random Al_bum"))]:
            act = Action(name="Random%s" % util.capitalize(tag_),
                         label=label, icon_name=Icons.DIALOG_QUESTION)
            act.connect('activate', self.__random, tag_)
            ag.add_action_with_accel(act, "<Primary>" + accel)

        if self._standalone:
            ui = Gtk.UIManager()
            ui.add_ui_from_string(self.__OUTER_MENU)
        ui.insert_action_group(ag, -1)
        self._ui = ui

        self._get_child_widget("TopRated").set_tooltip_text(
                _("The 40 songs you've played most (more than 40 may "
                  "be chosen if there are ties)"))

        # https://git.gnome.org/browse/gtk+/commit/?id=b44df22895c79
        menu_item = self._get_child_widget('/Menu/Filters')
        if isinstance(menu_item, Gtk.ImageMenuItem):
            menu_item.set_image(None)

        self._player_id = player.connect("song-started", self._on_song_started)
        self.set_song(player.song)

        self._hide_menus()
Ejemplo n.º 2
0
        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")
Ejemplo n.º 3
0
 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')))
Ejemplo n.º 4
0
    def __init__(self, library, player, ui=None):
        self._browser = None
        self._library = library
        self._player = player

        ag = Gtk.ActionGroup.new('QuodLibetFilterActions')
        for name, icon_name, label, cb in [
            ('Filters', "", _("_Filters"), None),
            ("PlayedRecently", Icons.EDIT_FIND, _("Recently _Played"),
             self.__filter_menu_actions),
            ("AddedRecently", Icons.EDIT_FIND, _("Recently _Added"),
             self.__filter_menu_actions),
            ("TopRated", Icons.EDIT_FIND, _("_Top 40"),
             self.__filter_menu_actions),
            ("All", Icons.EDIT_FIND, _("All _Songs"),
             self.__filter_menu_actions)
        ]:
            action = Action(name=name, icon_name=icon_name, label=label)
            if cb:
                action.connect('activate', cb)
            ag.add_action(action)

        for tag_, lab in [("genre", _("Filter on _Genre")),
                          ("artist", _("Filter on _Artist")),
                          ("album", _("Filter on Al_bum"))]:
            act = Action(name="Filter%s" % util.capitalize(tag_),
                         label=lab,
                         icon_name=Icons.EDIT_SELECT_ALL)
            act.connect('activate', self.__filter_on, tag_, None, player)
            ag.add_action(act)

        for (tag_, accel, label) in [("genre", "G", _("Random _Genre")),
                                     ("artist", "T", _("Random _Artist")),
                                     ("album", "M", _("Random Al_bum"))]:
            act = Action(name="Random%s" % util.capitalize(tag_),
                         label=label,
                         icon_name=Icons.DIALOG_QUESTION)
            act.connect('activate', self.__random, tag_)
            ag.add_action_with_accel(act, "<Primary>" + accel)

        ui = ui or Gtk.UIManager()
        ui.insert_action_group(ag, -1)
        ui.add_ui_from_string(self._MENU)
        self._ui = ui

        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)"))

        # https://git.gnome.org/browse/gtk+/commit/?id=b44df22895c79
        menu_item = ui.get_widget("/Menu/Filters")
        if isinstance(menu_item, Gtk.ImageMenuItem):
            menu_item.set_image(None)

        self._player_id = player.connect("song-started", self._on_song_started)
        self.set_song(player.song)

        self._hide_menus()
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
    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