本文整理汇总了Python中lollypop.selectionlist.SelectionList.update方法的典型用法代码示例。如果您正苦于以下问题:Python SelectionList.update方法的具体用法?Python SelectionList.update怎么用?Python SelectionList.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.selectionlist.SelectionList
的用法示例。
在下文中一共展示了SelectionList.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import update [as 别名]
class Container:
def __init__(self):
# Index will start at -VOLUMES
self._devices = {}
self._devices_index = Navigation.DEVICES
self._show_genres = Objects.settings.get_value('show-genres')
self._stack = ViewContainer(500)
self._stack.show()
self._setup_view()
self._setup_scanner()
self._list_one_restore = Navigation.POPULARS
self._list_two_restore = None
if Objects.settings.get_value('save-state'):
self._restore_view_state()
# Volume manager
self._vm = Gio.VolumeMonitor.get()
self._vm.connect('mount-added', self._on_mount_added)
self._vm.connect('mount-removed', self._on_mount_removed)
Objects.playlists.connect("playlists-changed",
self.update_lists)
"""
Update db at startup only if needed
@param force as bool to force update (if possible)
"""
def update_db(self, force=False):
if not self._progress.is_visible():
if force or Objects.tracks.is_empty():
self._scanner.update(False)
elif Objects.settings.get_value('startup-scan') or\
Objects.settings.get_value('force-scan'):
self._scanner.update(True)
"""
Save view state
"""
def save_view_state(self):
Objects.settings.set_value("list-one",
GLib.Variant(
'i',
self._list_one.get_selected_id()))
Objects.settings.set_value("list-two",
GLib.Variant(
'i',
self._list_two.get_selected_id()))
"""
Show playlist manager for object_id
Current view stay present in ViewContainer
@param object id as int
@param genre id as int
@param is_album as bool
"""
def show_playlist_manager(self, object_id, genre_id, is_album):
old_view = self._stack.get_visible_child()
view = PlaylistManageView(object_id, genre_id, is_album,
self._stack.get_allocated_width()/2)
view.show()
self._stack.add(view)
self._stack.set_visible_child(view)
start_new_thread(view.populate, ())
# Keep previous view,
if isinstance(old_view, PlaylistManageView):
old_view.destroy()
"""
Show playlist editor for playlist
Current view stay present in ViewContainer
@param playlist name as str
"""
def show_playlist_editor(self, playlist_name):
old_view = self._stack.get_visible_child()
view = PlaylistEditView(playlist_name,
self._stack.get_allocated_width()/2)
view.show()
self._stack.add(view)
self._stack.set_visible_child(view)
start_new_thread(view.populate, ())
# Keep previous view,
if isinstance(old_view, PlaylistEditView):
old_view.destroy()
"""
Update lists
@param updater as GObject
"""
def update_lists(self, updater=None):
self._update_list_one(updater)
self._update_list_two(updater)
"""
Load external files
@param files as [Gio.Files]
"""
def load_external(self, files):
#.........这里部分代码省略.........
示例2: Window
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import update [as 别名]
class Window(Gtk.ApplicationWindow):
"""
Init window objects
"""
def __init__(self, app):
Gtk.ApplicationWindow.__init__(self,
application=app,
title=_("Lollypop"))
self._timeout = None
self._scanner = CollectionScanner()
self._scanner.connect("scan-finished", self._setup_list_one, True)
self._setup_window()
self._setup_view()
self._setup_media_keys()
party_settings = Objects["settings"].get_value('party-ids')
ids = []
for setting in party_settings:
if isinstance(setting, int):
ids.append(setting)
Objects["player"].set_party_ids(ids)
self.connect("destroy", self._on_destroyed_window)
"""
Run collection update if needed
"""
def setup_view(self):
if Objects["tracks"].is_empty():
self._scanner.update(self._progress, False)
return
elif Objects["settings"].get_value('startup-scan'):
self._scanner.update(self._progress, True)
self._setup_list_one()
self._update_view_albums(POPULARS)
"""
Update music database
"""
def update_db(self):
self._list_one.widget.hide()
self._list_two.widget.hide()
old_view = self._stack.get_visible_child()
self._loading = True
view = LoadingView()
self._stack.add(view)
self._stack.set_visible_child(view)
self._scanner.update(self._progress, False)
if old_view:
self._stack.remove(old_view)
old_view.remove_signals()
"""
Update view class
@param bool
"""
def update_view_class(self, dark):
current_view = self._stack.get_visible_child()
if dark:
current_view.get_style_context().add_class('black')
else:
current_view.get_style_context().remove_class('black')
############
# Private #
############
"""
Setup media player keys
"""
def _setup_media_keys(self):
self._proxy = Gio.DBusProxy.new_sync(Gio.bus_get_sync(Gio.BusType.SESSION, None),
Gio.DBusProxyFlags.NONE,
None,
'org.gnome.SettingsDaemon',
'/org/gnome/SettingsDaemon/MediaKeys',
'org.gnome.SettingsDaemon.MediaKeys',
None)
self._grab_media_player_keys()
try:
self._proxy.connect('g-signal', self._handle_media_keys)
except GLib.GError:
# We cannot grab media keys if no settings daemon is running
pass
"""
Do key grabbing
"""
def _grab_media_player_keys(self):
try:
self._proxy.call_sync('GrabMediaPlayerKeys',
GLib.Variant('(su)', ('Lollypop', 0)),
Gio.DBusCallFlags.NONE,
-1,
#.........这里部分代码省略.........