本文整理匯總了Python中lollypop.pop_next.NextPopover.should_be_shown方法的典型用法代碼示例。如果您正苦於以下問題:Python NextPopover.should_be_shown方法的具體用法?Python NextPopover.should_be_shown怎麽用?Python NextPopover.should_be_shown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lollypop.pop_next.NextPopover
的用法示例。
在下文中一共展示了NextPopover.should_be_shown方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ToolbarEnd
# 需要導入模塊: from lollypop.pop_next import NextPopover [as 別名]
# 或者: from lollypop.pop_next.NextPopover import should_be_shown [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 should_be_shown [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
#.........這裏部分代碼省略.........