当前位置: 首页>>代码示例>>Python>>正文


Python coverart_browser_prefs.CoverLocale类代码示例

本文整理汇总了Python中coverart_browser_prefs.CoverLocale的典型用法代码示例。如果您正苦于以下问题:Python CoverLocale类的具体用法?Python CoverLocale怎么用?Python CoverLocale使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CoverLocale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_album_info

    def fetch_album_info(self, artist, album, index):
        print("start fetch_album_info")
        cl = CoverLocale()
        lang = cl.get_locale()[:2]
        qartist = urllib.parse.quote_plus(artist)
        qalbum = urllib.parse.quote_plus(album)
        self.fetched = 2

        def fetch_information(lang):
            cachekey = "lastfm:album:getinfojson:%s:%s:%s" % (qartist, qalbum, lang)
            url = "%s?method=album.getinfo&artist=%s&album=%s&api_key=%s&format=json&lang=%s" % (
                LastFM.API_URL,
                qartist,
                qalbum,
                LastFM.API_KEY,
                lang,
            )
            print(url)

            self.info_cache.fetch(cachekey, url, self.parse_album_info, album, index, lang)

        self.album_data = {}
        fetch_information("en")
        fetch_information(lang)
        print("end fetch_album_info")
开发者ID:fossfreedom,项目名称:coverart-browser,代码行数:25,代码来源:coverart_artistinfo.py

示例2: __init__

    def __init__(self, plugin, viewmgr):
        super(SortPopupController, self).__init__()

        self._viewmgr = viewmgr
        self.plugin = plugin
        # sorts dictionary
        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        self.values = OrderedDict(
            [
                (_("Sort by album name"), "name"),
                (_("Sort by album artist"), "artist"),
                (_("Sort by year"), "year"),
                (_("Sort by rating"), "rating"),
            ]
        )

        self.options = list(self.values.keys())

        # get the current sort key and initialise the superclass
        gs = GSetting()
        source_settings = gs.get_setting(gs.Path.PLUGIN)
        value = source_settings[gs.PluginKey.SORT_BY]

        self._spritesheet = None
        self.update_images(False)

        self.current_key = list(self.values.keys())[list(self.values.values()).index(value)]
开发者ID:jrbastien,项目名称:coverart-browser,代码行数:29,代码来源:coverart_controllers.py

示例3: __init__

    def __init__(self, plugin, album_model):
        super(SortPopupController, self).__init__()

        self._album_model = album_model
        self.plugin = plugin
        # sorts dictionary
        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        self.values = OrderedDict([(_('Sort by album name'), 'name'),
            (_('Sort by album artist'), 'artist'),
            (_('Sort by year'), 'year'),
            (_('Sort by rating'), 'rating')])

        self.options = self.values.keys()
        
        # get the current sort key and initialise the superclass
        gs = GSetting()
        source_settings = gs.get_setting(gs.Path.PLUGIN)
        value = source_settings[gs.PluginKey.SORT_BY]

        self._spritesheet = None
        self.update_images(False)
        
        self.current_key = self.values.keys()[
            self.values.values().index(value)]
开发者ID:Jeff1981,项目名称:coverart-browser,代码行数:26,代码来源:coverart_controllers.py

示例4: __init__

    def __init__(self, plugin, album_model):
        super(GenrePopupController, self).__init__()

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        self._album_model = album_model

        shell = plugin.shell
        self.plugin = plugin

        # create a new property model for the genres
        genres_model = RB.RhythmDBPropertyModel.new(shell.props.db,
            RB.RhythmDBPropType.GENRE)

        query = shell.props.library_source.props.base_query_model
        genres_model.props.query_model = query

        # initial genre
        self._initial_genre = _('All Genres')

        self._spritesheet = None
        self._default_image = None
        self._unrecognised_image = None

        self._connect_properties()
        self._connect_signals(query, genres_model)
        
        # generate initial popup
        self._update_options(genres_model)
开发者ID:Hunsu,项目名称:coverart-browser,代码行数:30,代码来源:coverart_controllers.py

