本文整理汇总了Python中lollypop.pop_next.NextPopover.is_visible方法的典型用法代码示例。如果您正苦于以下问题:Python NextPopover.is_visible方法的具体用法?Python NextPopover.is_visible怎么用?Python NextPopover.is_visible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.pop_next.NextPopover
的用法示例。
在下文中一共展示了NextPopover.is_visible方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ToolbarEnd
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import is_visible [as 别名]
class ToolbarEnd(Gtk.Bin):
"""
Toolbar end
"""
def __init__(self, app):
"""
Init toolbar
@param app as Gtk.Application
"""
Gtk.Bin.__init__(self)
self.connect('show', self._on_show)
self.connect('hide', self._on_hide)
self._next_popover = NextPopover()
self._search = None
self._next_was_inhibited = False
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarEnd.ui')
builder.connect_signals(self)
self.add(builder.get_object('end'))
self._grid_next = builder.get_object('grid-next')
self._shuffle_button = builder.get_object('shuffle-button')
self._shuffle_image = builder.get_object('shuffle-button-image')
shuffleAction = Gio.SimpleAction.new('shuffle-button', None)
shuffleAction.connect('activate', self._activate_shuffle_button)
app.add_action(shuffleAction)
app.set_accels_for_action("app.shuffle-button", ["<Control>r"])
Lp().settings.connect('changed::shuffle', self._on_shuffle_changed)
self._party_button = builder.get_object('party-button')
party_action = Gio.SimpleAction.new('party', None)
party_action.connect('activate', self._activate_party_button)
app.add_action(party_action)
app.set_accels_for_action("app.party", ["<Control>p"])
self._search_button = builder.get_object('search-button')
search_action = Gio.SimpleAction.new('search', None)
search_action.connect('activate', self._on_search_button_clicked)
app.add_action(search_action)
app.set_accels_for_action("app.search", ["<Control>f"])
self._settings_button = builder.get_object('settings-button')
self._list_button = builder.get_object('list-button')
self._list_button.set_property('has-tooltip', True)
self._list_button.connect('query-tooltip',
self._on_list_button_query_tooltip)
list_action = Gio.SimpleAction.new('list', None)
list_action.connect('activate', self._on_list_button_clicked)
app.add_action(list_action)
app.set_accels_for_action("app.list", ["<Control>i"])
self._list_popover = None
Lp().player.connect('party-changed', self._on_party_changed)
Lp().player.connect('state-changed', self._on_lock_changed)
def setup_menu(self, menu):
"""
Add an application menu to menu button
@parma: menu as Gio.Menu
"""
self._settings_button.show()
self._settings_button.set_menu_model(menu)
def on_status_changed(self, player):
"""
Update buttons on status changed
@param player as Player
"""
if player.is_playing():
# Party mode can be activated
# via Fullscreen class, so check button state
self._party_button.set_active(player.is_party())
def on_next_changed(self, player, force=False):
"""
Show next popover
@param player as Player
@param force to show the popover
"""
# Do not show popover is this menu is active
# or if we are hidden
if self._shuffle_button.get_active() or\
not self._grid_next.is_visible():
return
if self._next_popover.should_be_shown() or force:
if self._next_popover.is_visible():
self._next_popover.update()
else:
self._next_popover.set_relative_to(self._grid_next)
self._next_popover.show()
else:
self._next_popover.hide()
#######################
# PRIVATE #
#######################
def _on_lock_changed(self, player):
#.........这里部分代码省略.........
示例2: ToolbarEnd
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import is_visible [as 别名]
#.........这里部分代码省略.........
Lp().settings.get_enum('shuffle') == Shuffle.TRACKS):
self._pop_next.update()
self._pop_next.set_relative_to(self)
self._pop_next.show()
else:
self._pop_next.hide()
#######################
# PRIVATE #
#######################
def _set_shuffle_icon(self):
"""
Set shuffle icon
"""
shuffle = Lp().settings.get_enum('shuffle')
if shuffle == Shuffle.NONE:
self._shuffle_btn_image.get_style_context().remove_class(
'selected')
self._shuffle_btn_image.set_from_icon_name(
"media-playlist-consecutive-symbolic",
Gtk.IconSize.SMALL_TOOLBAR)
else:
self._shuffle_btn_image.set_from_icon_name(
"media-playlist-shuffle-symbolic",
Gtk.IconSize.SMALL_TOOLBAR)
if shuffle in [Shuffle.TRACKS, Shuffle.TRACKS_ARTIST]:
self._shuffle_btn_image.get_style_context().add_class(
'selected')
else:
self._shuffle_btn_image.get_style_context().remove_class(
'selected')
if shuffle == Shuffle.TRACKS:
if Lp().player.next_track.id is not None and\
not self._pop_next.is_visible():
self._pop_next.set_relative_to(self)
self._pop_next.update()
self._pop_next.show()
elif Lp().player.is_playing():
self._pop_next.set_relative_to(None)
self._pop_next.hide()
def _shuffle_btn_aspect(self, settings, value):
"""
Mark shuffle button as active when shuffle active
@param settings as Gio.Settings, value as str
"""
self._set_shuffle_icon()
def _activate_party_button(self, action=None, param=None):
"""
Activate party button
@param action as Gio.SimpleAction
@param param as GLib.Variant
"""
self._party_btn.set_active(not self._party_btn.get_active())
def _on_search_btn_clicked(self, obj, param=None):
"""
Show search widget on search button clicked
@param obj as Gtk.Button or Gtk.Action
"""
self._search.show()
def _on_queue_btn_clicked(self, button):
"""
Show queue widget on queue button clicked
示例3: ToolbarEnd
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import is_visible [as 别名]
class ToolbarEnd(Gtk.Bin):
"""
Toolbar end
"""
def __init__(self, app):
"""
Init toolbar
@param app as Gtk.Application
"""
Gtk.Bin.__init__(self)
self.connect('show', self._on_show)
self.connect('hide', self._on_hide)
self._pop_next = NextPopover()
self._queue = None
self._search = None
self._timeout_id = None
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarEnd.ui')
builder.connect_signals(self)
self.add(builder.get_object('end'))
self._grid_next = builder.get_object('grid-next')
self._shuffle_button = builder.get_object('shuffle-button')
self._shuffle_image = builder.get_object('shuffle-button-image')
shuffleAction = Gio.SimpleAction.new('shuffle-button', None)
shuffleAction.connect('activate', self._activate_shuffle_button)
app.add_action(shuffleAction)
app.set_accels_for_action("app.shuffle-button", ["<Control>r"])
Lp().settings.connect('changed::shuffle', self._on_shuffle_changed)
self._party_button = builder.get_object('party-button')
party_action = Gio.SimpleAction.new('party', None)
party_action.connect('activate', self._activate_party_button)
app.add_action(party_action)
app.set_accels_for_action("app.party", ["<Control>p"])
self._search_button = builder.get_object('search-button')
searchAction = Gio.SimpleAction.new('search', None)
searchAction.connect('activate', self._on_search_button_clicked)
app.add_action(searchAction)
app.set_accels_for_action("app.search", ["<Control>f"])
self._queue_button = builder.get_object('queue-button')
queueAction = Gio.SimpleAction.new('queue', None)
queueAction.connect('activate', self._on_queue_button_clicked)
app.add_action(queueAction)
app.set_accels_for_action("app.queue", ["<Control>l"])
self._settings_button = builder.get_object('settings-button')
Lp().player.connect('party-changed', self._on_party_changed)
Lp().player.connect('queue-changed', self._on_queue_changed)
def setup_menu(self, menu):
"""
Add an application menu to menu button
@parma: menu as Gio.Menu
"""
self._settings_button.show()
self._settings_button.set_menu_model(menu)
def on_status_changed(self, player):
"""
Update buttons on status changed
@param player as Player
"""
if player.is_playing():
# Party mode can be activated
# via Fullscreen class, so check button state
self._party_button.set_active(player.is_party())
def on_next_changed(self, player, force=False):
"""
Show next popover
@param player as Player
@param force to show the popover
"""
# Do not show popover is this menu is active
# or if we are hidden
if self._shuffle_button.get_active() or\
not self._grid_next.is_visible():
return
self._timeout_id = None
if self._pop_next.should_be_shown() or force:
self._pop_next.update()
if not self._pop_next.is_visible():
self._pop_next.set_relative_to(self._grid_next)
self._pop_next.show()
else:
self._pop_next.hide()
#######################
# PRIVATE #
#######################
def _on_button_press(self, button, event):
"""
Show next popover on long press
#.........这里部分代码省略.........