本文整理汇总了Python中lollypop.view_container.ViewContainer.hide方法的典型用法代码示例。如果您正苦于以下问题:Python ViewContainer.hide方法的具体用法?Python ViewContainer.hide怎么用?Python ViewContainer.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.view_container.ViewContainer
的用法示例。
在下文中一共展示了ViewContainer.hide方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import hide [as 别名]
#.........这里部分代码省略.........
"""
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:
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
@param child as Gtk.FlowboxChild
"""
album_widget = child.get_child()
if self._press_rect is None:
if self._context_album_id == album_widget.get_id():
self._context_album_id = None
self._context.hide()
self._context_widget.destroy()
self._context_widget = None
else:
if Lp().settings.get_value('auto-play'):
album = Album(album_widget.get_id())
track = Track(album.tracks_ids[0])
Lp().player.load(track)
Lp().player.set_albums(track.id, None,
self._genre_id)
else:
self._context_album_id = album_widget.get_id()
self._populate_context(self._context_album_id)
self._context.show()
else:
if self._context_album_id is not None:
self._context_album_id = None
self._context.hide()
self._context_widget.destroy()
self._context_widget = None
popover = AlbumPopoverWidget(album_widget.get_id(),
self._genre_id)
popover.set_relative_to(album_widget)
popover.set_pointing_to(self._press_rect)
self._context_widget = popover.get_widget()
popover.connect('destroy', self._on_popover_destroyed)
popover.show()
def _on_popover_destroyed(self, popover):
"""
Remove from context
@param popover as AlbumPopoverWidget
"""
self._context_widget = None
def _on_button_press(self, flowbox, event):
"""
Store pressed button
@param flowbox as Gtk.Flowbox
@param event as Gdk.EventButton
"""
if event.button == 1:
self._press_rect = None
else:
self._press_rect = Gdk.Rectangle()
self._press_rect.x = event.x
self._press_rect.y = event.y
self._press_rect.width = self._press_rect.height = 1
event.button = 1
示例2: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import hide [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()
示例3: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import hide [as 别名]
#.........这里部分代码省略.........
try:
(x, y) = widget.translate_coordinates(self._scrolled, 0, 0)
return (y > -widget_alloc.height-ArtSize.BIG or y >= 0) and\
y < scrolled_alloc.height+ArtSize.BIG
except:
return True
def _lazy_or_not(self):
"""
Add visible widgets to lazy queue
"""
self._timeout_id = None
widgets = []
for child in self._lazy_queue:
if self._is_visible(child):
widgets.append(child)
GLib.idle_add(self._lazy_loading, widgets, self._scroll_value)
def _on_value_changed(self, adj):
"""
Update scroll value and check for lazy queue
@param adj as Gtk.Adjustment
"""
if self._timeout_id is not None:
GLib.source_remove(self._timeout_id)
self._timeout_id = None
self._scroll_value = adj.get_value()
if not self._lazy_queue:
return
self._timeout_id = GLib.timeout_add(250, self._lazy_or_not)
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
@param child as Gtk.FlowboxChild
"""
album_widget = child.get_child()
if self._press_rect is None:
if self._context_album_id == album_widget.get_id():
self._context_album_id = None
self._context.hide()
self._context_widget.destroy()
self._context_widget = None
else:
if Lp().settings.get_value('auto-play'):
album = Album(album_widget.get_id())
track = Track(album.tracks_ids[0])
Lp().player.load(track)
Lp().player.set_albums(track.id, None,
self._genre_id)
else:
self._context_album_id = album_widget.get_id()
self._populate_context(self._context_album_id)
self._context.show()
else:
if self._context_album_id is not None:
self._context_album_id = None
self._context.hide()
self._context_widget.destroy()
self._context_widget = None
popover = AlbumPopoverWidget(album_widget.get_id(),
self._genre_id)
popover.set_relative_to(album_widget)
popover.set_pointing_to(self._press_rect)
self._context_widget = popover.get_widget()
popover.connect('destroy', self._on_popover_destroyed)
popover.show()
def _on_popover_destroyed(self, popover):
"""
Remove from context
@param popover as AlbumPopoverWidget
"""
self._context_widget = None
def _on_button_press(self, flowbox, event):
"""
Store pressed button
@param flowbox as Gtk.Flowbox
@param event as Gdk.EventButton
"""
if event.button == 1:
self._press_rect = None
else:
self._press_rect = Gdk.Rectangle()
self._press_rect.x = event.x
self._press_rect.y = event.y
self._press_rect.width = self._press_rect.height = 1
event.button = 1
示例4: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import hide [as 别名]
class AlbumsView(LazyLoadingView):
"""
Show albums in a box
"""
def __init__(self, genre_ids, artist_ids):
"""
Init album view
@param genre ids as [int]
@param artist ids as [int]
"""
LazyLoadingView.__init__(self)
self._signal = None
self._context_album_id = None
self._genre_ids = genre_ids
self._artist_ids = artist_ids
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._scrolled.set_property('expand', True)
self._scrolled.set_property('height-request', 10)
self._context = ViewContainer(500)
separator = Gtk.Separator()
separator.show()
self._paned = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
self._paned.pack1(self._scrolled, True, False)
self._paned.pack2(self._context, False, False)
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)
def show_context(self, show):
"""
Hide context widget
@param show as bool
"""
if show:
if self._context_widget is not None:
self._context.show()
elif self._context_widget is not None:
self._context.hide()
def stop(self):
"""
Stop loading
"""
self._lazy_queue = []
for child in self._get_children():
child.stop()
#######################
# PRIVATE #
#######################
def _update_overlays(self, widgets):
"""
Update children's overlay
@param widgets as AlbumWidget
"""
if self._context_widget in widgets:
widgets.remove(self._context_widget)
View._update_overlays(self, widgets)
def _init_context_position(self):
"""
Init context position if needed
See _on_position_notify()
"""
if self._paned.get_position() == 0:
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()
else:
height = self._paned.get_allocated_height() - height
self._paned.set_position(height)
def _get_children(self):
#.........这里部分代码省略.........
示例5: AlbumView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import hide [as 别名]
#.........这里部分代码省略.........
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):
Objects.settings.set_value(
'paned-context-height',
GLib.Variant('i', paned.get_position()))
return False
"""
Show Context view for activated album
@param flowbox, children
"""
def _on_album_activated(self, flowbox, child):
if self._context_album_id == child.get_child().get_id():
if Objects.settings.get_value('auto-play'):
Objects.player.play_album(self._context_album_id)
else:
self._context_album_id = None
self._context.hide()
else:
self._context_album_id = child.get_child().get_id()
self._populate_context(self._context_album_id)
self._context.show()
"""
Pop an album and add it to the view,
repeat operation until album list is empty
@param [album ids as int]
"""
def _add_albums(self, albums):
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