示例5: get_similar_info

    def get_similar_info(self):
        """
        Returns the dictionary { 'images', 'bio' }
        """
        cl = CoverLocale()
        lang = cl.get_locale()[:2]

        try:
            if not self.artist["similar_" + lang]["parsed"]:
                json_artists_data = self.artist["similar_" + lang]["data"]["similarartists"]

                results = []
                print(json_artists_data)
                for json_artist in json_artists_data["artist"]:
                    print(json_artist)
                    name = json_artist["name"]
                    image_url = json_artist["image"][1]["#text"]
                    similarity = int(100 * float(json_artist["match"]))

                    results.append({"name": name, "image_url": image_url, "similarity": similarity})

                self.artist["similar_" + lang]["data"] = results
                self.artist["similar_" + lang]["parsed"] = True

            return self.artist["similar_" + lang]["data"]
        except Exception as e:
            print("Error parsing similar_infot: %s" % e)
            return ""
开发者ID:fossfreedom,项目名称:coverart-browser,代码行数:28,代码来源:coverart_artistinfo.py

示例6: __init__

        def __init__(self, shell):
            '''
            Initializes the singleton interface, assigning all the constants
            used to access the plugin's settings.
            '''
            super(Views._impl, self).__init__()

            from coverart_covericonview import CoverIconView
            from coverart_coverflowview import CoverFlowView
            from coverart_artistview import ArtistView
            from coverart_listview import ListView
            from coverart_browser_prefs import webkit_support

            library_name = shell.props.library_source.props.name
            
            self._values = OrderedDict()
            
            cl = CoverLocale()
            cl.switch_locale(cl.Locale.LOCALE_DOMAIN)        

            self._values[CoverIconView.name] = [_('Tiles'), 
                GLib.Variant.new_string('coverart-browser-tile')]
            if webkit_support():
                self._values[CoverFlowView.name] = [_('Flow'), 
                GLib.Variant.new_string('coverart-browser-coverflow')]
            self._values[ArtistView.name] = [_('Artist'), 
                GLib.Variant.new_string('coverart-browser-artist')]
            self._values[ListView.name] = [library_name, 
                GLib.Variant.new_string('coverart-browser-list')]
            cl.switch_locale(cl.Locale.RB)   
            print (self._values)     
开发者ID:Hunsu,项目名称:coverart-browser,代码行数:31,代码来源:coverart_browser_source.py

示例7: artist_info_ready

    def artist_info_ready(self, ds):
        # Can only be called after the artist-info-ready signal has fired.
        # If called any other time, the behavior is undefined
        # try:
        info = ds.get_artist_info()

        small, med, big = info["images"] or (None, None, None)
        summary, full_bio = info["bio"] or (None, None)

        link_album = self.link_ds.get_album()
        if not link_album:
            link_album = ""

        links = self.link_ds.get_album_links()
        if not links:
            links = {}

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        self.file = self.template.render(
            artist=ds.get_current_artist(),
            error=ds.get_error(),
            image=med,
            fullbio=full_bio,
            shortbio=summary,
            datasource=lastfm_datasource_link(self.basepath),
            stylesheet=self.styles,
            album=link_album,
            art_links=self.link_ds.get_artist_links(),
            alb_links=links,
            link_images=self.link_images,
            similar=ds.get_similar_info(),
        )
        self.load_view()
开发者ID:fossfreedom,项目名称:coverart-browser,代码行数:35,代码来源:coverart_artistinfo.py

示例8: get_artist_bio

    def get_artist_bio(self):
        """
        Returns tuple of summary and full bio
        """
        cl = CoverLocale()
        lang = cl.get_locale()[:2]

        def get_bio(lang):
            data = self.artist["info_" + lang]["data"]
            if data is None:
                return None

            if not self.artist["info_" + lang]["parsed"]:
                content = data["artist"]["bio"]["content"]
                summary = data["artist"]["bio"]["summary"]
                return summary, content

            if lang != "en":
                return None
            else:
                return self.artist["info_" + lang]["data"]["bio"]

        arg = get_bio(lang)
        if not arg or arg[0] == "":
            arg = get_bio("en")

        return arg
