本文整理汇总了Python中quodlibet.qltk.songlist.SongList.get_selection方法的典型用法代码示例。如果您正苦于以下问题:Python SongList.get_selection方法的具体用法?Python SongList.get_selection怎么用?Python SongList.get_selection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quodlibet.qltk.songlist.SongList
的用法示例。
在下文中一共展示了SongList.get_selection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from quodlibet.qltk.songlist import SongList [as 别名]
# 或者: from quodlibet.qltk.songlist.SongList import get_selection [as 别名]
def __init__(self, Kind, library):
super(LibraryBrowser, self).__init__(dialog=False)
self.set_default_size(600, 400)
self.enable_window_tracking("browser_" + Kind.__name__)
self.set_border_width(6)
self.set_title(Kind.name + " - Quod Libet")
self.add(gtk.VBox(spacing=6))
view = SongList(library, update=True)
self.add_accel_group(view.accelerators)
self.songlist = view
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_IN)
sw.add(view)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
self.browser = browser = Kind(library, False)
if browser.reordered:
view.enable_drop()
elif browser.dropped:
view.enable_drop(False)
if browser.accelerators:
self.add_accel_group(browser.accelerators)
self.__container = browser.pack(sw)
self.child.pack_start(self.__container)
self.__statusbar = gtk.Label()
self.__statusbar.set_text(_("No time information"))
self.__statusbar.set_alignment(1.0, 0.5)
self.__statusbar.set_ellipsize(pango.ELLIPSIZE_START)
self.child.pack_end(self.__statusbar, expand=False)
browser.connect('songs-selected', self.__browser_cb)
browser.finalize(False)
view.connect('popup-menu', self.__menu, library)
view.connect('drag-data-received', self.__drag_data_recv)
view.connect('row-activated', self.__enqueue)
view.get_selection().connect('changed', self.__set_time)
if browser.headers is not None:
view.connect('columns-changed', self.__cols_changed, browser)
self.__cols_changed(view, browser)
sw.show_all()
for c in self.child.get_children():
c.show()
self.child.show()
self.show()
self.__set_pane_size()
示例2: TSongList
# 需要导入模块: from quodlibet.qltk.songlist import SongList [as 别名]
# 或者: from quodlibet.qltk.songlist.SongList import get_selection [as 别名]
#.........这里部分代码省略.........
self.assertTrue(s.get_sort_orders())
s.clear_sort()
self.assertFalse(s.get_sort_orders())
def test_not_sortable(self):
s = self.songlist
s.sortable = False
s.set_column_headers(["foo"])
s.toggle_column_sort(s.get_columns()[0])
self.assertEqual(self.orders_changed, 0)
self.assertFalse(s.get_sort_orders())
def test_find_default_sort_column(self):
s = self.songlist
self.assertTrue(s.find_default_sort_column() is None)
s.set_column_headers(["~#track"])
self.assertTrue(s.find_default_sort_column())
def test_inline_search_state(self):
self.assertEqual(self.songlist.get_search_column(), 0)
self.assertTrue(self.songlist.get_enable_search())
def test_set_songs(self):
self.songlist.set_songs([], sorted=True)
self.songlist.set_songs([], sorted=False)
self.songlist.set_songs([], scroll_select=True)
self.songlist.set_songs([], scroll_select=False)
self.songlist.set_songs([], scroll=True)
self.songlist.set_songs([], scroll=False)
def test_set_songs_restore_select(self):
song = AudioFile({"~filename": "/dev/null"})
self.songlist.add_songs([song])
sel = self.songlist.get_selection()
sel.select_path(Gtk.TreePath.new_first())
self.songlist.set_songs([song], scroll_select=True)
self.assertEqual(self.songlist.get_selected_songs(), [song])
song2 = AudioFile({"~filename": "/dev/null"})
self.songlist.set_songs([song2], scroll_select=True)
self.assertEqual(self.songlist.get_selected_songs(), [])
def test_set_songs_no_restore_select(self):
song = AudioFile({"~filename": "/dev/null"})
self.songlist.add_songs([song])
model = self.songlist.get_model()
model.go_to(song)
self.assertIs(model.current, song)
# only restore if there was a selected one
self.songlist.set_songs([song], scroll_select=True)
self.assertEqual(self.songlist.get_selected_songs(), [])
def test_get_selected_songs(self):
song = AudioFile({"~filename": "/dev/null"})
self.songlist.add_songs([song])
sel = self.songlist.get_selection()
sel.select_path(Gtk.TreePath.new_first())
self.assertEqual(self.songlist.get_selected_songs(), [song])
self.assertEqual(self.songlist.get_first_selected_song(), song)
sel.unselect_all()
self.assertEqual(self.songlist.get_selected_songs(), [])
self.assertIs(self.songlist.get_first_selected_song(), None)
示例3: TEventPlugins
# 需要导入模块: from quodlibet.qltk.songlist import SongList [as 别名]
# 或者: from quodlibet.qltk.songlist.SongList import get_selection [as 别名]
class TEventPlugins(TestCase):
def setUp(self):
self.tempdir = mkdtemp()
self.pm = PluginManager(folders=[self.tempdir])
self.lib = SongLibrarian()
lib = SongLibrary()
lib.librarian = self.lib
self.songlist = SongList(library=lib)
self.player = player.init_player("nullbe", self.lib)
self.handler = EventPluginHandler(
librarian=self.lib, player=self.player, songlist=self.songlist)
self.pm.register_handler(self.handler)
self.pm.rescan()
self.assertEquals(self.pm.plugins, [])
def tearDown(self):
self.pm.quit()
shutil.rmtree(self.tempdir)
def create_plugin(self, name='', funcs=None):
fd, fn = mkstemp(suffix='.py', text=True, dir=self.tempdir)
file = os.fdopen(fd, 'w')
file.write("from quodlibet.plugins.events import EventPlugin\n")
file.write("log = []\n")
file.write("class %s(EventPlugin):\n" % name)
indent = ' '
file.write("%spass\n" % indent)
if name:
file.write("%sPLUGIN_ID = %r\n" % (indent, name))
file.write("%sPLUGIN_NAME = %r\n" % (indent, name))
for f in (funcs or []):
file.write("%sdef %s(s, *args): log.append((%r, args))\n" %
(indent, f, f))
file.flush()
file.close()
def _get_calls(self, plugin):
mod = sys.modules[plugin.cls.__module__]
return mod.log
def test_found(self):
self.create_plugin(name='Name')
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
def test_player_paused(self):
self.create_plugin(name='Name', funcs=["plugin_on_paused"])
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
plugin = self.pm.plugins[0]
self.pm.enable(plugin, True)
self.player.emit("paused")
self.failUnlessEqual([("plugin_on_paused", tuple())],
self._get_calls(plugin))
def test_lib_changed(self):
self.create_plugin(name='Name', funcs=["plugin_on_changed"])
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
plugin = self.pm.plugins[0]
self.pm.enable(plugin, True)
self.lib.emit("changed", [None])
self.failUnlessEqual([("plugin_on_changed", ([None],))],
self._get_calls(plugin))
def test_songs_selected(self):
self.create_plugin(name='Name', funcs=["plugin_on_songs_selected"])
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
plugin = self.pm.plugins[0]
self.pm.enable(plugin, True)
self.songlist.emit("selection-changed", self.songlist.get_selection())
self.failUnlessEqual(self._get_calls(plugin),
[("plugin_on_songs_selected", ([], ))])