private bool UpdatePopup() { if (CurrentTrack == null || ArtworkManager == null || !in_thumbnail_region) { HidePopup(); return(false); } Gdk.Pixbuf pixbuf = ArtworkManager.LookupPixbuf(CurrentTrack.ArtworkId); if (pixbuf == null) { HidePopup(); return(false); } if (popup == null) { popup = new ArtworkPopup(); popup.EnterNotifyEvent += OnPopupEnterNotifyEvent; popup.LeaveNotifyEvent += OnPopupLeaveNotifyEvent; } popup.Label = String.Format("{0} - {1}", CurrentTrack.DisplayArtistName, CurrentTrack.DisplayAlbumTitle); if (popup.Image != null) { ArtworkManager.DisposePixbuf(popup.Image); } popup.Image = pixbuf; if (in_thumbnail_region) { popup.Show(); } return(true); }
private void ShowTrackNotification() { // This has to happen before the next if, otherwise the last_* members aren't set correctly. if (current_track == null || (notify_last_title == current_track.DisplayTrackTitle && notify_last_artist == current_track.DisplayArtistName)) { return; } notify_last_title = current_track.DisplayTrackTitle; notify_last_artist = current_track.DisplayArtistName; if (!show_notifications) { return; } foreach (var window in elements_service.ContentWindows) { if (window.HasToplevelFocus) { return; } } bool is_notification_daemon = false; try { var name = Notifications.Global.ServerInformation.Name; is_notification_daemon = name == "notification-daemon" || name == "Notification Daemon"; } catch { // This will be reached if no notification daemon is running return; } string message = GetByFrom( current_track.ArtistName, current_track.DisplayArtistName, current_track.AlbumTitle, current_track.DisplayAlbumTitle); string image = null; image = is_notification_daemon ? CoverArtSpec.GetPathForSize(current_track.ArtworkId, icon_size) : CoverArtSpec.GetPath(current_track.ArtworkId); if (!File.Exists(new SafeUri(image))) { if (artwork_manager_service != null) { // artwork does not exist, try looking up the pixbuf to trigger scaling or conversion Gdk.Pixbuf tmp_pixbuf = is_notification_daemon ? artwork_manager_service.LookupScalePixbuf(current_track.ArtworkId, icon_size) : artwork_manager_service.LookupPixbuf(current_track.ArtworkId); if (tmp_pixbuf == null) { image = "audio-x-generic"; } else { tmp_pixbuf.Dispose(); } } } try { if (current_nf == null) { current_nf = new Notification(current_track.DisplayTrackTitle, message, image, notif_area.Widget); } else { current_nf.Summary = current_track.DisplayTrackTitle; current_nf.Body = message; current_nf.IconName = image; current_nf.AttachToWidget(notif_area.Widget); } current_nf.Urgency = Urgency.Low; current_nf.Timeout = 4500; if (!current_track.IsLive && ActionsSupported && interface_action_service.PlaybackActions["NextAction"].Sensitive) { current_nf.AddAction("skip-song", Catalog.GetString("Skip this item"), OnSongSkipped); } current_nf.Show(); } catch (Exception e) { Hyena.Log.Warning(Catalog.GetString("Cannot show notification"), e.Message, false); } }
private void ShowTrackNotification() { // This has to happen before the next if, otherwise the last_* members aren't set correctly. if (current_track == null || (notify_last_title == current_track.DisplayTrackTitle && notify_last_artist == current_track.DisplayArtistName)) { return; } notify_last_title = current_track.DisplayTrackTitle; notify_last_artist = current_track.DisplayArtistName; if (!show_notifications) { return; } // If we have persistent notifications, we show a notification even if the main window has focus // so that the information displayed (track title, etc.) gets updated. if (!PersistenceSupported) { foreach (var window in elements_service.ContentWindows) { if (window.HasToplevelFocus) { return; } } } string message = GetByFrom( current_track.ArtistName, current_track.DisplayArtistName, current_track.AlbumTitle, current_track.DisplayAlbumTitle); string image = null; image = CoverArtSpec.GetPath(current_track.ArtworkId); if (!File.Exists(new SafeUri(image))) { if (artwork_manager_service != null) { // artwork does not exist, try looking up the pixbuf to trigger scaling or conversion Gdk.Pixbuf tmp_pixbuf = artwork_manager_service.LookupPixbuf(current_track.ArtworkId); if (tmp_pixbuf == null) { // TODO: image should be set to "audio-x-generic", but icon names are not supported by the // notification daemon in GNOME Shell. See https://bugzilla.gnome.org/show_bug.cgi?id=665957 image = null; } else { tmp_pixbuf.Dispose(); } } } try { if (current_nf == null) { current_nf = new Notification(current_track.DisplayTrackTitle, message, Banshee.ServiceStack.Application.IconName); } else { current_nf.Summary = current_track.DisplayTrackTitle; current_nf.Body = message; current_nf.IconName = Banshee.ServiceStack.Application.IconName; if (notif_area != null && notif_area.Widget != null) { current_nf.AttachToWidget(notif_area.Widget); } } current_nf.Urgency = Urgency.Low; current_nf.Timeout = 4500; if (image == null) { current_nf.RemoveHint("image-path"); } else { current_nf.AddHint("image-path", image); } if (ServiceManager.PlayerEngine.IsPlaying()) { current_nf.Category = "x-gnome.music"; } if (PersistenceSupported) { current_nf.AddHint("resident", true); } current_nf.Show(); } catch (Exception e) { Log.Error(Catalog.GetString("Cannot show notification"), e); } }
private void ShowTrackNotification() { // This has to happen before the next if, otherwise the last_* members aren't set correctly. if (current_track == null || (notify_last_title == current_track.DisplayTrackTitle && notify_last_artist == current_track.DisplayArtistName)) { return; } notify_last_title = current_track.DisplayTrackTitle; notify_last_artist = current_track.DisplayArtistName; if (!show_notifications) { return; } foreach (var window in elements_service.ContentWindows) { if (window.HasToplevelFocus) { return; } } bool is_notification_daemon = false; try { var name = Notifications.Global.ServerInformation.Name; is_notification_daemon = name == "notification-daemon" || name == "Notification Daemon"; } catch { // This will be reached if no notification daemon is running return; } string message = GetByFrom( current_track.ArtistName, current_track.DisplayArtistName, current_track.AlbumTitle, current_track.DisplayAlbumTitle); if (artwork_manager_service == null) { artwork_manager_service = ServiceManager.Get <ArtworkManager> (); } Gdk.Pixbuf image = null; if (artwork_manager_service != null) { image = is_notification_daemon ? artwork_manager_service.LookupScalePixbuf(current_track.ArtworkId, 42) : artwork_manager_service.LookupPixbuf(current_track.ArtworkId); } if (image == null) { image = IconThemeUtils.LoadIcon(48, "audio-x-generic"); if (image != null) { image.ScaleSimple(42, 42, Gdk.InterpType.Bilinear); } } try { if (current_nf == null) { current_nf = new Notification(current_track.DisplayTrackTitle, message, image, notif_area.Widget); } else { current_nf.Summary = current_track.DisplayTrackTitle; current_nf.Body = message; current_nf.Icon = image; current_nf.AttachToWidget(notif_area.Widget); } current_nf.Urgency = Urgency.Low; current_nf.Timeout = 4500; if (!current_track.IsLive && ActionsSupported && interface_action_service.PlaybackActions["NextAction"].Sensitive) { current_nf.AddAction("skip-song", Catalog.GetString("Skip this item"), OnSongSkipped); } current_nf.Show(); } catch (Exception e) { Hyena.Log.Warning(Catalog.GetString("Cannot show notification"), e.Message, false); } }