本文整理汇总了Python中lollypop.view_container.ViewContainer.show方法的典型用法代码示例。如果您正苦于以下问题:Python ViewContainer.show方法的具体用法?Python ViewContainer.show怎么用?Python ViewContainer.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.view_container.ViewContainer
的用法示例。
在下文中一共展示了ViewContainer.show方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [as 别名]
class Container:
"""
Container for main view
"""
def __init__(self):
"""
Init container
"""
self._pulse_timeout = None
# Index will start at -VOLUMES
self._devices = {}
self._devices_index = Type.DEVICES
self._show_genres = Lp().settings.get_value('show-genres')
self._stack = ViewContainer(500)
self._stack.show()
self._setup_view()
self._setup_scanner()
(list_one_ids, list_two_ids) = self._get_saved_view_state()
if list_one_ids and list_one_ids[0] != Type.NONE:
self._list_one.select_ids(list_one_ids)
if list_two_ids and list_two_ids[0] != Type.NONE:
self._list_two.select_ids(list_two_ids)
# 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)
for mount in self._vm.get_mounts():
self._add_device(mount, False)
Lp().playlists.connect('playlists-changed',
self._update_playlists)
def update_db(self):
"""
Update db at startup only if needed
"""
# Stop previous scan
if Lp().scanner.is_locked():
Lp().scanner.stop()
GLib.timeout_add(250, self.update_db)
else:
# Something (device manager) is using progress bar
if not self._progress.is_visible():
Lp().scanner.update(self._progress)
def get_genre_id(self):
"""
Return current selected genre
@return genre id as int
"""
if self._show_genres:
return self._list_one.get_selected_id()
else:
return None
def init_list_one(self):
"""
Init list one
"""
self._update_list_one(None)
def save_view_state(self):
"""
Save view state
"""
Lp().settings.set_value(
"list-one-ids",
GLib.Variant('ai',
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
"""
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [as 别名]
class Container:
def __init__(self):
# Try to update db on start, will be done after list one populating
# finished
self._need_to_update_db = Lp.settings.get_value('auto-update') or\
Lp.tracks.is_empty()
# Index will start at -VOLUMES
self._devices = {}
self._devices_index = Type.DEVICES
self._show_genres = Lp.settings.get_value('show-genres')
self._stack = ViewContainer(500)
self._stack.show()
self._setup_view()
self._setup_scanner()
(list_one_id, list_two_id) = self._get_saved_view_state()
self._list_one.select_id(list_one_id)
self._list_two.select_id(list_two_id)
# 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)
Lp.playlists.connect('playlists-changed',
self._update_lists)
"""
Update db at startup only if needed
"""
def update_db(self):
# Stop previous scan
if Lp.scanner.is_locked():
Lp.scanner.stop()
GLib.timeout_add(250, self.update_db)
else:
# Something (device manager) is using progress bar
progress = None
if not self._progress.is_visible():
progress = self._progress
Lp.scanner.update(progress)
"""
Return current selected genre
@return genre id as int
"""
def get_genre_id(self):
if self._show_genres:
return self._list_one.get_selected_id()
else:
return None
"""
Init list one
"""
def init_list_one(self):
self._update_list_one(None)
"""
Save view state
"""
def save_view_state(self):
Lp.settings.set_value("list-one",
GLib.Variant('i',
self._list_one.get_selected_id()))
Lp.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):
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
#.........这里部分代码省略.........
示例3: AlbumsPopover
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [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 show [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._albumbox = Gtk.FlowBox()
self._albumbox.set_selection_mode(Gtk.SelectionMode.NONE)
self._albumbox.connect('child-activated', self._on_album_activated)
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):
"""
Populate albums
@param is compilation as bool
@thread safe
"""
albums = self._get_albums()
GLib.idle_add(self._add_albums, albums)
#######################
# PRIVATE #
#######################
def _get_albums(self):
"""
Get albums
@return album ids as [int]
@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():
#.........这里部分代码省略.........
示例5: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [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 show [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 show [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):
#.........这里部分代码省略.........
示例8: AlbumsView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [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._lazy_queue = [] # Widgets not initialized
self._scroll_value = 0
self._timeout_id = 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.get_vadjustment().connect('value-changed',
self._on_value_changed)
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)
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
"""
# Add first album to get album size,
# used to precalculate next albums size
if albums:
widget = AlbumSimpleWidget(albums.pop(0))
widget.init_widget()
widget.show_all()
self._albumbox.insert(widget, -1)
# Keep album requisition
self._requisition = widget.get_preferred_size()[1]
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)
#.........这里部分代码省略.........
示例9: AlbumsPopover
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [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 show [as 别名]
class RadioPopover(Gtk.Popover):
"""
Popover with radio logos from the web
"""
def __init__(self, name, radios_manager):
"""
Init Popover
@param name as string
@param radios_manager as RadiosManager
"""
Gtk.Popover.__init__(self)
self._name = name
self._radios_manager = radios_manager
self._start = 0
self._orig_pixbufs = {}
self._stack = ViewContainer(1000)
self._stack.show()
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/RadioPopover.ui')
builder.connect_signals(self)
self._view = Gtk.FlowBox()
self._view.set_selection_mode(Gtk.SelectionMode.NONE)
self._view.connect('child-activated', self._on_activate)
self._view.set_max_children_per_line(100)
self._view.set_property('row-spacing', 10)
self._view.show()
builder.get_object('viewport').add(self._view)
self._widget = builder.get_object('widget')
self._logo = builder.get_object('logo')
self._spinner = builder.get_object('spinner')
self._not_found = builder.get_object('notfound')
self._name_entry = builder.get_object('name')
self._uri_entry = builder.get_object('uri')
self._btn_add_modify = builder.get_object('btn_add_modify')
self._stack.add(self._spinner)
self._stack.add(self._not_found)
self._stack.add(self._logo)
self._stack.add(self._widget)
self._stack.set_visible_child(self._widget)
self.add(self._stack)
if self._name == '':
builder.get_object('btn_add_modify').set_label(_("Add"))
else:
builder.get_object('btn_add_modify').set_label(_("Modify"))
builder.get_object('btn_delete').show()
self._name_entry.set_text(self._name)
uris = self._radios_manager.get_tracks(self._name)
if len(uris) > 0:
self._uri_entry.set_text(uris[0])
def do_show(self):
"""
Resize popover and set signals callback
"""
Gtk.Popover.do_show(self)
self._name_entry.grab_focus()
Lp.window.enable_global_shorcuts(False)
def do_hide(self):
"""
Kill thread
"""
self._thread = False
Gtk.Popover.do_hide(self)
Lp.window.enable_global_shorcuts(True)
#######################
# PRIVATE #
#######################
def _populate_threaded(self):
"""
Populate view
"""
self._thread = True
t = Thread(target=self._populate)
t.daemon = True
t.start()
def _populate(self):
"""
Same as _populate_threaded()
@thread safe
"""
self._urls = Lp.art.get_google_arts(self._name+"+logo+radio",
self._start)
if self._urls:
self._start += GOOGLE_INC
self._add_pixbufs()
else:
GLib.idle_add(self._show_not_found)
def _add_pixbufs(self):
"""
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [as 别名]
class Container:
def __init__(self):
# Try to update db on start, will be done after list one poplating
# finished
self._need_to_update_db = True
# 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 = Navigation.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):
# Stop previous scan
if self._scanner.is_locked():
self._scanner.stop()
GLib.timeout_add(250, self.update_db, force)
# Something is using progress bar, do nothing
elif not self._progress.is_visible():
if force:
Objects.tracks.remove_outside()
self._list_one_restore = self._list_one.get_selected_id()
self._list_two_restore = self._list_two.get_selected_id()
self.update_lists(True)
self._scanner.update(False)
elif Objects.tracks.is_empty():
self._scanner.update(False)
elif Objects.settings.get_value('startup-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):
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, ())
"""
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, ())
"""
Update lists
@param updater as GObject
"""
def update_lists(self, updater=None):
self._update_list_one(updater)
self._update_list_two(updater)
#.........这里部分代码省略.........
示例12: AlbumView
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [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 show [as 别名]
class Container:
"""
Container for main view
"""
def __init__(self):
"""
Init container
"""
self.__pulse_timeout = None
# Index will start at -VOLUMES
self.__devices = {}
self.__devices_index = Type.DEVICES
self.__show_genres = Lp().settings.get_value('show-genres')
self.__stack = ViewContainer(500)
self.__stack.show()
self.__setup_view()
self.__setup_scanner()
(list_one_ids, list_two_ids) = self.__get_saved_view_state()
if list_one_ids and list_one_ids[0] != Type.NONE:
self.__list_one.select_ids(list_one_ids)
if list_two_ids and list_two_ids[0] != Type.NONE:
self.__list_two.select_ids(list_two_ids)
# 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)
for mount in self.__vm.get_mounts():
self.__add_device(mount, False)
Lp().playlists.connect('playlists-changed',
self.__update_playlists)
def update_db(self):
"""
Update db at startup only if needed
"""
# Stop previous scan
if Lp().scanner.is_locked():
Lp().scanner.stop()
GLib.timeout_add(250, self.update_db)
else:
Lp().scanner.update()
def get_genre_id(self):
"""
Return current selected genre
@return genre id as int
"""
if self.__show_genres:
return self.__list_one.get_selected_id()
else:
return None
def init_list_one(self):
"""
Init list one
"""
self.__update_list_one(None)
def save_view_state(self):
"""
Save view state
"""
Lp().settings.set_value(
"list-one-ids",
GLib.Variant('ai',
self.__list_one.selected_ids))
Lp().settings.set_value(
"list-two-ids",
GLib.Variant('ai',
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
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import show [as 别名]
class Container:
"""
Container for main view
"""
def __init__(self):
"""
Init container
"""
# Index will start at -VOLUMES
self._devices = {}
self._devices_index = Type.DEVICES
self._show_genres = Lp.settings.get_value("show-genres")
self._stack = ViewContainer(500)
self._stack.show()
self._setup_view()
self._setup_scanner()
(list_one_id, list_two_id) = self._get_saved_view_state()
self._list_one.select_id(list_one_id)
self._list_two.select_id(list_two_id)
# 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)
Lp.playlists.connect("playlists-changed", self._update_lists)
def update_db(self):
"""
Update db at startup only if needed
"""
# Stop previous scan
if Lp.scanner.is_locked():
Lp.scanner.stop()
GLib.timeout_add(250, self.update_db)
else:
# Something (device manager) is using progress bar
progress = None
if not self._progress.is_visible():
progress = self._progress
Lp.scanner.update(progress)
def get_genre_id(self):
"""
Return current selected genre
@return genre id as int
"""
if self._show_genres:
return self._list_one.get_selected_id()
else:
return None
def init_list_one(self):
"""
Init list one
"""
self._update_list_one(None)
def save_view_state(self):
"""
Save view state
"""
Lp.settings.set_value("list-one", GLib.Variant("i", self._list_one.get_selected_id()))
Lp.settings.set_value("list-two", GLib.Variant("i", self._list_two.get_selected_id()))
def show_playlist_manager(self, object_id, genre_id, is_album):
"""
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
"""
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
#.........这里部分代码省略.........