本文整理汇总了Python中lollypop.pop_next.NextPopover.set_relative_to方法的典型用法代码示例。如果您正苦于以下问题:Python NextPopover.set_relative_to方法的具体用法?Python NextPopover.set_relative_to怎么用?Python NextPopover.set_relative_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lollypop.pop_next.NextPopover
的用法示例。
在下文中一共展示了NextPopover.set_relative_to方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FullScreen
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import set_relative_to [as 别名]
class FullScreen(Gtk.Window, InfosController,
PlaybackController, ProgressController):
"""
Show a fullscreen window showing current track context
"""
def __init__(self, app, parent):
"""
Init window and set transient for parent
@param app as Gio.Application
@param parent as Gtk.window
"""
Gtk.Window.__init__(self)
PlaybackController.__init__(self)
ProgressController.__init__(self)
self.set_application(app)
self._timeout1 = None
self._timeout2 = None
self._seeking = False
self._signal1_id = None
self._signal2_id = None
self.set_decorated(False)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/FullScreen.ui')
builder.connect_signals(self)
# Calculate cover size
screen = Gdk.Screen.get_default()
monitor = screen.get_primary_monitor()
geometry = screen.get_monitor_geometry(monitor)
# We want 500 and 200 in full hd
if geometry.width > geometry.height:
artsize = int(ArtSize.MONSTER*geometry.width/1920)
else:
artsize = int(ArtSize.MONSTER*geometry.height/1920)
InfosController.__init__(self, artsize)
self._play_btn = builder.get_object('play_btn')
self._next_btn = builder.get_object('next_btn')
self._prev_btn = builder.get_object('prev_btn')
self._next_popover = NextPopover()
self._next_popover.set_position(Gtk.PositionType.BOTTOM)
self._play_image = builder.get_object('play_image')
self._pause_image = builder.get_object('pause_image')
close_btn = builder.get_object('close_btn')
close_btn.connect('clicked', self._destroy)
self._cover = builder.get_object('cover')
self._cover_frame = builder.get_object('frame')
self._title_label = builder.get_object('title')
self._artist_label = builder.get_object('artist')
self._album_label = builder.get_object('album')
self._datetime = builder.get_object('datetime')
self._progress = builder.get_object('progress_scale')
self._timelabel = builder.get_object('playback')
self._total_time_label = builder.get_object('duration')
self.connect('key-release-event', self._on_key_release_event)
self.add(builder.get_object('widget'))
def do_show(self):
"""
Init signals, set color and go party mode if nothing is playing
"""
self._signal1_id = Lp().player.connect('current-changed',
self.on_current_changed)
self._signal2_id = Lp().player.connect('status-changed',
self.on_status_changed)
if Lp().player.current_track.id is None:
Lp().player.set_party(True)
else:
self.on_status_changed(Lp().player)
self.on_current_changed(Lp().player)
if self._timeout1 is None:
self._timeout1 = GLib.timeout_add(1000, self._update_position)
Gtk.Window.do_show(self)
now = datetime.now()
self._datetime.set_label(now.strftime('%a %d %b, %X')[:-3])
if self._timeout2 is None:
second = datetime.now().second
if 60 - second > 0:
GLib.timeout_add((60-second)*1000, self._update_datetime)
else:
self._timeout2 = GLib.timeout_add(60000, self._update_datetime)
self._update_position()
self.fullscreen()
self._next_popover.set_relative_to(self._album_label)
if Lp().player.next_track.id != Type.RADIOS:
self._next_popover.show()
def do_hide(self):
"""
Remove signals and unset color
"""
Gtk.Window.do_hide(self)
if self._signal1_id is not None:
Lp().player.disconnect(self._signal1_id)
self._signal1_id = None
if self._signal2_id is not None:
Lp().player.disconnect(self._signal2_id)
#.........这里部分代码省略.........
示例2: FullScreen
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import set_relative_to [as 别名]
class FullScreen(Gtk.Window):
"""
Show a fullscreen window showing current track context
"""
def __init__(self, app, parent):
"""
Init window and set transient for parent
@param app as Gio.Application
@param parent as Gtk.window
"""
Gtk.Window.__init__(self)
self.set_application(app)
self._timeout1 = None
self._timeout2 = None
self._seeking = False
self._signal1_id = None
self._signal2_id = None
self.set_decorated(False)
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/FullScreen.ui')
builder.connect_signals(self)
# Calculate cover size
screen = Gdk.Screen.get_default()
monitor = screen.get_primary_monitor()
geometry = screen.get_monitor_geometry(monitor)
# We want 500 and 200 in full hd
if geometry.width > geometry.height:
self._artsize = int(ArtSize.MONSTER*geometry.width/1920)
else:
self._artsize = int(ArtSize.MONSTER*geometry.height/1920)
self._play_btn = builder.get_object('play_btn')
self._next_btn = builder.get_object('next_btn')
self._prev_btn = builder.get_object('prev_btn')
self._next_popover = NextPopover()
self._next_popover.set_position(Gtk.PositionType.BOTTOM)
self._play_image = builder.get_object('play_image')
self._pause_image = builder.get_object('pause_image')
close_btn = builder.get_object('close_btn')
close_btn.connect('clicked', self._destroy)
self._cover = builder.get_object('cover')
self._title = builder.get_object('title')
self._artist = builder.get_object('artist')
self._album = builder.get_object('album')
self._datetime = builder.get_object('datetime')
self._progress = builder.get_object('progress_scale')
self._timelabel = builder.get_object('playback')
self._total_time_label = builder.get_object('duration')
self.connect('key-release-event', self._on_key_release_event)
self.add(builder.get_object('widget'))
def do_show(self):
"""
Init signals, set color and go party mode if nothing is playing
"""
is_playing = Lp().player.is_playing()
self._signal1_id = Lp().player.connect('current-changed',
self._on_current_changed)
self._signal2_id = Lp().player.connect('status-changed',
self._on_status_changed)
if Lp().player.current_track is None:
Lp().player.set_party(True)
else:
if is_playing:
self._change_play_btn_status(self._pause_image, _('Pause'))
else:
self._on_status_changed(Lp().player)
self._on_current_changed(Lp().player)
if self._timeout1 is None:
self._timeout1 = GLib.timeout_add(1000, self._update_position)
Gtk.Window.do_show(self)
now = datetime.now()
self._datetime.set_label(now.strftime('%a %d %b, %X')[:-3])
if self._timeout2 is None:
second = datetime.now().second
if 60 - second > 0:
GLib.timeout_add((60-second)*1000, self._update_datetime)
else:
self._timeout2 = GLib.timeout_add(60000, self._update_datetime)
self._update_position()
self.fullscreen()
self._next_popover.set_relative_to(self._album)
if Lp().player.next_track.id != Type.RADIOS:
self._next_popover.show()
def do_hide(self):
"""
Remove signals and unset color
"""
Gtk.Window.do_hide(self)
if self._signal1_id is not None:
Lp().player.disconnect(self._signal1_id)
self._signal1_id = None
if self._signal2_id is not None:
Lp().player.disconnect(self._signal2_id)
self._signal2_id = None
#.........这里部分代码省略.........
示例3: ToolbarEnd
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import set_relative_to [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):
#.........这里部分代码省略.........
示例4: ToolbarEnd
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import set_relative_to [as 别名]
class ToolbarEnd(Gtk.Bin):
"""
Toolbar end
"""
def __init__(self, app):
"""
Init toolbar
@param app as Gtk.Application
"""
Gtk.Bin.__init__(self)
self._pop_next = NextPopover()
builder = Gtk.Builder()
builder.add_from_resource('/org/gnome/Lollypop/ToolbarEnd.ui')
builder.connect_signals(self)
self.add(builder.get_object('end'))
self._shuffle_btn = builder.get_object('shuffle-button')
self._shuffle_btn_image = builder.get_object('shuffle-button-image')
Lp().settings.connect('changed::shuffle', self._shuffle_btn_aspect)
self._party_btn = 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"])
search_button = builder.get_object('search-button')
self._search = SearchPopover(self)
self._search.set_relative_to(search_button)
searchAction = Gio.SimpleAction.new('search', None)
searchAction.connect('activate', self._on_search_btn_clicked)
app.add_action(searchAction)
app.set_accels_for_action("app.search", ["<Control>f"])
self._queue_button = builder.get_object('queue-button')
self._settings_button = builder.get_object('settings-button')
Lp().player.connect('party-changed', self._on_party_changed)
def setup_menu_btn(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_btn.set_active(player.is_party())
def do_realize(self):
"""
Show popover if needed
"""
Gtk.Bin.do_realize(self)
self._set_shuffle_icon()
def on_next_changed(self, player):
"""
Update buttons on current changed
@param player as Player
"""
# Do not show next popover non internal tracks as
# tags will be readed on the fly
if player.next_track.id is not None and\
player.next_track.id >= 0 and\
player.is_playing() and\
(player.is_party() or
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:
#.........这里部分代码省略.........
示例5: ToolbarEnd
# 需要导入模块: from lollypop.pop_next import NextPopover [as 别名]
# 或者: from lollypop.pop_next.NextPopover import set_relative_to [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
#.........这里部分代码省略.........