开发者ID:fossfreedom,项目名称:coverart-browser,代码行数:27,代码来源:coverart_artistinfo.py

示例9: get_current_description

 def get_current_description(self):
     cl = CoverLocale()
     cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
     if self.current_key == self._initial_genre:
         return _('All Genres')
     else:
         return self.current_key
开发者ID:aldimic,项目名称:coverart-browser,代码行数:7,代码来源:coverart_controllers.py

示例10: _update_options

    def _update_options(self, *args):
        genres_model = args[-1]

        self.update_images(False)

        still_exists = False

        # retrieve the options
        options = []
        row_num = 0
        for row in genres_model:
            if row_num == 0:
                cl = CoverLocale()
                cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
                genre = _('All Genres')
                row_num = row_num + 1
            else:
                genre = row[0]

            options.append(genre)

            still_exists = still_exists or genre == self.current_key

        self.options = options

        self.current_key = self.current_key if still_exists else \
            self._initial_genre
开发者ID:aldimic,项目名称:coverart-browser,代码行数:27,代码来源:coverart_controllers.py

示例11: set_tooltip

 def set_tooltip(self, val):
     cl = CoverLocale()
     cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
     if not val:
         self.set_tooltip_text(_('Sort in descending order'))
     else:
         self.set_tooltip_text(_('Sort in ascending order'))
开发者ID:fossfreedom,项目名称:cb_dev,代码行数:7,代码来源:coverart_widgets.py

示例12: _create_menu

    def _create_menu(self):
        app = Gio.Application.get_default()
        self.app_id = 'coverart-browser'

        self.locations = ['library-toolbar', 'queue-toolbar']
        action_name = 'coverart-browser-views'
        self.action = Gio.SimpleAction.new_stateful(
            action_name, GLib.VariantType.new('s'),
            self._views.get_action_name(ListView.name)
        )
        self.action.connect("activate", self.view_change_cb)
        app.add_action(self.action)

        menu_item = Gio.MenuItem()
        section = Gio.Menu()
        menu = Gio.Menu()
        toolbar_item = Gio.MenuItem()

        for view_name in self._views.get_view_names():
            menu_item.set_label(self._views.get_menu_name(view_name))
            menu_item.set_action_and_target_value(
                'app.' + action_name, self._views.get_action_name(view_name)
            )
            section.append_item(menu_item)

        menu.append_section(None, section)

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
        toolbar_item.set_label(_('Views'))
        cl.switch_locale(cl.Locale.RB)

        toolbar_item.set_submenu(menu)
        for location in self.locations:
            app.add_plugin_menu_item(location, self.app_id, toolbar_item)
开发者ID:jrbastien,项目名称:coverart-browser,代码行数:35,代码来源:coverart_browser.py

示例13: do_activate

    def do_activate(self):
        '''
        Called by Rhythmbox when the plugin is activated. It creates the
        plugin's source and connects signals to manage the plugin's
        preferences.
        '''

        print("CoverArtBrowser DEBUG - do_activate")
        self.shell = self.object
        self.db = self.shell.props.db

        try:
            entry_type = CoverArtBrowserEntryType()
            self.db.register_entry_type(entry_type)
        except NotImplementedError:
            entry_type = self.db.entry_register_type(
                'CoverArtBrowserEntryType')

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        entry_type.category = RB.RhythmDBEntryCategory.NORMAL
        
        group = RB.DisplayPageGroup.get_by_id('library')
        # load plugin icon
        theme = Gtk.IconTheme.get_default()
        rb.append_plugin_source_path(theme, '/icons')

        # lets assume that python3 versions of RB only has the new icon attribute in the source
        if rb3compat.PYVER >=3:
                iconfile = Gio.File.new_for_path(
                    rb.find_plugin_file(self, 'img/' + Theme(self).current\
                    + '/covermgr.png'))
                    
                self.source = CoverArtBrowserSource(
                        shell=self.shell,
                        name=_("CoverArt"), 
                        entry_type=entry_type,
                        plugin=self,
                        icon=Gio.FileIcon.new(iconfile), 
                        query_model=self.shell.props.library_source.props.base_query_model)
        else:
                what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
                pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                    rb.find_plugin_file(self, 'img/' + Theme(self).current\
                    + '/covermgr.png'), width, height)

                self.source = CoverArtBrowserSource(
                        shell=self.shell,
                        name=_("CoverArt"), entry_type=entry_type,
                        plugin=self, pixbuf=pxbf,
                        query_model=self.shell.props.library_source.props.base_query_model)
                    
        self.shell.register_entry_type_for_source(self.source, entry_type)
        self.shell.append_display_page(self.source, group)

        self.source.props.query_model.connect('complete', self.load_complete)

        print("CoverArtBrowser DEBUG - end do_activate")
