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


Python CoverLocale.switch_locale方法代码示例

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


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

示例1: set_tooltip

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
 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,代码行数:9,代码来源:coverart_widgets.py

示例2: __init__

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:31,代码来源:coverart_controllers.py

示例3: artist_info_ready

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:37,代码来源:coverart_artistinfo.py

示例4: __init__

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:28,代码来源:coverart_controllers.py

示例5: __init__

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:32,代码来源:coverart_controllers.py

示例6: __init__

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
        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,代码行数:33,代码来源:coverart_browser_source.py

示例7: _create_menu

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:37,代码来源:coverart_browser.py

示例8: get_current_description

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
 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,代码行数:9,代码来源:coverart_controllers.py

示例9: _update_options

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:29,代码来源:coverart_controllers.py

示例10: do_activate

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:61,代码来源:coverart_browser.py

示例11: _toolbar

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:58,代码来源:coverart_browser_source.py

示例12: load_tmpl

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    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,代码行数:13,代码来源:coverart_artistinfo.py

示例13: __init__

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    def __init__(self, plugin, mainbox, controllers):
        super(Toolbar, self).__init__()

        self.plugin = plugin
        self.mainbox = mainbox
        cl = CoverLocale()

        ui_file = rb.find_plugin_file(plugin, self.ui)

        # create the toolbar
        builder = Gtk.Builder()
        builder.set_translation_domain(cl.Locale.LOCALE_DOMAIN)
        print (ui_file)
        builder.add_from_file(ui_file)

        # assign the controllers to the buttons
        for button, controller in controllers.items():
            if button != 'search':
                builder.get_object(button).controller = controller

        if not webkit_support():
            # button = builder.get_object('flowview_button')
            #button.set_visible(False)
            separator = builder.get_object('properties_separator')
            if separator:
                separator.set_visible(False)

        # workaround to translate the search entry tooltips
        cl.switch_locale(cl.Locale.RB)
        search_entry = SearchEntry(has_popup=True)
        search_entry.show_all()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        # add it to the ui
        align = builder.get_object('entry_search_alignment')
        align.add(search_entry)

        # assign the controller
        search_entry.controller = controllers['search']

        Theme(self.plugin).connect('theme_changed', self._theme_changed,
                                   controllers)

        self.builder = builder.get_object('toolbar')

        # now theme the toolbar including child objects such as the button popups
        style_context = self.builder.get_style_context()
        style_context.add_class(Gtk.STYLE_CLASS_TOOLBAR)

        view_button = builder.get_object(ToolbarObject.VIEW)
        view_button.set_visible(not self.plugin.using_headerbar)
开发者ID:fossfreedom,项目名称:coverart-browser,代码行数:53,代码来源:coverart_toolbar.py

示例14: on_artist_treeview_selection_changed

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    def on_artist_treeview_selection_changed(self, view):
        model, artist_iter = view.get_selected()
        if artist_iter:
            artist = model[artist_iter][0]

            cl = CoverLocale()
            cl.switch_locale(cl.Locale.RB)
            #. TRANSLATORS - "All" is used in the context of "All artist names"
            if artist == _('All'):
                self.album_manager.model.remove_filter('quick_artist')
            else:
                self.album_manager.model.replace_filter('quick_artist', artist)

            cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
开发者ID:Hunsu,项目名称:coverart-browser,代码行数:16,代码来源:coverart_browser_source.py

示例15: __init__

# 需要导入模块: from coverart_browser_prefs import CoverLocale [as 别名]
# 或者: from coverart_browser_prefs.CoverLocale import switch_locale [as 别名]
    def __init__(self, plugin, parent, savedir=None):
        """Initializes and shows the cover

        :param plugin: source
        :type plugin: RBSource
        :param parent: Parent window to attach to
        :type parent: Gtk.Window
        :param savedir: Initial directory for the Save As functionality
        :type savedir: basestring
        """

        super(CoverWindow, self).__init__()
        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
        self.builder = Gtk.Builder()
        self.builder.add_from_file(rb.find_plugin_file(plugin,
                                                       'ui/coverart_window.ui'))
        self.builder.connect_signals(self)

        self.cover_window = self.builder.get_object('CoverWindow')
        self.cover_window.connect('destroy', self.send_destroy_signal)
        self.layout = self.builder.get_object('layout')
        self.toolbar = self.builder.get_object('toolbar')
        self.save_as_button = self.builder.get_object('save_as_button')
        self.zoom_in_button = self.builder.get_object('zoom_in_button')
        self.zoom_out_button = self.builder.get_object('zoom_out_button')
        self.zoom_100_button = self.builder.get_object('zoom_100_button')
        self.zoom_fit_button = self.builder.get_object('zoom_fit_button')
        self.close_button = self.builder.get_object('close_button')
        self.image = self.builder.get_object('image')
        self.statusbar = self.builder.get_object('statusbar')
        self.scrolledwindow = self.builder.get_object('scrolledwindow')
        self.scrolledwindow.set_hadjustment(self.layout.get_hadjustment())
        self.scrolledwindow.set_vadjustment(self.layout.get_vadjustment())

        self.savedir = savedir

        if parent:
            self.cover_window.set_transient_for(parent)
        self.cover_window_width = 500
        self.cover_window_height = 500 + self.toolbar.size_request().height + \
                                   self.statusbar.size_request().height
        self.cover_window.set_default_size(self.cover_window_width, \
                                           self.cover_window_height)

        self.min_percent = 1
        self.max_percent = 500
        self.ratio = 1.5
        self.image_interp = GdkPixbuf.InterpType.BILINEAR
        self.image_fitted = True
开发者ID:aldimic,项目名称:coverart-browser,代码行数:52,代码来源:coverart_window.py


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