def update_player_info(self): def _update_pic(info, error=None): if info is None or error: return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: pix = GdkPixbuf.Pixbuf.new_from_file_at_size( info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix) song = self.curr_song name = Widgets.short_tooltip(song['name'], 45) if len(song['artist']) > 0: artist = Widgets.short_tooltip(song['artist'], 20) else: artist = _('Unknown') if len(song['album']) > 0: album = Widgets.short_tooltip(song['album'], 30) else: album = _('Unknown') label = '<b>{0}</b> <i><small>by {1} from {2}</small></i>'.format( name, artist, album) self.label.set_label(label) self.artist_pic.set_from_pixbuf(self.app.theme['anonymous']) Net.async_call(Net.get_artist_info, _update_pic, song['artistid'], song['artist'])
def update_player_info(self): def _update_pic(info, error=None): if not info or error: return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: self.meta_artUrl = info['pic'] pix = GdkPixbuf.Pixbuf.new_from_file_at_size( info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix) else: self.meta_artUrl = self.app.theme_path['anonymous'] self.notify.refresh() self.dbus.update_meta() song = self.curr_song name = Widgets.short_tooltip(song['name'], 45) if song['artist']: artist = Widgets.short_tooltip(song['artist'], 20) else: artist = _('Unknown') if song['album']: album = Widgets.short_tooltip(song['album'], 30) else: album = _('Unknown') label = '<b>{0}</b> <small>by {1} from {2}</small>'.format( name, artist, album) self.label.set_label(label) self.app.window.set_title(name) self.artist_pic.set_from_pixbuf(self.app.theme['anonymous']) Net.async_call( Net.get_artist_info, _update_pic, song['artistid'], song['artist'])
def update_player_info(self): def _update_pic(info, error=None): if not info or error: return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: self.meta_artUrl = info['pic'] pix = GdkPixbuf.Pixbuf.new_from_file_at_size( info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix) else: self.meta_artUrl = self.app.theme_path['anonymous'] self.notify.refresh() self.dbus.update_meta() song = self.curr_song name = Widgets.short_tooltip(song['name'], 45) if song['artist']: artist = Widgets.short_tooltip(song['artist'], 20) else: artist = _('Unknown') if song['album']: album = Widgets.short_tooltip(song['album'], 30) else: album = _('Unknown') label = '<b>{0}</b> <small>by {1} from {2}</small>'.format( name, artist, album) self.label.set_label(label) self.app.window.set_title(name) self.artist_pic.set_from_pixbuf(self.app.theme['anonymous']) Net.async_call(Net.get_artist_info, _update_pic, song['artistid'], song['artist'])
def update_player_info(self): def _update_pic(info, error=None): if not info or error: logger.error('update_player_info(): %s, %s' % (info, error)) return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: self.meta_artUrl = info['pic'] pix = GdkPixbuf.Pixbuf.new_from_file_at_size(info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix) else: self.meta_artUrl = Config.ANONYMOUS_IMG self.notify.refresh() self.dbus.update_meta() song = self.curr_song name = Widgets.short_tooltip(song['name'], 45) if song['artist']: artist = Widgets.short_tooltip(song['artist'], 20) else: artist = _('Unknown') if song['album']: album = Widgets.short_tooltip(song['album'], 30) else: album = _('Unknown') label = '<b>{0}</b> <small>{1}</small> <span size="x-small">{2}</span>'.format( name, artist, album) self.label.set_label(label) self.app.window.set_title(name) self.artist_pic.set_from_pixbuf(Config.ANONYMOUS_PIXBUF) Net.async_call(Net.get_artist_info, song['artistid'], song['artist'], callback=_update_pic)
def refresh(self): if not self.player.app.conf["use-notify"]: return notify = self.notify song = self.player.curr_song notify.clear_hints() # notify.set_timeout(4000) if song["artist"]: artist = Widgets.short_tooltip(song["artist"], 20) else: artist = _("Unknown") if song["album"]: album = Widgets.short_tooltip(song["album"], 30) else: album = _("Unknown") notify.update(song["name"], "by {0} from {1}".format(artist, album), self.player.meta_artUrl) notify.set_hint("image-path", GLib.Variant.new_string(self.player.meta_artUrl)) notify.clear_actions() try: notify.add_action("media-skip-backward", _("Previous"), self.on_prev_action_activated, None) if self.player.is_playing(): notify.add_action("media-playback-pause", _("Pause"), self.on_playpause_action_activated, None) else: notify.add_action("media-playback-start", _("Play"), self.on_playpause_action_activated, None) notify.add_action("media-skip-forward", _("Next"), self.on_next_action_activated, None) except TypeError: # For Fedora 19, which needs 6 parameters. notify.add_action("media-skip-backward", _("Previous"), self.on_prev_action_activated, None, None) if self.player.is_playing(): notify.add_action("media-playback-pause", _("Pause"), self.on_playpause_action_activated, None, None) else: notify.add_action("media-playback-start", _("Play"), self.on_playpause_action_activated, None, None) notify.add_action("media-skip-forward", _("Next"), self.on_next_action_activated, None, None) notify.set_hint("action-icons", GLib.Variant.new_boolean(True)) # gnome shell screenlocker will get `x-gnome.music` notification # and the whole notification content will be presented # from rhythmbox/plugins/rb-notification-plugin.c notify.set_category("x-gnome.music") # show on lock screen hint = "resident" # show on desktop # hint = 'transient' notify.set_hint(hint, GLib.Variant.new_boolean(True)) notify.show()
def _update_pic(info, error=None): if info is None or error: return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: pix = GdkPixbuf.Pixbuf.new_from_file_at_size( info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix)
def _update_pic(info, error=None): if not info or error: return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: self.meta_artUrl = info['pic'] pix = GdkPixbuf.Pixbuf.new_from_file_at_size( info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix) else: self.meta_artUrl = self.app.theme_path['anonymous'] self.notify.refresh() self.dbus.update_meta()
def _update_pic(info, error=None): if not info or error: logger.error('update_player_info(): %s, %s' % (info, error)) return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: self.meta_artUrl = info['pic'] pix = GdkPixbuf.Pixbuf.new_from_file_at_size( info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix) else: self.meta_artUrl = Config.ANONYMOUS_IMG self.notify.refresh() self.dbus.update_meta()
def _update_pic(info, error=None): if not info or error: logger.error('update_player_info(): %s, %s' % (info, error)) return self.artist_pic.set_tooltip_text( Widgets.short_tooltip(info['info'], length=500)) if info['pic']: self.meta_artUrl = info['pic'] pix = GdkPixbuf.Pixbuf.new_from_file_at_size(info['pic'], 100, 100) self.artist_pic.set_from_pixbuf(pix) else: self.meta_artUrl = Config.ANONYMOUS_IMG self.notify.refresh() self.dbus.update_meta()
def refresh(self): if not self.player.app.conf['use-notify']: return notify = self.notify song = self.player.curr_song notify.clear_hints() #notify.set_timeout(4000) if len(song['artist']) > 0: artist = Widgets.short_tooltip(song['artist'], 20) else: artist = _('Unknown') if len(song['album']) > 0: album = Widgets.short_tooltip(song['album'], 30) else: album = _('Unknown') notify.update( song['name'], 'by <i>{0}</i> from <i>{1}</i>'.format(artist, album), self.player.meta_artUrl ) notify.set_hint('image-path', GLib.Variant.new_string( self.player.meta_artUrl)) #notify.set_hint('icon-name', GLib.Variant.new_string( # self.player.meta_artUrl)) #notify.set_image_from_pixbuf( # self.player.artist_pic.get_pixbuf()) notify.clear_actions() try: notify.add_action( 'media-skip-backward', _('Previous'), self.on_prev_action_activated, None) if self.player.is_playing(): notify.add_action( 'media-playback-pause', _('Pause'), self.on_playpause_action_activated, None) else: notify.add_action( 'media-playback-start', _('Play'), self.on_playpause_action_activated, None) notify.add_action( 'media-skip-forward', _('Next'), self.on_next_action_activated, None) except Exception: notify.add_action( 'media-skip-backward', _('Previous'), self.on_prev_action_activated, None, None) if self.player.is_playing(): notify.add_action( 'media-playback-pause', _('Pause'), self.on_playpause_action_activated, None, None) else: notify.add_action( 'media-playback-start', _('Play'), self.on_playpause_action_activated, None, None) notify.add_action( 'media-skip-forward', _('Next'), self.on_next_action_activated, None, None) notify.set_hint('action-icons', GLib.Variant.new_boolean(True)) # gnome shell screenlocker will get `x-gnome.music` notification # and the whole notification content will be presented # from rhythmbox/plugins/rb-notification-plugin.c notify.set_category('x-gnome.music') #notify.set_hint('desktop-entry', # GLib.Variant.new_string('kwplayer')) # show on lock screen hint = 'resident' # show on desktop #hint = 'transient' notify.set_hint(hint, GLib.Variant.new_boolean(True)) notify.show()
def refresh(self): if not self.player.app.conf['use-notify']: return notify = self.notify song = self.player.curr_song notify.clear_hints() #notify.set_timeout(4000) if song['artist']: artist = Widgets.short_tooltip(song['artist'], 20) else: artist = _('Unknown') if song['album']: album = Widgets.short_tooltip(song['album'], 30) else: album = _('Unknown') notify.update(song['name'], 'by {0} from {1}'.format(artist, album), self.player.meta_artUrl) notify.set_hint('image-path', GLib.Variant.new_string(self.player.meta_artUrl)) notify.clear_actions() try: notify.add_action('media-skip-backward', _('Previous'), self.on_prev_action_activated, None) if self.player.playback_action.get_active(): notify.add_action('media-playback-pause', _('Pause'), self.on_playpause_action_activated, None) else: notify.add_action('media-playback-start', _('Play'), self.on_playpause_action_activated, None) notify.add_action('media-skip-forward', _('Next'), self.on_next_action_activated, None) except TypeError: # For Fedora 19, which needs 6 parameters. notify.add_action('media-skip-backward', _('Previous'), self.on_prev_action_activated, None, None) if self.player.playback_action.get_active(): notify.add_action('media-playback-pause', _('Pause'), self.on_playpause_action_activated, None, None) else: notify.add_action('media-playback-start', _('Play'), self.on_playpause_action_activated, None, None) notify.add_action('media-skip-forward', _('Next'), self.on_next_action_activated, None, None) notify.set_hint('action-icons', GLib.Variant.new_boolean(True)) # gnome shell screenlocker will get `x-gnome.music` notification # and the whole notification content will be presented # from rhythmbox/plugins/rb-notification-plugin.c notify.set_category('x-gnome.music') # show on lock screen hint = 'resident' # show on desktop #hint = 'transient' notify.set_hint(hint, GLib.Variant.new_boolean(True)) notify.show()
def refresh(self): if not self.player.app.conf['use-notify']: return notify = self.notify song = self.player.curr_song notify.clear_hints() #notify.set_timeout(4000) if song['artist']: artist = Widgets.short_tooltip(song['artist'], 20) else: artist = _('Unknown') if song['album']: album = Widgets.short_tooltip(song['album'], 30) else: album = _('Unknown') notify.update( song['name'], 'by {0} from {1}'.format(artist, album), self.player.meta_artUrl ) notify.set_hint('image-path', GLib.Variant.new_string(self.player.meta_artUrl)) notify.clear_actions() try: notify.add_action('media-skip-backward', _('Previous'), self.on_prev_action_activated, None) if self.player.playback_action.get_active(): notify.add_action('media-playback-pause', _('Pause'), self.on_playpause_action_activated, None) else: notify.add_action('media-playback-start', _('Play'), self.on_playpause_action_activated, None) notify.add_action('media-skip-forward', _('Next'), self.on_next_action_activated, None) except TypeError: # For Fedora 19, which needs 6 parameters. notify.add_action('media-skip-backward', _('Previous'), self.on_prev_action_activated, None, None) if self.player.playback_action.get_active(): notify.add_action('media-playback-pause', _('Pause'), self.on_playpause_action_activated, None, None) else: notify.add_action('media-playback-start', _('Play'), self.on_playpause_action_activated, None, None) notify.add_action('media-skip-forward', _('Next'), self.on_next_action_activated, None, None) notify.set_hint('action-icons', GLib.Variant.new_boolean(True)) # gnome shell screenlocker will get `x-gnome.music` notification # and the whole notification content will be presented # from rhythmbox/plugins/rb-notification-plugin.c notify.set_category('x-gnome.music') # show on lock screen hint = 'resident' # show on desktop #hint = 'transient' notify.set_hint(hint, GLib.Variant.new_boolean(True)) try: notify.show() except GLib.Error: pass