本文整理匯總了Python中lollypop.radios.Radios.get_cursor方法的典型用法代碼示例。如果您正苦於以下問題:Python Radios.get_cursor方法的具體用法?Python Radios.get_cursor怎麽用?Python Radios.get_cursor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lollypop.radios.Radios
的用法示例。
在下文中一共展示了Radios.get_cursor方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: quit
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_cursor [as 別名]
def quit(self):
"""
Quit lollypop
"""
if Lp.scanner.is_locked():
Lp.scanner.stop()
GLib.idle_add(self.quit)
return
try:
Lp.sql.execute('VACUUM')
sql_p = Lp.playlists.get_cursor()
sql_p.execute('VACUUM')
sql_p.close()
radios = Radios()
sql_r = radios.get_cursor()
sql_r.execute('VACUUM')
sql_r.close()
except Exception as e:
print("Application::quit(): ", e)
Lp.window.destroy()
Lp.sql.close()
Gst.deinit()
示例2: RadiosView
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_cursor [as 別名]
class RadiosView(View):
"""
Show radios in a grid
"""
def __init__(self):
"""
Init view
"""
View.__init__(self)
self._signal = Lp.art.connect('radio-artwork-changed',
self._on_logo_changed)
self._radios_manager = Radios()
self._radios_manager.connect('radios-changed',
self._on_radios_changed)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
builder.connect_signals(self)
widget = builder.get_object('widget')
self._empty = builder.get_object('empty')
self._pop_tunein = TuneinPopover(self._radios_manager)
self._pop_tunein.set_relative_to(builder.get_object('search_btn'))
self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)
self._radiobox = Gtk.FlowBox()
self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
self._radiobox.connect("child-activated", self._on_album_activated)
self._radiobox.set_property('column-spacing', 5)
self._radiobox.set_property('row-spacing', 5)
self._radiobox.set_homogeneous(True)
self._radiobox.set_max_children_per_line(1000)
self._radiobox.show()
self._stack = Gtk.Stack()
self._stack.set_transition_duration(500)
self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
self._stack.add(self._scrolledWindow)
self._stack.add(self._empty)
self._stack.show()
self._viewport.set_property("valign", Gtk.Align.START)
self._viewport.set_property('margin', 5)
self._viewport.add(self._radiobox)
self._scrolledWindow.set_property('expand', True)
self.add(widget)
self.add(self._stack)
def populate(self):
"""
Populate view with tracks from playlist
Thread safe
"""
t = Thread(target=self._populate)
t.daemon = True
t.start()
#######################
# PRIVATE #
#######################
def _populate(self):
"""
Populate view with tracks from playlist
Thread safe
"""
radios = []
# Get radios name
sql = self._radios_manager.get_cursor()
for (name, url) in self._radios_manager.get(sql):
radios.append(name)
sql.close()
GLib.idle_add(self._show_stack, radios)
def _get_children(self):
"""
Return view children
@return [RadioWidget]
"""
children = []
for child in self._radiobox.get_children():
widget = child.get_child()
children.append(widget)
return children
def _on_destroy(self, widget):
"""
Disconnect signals
@param widget as Gtk.Widget
"""
if self._signal is not None:
Lp.art.disconnect(self._signal)
def _on_new_clicked(self, widget):
"""
Show popover for adding a new radio
@param widget as Gtk.Widget
"""
#.........這裏部分代碼省略.........
示例3: TuneinPopover
# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_cursor [as 別名]
#.........這裏部分代碼省略.........
self._stack.set_visible_child_name('scrolled')
self._label.set_text(_("Browse themes and add a new radio"))
if self._current_url is not None:
self._back_btn.set_sensitive(True)
self._home_btn.set_sensitive(True)
def _clear(self):
"""
Clear view
"""
for child in self._view.get_children():
self._view.remove(child)
child.destroy()
def _add_radio(self, item):
"""
Add selected radio
@param item as TuneIn Item
"""
# Get cover art
try:
cache = Art._RADIOS_PATH
s = Gio.File.new_for_uri(item.LOGO)
d = Gio.File.new_for_path(cache+"/%s.png" %
item.TEXT.replace('/', '-'))
s.copy(d, Gio.FileCopyFlags.OVERWRITE, None, None)
except Exception as e:
print("TuneinPopover::_add_radio: %s" % e)
url = item.URL
# Tune in embbed uri in ashx files, so get content if possible
try:
f = Gio.File.new_for_uri(url)
(status, data, tag) = f.load_contents()
if status:
url = data.decode('utf-8').split('\n')[0]
except Exception as e:
print("TuneinPopover::_add_radio: %s" % e)
sql = self._radios_manager.get_cursor()
self._radios_manager.add(item.TEXT.replace('/', '-'), url, sql)
sql.close()
def _on_back_btn_clicked(self, btn):
"""
Go to previous URL
@param btn as Gtk.Button
"""
url = None
self._current_url = None
if self._previous_urls:
url = self._previous_urls.pop()
self._stack.set_visible_child_name('spinner')
self._clear()
self.populate(url)
def _on_home_btn_clicked(self, btn):
"""
Go to root URL
@param btn as Gtk.Button
"""
self._current_url = None
self._previous_urls = []
self._stack.set_visible_child_name('spinner')
self._clear()
self.populate()
def _on_activate_link(self, link, item):
"""
Update header with new link
@param link as Gtk.LinkButton
@param item as TuneIn Item
"""
if item.TYPE == "link":
self._stack.set_visible_child_name('spinner')
self._clear()
self._scrolled.get_vadjustment().set_value(0.0)
if self._current_url is not None:
self._previous_urls.append(self._current_url)
self.populate(item.URL)
elif item.TYPE == "audio":
for i in self._current_items:
Lp.player.load_external(i.URL, i.TEXT)
Lp.player.play_this_external(item.URL)
# Only toolbar will get this one, so only create small in cache
if Gio.NetworkMonitor.get_default().get_network_available():
t = Thread(target=Lp.art.copy_uri_to_cache,
args=(item.LOGO, item.TEXT, ArtSize.SMALL))
t.daemon = True
t.start()
return True
def _on_button_clicked(self, button, item):
"""
Play the radio
@param link as Gtk.Button
@param item as TuneIn Item
"""
t = Thread(target=self._add_radio, args=(item,))
t.daemon = True
t.start()
self.hide()