开发者ID:coolono,项目名称:coverart-browser,代码行数:59,代码来源:coverart_browser.py

示例14: _toolbar

    def _toolbar(self, ui):
        '''
        setup toolbar ui - called for sidebar and main-view
        '''
        print "CoverArtBrowser DEBUG - _toolbar"

        # dialog has not been created so lets do so.
        cl = CoverLocale()

        # get widgets for main icon-view
        # the first part is to first remove the current search-entry
        # before recreating it again - we have to do this to ensure
        # the locale is set correctly i.e. the overall ui is coverart
        # locale but the search-entry uses rhythmbox translation
        align = ui.get_object('entry_search_alignment')
        align.remove(align.get_child())
        cl.switch_locale(cl.Locale.RB)
        self.search_entry = RB.SearchEntry(has_popup=True)
        align.add(self.search_entry)
        align.show_all()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        self.search_entry.connect('search', self.searchchanged_callback)
        self.search_entry.connect('show-popup',
            self.search_show_popup_callback)

        self.sort_by = ui.get_object('sort_by')
        self.sort_by.initialise(self.plugin, self.shell,
            self.sorting_criteria_changed)
        self.sort_order_button = ui.get_object('sort_order')
        self.sort_order_button.initialise(self.plugin,
            self.sorting_direction_changed, self.sort_order)

        # get widget for search and apply some workarounds
        search_entry = ui.get_object('search_entry')
        search_entry.set_placeholder(_('Search album'))
        search_entry.show_all()
        self.search_entry.set_placeholder(ui.get_object(
            'filter_all_menu_item').get_label())

        # genre
        genre_button = ui.get_object('genre_button')
        genre_button.initialise(self.plugin, self.shell,
            self.genre_filter_callback)

        # get playlist popup
        playlist_button = ui.get_object('playlist_button')
        playlist_button.initialise(self.plugin, self.shell,
            self.filter_by_model)

        # decade
        decade_button = ui.get_object('decade_button')
        decade_button.initialise(self.plugin, self.shell,
            self.decade_filter_callback)

        print "CoverArtBrowser DEBUG - end _toolbar"
开发者ID:fossfreedom,项目名称:cb_dev,代码行数:56,代码来源:coverart_browser_source.py

示例15: load_tmpl

    def load_tmpl(self):
        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        path = rb.find_plugin_file(self.plugin, "tmpl/artist-tmpl.html")
        empty_path = rb.find_plugin_file(self.plugin, "tmpl/artist_empty-tmpl.html")
        loading_path = rb.find_plugin_file(self.plugin, "tmpl/loading.html")
        self.template = Template(filename=path)
        self.loading_template = Template(filename=loading_path)
        self.empty_template = Template(filename=empty_path)
        self.styles = self.basepath + "/tmpl/artistmain.css"
开发者ID:fossfreedom,项目名称:coverart-browser,代码行数:11,代码来源:coverart_artistinfo.py


注:本文中的coverart_browser_prefs.CoverLocale类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。