Exemplo n.º 1
0
    def _init_collectors_and_menu(self, submenu):
        import_item = Gtk.MenuItem(label=_("Import"))
        connect_obj(import_item, 'activate',
                    self.__set_import_export_option_index, -1)

        submenu.append(import_item)
        submenu.append(SeparatorMenuItem())

        for idx, (name, query) in enumerate(EXPORT_OPTIONS):
            collector = track_data_collector_for(query)
            self._export_collectors.append(collector)

            item = Gtk.MenuItem(label=name)
            connect_obj(item, 'activate',
                        self.__set_import_export_option_index, idx)
            submenu.append(item)

        submenu.append(SeparatorMenuItem())
        open_dir_item = Gtk.MenuItem(label=_("Open Export Directory"))

        def open_export_dir(_):
            show_files(path2fsn(EXPORT_DIR_PATH),
                       [path2fsn(TAGS_AND_USERDATA_INDEX_FILE_PATH.name)])

        connect_obj(open_dir_item, 'activate', open_export_dir, None)
        submenu.append(open_dir_item)
Exemplo n.º 2
0
    def __init__(self, songs, library, label=_("_Rating")):
        super(RatingsMenuItem, self).__init__(label=label, use_underline=True)
        self._songs = songs
        image = Gtk.Image.new_from_icon_name(Icons.FAVORITE, Gtk.IconSize.MENU)
        image.show()
        self.set_image(image)

        submenu = Gtk.Menu()
        self.set_submenu(submenu)
        self._rating_menu_items = []
        for i in RATINGS.all:
            text = "%0.2f\t%s" % (i, util.format_rating(i))
            itm = Gtk.CheckMenuItem(label=text)
            itm.rating = i
            submenu.append(itm)
            handler = itm.connect('toggled', self._on_rating_change, i,
                                  library)
            self._rating_menu_items.append((itm, handler))
        reset = Gtk.MenuItem(label=_("_Remove Rating"), use_underline=True)
        reset.connect('activate', self._on_rating_remove, library)
        self._select_ratings()

        submenu.append(SeparatorMenuItem())
        submenu.append(reset)
        submenu.show_all()
Exemplo n.º 3
0
 def __init__(self, songs, library, label=_("_Rating")):
     super(RatingsMenuItem, self).__init__(label=label, use_underline=True)
     submenu = Gtk.Menu()
     self.set_submenu(submenu)
     for i in RATINGS.all:
         itm = Gtk.MenuItem(label="%0.2f\t%s" % (i, util.format_rating(i)))
         submenu.append(itm)
         connect_obj(itm, 'activate', self.set_rating, i, songs, library)
     reset = Gtk.MenuItem(label=_("_Remove rating"), use_underline=True)
     connect_obj(reset, 'activate', self.remove_rating, songs, library)
     submenu.append(SeparatorMenuItem())
     submenu.append(reset)
     submenu.show_all()
Exemplo n.º 4
0
    def __init__(self, songs, library, label=_("_Rating")):
        super(RatingsMenuItem, self).__init__(label=label, use_underline=True)
        self.set_songs(songs)

        submenu = Gtk.Menu()
        self.set_submenu(submenu)
        for i in RATINGS.all:
            itm = Gtk.MenuItem(label="%0.2f\t%s" % (i, util.format_rating(i)))
            submenu.append(itm)
            itm.connect('activate', self._on_rating_change, i, library)
        reset = Gtk.MenuItem(label=_("_Remove Rating"), use_underline=True)
        reset.connect('activate', self._on_rating_remove, library)

        submenu.append(SeparatorMenuItem())
        submenu.append(reset)
        submenu.show_all()
Exemplo n.º 5
0
    def __init__(self, songs):
        super(PlaylistMenu, self).__init__()
        i = Gtk.MenuItem(label=_(u"_New Playlist…"), use_underline=True)
        i.connect('activate', self._on_new_playlist_activate, songs)
        self.append(i)
        self.append(SeparatorMenuItem())
        self.set_size_request(int(i.size_request().width * 2), -1)

        for playlist in PlaylistsBrowser.playlists():
            name = playlist.name
            i = Gtk.CheckMenuItem(name)
            some, all = playlist.has_songs(songs)
            i.set_active(some)
            i.set_inconsistent(some and not all)
            i.get_child().set_ellipsize(Pango.EllipsizeMode.END)
            i.connect(
                'activate', self._on_toggle_playlist_activate, playlist, songs)
            self.append(i)
Exemplo n.º 6
0
    def __init__(self, songs, library, label=_("_Rating")):
        super(RatingsMenuItem, self).__init__(label=label, use_underline=True)
        self._songs = songs
        ratings = {song("~#rating") for song in songs if song.has_rating}

        submenu = Gtk.Menu()
        self.set_submenu(submenu)
        for i in RATINGS.all:
            text = "%0.2f\t%s" % (i, util.format_rating(i))
            itm = Gtk.CheckMenuItem(label=text)
            is_selected = i in ratings
            itm.set_active(is_selected)
            submenu.append(itm)
            itm.connect('activate', self._on_rating_change, i, library)
        reset = Gtk.MenuItem(label=_("_Remove Rating"), use_underline=True)
        reset.connect('activate', self._on_rating_remove, library)

        submenu.append(SeparatorMenuItem())
        submenu.append(reset)
        submenu.show_all()