本文整理汇总了Python中lollypop.view_container.ViewContainer.clean_old_views方法的典型用法代码示例。如果您正苦于以下问题:Python ViewContainer.clean_old_views方法的具体用法?Python ViewContainer.clean_old_views怎么用?Python ViewContainer.clean_old_views使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.view_container.ViewContainer
的用法示例。
在下文中一共展示了ViewContainer.clean_old_views方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
self._list_one.get_selected_ids()))
Lp().settings.set_value(
"list-two-ids",
GLib.Variant('ai',
self._list_two.get_selected_ids()))
def show_playlist_manager(self, object_id, genre_ids,
artist_ids, is_album):
"""
Show playlist manager for object_id
Current view stay present in ViewContainer
@param object id as int
@param genre ids as [int]
@param artist ids as [int]
@param is_album as bool
"""
view = PlaylistsManageView(object_id, genre_ids, artist_ids, is_album)
view.populate()
view.show()
self._stack.add(view)
self._stack.set_visible_child(view)
def show_playlist_editor(self, playlist_id):
"""
Show playlist editor for playlist
Current view stay present in ViewContainer
@param playlist id as int
@param playlist name as str
"""
view = PlaylistEditView(playlist_id)
view.show()
self._stack.add(view)
self._stack.set_visible_child(view)
self._stack.clean_old_views(view)
view.populate()
def main_widget(self):
"""
Get main widget
@return Gtk.HPaned
"""
return self._paned_main_list
def get_view_width(self):
"""
Return view width
@return width as int
"""
return self._stack.get_allocation().width
def stop_all(self):
"""
Stop current view from processing
"""
view = self._stack.get_visible_child()
if view is not None:
self._stack.clean_old_views(None)
def show_genres(self, show):
"""
Show/Hide genres
@param bool
"""
self._show_genres = show
self._list_one.clear()
self._update_list_one(None)
示例2: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
view = PlaylistsManageView(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, ())
"""
Show playlist editor for playlist
Current view stay present in ViewContainer
@param playlist name as str
"""
def show_playlist_editor(self, playlist_name):
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, ())
"""
Get main widget
@return Gtk.HPaned
"""
def main_widget(self):
return self._paned_main_list
"""
Stop current view from processing
"""
def stop_all(self):
view = self._stack.get_visible_child()
if view is not None:
self._stack.clean_old_views(None)
"""
Show/Hide genres
@param bool
"""
def show_genres(self, show):
self._show_genres = show
self._list_one.clear()
self._update_list_one(None)
"""
Destroy current view
"""
def destroy_current_view(self):
view = self._stack.get_visible_child()
for child in self._stack.get_children():
if child != view:
self._stack.set_visible_child(child)
self._stack.clean_old_views(child)
break
"""
Update current view
"""
def update_view(self):
view = self._stack.get_visible_child()
if view:
start_new_thread(view.update_covers, ())
"""
Mark force scan as False, update lists
@param scanner as CollectionScanner
示例3: AlbumsPopover
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
class AlbumsPopover(Gtk.Popover):
"""
Init Popover ui with a text entry and a scrolled treeview
"""
def __init__(self):
Gtk.Popover.__init__(self)
self._stack = ViewContainer(1000)
self._stack.show()
self._on_screen_id = None
self.add(self._stack)
Lp.player.connect("current-changed", self._update_content)
"""
Run _populate in a thread
"""
def populate(self):
if Lp.player.current_track.aartist_id == Type.COMPILATIONS:
new_id = Lp.player.current_track.album_id
else:
new_id = Lp.player.current_track.aartist_id
if self._on_screen_id != new_id:
self._on_screen_id = new_id
view = PopArtistView(Lp.player.current_track.aartist_id)
view.show()
start_new_thread(view.populate, ())
self._stack.add(view)
self._stack.set_visible_child(view)
self._stack.clean_old_views(view)
"""
Resize popover
"""
def do_show(self):
size_setting = Lp.settings.get_value('window-size')
if isinstance(size_setting[0], int) and\
isinstance(size_setting[1], int):
self.set_size_request(size_setting[0]*0.65, size_setting[1]*0.8)
else:
self.set_size_request(600, 600)
Gtk.Popover.do_show(self)
"""
Remove view
"""
def do_hide(self):
Gtk.Popover.do_hide(self)
child = self._stack.get_visible_child()
if child is not None:
child.stop()
self._on_screen_id = None
self._stack.clean_old_views(None)
#######################
# PRIVATE #
#######################
"""
Update the content view
@param player as Player
@param track id as int
"""
def _update_content(self, player):
if self.is_visible():
self.populate()
示例4: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
@thread safe
"""
sql = Lp.db.get_cursor()
if self._genre_id == Type.ALL:
if self._is_compilation:
albums = Lp.albums.get_compilations(None,
sql)
else:
albums = Lp.albums.get_ids(None, None, sql)
elif self._genre_id == Type.POPULARS:
albums = Lp.albums.get_populars(sql)
elif self._genre_id == Type.RECENTS:
albums = Lp.albums.get_recents(sql)
elif self._genre_id == Type.RANDOMS:
albums = Lp.albums.get_randoms(sql)
elif self._is_compilation:
albums = Lp.albums.get_compilations(self._genre_id,
sql)
else:
albums = []
if Lp.settings.get_value('show-compilations'):
albums += Lp.albums.get_compilations(self._genre_id,
sql)
albums += Lp.albums.get_ids(None, self._genre_id, sql)
sql.close()
return albums
def _get_children(self):
"""
Return view children
@return [AlbumWidget]
"""
children = []
for child in self._albumbox.get_children():
widget = child.get_child()
children.append(widget)
if self._context_widget is not None:
children.append(self._context_widget)
return children
def _populate_context(self, album_id):
"""
populate context view
@param album id as int
"""
size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
self._context_widget = AlbumDetailedWidget(album_id,
self._genre_id,
True,
True,
size_group)
start_new_thread(self._context_widget.populate, ())
self._context_widget.show()
view = AlbumContextView(self._context_widget)
view.show()
self._context.add(view)
self._context.set_visible_child(view)
self._context.clean_old_views(view)
def _add_albums(self, albums):
"""
Pop an album and add it to the view,
repeat operation until album list is empty
@param [album ids as int]
"""
if albums and not self._stop:
widget = AlbumSimpleWidget(albums.pop(0))
widget.show()
self._albumbox.insert(widget, -1)
GLib.idle_add(self._add_albums, albums)
else:
self._stop = False
def _on_position_notify(self, paned, param):
"""
Save paned position
@param paned as Gtk.Paned
@param param as Gtk.Param
"""
Lp.settings.set_value('paned-context-height',
GLib.Variant('i', paned.get_position()))
return False
def _on_album_activated(self, flowbox, child):
"""
Show Context view for activated album
@param flowbox as Gtk.Flowbox
@child as Gtk.FlowboxChild
"""
if self._context_album_id == child.get_child().get_id():
self._context_album_id = None
self._context.hide()
self._context_widget.destroy()
self._context_widget = None
else:
self._context_album_id = child.get_child().get_id()
if Lp.settings.get_value('auto-play'):
Lp.player.play_album(self._context_album_id, self._genre_id)
self._populate_context(self._context_album_id)
self._context.show()
示例5: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
class AlbumsView(View):
"""
Show albums in a box
"""
def __init__(self, genre_id, is_compilation):
"""
Init album view
@param genre id as int
@param is compilation as bool
"""
View.__init__(self)
self._signal = None
self._context_album_id = None
self._genre_id = genre_id
self._is_compilation = is_compilation
self._albumsongs = None
self._context_widget = None
self._press_rect = None
self._albumbox = Gtk.FlowBox()
self._albumbox.set_selection_mode(Gtk.SelectionMode.NONE)
self._albumbox.connect('child-activated', self._on_album_activated)
self._albumbox.connect('button-press-event', self._on_button_press)
self._albumbox.set_property('column-spacing', 5)
self._albumbox.set_property('row-spacing', 5)
self._albumbox.set_homogeneous(True)
self._albumbox.set_max_children_per_line(1000)
self._albumbox.show()
self._viewport.set_property('valign', Gtk.Align.START)
self._viewport.set_property('margin', 5)
self._viewport.add(self._albumbox)
self._scrolledWindow.set_property('expand', True)
self._context = ViewContainer(500)
separator = Gtk.Separator()
separator.show()
self._paned = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
self._paned.pack1(self._scrolledWindow, True, False)
self._paned.pack2(self._context, False, False)
height = Lp().settings.get_value('paned-context-height').get_int32()
# We set a stupid max value, safe as self._context is shrinked
if height == -1:
height = Lp().window.get_allocated_height()
self._paned.set_position(height)
self._paned.connect('notify::position', self._on_position_notify)
self._paned.show()
self.add(self._paned)
def populate(self, albums):
"""
Populate albums
@param is compilation as bool
"""
self._add_albums(albums)
#######################
# PRIVATE #
#######################
def _get_children(self):
"""
Return view children
@return [AlbumWidget]
"""
children = []
for child in self._albumbox.get_children():
widget = child.get_child()
children.append(widget)
if self._context_widget is not None:
children.append(self._context_widget)
return children
def _populate_context(self, album_id):
"""
populate context view
@param album id as int
"""
size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
self._context_widget = AlbumContextWidget(album_id,
self._genre_id,
True,
size_group)
self._context_widget.populate()
self._context_widget.show()
view = AlbumContextView(self._context_widget)
view.show()
self._context.add(view)
self._context.set_visible_child(view)
self._context.clean_old_views(view)
def _add_albums(self, albums):
"""
Pop an album and add it to the view,
repeat operation until album list is empty
@param [album ids as int]
"""
if albums and not self._stop:
#.........这里部分代码省略.........
示例6: PopImages
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
class PopImages(Gtk.Popover):
"""
Init Popover ui with a text entry and a scrolled treeview
"""
def __init__(self, album_id):
Gtk.Popover.__init__(self)
self._album_id = album_id
self._stack = ViewContainer(1000)
self._stack.show()
builder = Gtk.Builder()
builder.add_from_resource(
'/org/gnome/Lollypop/PopImages.ui')
self._view = Gtk.FlowBox()
self._view.set_selection_mode(Gtk.SelectionMode.NONE)
self._view.connect("child-activated", self._on_activate)
self._view.show()
builder.get_object('viewport').add(self._view)
self._widget = builder.get_object('widget')
self._spinner = builder.get_object('spinner')
self._not_found = builder.get_object('notfound')
self._stack.add(self._spinner)
self._stack.add(self._not_found)
self._stack.add(self._widget)
self._stack.set_visible_child(self._spinner)
self.add(self._stack)
"""
Populate view
@param searched words as string
"""
def populate(self, string):
self._thread = True
start_new_thread(self._populate, (string,))
"""
Resize popover and set signals callback
"""
def do_show(self):
self.set_size_request(700, 400)
Gtk.Popover.do_show(self)
"""
Kill thread
"""
def do_hide(self):
self._thread = False
Gtk.Popover.do_hide(self)
#######################
# PRIVATE #
#######################
"""
Same as populate()
"""
def _populate(self, string):
self._urls = Objects.art.get_google_arts(string)
if self._urls:
self._add_pixbufs()
else:
GLib.idle_add(self._show_not_found)
"""
Add urls to the view
"""
def _add_pixbufs(self):
if self._urls:
url = self._urls.pop()
stream = None
try:
response = urllib.request.urlopen(url)
stream = Gio.MemoryInputStream.new_from_data(
response.read(), None)
except:
if self._thread:
self._add_pixbufs()
if stream:
GLib.idle_add(self._add_pixbuf, stream)
if self._thread:
self._add_pixbufs()
"""
Show not found message
"""
def _show_not_found(self):
self._stack.set_visible_child(self._not_found)
self._stack.clean_old_views(self._not_found)
"""
Add stream to the view
"""
def _add_pixbuf(self, stream):
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(
stream, ArtSize.MONSTER,
#.........这里部分代码省略.........
示例7: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
height = self._paned.get_allocated_height() - height
self._paned.set_position(height)
def _get_children(self):
"""
Return view children
@return [AlbumWidget]
"""
children = []
for child in self._albumbox.get_children():
widget = child.get_child()
children.append(widget)
if self._context_widget is not None:
children.append(self._context_widget)
return children
def _populate_context(self, album_id):
"""
populate context view
@param album id as int
"""
size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
self._context_widget = AlbumContextWidget(album_id,
self._genre_ids,
self._artist_ids,
size_group)
self._context_widget.connect('populated',
self._on_context_populated)
self._context_widget.show()
view = AlbumContextView(self._context_widget)
view.show()
self._context.add(view)
self._context.set_visible_child(view)
self._context.clean_old_views(view)
# We delay populate() to be sure widget get it size allocated
GLib.idle_add(self._context_widget.populate)
def _add_albums(self, albums):
"""
Add albums to the view
Start lazy loading
@param [album ids as int]
"""
if albums and not self._stop:
widget = AlbumSimpleWidget(albums.pop(0),
self._genre_ids,
self._artist_ids)
self._albumbox.insert(widget, -1)
widget.show()
self._lazy_queue.append(widget)
GLib.idle_add(self._add_albums, albums)
else:
self._stop = False
GLib.idle_add(self.lazy_loading)
if self._viewport.get_child() is None:
self._viewport.add(self._albumbox)
def _on_context_populated(self, widget):
"""
Populate again if needed
@param widget as AlbumContextWidget
"""
if not widget.is_populated():
widget.populate()
elif not self._stop:
GLib.idle_add(self._context_widget.populate)
示例8: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
#######################
# PRIVATE #
#######################
def _get_children(self):
"""
Return view children
@return [AlbumWidget]
"""
children = []
for child in self._albumbox.get_children():
widget = child.get_child()
children.append(widget)
if self._context_widget is not None:
children.append(self._context_widget)
return children
def _populate_context(self, album_id):
"""
populate context view
@param album id as int
"""
size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
self._context_widget = AlbumContextWidget(album_id,
self._genre_id,
True,
size_group)
self._context_widget.populate()
self._context_widget.show()
view = AlbumContextView(self._context_widget)
view.show()
self._context.add(view)
self._context.set_visible_child(view)
self._context.clean_old_views(view)
def _add_albums(self, albums):
"""
Add albums to the view
Start lazy loading
@param [album ids as int]
"""
if albums and not self._stop:
widget = AlbumSimpleWidget(albums.pop(0),
self._requisition.width,
self._requisition.height)
self._albumbox.insert(widget, -1)
widget.show_all()
self._lazy_queue.append(widget)
GLib.idle_add(self._add_albums, albums)
else:
GLib.idle_add(self._lazy_loading)
self._viewport.add(self._albumbox)
def _lazy_loading(self, widgets=[], scroll_value=0):
"""
Load the view in a lazy way:
- widgets first
- _waiting_init then
@param widgets as [AlbumSimpleWidgets]
@param scroll_value as float
"""
widget = None
if self._stop or self._scroll_value != scroll_value:
return
if widgets:
widget = widgets.pop(0)
示例9: AlbumsPopover
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
class AlbumsPopover(Gtk.Popover):
"""
Popover => CurrentArtistView
"""
def __init__(self):
"""
Init popover
"""
Gtk.Popover.__init__(self)
self._stack = ViewContainer(1000)
self._stack.show()
self._on_screen_id = None
self.add(self._stack)
Lp.player.connect("current-changed", self._update_content)
def populate(self):
"""
Load content of the popover
"""
if Lp.player.current_track.album_artist_id == Type.COMPILATIONS:
new_id = Lp.player.current_track.album_id
else:
new_id = Lp.player.current_track.album_artist_id
if self._on_screen_id != new_id:
self._on_screen_id = new_id
view = CurrentArtistView(Lp.player.current_track.album_artist_id)
albums = self._get_albums(Lp.player.current_track.album_artist_id)
view.populate(albums)
view.show()
self._stack.add(view)
self._stack.set_visible_child(view)
self._stack.clean_old_views(view)
def do_show(self):
"""
Resize popover
"""
size_setting = Lp.settings.get_value('window-size')
if isinstance(size_setting[0], int) and\
isinstance(size_setting[1], int):
self.set_size_request(size_setting[0]*0.65, size_setting[1]*0.8)
else:
self.set_size_request(600, 600)
Gtk.Popover.do_show(self)
def do_hide(self):
"""
Remove view
"""
Gtk.Popover.do_hide(self)
child = self._stack.get_visible_child()
if child is not None:
child.stop()
self._on_screen_id = None
self._stack.clean_old_views(None)
#######################
# PRIVATE #
#######################
def _get_albums(self, artist_id):
"""
Get albums
@return album ids as [int]
"""
sql = Lp.db.get_cursor()
if artist_id == Type.COMPILATIONS:
albums = [Lp.player.current_track.album_id]
else:
albums = Lp.artists.get_albums(artist_id, sql)
sql.close()
return albums
def _update_content(self, player):
"""
Update the content view
@param player as Player
@param track id as int
"""
if self.is_visible():
self.populate()
def do_get_preferred_width(self):
"""
Set 0 to force popover to not expand
"""
return (0, 0)
示例10: RadioPopover
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
self._start += GOOGLE_INC
self._add_pixbufs()
else:
GLib.idle_add(self._show_not_found)
def _add_pixbufs(self):
"""
Add urls to the view
"""
if self._urls:
url = self._urls.pop()
stream = None
try:
f = Gio.File.new_for_uri(url)
(status, data, tag) = f.load_contents()
if status:
stream = Gio.MemoryInputStream.new_from_data(data, None)
except:
if self._thread:
self._add_pixbufs()
if stream:
GLib.idle_add(self._add_pixbuf, stream)
if self._thread:
self._add_pixbufs()
elif self._start < GOOGLE_MAX:
self._populate_threaded()
def _show_not_found(self):
"""
Show not found message if view empty
"""
if len(self._view.get_children()) == 0:
self._stack.set_visible_child(self._not_found)
self._stack.clean_old_views(self._not_found)
def _add_pixbuf(self, stream):
"""
Add stream to the view
"""
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(
stream, ArtSize.MONSTER,
ArtSize.MONSTER,
True,
None)
image = Gtk.Image()
self._orig_pixbufs[image] = pixbuf
# Scale preserving aspect ratio
width = pixbuf.get_width()
height = pixbuf.get_height()
if width > height:
height = height*ArtSize.BIG*self.get_scale_factor()/width
width = ArtSize.BIG*self.get_scale_factor()
else:
width = width*ArtSize.BIG*self.get_scale_factor()/height
height = ArtSize.BIG*self.get_scale_factor()
scaled_pixbuf = pixbuf.scale_simple(width,
height,
GdkPixbuf.InterpType.BILINEAR)
del pixbuf
surface = Gdk.cairo_surface_create_from_pixbuf(scaled_pixbuf,
0,
None)
del scaled_pixbuf
image.set_from_surface(surface)
del surface
示例11: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
self._update_list_two(updater)
"""
Load external files
@param files as [Gio.Files]
"""
def load_external(self, files):
self._need_to_update_db = False
# We wait as selection list is threaded,
# we don't want to insert item before populated
# Same for locked db
if self._list_one.is_populating() or\
self._list_one.is_populating() or\
self._scanner.is_locked():
self._scanner.stop()
GLib.timeout_add(250, self.load_external, files)
else:
self._scanner.add(files)
"""
Get main widget
@return Gtk.HPaned
"""
def main_widget(self):
return self._paned_main_list
"""
Stop current view from processing
"""
def stop_all(self):
self._scanner.stop()
view = self._stack.get_visible_child()
if view is not None:
self._stack.clean_old_views(None)
"""
Show/Hide genres
@param bool
"""
def show_genres(self, show):
self._show_genres = show
self._update_list_one(None)
"""
Destroy current view
"""
def destroy_current_view(self):
view = self._stack.get_visible_child()
for child in self._stack.get_children():
if child != view:
self._stack.set_visible_child(child)
self._stack.clean_old_views(child)
break
"""
Update current view
"""
def update_view(self):
view = self._stack.get_visible_child()
if view:
start_new_thread(view.update_covers, ())
############
# Private #
############
"""
示例12: AlbumView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
class AlbumView(View):
"""
Init album view ui with a scrolled flow box and a scrolled context view
@param navigation id as int
"""
def __init__(self, navigation_id):
View.__init__(self)
self._signal = None
self._context_album_id = None
self._genre_id = navigation_id
self._albumsongs = None
self._context_widget = None
self._albumbox = Gtk.FlowBox()
self._albumbox.set_selection_mode(Gtk.SelectionMode.NONE)
self._albumbox.connect("child-activated", self._on_album_activated)
self._albumbox.set_max_children_per_line(100)
self._albumbox.show()
self._viewport.set_property("valign", Gtk.Align.START)
self._viewport.add(self._albumbox)
self._scrolledWindow.set_property('expand', True)
self._context = ViewContainer(500)
separator = Gtk.Separator()
separator.show()
self._paned = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
self._paned.pack1(self._scrolledWindow)
self._paned.pack2(self._context, True, False)
height = Objects.settings.get_value(
'paned-context-height').get_int32()
# We set a stupid max value, safe as self._context is shrinked
if height == -1:
height = Objects.window.get_allocated_height()
self._paned.set_position(height)
self._paned.connect('notify::position', self._on_position_notify)
self._paned.show()
self.add(self._paned)
"""
Populate albums, thread safe
@param navigation id as int
"""
def populate(self, navigation_id):
sql = Objects.db.get_cursor()
if self._genre_id == Navigation.ALL:
albums = Objects.albums.get_ids(None, None, sql)
elif self._genre_id == Navigation.POPULARS:
albums = Objects.albums.get_populars(sql)
elif self._genre_id == Navigation.RECENTS:
albums = Objects.albums.get_recents(sql)
elif self._genre_id == Navigation.COMPILATIONS:
albums = Objects.albums.get_compilations(navigation_id,
sql)
else:
albums = Objects.albums.get_ids(None, self._genre_id, sql)
GLib.idle_add(self._add_albums, albums)
sql.close()
#######################
# PRIVATE #
#######################
"""
Return view children
@return [AlbumWidget]
"""
def _get_children(self):
children = []
for child in self._albumbox.get_children():
for widget in child.get_children():
children.append(widget)
return children
"""
populate context view
@param album id as int
"""
def _populate_context(self, album_id):
size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
self._context_widget = AlbumDetailedWidget(album_id,
self._genre_id,
True,
True,
size_group)
start_new_thread(self._context_widget.populate, ())
self._context_widget.show()
view = AlbumContextView(self._context_widget)
view.show()
self._context.add(view)
self._context.set_visible_child(view)
self._context.clean_old_views(view)
"""
Save paned position
@param paned as Gtk.Paned
@param param as Gtk.Param
"""
def _on_position_notify(self, paned, param):
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
self.__list_two.selected_ids))
def show_playlist_manager(self, object_id, genre_ids,
artist_ids, is_album):
"""
Show playlist manager for object_id
Current view stay present in ViewContainer
@param object id as int
@param genre ids as [int]
@param artist ids as [int]
@param is_album as bool
"""
from lollypop.view_playlists import PlaylistsManageView
current = self.__stack.get_visible_child()
view = PlaylistsManageView(object_id, genre_ids, artist_ids, is_album)
view.populate()
view.show()
self.__stack.add(view)
self.__stack.set_visible_child(view)
current.disable_overlay()
def show_playlist_editor(self, playlist_id):
"""
Show playlist editor for playlist
Current view stay present in ViewContainer
@param playlist id as int
@param playlist name as str
"""
from lollypop.view_playlists import PlaylistEditView
view = PlaylistEditView(playlist_id)
view.show()
self.__stack.add(view)
self.__stack.set_visible_child(view)
self.__stack.clean_old_views(view)
view.populate()
def get_view_width(self):
"""
Return view width
@return width as int
"""
return self.__stack.get_allocation().width
def stop_all(self):
"""
Stop current view from processing
"""
view = self.__stack.get_visible_child()
if view is not None:
self.__stack.clean_old_views(None)
def show_genres(self, show):
"""
Show/Hide genres
@param bool
"""
self.__show_genres = show
self.__list_one.clear()
self.__list_two.clear()
self.__list_two.hide()
self.__update_list_one(None)
self.__list_one.select_ids([Type.POPULARS])
def destroy_current_view(self):
"""
Destroy current view
示例14: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import clean_old_views [as 别名]
#.........这里部分代码省略.........
@param is_album as bool
"""
view = PlaylistsManageView(object_id, genre_id, is_album)
view.populate()
view.show()
self._stack.add(view)
self._stack.set_visible_child(view)
def show_playlist_editor(self, playlist_name):
"""
Show playlist editor for playlist
Current view stay present in ViewContainer
@param playlist name as str
"""
view = PlaylistEditView(playlist_name)
view.show()
self._stack.add(view)
self._stack.set_visible_child(view)
view.populate()
def main_widget(self):
"""
Get main widget
@return Gtk.HPaned
"""
return self._paned_main_list
def stop_all(self):
"""
Stop current view from processing
"""
view = self._stack.get_visible_child()
if view is not None:
self._stack.clean_old_views(None)
def show_genres(self, show):
"""
Show/Hide genres
@param bool
"""
self._show_genres = show
self._list_one.clear()
self._update_list_one(None)
def destroy_current_view(self):
"""
Destroy current view
"""
view = self._stack.get_visible_child()
for child in self._stack.get_children():
if child != view:
self._stack.set_visible_child(child)
self._stack.clean_old_views(child)
break
def update_view(self):
"""
Update current view
"""
view = self._stack.get_visible_child()
if view:
view.update_covers()
def on_scan_finished(self, scanner):
"""
Mark force scan as False, update lists