本文整理汇总了Python中lollypop.selectionlist.SelectionList.connect方法的典型用法代码示例。如果您正苦于以下问题:Python SelectionList.connect方法的具体用法?Python SelectionList.connect怎么用?Python SelectionList.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.selectionlist.SelectionList
的用法示例。
在下文中一共展示了SelectionList.connect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [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.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [as 别名]
class Container:
def __init__(self):
# 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 = 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):
if not self._progress.is_visible():
if force or Objects.tracks.is_empty():
self._scanner.update(False)
elif Objects.settings.get_value('startup-scan') or\
Objects.settings.get_value('force-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):
old_view = self._stack.get_visible_child()
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, ())
# Keep previous view,
if isinstance(old_view, PlaylistManageView):
old_view.destroy()
"""
Show playlist editor for playlist
Current view stay present in ViewContainer
@param playlist name as str
"""
def show_playlist_editor(self, playlist_name):
old_view = self._stack.get_visible_child()
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, ())
# Keep previous view,
if isinstance(old_view, PlaylistEditView):
old_view.destroy()
"""
Update lists
@param updater as GObject
"""
def update_lists(self, updater=None):
self._update_list_one(updater)
self._update_list_two(updater)
"""
Load external files
@param files as [Gio.Files]
"""
def load_external(self, files):
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [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
#.........这里部分代码省略.........
示例4: Window
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [as 别名]
class Window(Gtk.ApplicationWindow):
"""
Init window objects
"""
def __init__(self, app):
Gtk.ApplicationWindow.__init__(self,
application=app,
title=_("Lollypop"))
self._timeout = None
self._scanner = CollectionScanner()
self._scanner.connect("scan-finished", self._setup_list_one, True)
self._setup_window()
self._setup_view()
self._setup_media_keys()
party_settings = Objects["settings"].get_value('party-ids')
ids = []
for setting in party_settings:
if isinstance(setting, int):
ids.append(setting)
Objects["player"].set_party_ids(ids)
self.connect("destroy", self._on_destroyed_window)
"""
Run collection update if needed
"""
def setup_view(self):
if Objects["tracks"].is_empty():
self._scanner.update(self._progress, False)
return
elif Objects["settings"].get_value('startup-scan'):
self._scanner.update(self._progress, True)
self._setup_list_one()
self._update_view_albums(POPULARS)
"""
Update music database
"""
def update_db(self):
self._list_one.widget.hide()
self._list_two.widget.hide()
old_view = self._stack.get_visible_child()
self._loading = True
view = LoadingView()
self._stack.add(view)
self._stack.set_visible_child(view)
self._scanner.update(self._progress, False)
if old_view:
self._stack.remove(old_view)
old_view.remove_signals()
"""
Update view class
@param bool
"""
def update_view_class(self, dark):
current_view = self._stack.get_visible_child()
if dark:
current_view.get_style_context().add_class('black')
else:
current_view.get_style_context().remove_class('black')
############
# Private #
############
"""
Setup media player keys
"""
def _setup_media_keys(self):
self._proxy = Gio.DBusProxy.new_sync(Gio.bus_get_sync(Gio.BusType.SESSION, None),
Gio.DBusProxyFlags.NONE,
None,
'org.gnome.SettingsDaemon',
'/org/gnome/SettingsDaemon/MediaKeys',
'org.gnome.SettingsDaemon.MediaKeys',
None)
self._grab_media_player_keys()
try:
self._proxy.connect('g-signal', self._handle_media_keys)
except GLib.GError:
# We cannot grab media keys if no settings daemon is running
pass
"""
Do key grabbing
"""
def _grab_media_player_keys(self):
try:
self._proxy.call_sync('GrabMediaPlayerKeys',
GLib.Variant('(su)', ('Lollypop', 0)),
Gio.DBusCallFlags.NONE,
-1,
#.........这里部分代码省略.........
示例5: Window
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [as 别名]
class Window(Gtk.ApplicationWindow):
"""
Init window objects
"""
def __init__(self, app, db, player):
Gtk.ApplicationWindow.__init__(self,
application=app,
title=_("Lollypop"))
self._db = db
self._player = player
self._scanner = CollectionScanner()
self._settings = Gio.Settings.new('org.gnome.Lollypop')
self._artist_signal_id = 0
self._setup_window()
self._setup_view()
self._setup_media_keys()
party_settings = self._settings.get_value('party-ids')
ids = []
for setting in party_settings:
if isinstance(setting, int):
ids.append(setting)
self._player.set_party_ids(ids)
self.connect("map-event", self._on_mapped_window)
def edit_party(self):
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/PartyDialog.ui')
self._party_dialog = builder.get_object('party_dialog')
self._party_dialog.set_transient_for(self)
self._party_dialog.set_title(_("Select what will be available in party mode"))
party_button = builder.get_object('button1')
party_button.connect("clicked", self._edit_party_close)
scrolled = builder.get_object('scrolledwindow1')
genres = self._db.get_all_genres()
genres.insert(0, (-1, "Populars"))
self._party_grid = Gtk.Grid()
self._party_grid.set_orientation(Gtk.Orientation.VERTICAL)
self._party_grid.set_property("column-spacing", 10)
ids = self._player.get_party_ids()
i = 0
x = 0
for genre_id, genre in genres:
label = Gtk.Label()
label.set_text(genre)
switch = Gtk.Switch()
if genre_id in ids:
switch.set_state(True)
switch.connect("state-set", self._party_switch_state, genre_id)
self._party_grid.attach(label, x, i, 1, 1)
self._party_grid.attach(switch, x+1, i, 1, 1)
if x == 0:
x += 2
else:
i += 1
x = 0
scrolled.add(self._party_grid)
self._party_dialog.show_all()
"""
Update music database
Empty database if reinit True
"""
def update_db(self, reinit):
if reinit:
self._player.stop()
self._player.clear_albums()
self._toolbar.update_toolbar(None, None)
self._db.reset()
self._list_genres.widget.hide()
self._list_artists.widget.hide()
self._box.remove(self._view)
self._view = LoadingView()
self._box.add(self._view)
self._scanner.update(self._update_genres)
############
# Private #
############
"""
Update party ids when use change a switch in dialog
"""
def _party_switch_state(self, widget, state, genre_id):
ids = self._player.get_party_ids()
if state:
try:
ids.append(genre_id)
except:
pass
else:
try:
ids.remove(genre_id)
#.........这里部分代码省略.........
示例6: DeviceManagerWidget
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [as 别名]
class DeviceManagerWidget(Gtk.Bin, MtpSync):
"""
Widget for synchronize mtp devices
"""
__gsignals__ = {
'sync-finished': (GObject.SignalFlags.RUN_FIRST, None, ())
}
def __init__(self, parent):
"""
Init widget
@param device as Device
@param parent as Gtk.Widget
"""
Gtk.Bin.__init__(self)
MtpSync.__init__(self)
self.__parent = parent
self.__stop = False
self._uri = None
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/DeviceManagerWidget.ui')
widget = builder.get_object('widget')
self.__error_label = builder.get_object('error-label')
self.__switch_albums = builder.get_object('switch_albums')
self.__switch_albums.set_state(Lp().settings.get_value('sync-albums'))
self.__switch_mp3 = builder.get_object('switch_mp3')
self.__switch_normalize = builder.get_object('switch_normalize')
if not self._check_encoder_status():
self.__switch_mp3.set_sensitive(False)
self.__switch_normalize.set_sensitive(False)
self.__switch_mp3.set_tooltip_text(_("You need to install " +
"gstreamer-plugins-ugly"))
else:
self.__switch_mp3.set_state(Lp().settings.get_value('convert-mp3'))
self.__menu_items = builder.get_object('menu-items')
self.__menu = builder.get_object('menu')
self.__model = Gtk.ListStore(bool, str, int)
self.__selection_list = SelectionList(False)
self.__selection_list.connect('item-selected',
self.__on_item_selected)
widget.attach(self.__selection_list, 1, 1, 1, 1)
self.__selection_list.set_hexpand(True)
self.__view = builder.get_object('view')
self.__view.set_model(self.__model)
builder.connect_signals(self)
self.add(widget)
self.__infobar = builder.get_object('infobar')
self.__infobar_label = builder.get_object('infobarlabel')
renderer0 = Gtk.CellRendererToggle()
renderer0.set_property('activatable', True)
renderer0.connect('toggled', self.__on_item_toggled)
column0 = Gtk.TreeViewColumn(" ✓", renderer0, active=0)
column0.set_clickable(True)
column0.connect('clicked', self.__on_column0_clicked)
renderer1 = CellRendererAlbum()
self.__column1 = Gtk.TreeViewColumn("", renderer1, album=2)
renderer2 = Gtk.CellRendererText()
renderer2.set_property('ellipsize-set', True)
renderer2.set_property('ellipsize', Pango.EllipsizeMode.END)
self.__column2 = Gtk.TreeViewColumn("", renderer2, markup=1)
self.__column2.set_expand(True)
self.__view.append_column(column0)
self.__view.append_column(self.__column1)
self.__view.append_column(self.__column2)
def populate(self):
"""
Populate playlists
@thread safe
"""
self.__model.clear()
self.__stop = False
if Lp().settings.get_value('sync-albums'):
self.__selection_list.clear()
self.__setup_list_artists(self.__selection_list)
self.__column1.set_visible(True)
self.__column2.set_title(_("Albums"))
self.__selection_list.show()
self.__selection_list.select_ids([Type.ALL])
else:
playlists = [(Type.LOVED, Lp().playlists.LOVED)]
playlists += Lp().playlists.get()
self.__append_playlists(playlists)
self.__column1.set_visible(False)
self.__column2.set_title(_("Playlists"))
self.__selection_list.hide()
def set_uri(self, uri):
"""
#.........这里部分代码省略.........
示例7: __init__
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [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
#.........这里部分代码省略.........
示例8: __init__
# 需要导入模块: from lollypop.selectionlist import SelectionList [as 别名]
# 或者: from lollypop.selectionlist.SelectionList import connect [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
#.........这里部分代码省略.........