本文整理汇总了Python中coverart_browser_prefs.GSetting类的典型用法代码示例。如果您正苦于以下问题:Python GSetting类的具体用法?Python GSetting怎么用?Python GSetting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GSetting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_notify_view_name
def on_notify_view_name(self, *args):
if self._lastview and self.view_name != self._lastview:
selected = self._views[self._lastview].get_selected_objects()
current_album = None
if len(selected) > 0:
current_album = self._views[self._lastview].get_selected_objects()[0]
self.window.remove(self._views[self._lastview].view)
self.window.add(self._views[self.view_name].view)
self.window.show_all()
self.click_count = 0
self._views[self._lastview].panedposition = self.source.paned.get_expansion_status()
self._views[self.view_name].switch_to_view(self.source, current_album)
self.source.paned.expand(self._views[self.view_name].panedposition)
self._lastview = self.view_name
self.current_view.set_popup_menu(self.source.popup_menu)
self.source.album_manager.current_view = self.current_view
gs = GSetting()
setting = gs.get_setting(gs.Path.PLUGIN)
setting[gs.PluginKey.VIEW_NAME] = self.view_name
self.emit('new-view')
示例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)]
示例3: __init__
def __init__(self, *args, **kwargs):
'''
Initializes the button.
'''
Gtk.RadioButton.__init__(self, *args, **kwargs)
OptionsWidget.__init__(self, *args, **kwargs)
gs = GSetting()
setting = gs.get_setting(gs.Path.PLUGIN)
setting.bind(gs.PluginKey.BUTTON_RELIEF, self,
'button_relief', Gio.SettingsBindFlags.GET)
self.connect('notify::button-relief',
self.on_notify_button_relief)
# initialise some variables
self.image_display = False
self.initialised = False
#ensure button appearance rather than standard radio toggle
self.set_mode(False)
#label colours
self._not_active_colour = None
self._active_colour = None
示例4: initialise
def initialise(self, plugin, shell, callback):
'''
extend the default initialise function
because we need to also resize the picture
associated with the sort button as well as find the
saved sort order
'''
if self.is_initialised:
return
self._spritesheet = ConfiguredSpriteSheet(plugin, 'sort')
gs = GSetting()
source_settings = gs.get_setting(gs.Path.PLUGIN)
source_settings.bind(gs.PluginKey.SORT_BY,
self, 'sort_by', Gio.SettingsBindFlags.DEFAULT)
super(SortPopupButton, self).initialise(shell, callback,
self.sorts[self.sort_by])
# create the pop up menu
for key, text in sorted(self.sorts.iteritems()):
self.add_menuitem(text, self._sort_changed, key)
self._sort_changed(None, self.sort_by)
示例5: __init__
def __init__(self, plugin, viewmgr):
super(ArtistSortPopupController, 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_artist'),
(_('Sort by year'), 'year_artist'),
(_('Sort by rating'), 'rating_artist')])
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_ARTIST]
if value not in list(self.values.values()):
print ("here")
value = 'name_artist'
source_settings[gs.PluginKey.SORT_BY_ARTIST]=value
self._spritesheet = None
self.update_images(False)
self.current_key = list(self.values.keys())[
list(self.values.values()).index(value)]
print (self.current_key)
示例6: __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)]
示例7: display_columns
def display_columns(self):
self.col_map = OrderedDict([
('track-number', RB.EntryViewColumn.TRACK_NUMBER),
('title', RB.EntryViewColumn.TITLE),
('genre', RB.EntryViewColumn.GENRE),
('artist', RB.EntryViewColumn.ARTIST),
('album', RB.EntryViewColumn.ALBUM),
('composer', RB.EntryViewColumn.COMPOSER),
('date', RB.EntryViewColumn.YEAR),
('duration', RB.EntryViewColumn.DURATION),
('bitrate', RB.EntryViewColumn.QUALITY),
('play-count', RB.EntryViewColumn.PLAY_COUNT),
('beats-per-minute', RB.EntryViewColumn.BPM),
('comment', RB.EntryViewColumn.COMMENT),
('location', RB.EntryViewColumn.LOCATION),
('rating', RB.EntryViewColumn.RATING),
('last-played', RB.EntryViewColumn.LAST_PLAYED),
('first-seen', RB.EntryViewColumn.FIRST_SEEN)
])
for entry in self.col_map:
visible = True if entry == 'title' else False
self.append_column(self.col_map[entry], visible)
# connect the visible-columns global setting to update our entryview
gs = GSetting()
rhythm_settings = gs.get_setting(gs.Path.RBSOURCE)
rhythm_settings.connect('changed::visible-columns',
self.on_visible_columns_changed)
self.on_visible_columns_changed(rhythm_settings, 'visible-columns')
示例8: do_action
def do_action(self):
sort = self.values[self.current_key]
gs = GSetting()
settings = gs.get_setting(gs.Path.PLUGIN)
settings[gs.PluginKey.SORT_BY_ARTIST] = sort
self._viewmgr.current_view.get_default_manager().emit('sort', "artist")
示例9: do_action
def do_action(self):
sort = self.values[self.current_key]
gs = GSetting()
settings = gs.get_setting(gs.Path.PLUGIN)
settings[gs.PluginKey.SORT_BY] = sort
self._album_model.sort(sort)
示例10: __init__
def __init__(self, *args, **kwargs):
super(EnhancedButton, self).__init__(*args, **kwargs)
gs = GSetting()
setting = gs.get_setting(gs.Path.PLUGIN)
setting.bind(gs.PluginKey.BUTTON_RELIEF, self, "button_relief", Gio.SettingsBindFlags.GET)
self.connect("notify::button-relief", self.on_notify_button_relief)
示例11: _connect_properties
def _connect_properties(self):
gs = GSetting()
setting = gs.get_setting(gs.Path.PLUGIN)
setting.bind(
gs.PluginKey.USE_FAVOURITES,
self,
'favourites',
Gio.SettingsBindFlags.DEFAULT)
示例12: play_random_album_menu_item_callback
def play_random_album_menu_item_callback(self, favourites=False):
print('''CoverArtBrowser DEBUG - play_random_album_menu_item_callback''')
query_model = RB.RhythmDBQueryModel.new_empty(self.shell.props.db)
num_albums = len(self.album_manager.model.store)
#random_list = []
selected_albums = []
gs = GSetting()
settings = gs.get_setting(gs.Path.PLUGIN)
to_queue = settings[gs.PluginKey.RANDOM]
if num_albums <= to_queue:
dialog = Gtk.MessageDialog(None,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.INFO,
Gtk.ButtonsType.OK,
_("The number of albums to randomly play is less than that displayed."))
dialog.run()
dialog.destroy()
return
album_col = self.album_manager.model.columns['album']
chosen = {}
# now loop through finding unique random albums
# i.e. ensure we dont queue the same album twice
for loop in range(0, to_queue):
while True:
pos = random.randint(0, num_albums - 1)
if pos not in chosen:
chosen[pos] = None
selected_albums.append(self.album_manager.model.store[pos][album_col])
break
threshold = self.rating_threshold if favourites else 0
for album in selected_albums:
# Retrieve and sort the entries of the album
tracks = album.get_tracks(threshold)
# Add the songs to the play queue
for track in tracks:
query_model.add_entry(track.entry, -1)
self.props.query_model = query_model
# Start the music
player = self.shell.props.shell_player
player.play_entry(query_model[0][0], self)
print("CoverArtBrowser DEBUG - end play_selected_album")
示例13: sort
def sort(self):
albums = SortedCollection(key=lambda album: getattr(album, 'name'))
gs = GSetting()
source_settings = gs.get_setting(gs.Path.PLUGIN)
key = source_settings[gs.PluginKey.SORT_BY_ARTIST]
order = source_settings[gs.PluginKey.SORT_ORDER_ARTIST]
sort_keys = {
'name_artist': ('album_sort', 'album_sort'),
'year_artist': ('real_year', 'calc_year_sort'),
'rating_artist': ('rating', 'album_sort')
}
props = sort_keys[key]
def key_function(album):
keys = [getattr(album, prop) for prop in props]
return keys
# remember the current sort then remove the sort order
# because sorting will only work in unsorted lists
sortSettings = self.store.get_sort_column_id()
self.store.set_sort_column_id(-1, Gtk.SortType.ASCENDING)
for artist in self._iters:
albums.clear()
albums.key = key_function
if 'album' in self._iters[artist] and len(self._iters[artist]['album']) > 1:
# we only need to sort an artists albums if there is more than one album
# sort all the artists albums
for album_iter in self._iters[artist]['album']:
albums.insert(self._tree_store[album_iter][self.columns['artist_album']])
if not order:
albums = reversed(albums)
# now we iterate through the sorted artist albums. Look and swap iters
# according to where they are in the tree store
artist_iter = self._iters[artist]['iter']
next_iter = self._tree_store.iter_children(artist_iter)
for album in albums:
if self._tree_store[next_iter][self.columns['artist_album']] != album:
self._tree_store.swap(next_iter, self._albumiters[album]['iter'])
next_iter = self._albumiters[album]['iter']
next_iter = self._tree_store.iter_next(next_iter)
# now we have finished sorting, reapply the sort
if sortSettings[0]:
self.store.set_sort_column_id(*sortSettings)
示例14: load_complete
def load_complete(self, *args, **kwargs):
'''
Called by Rhythmbox when it has completed loading all data
Used to automatically switch to the browser if the user
has set in the preferences
'''
gs = GSetting()
setting = gs.get_setting(gs.Path.PLUGIN)
if setting[gs.PluginKey.AUTOSTART]:
GLib.idle_add(self.shell.props.display_page_tree.select,
self.source)
示例15: _connect_properties
def _connect_properties(self):
gs = GSetting()
setting = gs.get_setting(gs.Path.PLUGIN)
setting.bind(gs.PluginKey.COVER_SIZE, self, 'cover-size',
Gio.SettingsBindFlags.GET)
setting.bind(gs.PluginKey.DISPLAY_TEXT_POS, self, 'display-text-pos',
Gio.SettingsBindFlags.GET)
setting.bind(gs.PluginKey.DISPLAY_TEXT, self, 'display-text',
Gio.SettingsBindFlags.GET)