Example #1
0
 public CoverArtBrush()
 {
     if (ServiceManager.Contains <ArtworkManager> ())
     {
         artwork_manager = ServiceManager.Get <ArtworkManager> ();
     }
 }
Example #2
0
        private void Initialize()
        {
            interface_action_service.GlobalActions.Add(new Gtk3.ActionEntry [] {
                new Gtk3.ActionEntry("CloseAction", Gtk3.Stock.Close,
                                     AddinManager.CurrentLocalizer.GetString("_Close"), "<Control>W",
                                     AddinManager.CurrentLocalizer.GetString("Close"), CloseWindow)
            });

            actions = new BansheeActionGroup(interface_action_service, "AppIndicator");
            actions.Add(new Gtk3.ToggleActionEntry [] {
                new Gtk3.ToggleActionEntry("ShowHideAction", null,
                                           AddinManager.CurrentLocalizer.GetString("_Show Banshee"), null,
                                           AddinManager.CurrentLocalizer.GetString("Show the Banshee main window"), ToggleShowHide, PrimaryWindowVisible)
            });

            interface_action_service.AddActionGroup(actions);
            ui_manager_id = (int)interface_action_service.UIManager.AddUiFromResource("AppIndicatorMenu.xml");

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.EndOfStream |
                                                     PlayerEvent.TrackInfoUpdated |
                                                     PlayerEvent.StateChange);

            artwork_manager_service = ServiceManager.Get <ArtworkManager> ();
            artwork_manager_service.AddCachedSize(icon_size);

            // Forcefully load this
            show_notifications = ShowNotifications;

            DrawAppIndicator();
        }
Example #3
0
        private bool UpdatePopup()
        {
            if (CurrentTrack == null || ArtworkManager == null)
            {
                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);
            popup.Image = pixbuf;

            if (in_thumbnail_region)
            {
                popup.Show();
            }

            return(true);
        }
Example #4
0
        private void Initialize()
        {
            interface_action_service.GlobalActions.Add(new ActionEntry [] {
                new ActionEntry("CloseAction", Stock.Close,
                                Catalog.GetString("_Close"), "<Control>W",
                                Catalog.GetString("Close"), CloseWindow)
            });

            actions = new BansheeActionGroup(interface_action_service, "NotificationArea");
            actions.Add(new ToggleActionEntry [] {
                new ToggleActionEntry("ToggleNotificationsAction", null,
                                      Catalog.GetString("_Show Notifications"), null,
                                      Catalog.GetString("Show notifications when item changes"), ToggleNotifications, ShowNotifications)
            });

            interface_action_service.AddActionGroup(actions);
            ui_manager_id = (int)interface_action_service.UIManager.AddUiFromResource("NotificationAreaMenu.xml");

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.EndOfStream |
                                                     PlayerEvent.TrackInfoUpdated |
                                                     PlayerEvent.StateChange);

            // Forcefully load this
            show_notifications = ShowNotifications;

            artwork_manager_service = ServiceManager.Get <ArtworkManager> ();
            artwork_manager_service.AddCachedSize(icon_size);
        }
Example #5
0
        public void Constructor_For_Water_Only_Contains_Water_Images()
        {
            // arrange
            var manager = new ArtworkManager("Water");

            // assert
            Assert.IsTrue(ValidArtworksContainedTest(manager, "Water"));
        }
 public ArtworkLookup(CoverManager cover_manager)
 {
     //Log.Debug ("ArtworkLookup ctor ()");
     this.cover_manager = cover_manager;
     this.cover_manager.TargetIndexChanged += HandleTargetIndexChanged;
     artwork_manager = ServiceManager.Get <ArtworkManager> ();
     artwork_manager.AddCachedSize(cover_manager.TextureSize);
 }
 public ArtworkLookup(CoverManager cover_manager)
 {
     //Log.Debug ("ArtworkLookup ctor ()");
     this.cover_manager = cover_manager;
     this.cover_manager.TargetIndexChanged += HandleTargetIndexChanged;
     artwork_manager = ServiceManager.Get<ArtworkManager> ();
     artwork_manager.AddCachedSize (cover_manager.TextureSize);
 }
Example #8
0
        public void Constructor_For_Landscape_Only_Contains_Landscape_Images()
        {
            // arrange
            var manager = new ArtworkManager("Landscape");

            // assert
            Assert.IsTrue(ValidArtworksContainedTest(manager, "Landscape"));
        }
Example #9
0
        public void Constructor_Default_Only_Containing_Sky_Images()
        {
            // arrange
            var manager = new ArtworkManager();

            // assert
            Assert.IsTrue(ValidArtworksContainedTest(manager, "Sky"));
        }
Example #10
0
    /// <summary>
    /// AlbumMangaerを生成する。
    /// </summary>
    /// <param name="database">DB情報</param>
    /// <param name="artwork">アートワーク</param>
    public AlbumManager(Database database, ArtworkManager artwork)
    {
        this._database = database ?? throw new InvalidOperationException();

        this.Albums  = new ConcurrentObservableList <AlbumInfo>();
        this.Artwork = artwork;

        BindingOperations.EnableCollectionSynchronization(this.Albums, new object());
    }
Example #11
0
        private void categoryDrawerListView_ItemClicked(object sender, AdapterView.ItemClickEventArgs e)
        {
            drawerLayout.CloseDrawer(categoryDrawerListView);
            _artworkCategoryManager.MoveTo(e.Position);
            _artworkManager = new ArtworkManager(_artworkCategoryManager.Current.Title);
            artworkPagerAdapter.ArtworkManager = _artworkManager;

            viewPager.CurrentItem = 0;
        }
Example #12
0
        public void Managers_Current_Is_First_Of_Collection()
        {
            var manager      = new ArtworkManager();
            var currentStart = manager.CurrentArtwork;

            manager.MoveFirst();
            var fist = manager.CurrentArtwork;

            Assert.AreEqual(currentStart, fist);
        }
 private void HidePopup()
 {
     if (popup != null)
     {
         ArtworkManager.DisposePixbuf(popup.Image);
         popup.Destroy();
         popup.EnterNotifyEvent -= OnPopupEnterNotifyEvent;
         popup.LeaveNotifyEvent -= OnPopupLeaveNotifyEvent;
         popup = null;
     }
 }
        public ArtworkLookup(CoverManager coverManager)
        {
            //Log.Debug ("ArtworkLookup ctor ()");
             	this.coverManager = coverManager;
            CoverManager.TargetIndexChanged += HandleTargetIndexChanged;
            artwork_manager = ServiceManager.Get<ArtworkManager> ();
            artwork_manager.AddCachedSize (CoverManager.TextureSize);

            threaded = ClutterFlowSchemas.ThreadedArtwork.Get ();
            //Start ();
        }
Example #15
0
        public TrackInfoDisplay()
        {
            MissingAudioIconName = "audio-x-generic";
            MissingVideoIconName = "video-x-generic";
            stage.Iteration += OnStageIteration;

            if (ServiceManager.Contains<ArtworkManager> ()) {
                artwork_manager = ServiceManager.Get<ArtworkManager> ();
            }

            Connected = true;
            HasWindow = false;
        }
Example #16
0
        public TrackInfoDisplay()
        {
            MissingAudioIconName = "audio-x-generic";
            MissingVideoIconName = "video-x-generic";
            stage.Iteration     += OnStageIteration;

            if (ServiceManager.Contains <ArtworkManager> ())
            {
                artwork_manager = ServiceManager.Get <ArtworkManager> ();
            }

            Connected = true;
            HasWindow = false;
        }
Example #17
0
        public void Manager_WhenJumpToIndexToBig_ShouldThrowOutOfIndexOutOfRange()
        {
            var manager   = new ArtworkManager();
            var afterLast = manager.Length;

            try
            {
                manager.MoveTo(afterLast);
                Assert.Fail("Should not be able to move to Index greater than last");
            }
            catch (Exception e)
            {
                StringAssert.Contains(e.Message, ArtworkManager.OUT_OF_RANGE_INDEX);
            }
        }
Example #18
0
        public TrackInfoDisplay()
        {
            stage.Iteration += OnStageIteration;

            if (ServiceManager.Contains <ArtworkManager> ())
            {
                artwork_manager = ServiceManager.Get <ArtworkManager> ();
            }

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.TrackInfoUpdated |
                                                     PlayerEvent.StateChange);

            WidgetFlags |= WidgetFlags.NoWindow;
        }
Example #19
0
        private bool ServiceStartup()
        {
            if (elements_service == null || interface_action_service == null)
            {
                return(false);
            }

            interface_action_service.GlobalActions.Add(new ActionEntry [] {
                new ActionEntry("CloseAction", Stock.Close,
                                Catalog.GetString("_Close"), "<Control>W",
                                Catalog.GetString("Close"), CloseWindow)
            });
            ui_manager_id = interface_action_service.UIManager.AddUiFromString(@"
              <ui>
                <menubar name=""MainMenu"">
                  <menu name=""MediaMenu"" action=""MediaMenuAction"">
                    <placeholder name=""ClosePlaceholder"">
                    <menuitem name=""Close"" action=""CloseAction""/>
                    </placeholder>
                  </menu>
                </menubar>
              </ui>
            ");
            interface_action_service.GlobalActions.UpdateAction("QuitAction", false);

            InstallPreferences();
            sound_menu = new SoundMenuProxy();
            if (Enabled)
            {
                sound_menu.Register(true);
            }

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.EndOfStream |
                                                     PlayerEvent.TrackInfoUpdated |
                                                     PlayerEvent.StateChange);

            artwork_manager_service = ServiceManager.Get <ArtworkManager> ();
            artwork_manager_service.AddCachedSize(icon_size);

            RegisterCloseHandler();

            ServiceManager.ServiceStarted -= OnServiceStarted;

            return(true);
        }
        private void HandleActiveSourceChanged(SourceEventArgs args)
        {
            artwork_manager = ServiceManager.Get <ArtworkManager> ();

            if (!artwork_manager.IsCachedSize(image_size))
            {
                artwork_manager.AddCachedSize(image_size);
            }
            if (artwork_manager != null)
            {
                artwork_manager.ChangeCacheSize(ImageSize, GetAllAlbumsCount() + 3);
            }

            artwork_initialized = true;

            ServiceManager.SourceManager.ActiveSourceChanged -= HandleActiveSourceChanged;
        }
Example #21
0
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            ThreadAssist.ProxyToMain(delegate {
                ServiceManager.PlayerEngine.DisconnectEvent(OnPlayerEvent);
                artwork_manager_service = null;
                current_track           = null;
                image = null;

                // reestablish the user wallpaper
                SetWallpaper(userWallpaper);
                disposed = true;
            });
        }
Example #22
0
        public AlbumArtActor(AlbumInfo album, double textureSize) : base()
        {
            if (artwork_manager == null && ServiceManager.Contains <ArtworkManager> ())
            {
                artwork_manager = ServiceManager.Get <ArtworkManager> ();
            }

            var image = artwork_manager.LookupScalePixbuf(album.ArtworkId, (int)textureSize);

            if (image != null)
            {
                var img = (Image)Image.New();
                img.SetData(image.Pixels, image.HasAlpha ? Cogl.PixelFormat.Rgba8888 : Cogl.PixelFormat.Rgb888,
                            (uint)image.Width, (uint)image.Height, (uint)image.Rowstride);
                Content = img;
            }

            this.album = album;
        }
Example #23
0
        public void Length_Property_Matches_Entries()
        {
            var manager = new ArtworkManager();

            manager.MoveFirst();
            var length = manager.Length;

            for (int i = 0; i < length; i++)
            {
                //last run cant move foreward
                if (i == length - 1)
                {
                    Assert.IsFalse(manager.CanMoveNext);
                }

                manager.MoveNext();
            }
            //Assert.Fail();
        }
Example #24
0
        void IExtensionService.Initialize()
        {
            artwork_manager_service = ServiceManager.Get <ArtworkManager> ();

            ThreadAssist.AssertInMainThread();

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent,
                                                     PlayerEvent.StartOfStream |
                                                     PlayerEvent.TrackInfoUpdated);

            // capture the current wallpaper to reestablish when exiting or in albums with no art
            gClient = new GConf.Client();
            try {
                userWallpaper = (string)gClient.Get(GCONF_BACKGROUND_PATH);
            } catch (GConf.NoSuchKeyException ex) {
                Log.Error(ex.Message);
                //TODO: handle this exception (shouldn't happen though)
            }
        }
Example #25
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            backButton = FindViewById <Button>(Resource.Id.buttonBack);
            nextButton = FindViewById <Button>(Resource.Id.buttonNext);
            textTitle  = FindViewById <TextView>(Resource.Id.textTitle);
            textDesc   = FindViewById <TextView>(Resource.Id.textDesc);
            image      = FindViewById <ImageView>(Resource.Id.imageView);

            backButton.Click += backButton_Click;
            nextButton.Click += nextButton_Click;

            manager = new ArtworkManager();
            manager.MoveFirst();
            DisplayCurrentArtwork();
        }
Example #26
0
        private static bool ValidArtworksContainedTest(ArtworkManager manager, string testStr)
        {
            manager.MoveFirst();
            var artwork = manager.CurrentArtwork;
            var length  = manager.Length;

            for (int i = 0; i < length; i++)
            {
                if (artwork.Description.ToLower().Contains(testStr.ToLower()) == false)
                {
                    return(false);
                }

                if (manager.CanMoveNext)
                {
                    manager.MoveNext();
                    artwork = manager.CurrentArtwork;
                }
            }

            return(true);
        }
Example #27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ArtworkActivity);

            _artworkCategoryManager = new ArtworkCategoryManager();
            _artworkCategoryManager.MoveFirst();

            var categoryTitle = _artworkCategoryManager.Current.Title;

            _artworkManager = new ArtworkManager(categoryTitle);
            _artworkManager.MoveFirst();
            artworkPagerAdapter = new ArtworkPagerAdapter(SupportFragmentManager, _artworkManager);
            viewPager           = FindViewById <ViewPager>(Resource.Id.artworkPager);
            viewPager.Adapter   = artworkPagerAdapter;

            drawerLayout           = FindViewById <DrawerLayout>(Resource.Id.drawerLayout);
            categoryDrawerListView = FindViewById <ListView>(Resource.Id.categoryDrawerListView);

            categoryDrawerListView.Adapter = new ArtworkCategoryManagerAdapter(this, Resource.Layout.CategoryItem, _artworkCategoryManager);
            categoryDrawerListView.SetItemChecked(0, true);

            categoryDrawerListView.ItemClick += categoryDrawerListView_ItemClicked;
        }
Example #28
0
 public CoverArtBrush()
 {
     if (ServiceManager.Contains<ArtworkManager> ()) {
         artwork_manager = ServiceManager.Get<ArtworkManager> ();
     }
 }
Example #29
0
 public DataViewChildImage()
 {
     Binder = new Hyena.Data.ObjectBinder () { Property = "ArtworkId" };
     artwork_manager = ServiceManager.Get<ArtworkManager> ();
     ImageSize = 90;
 }
 public ArtworkPagerAdapter(FragmentManager fm, ArtworkManager am) : base(fm)
 {
     this.artworkManager = am;
 }
        void IExtensionService.Initialize()
        {
            artwork_manager_service = ServiceManager.Get<ArtworkManager> ();

            Banshee.Base.ThreadAssist.AssertInMainThread ();

            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
               PlayerEvent.StartOfStream |
               PlayerEvent.TrackInfoUpdated);

            // capture the current wallpaper to reestablish when exiting or in albums with no art
            gClient = new GConf.Client();
            try {
                userWallpaper = (string) gClient.Get(GCONF_BACKGROUND_PATH);
            } catch (GConf.NoSuchKeyException ex) {
                Hyena.Log.Error(ex.Message);
                //TODO: handle this exception (shouldn't happen though)
            }
        }
        public void Dispose()
        {
            if (disposed)
                return;

            Banshee.Base.ThreadAssist.ProxyToMain (delegate {
                ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
                artwork_manager_service = null;
                current_track = null;
                image = null;

                // reestablish the user wallpaper
                SetWallpaper(userWallpaper);
                disposed = 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);

            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);
            }
        }
        public override void Render(CellContext context, double cellWidth, double cellHeight)
        {
            if (!artwork_initialized) {
                artwork_manager = ServiceManager.Get<ArtworkManager> ();

                if (!artwork_manager.IsCachedSize (image_size)) {
                    artwork_manager.AddCachedSize (image_size);
                }
                if (artwork_manager != null) {
                    artwork_manager.ChangeCacheSize (ImageSize, GetAllAlbumsCount () + 3);
                }

                artwork_initialized = true;
            }

            bool is_queryalble_source = ServiceManager.SourceManager.ActiveSource is PrimarySource;
            is_queryalble_source = is_queryalble_source || ServiceManager.SourceManager.ActiveSource is PlaylistSource;
            is_queryalble_source = is_queryalble_source || ServiceManager.SourceManager.ActiveSource is SmartPlaylistSource;

            if (BoundObject == null) {
                return;
            }

            if (!(BoundObject is ArtistInfo)) {
                throw new InvalidCastException ("ColumnCellArtist can only bind to ArtistInfo objects");
            }
            var artist = (ArtistInfo)BoundObject;

            DatabaseArtistInfo db_artist = DatabaseArtistInfo.FindOrCreate (artist.Name, artist.NameSort);

            AlbumInfo[] albums = GetAlbums (db_artist.DbId);
            int album_count = albums.Length;

            string pattern = Catalog.GetString ("All Artists ({0})")
                .Replace ("(", "\\(")
                .Replace (")", "\\)")
                .Replace ("{0}", "[0-9]+");

            if (!String.IsNullOrEmpty (artist.Name) && System.Text.RegularExpressions.Regex.IsMatch (artist.Name, pattern)) {
                album_count = GetAllAlbumsCount ();
            }

            ImageSurface image = null;
            var images = new List<ImageSurface> ();

            int non_empty = 0;
            for (int i = 0; i < albums.Length && non_empty < 3; i++) {
                if (artwork_manager != null) {
                    ImageSurface sur = artwork_manager.LookupScaleSurface (albums [i].ArtworkId, image_size, true);
                    images.Add (sur);
                    if (sur != null) {
                        non_empty++;
                    }
                }
            }

            //bringing non-empty images to the front
            images.Sort (delegate (ImageSurface a, ImageSurface b) {
                if (a == null && b != null) return -1;
                if (a != null && b == null) return 1;
                return 0;
            });

            if (images.Count > 3) {
                images.RemoveRange (3, images.Count - 3);
            }

            bool is_default = false;
            if (images.Count == 0) {
                image = default_cover_image;
                is_default = true;
            } else {
                image = images[images.Count - 1];
            }

            int image_render_size = image_size;
            int x = image_spacing;
            int y = image_spacing;

            if (use_small_images) {
                x = image_spacing / 2;
                y = image_spacing / 2;
            }

            const int y_image_spacing = 1;
            int x_offset = (use_small_images ? album_spacing_small : album_spacing_normal);
            if (images.Count > 1)
                x_offset *= 2;
            int y_offset = (images.Count > 1) ? y_image_spacing * 2 : y_image_spacing;

            for (int i = 0; i < images.Count - 1; i++) {
                int move_x = x + ((i) * (use_small_images ? album_spacing_small : album_spacing_normal));
                int move_y = y + ((i) * y_image_spacing);
                ArtworkRenderer.RenderThumbnail (context.Context, images[i], false, move_x, move_y,
                    image_render_size, image_render_size, !is_default, context.Theme.Context.Radius, true, new Color (1.0, 1.0, 1.0, 1.0));
            }

            if (images.Count > 0) {
                ArtworkRenderer.RenderThumbnail (context.Context, image, false, x + x_offset, y + y_offset,
                    image_render_size, image_render_size, !is_default, context.Theme.Context.Radius, true, new Color (1.0, 1.0, 1.0, 1.0));
            } else {
                ArtworkRenderer.RenderThumbnail (context.Context, image, false, x + x_offset, y + y_offset,
                    image_render_size, image_render_size, !is_default, context.Theme.Context.Radius);
            }

            int fl_width = 0, fl_height = 0, sl_width = 0, sl_height = 0;
            context.Widget.StyleContext.Save ();
            context.Widget.StyleContext.AddClass ("entry");
            Color text_color = CairoExtensions.GdkRGBAToCairoColor (context.Widget.StyleContext.GetColor (context.State));
            context.Widget.StyleContext.Restore ();
            text_color.A = 0.75;

            Pango.Layout layout = context.Layout;
            layout.Width = (int)((cellWidth - cellHeight - x - 10) * Pango.Scale.PangoScale);
            layout.Ellipsize = Pango.EllipsizeMode.End;
            layout.FontDescription.Weight = Pango.Weight.Bold;

            // Compute the layout sizes for both lines for centering on the cell
            int old_size = layout.FontDescription.Size;

            layout.SetText (artist.DisplayName);
            layout.GetPixelSize (out fl_width, out fl_height);

            layout.FontDescription.Weight = Pango.Weight.Normal;
            layout.FontDescription.Size = (int)(old_size * Pango.Scale.Small);
            layout.FontDescription.Style = Pango.Style.Italic;

            string album_string_singular = Catalog.GetString ("Album");
            string album_string_plural = Catalog.GetString ("Albums");

            layout.SetText (album_count + " " + ((album_count == 1) ? album_string_singular : album_string_plural));
            layout.GetPixelSize (out sl_width, out sl_height);

            // Calculate the layout positioning
            x = ((int)cellHeight - x) + (use_small_images ? album_spacing_small : album_spacing_normal) + 8;
            y = use_small_images ? (int)((cellHeight - (fl_height)) / 2) : (int)((cellHeight - (fl_height + sl_height)) / 2);

            // Render the second line first since we have that state already
            if (album_count > 0 && is_queryalble_source) {
                if (use_small_images) {
                    context.Context.MoveTo (cellWidth - sl_width - image_spacing, y + image_spacing / 2);
                } else {
                    context.Context.MoveTo (x, y + fl_height);
                }
                context.Context.SetSourceColor (text_color);
                if (!use_small_images || fl_width + x + sl_width <= cellWidth) {
                    Pango.CairoHelper.ShowLayout (context.Context, layout);
                }
            }

            // Render the first line, resetting the state
            layout.SetText (artist.DisplayName);
            layout.FontDescription.Weight = Pango.Weight.Bold;
            layout.FontDescription.Size = old_size;
            layout.FontDescription.Style = Pango.Style.Normal;

            layout.SetText (artist.DisplayName);

            context.Context.MoveTo (x, y);
            text_color.A = 1;
            context.Context.SetSourceColor (text_color);
            Pango.CairoHelper.ShowLayout (context.Context, layout);
        }
Example #35
0
        private void Initialize ()
        {
            interface_action_service.GlobalActions.Add (new ActionEntry [] {
                new ActionEntry ("CloseAction", Stock.Close,
                    AddinManager.CurrentLocalizer.GetString ("_Close"), "<Control>W",
                    AddinManager.CurrentLocalizer.GetString ("Close"), CloseWindow)
            });

            actions = new BansheeActionGroup (interface_action_service, "AppIndicator");
            actions.Add (new ToggleActionEntry [] {
                new ToggleActionEntry ("ShowHideAction", null,
                    AddinManager.CurrentLocalizer.GetString ("_Show Banshee"), null,
                    AddinManager.CurrentLocalizer.GetString ("Show the Banshee main window"), ToggleShowHide, PrimaryWindowVisible)
            });

            interface_action_service.AddActionGroup (actions);
            ui_manager_id = (int)interface_action_service.UIManager.AddUiFromResource ("AppIndicatorMenu.xml");

            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
               PlayerEvent.StartOfStream |
               PlayerEvent.EndOfStream |
               PlayerEvent.TrackInfoUpdated |
               PlayerEvent.StateChange);

            artwork_manager_service = ServiceManager.Get<ArtworkManager> ();
            artwork_manager_service.AddCachedSize (icon_size);

            // Forcefully load this
            show_notifications = ShowNotifications;

            DrawAppIndicator ();
        }
 public ColumnCellPodcast () : base ()
 {
     artwork_manager = ServiceManager.Get<ArtworkManager> ();
 }
Example #37
0
        private bool ServiceStartup()
        {
            if (elements_service == null || interface_action_service == null) {
                return false;
            }

            interface_action_service.GlobalActions.Add (new ActionEntry [] {
                new ActionEntry ("CloseAction", Stock.Close,
                    Catalog.GetString ("_Close"), "<Control>W",
                    Catalog.GetString ("Close"), CloseWindow)
            });
            ui_manager_id = interface_action_service.UIManager.AddUiFromString (@"
              <ui>
                <menubar name=""MainMenu"">
                  <menu name=""MediaMenu"" action=""MediaMenuAction"">
                    <placeholder name=""ClosePlaceholder"">
                    <menuitem name=""Close"" action=""CloseAction""/>
                    </placeholder>
                  </menu>
                </menubar>
              </ui>
            ");
            interface_action_service.GlobalActions.UpdateAction ("QuitAction", false);

            InstallPreferences ();
            sound_menu = new SoundMenuProxy ();
            if (Enabled) {
                sound_menu.Register (true);
            }

            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
               PlayerEvent.StartOfStream |
               PlayerEvent.EndOfStream |
               PlayerEvent.TrackInfoUpdated |
               PlayerEvent.StateChange);

            artwork_manager_service = ServiceManager.Get<ArtworkManager> ();
            artwork_manager_service.AddCachedSize (icon_size);

            RegisterCloseHandler ();

            ServiceManager.ServiceStarted -= OnServiceStarted;

            return true;
        }
        public DataViewChildAlbum ()
        {
            artwork_manager = ServiceManager.Get<ArtworkManager> ();

            Padding = new Thickness (5);
            ImageSize = 90;
            ImageSpacing = 2;
            TextSpacing = 2;
        }
Example #39
0
 public ColumnCellAlbum () : base (null, true)
 {
     artwork_manager = ServiceManager.Get<ArtworkManager> ();
 }
        public override void Render(CellContext context, double cellWidth, double cellHeight)
        {
            if (!artwork_initialized)
            {
                artwork_manager = ServiceManager.Get <ArtworkManager> ();

                if (!artwork_manager.IsCachedSize(image_size))
                {
                    artwork_manager.AddCachedSize(image_size);
                }
                if (artwork_manager != null)
                {
                    artwork_manager.ChangeCacheSize(ImageSize, GetAllAlbumsCount() + 3);
                }

                artwork_initialized = true;
            }

            bool is_queryalble_source = ServiceManager.SourceManager.ActiveSource is PrimarySource;

            is_queryalble_source = is_queryalble_source || ServiceManager.SourceManager.ActiveSource is PlaylistSource;
            is_queryalble_source = is_queryalble_source || ServiceManager.SourceManager.ActiveSource is SmartPlaylistSource;

            if (BoundObject == null)
            {
                return;
            }

            if (!(BoundObject is ArtistInfo))
            {
                throw new InvalidCastException("ColumnCellArtist can only bind to ArtistInfo objects");
            }
            var artist = (ArtistInfo)BoundObject;

            DatabaseArtistInfo db_artist = DatabaseArtistInfo.FindOrCreate(artist.Name, artist.NameSort);

            AlbumInfo[] albums      = GetAlbums(db_artist.DbId);
            int         album_count = albums.Length;

            string pattern = Catalog.GetString("All Artists ({0})")
                             .Replace("(", "\\(")
                             .Replace(")", "\\)")
                             .Replace("{0}", "[0-9]+");

            if (!String.IsNullOrEmpty(artist.Name) && System.Text.RegularExpressions.Regex.IsMatch(artist.Name, pattern))
            {
                album_count = GetAllAlbumsCount();
            }

            ImageSurface image  = null;
            var          images = new List <ImageSurface> ();

            int non_empty = 0;

            for (int i = 0; i < albums.Length && non_empty < 3; i++)
            {
                if (artwork_manager != null)
                {
                    ImageSurface sur = artwork_manager.LookupScaleSurface(albums [i].ArtworkId, image_size, true);
                    images.Add(sur);
                    if (sur != null)
                    {
                        non_empty++;
                    }
                }
            }

            //bringing non-empty images to the front
            images.Sort(delegate(ImageSurface a, ImageSurface b) {
                if (a == null && b != null)
                {
                    return(-1);
                }
                if (a != null && b == null)
                {
                    return(1);
                }
                return(0);
            });

            if (images.Count > 3)
            {
                images.RemoveRange(3, images.Count - 3);
            }

            bool is_default = false;

            if (images.Count == 0)
            {
                image      = default_cover_image;
                is_default = true;
            }
            else
            {
                image = images[images.Count - 1];
            }

            int image_render_size = image_size;
            int x = image_spacing;
            int y = image_spacing;

            if (use_small_images)
            {
                x = image_spacing / 2;
                y = image_spacing / 2;
            }

            const int y_image_spacing = 1;
            int       x_offset        = (use_small_images ? album_spacing_small : album_spacing_normal);

            if (images.Count > 1)
            {
                x_offset *= 2;
            }
            int y_offset = (images.Count > 1) ? y_image_spacing * 2 : y_image_spacing;

            for (int i = 0; i < images.Count - 1; i++)
            {
                int move_x = x + ((i) * (use_small_images ? album_spacing_small : album_spacing_normal));
                int move_y = y + ((i) * y_image_spacing);
                ArtworkRenderer.RenderThumbnail(context.Context, images[i], false, move_x, move_y,
                                                image_render_size, image_render_size, !is_default, context.Theme.Context.Radius, true, new Color(1.0, 1.0, 1.0, 1.0));
            }

            if (images.Count > 0)
            {
                ArtworkRenderer.RenderThumbnail(context.Context, image, false, x + x_offset, y + y_offset,
                                                image_render_size, image_render_size, !is_default, context.Theme.Context.Radius, true, new Color(1.0, 1.0, 1.0, 1.0));
            }
            else
            {
                ArtworkRenderer.RenderThumbnail(context.Context, image, false, x + x_offset, y + y_offset,
                                                image_render_size, image_render_size, !is_default, context.Theme.Context.Radius);
            }

            int fl_width = 0, fl_height = 0, sl_width = 0, sl_height = 0;

            context.Widget.StyleContext.Save();
            context.Widget.StyleContext.AddClass("entry");
            Color text_color = CairoExtensions.GdkRGBAToCairoColor(context.Widget.StyleContext.GetColor(context.State));

            context.Widget.StyleContext.Restore();
            text_color.A = 0.75;

            Pango.Layout layout = context.Layout;
            layout.Width     = (int)((cellWidth - cellHeight - x - 10) * Pango.Scale.PangoScale);
            layout.Ellipsize = Pango.EllipsizeMode.End;
            layout.FontDescription.Weight = Pango.Weight.Bold;

            // Compute the layout sizes for both lines for centering on the cell
            int old_size = layout.FontDescription.Size;

            layout.SetText(artist.DisplayName);
            layout.GetPixelSize(out fl_width, out fl_height);

            layout.FontDescription.Weight = Pango.Weight.Normal;
            layout.FontDescription.Size   = (int)(old_size * Pango.Scale.Small);
            layout.FontDescription.Style  = Pango.Style.Italic;

            string album_string_singular = Catalog.GetString("Album");
            string album_string_plural   = Catalog.GetString("Albums");

            layout.SetText(album_count + " " + ((album_count == 1) ? album_string_singular : album_string_plural));
            layout.GetPixelSize(out sl_width, out sl_height);

            // Calculate the layout positioning
            x = ((int)cellHeight - x) + (use_small_images ? album_spacing_small : album_spacing_normal) + 8;
            y = use_small_images ? (int)((cellHeight - (fl_height)) / 2) : (int)((cellHeight - (fl_height + sl_height)) / 2);

            // Render the second line first since we have that state already
            if (album_count > 0 && is_queryalble_source)
            {
                if (use_small_images)
                {
                    context.Context.MoveTo(cellWidth - sl_width - image_spacing, y + image_spacing / 2);
                }
                else
                {
                    context.Context.MoveTo(x, y + fl_height);
                }
                context.Context.SetSourceColor(text_color);
                if (!use_small_images || fl_width + x + sl_width <= cellWidth)
                {
                    Pango.CairoHelper.ShowLayout(context.Context, layout);
                }
            }

            // Render the first line, resetting the state
            layout.SetText(artist.DisplayName);
            layout.FontDescription.Weight = Pango.Weight.Bold;
            layout.FontDescription.Size   = old_size;
            layout.FontDescription.Style  = Pango.Style.Normal;

            layout.SetText(artist.DisplayName);

            context.Context.MoveTo(x, y);
            text_color.A = 1;
            context.Context.SetSourceColor(text_color);
            Pango.CairoHelper.ShowLayout(context.Context, layout);
        }
Example #41
0
        protected override void AddTrackToDevice(DatabaseTrackInfo track, SafeUri fromUri)
        {
            if (track.PrimarySourceId == DbId)
            {
                return;
            }

            lock (mtp_device) {
                Track  mtp_track = TrackInfoToMtpTrack(track, fromUri);
                bool   video     = track.HasAttribute(TrackMediaAttributes.VideoStream);
                Folder folder    = GetFolderForTrack(track);
                mtp_device.UploadTrack(fromUri.LocalPath, mtp_track, folder, OnUploadProgress);

                // Add/update album art
                if (!video)
                {
                    string key = MakeAlbumKey(track);
                    if (!album_cache.ContainsKey(key))
                    {
                        // LIBMTP 1.0.3 BUG WORKAROUND
                        // In libmtp.c the 'LIBMTP_Create_New_Album' function invokes 'create_new_abstract_list'.
                        // The latter calls strlen on the 'name' parameter without null checking. If AlbumTitle is
                        // null, this causes a sigsegv. Lets be safe and always pass non-null values.
                        Album album = new Album(mtp_device, track.AlbumTitle ?? "", track.AlbumArtist ?? "", track.Genre ?? "", track.Composer ?? "");
                        album.AddTrack(mtp_track);

                        if (supports_jpegs && can_sync_albumart)
                        {
                            ArtworkManager art = ServiceManager.Get <ArtworkManager> ();
                            Exception      ex = null;
                            Gdk.Pixbuf     pic = null;
                            byte[]         bytes = null;
                            uint           width = 0, height = 0;
                            ThreadAssist.BlockingProxyToMain(() => {
                                try {
                                    pic = art.LookupScalePixbuf(track.ArtworkId, thumb_width);
                                    if (pic != null)
                                    {
                                        bytes  = pic.SaveToBuffer("jpeg");
                                        width  = (uint)pic.Width;
                                        height = (uint)pic.Height;
                                    }
                                } catch (Exception e) {
                                    ex = e;
                                }
                            });

                            try {
                                if (ex != null)
                                {
                                    throw ex;
                                }
                                if (bytes != null)
                                {
                                    ArtworkManager.DisposePixbuf(pic);
                                    album.Save(bytes, width, height);
                                    album_cache [key] = Tuple.Create(album, folder);
                                }
                            } catch (Exception e) {
                                Log.Debug("Failed to create MTP Album", e.Message);
                            }
                        }
                        else
                        {
                            album.Save();
                            album_cache[key] = Tuple.Create(album, folder);
                        }
                    }
                    else
                    {
                        Album album = album_cache[key].Item1;
                        album.AddTrack(mtp_track);
                        album.Save();
                    }
                }

                MtpTrackInfo new_track = new MtpTrackInfo(mtp_device, mtp_track);
                new_track.PrimarySource = this;
                new_track.Save(false);
                track_map[new_track.TrackId] = mtp_track;
            }
        }
        private void HandleActiveSourceChanged(SourceEventArgs args)
        {
            artwork_manager = ServiceManager.Get<ArtworkManager> ();

            if (!artwork_manager.IsCachedSize (image_size)) {
                artwork_manager.AddCachedSize (image_size);
            }
            if (artwork_manager != null) {
                artwork_manager.ChangeCacheSize (ImageSize, GetAllAlbumsCount () + 3);
            }

            artwork_initialized = true;

            ServiceManager.SourceManager.ActiveSourceChanged -= HandleActiveSourceChanged;
        }
Example #43
0
 public ColumnCellPodcast() : base()
 {
     artwork_manager = ServiceManager.Get <ArtworkManager> ();
 }
Example #44
0
        private void Initialize()
        {
            interface_action_service.GlobalActions.Add (new ActionEntry [] {
                new ActionEntry ("CloseAction", Stock.Close,
                    Catalog.GetString ("_Close"), "<Control>W",
                    Catalog.GetString ("Close"), CloseWindow)
            });

            actions = new BansheeActionGroup (interface_action_service, "NotificationArea");
            actions.Add (new ToggleActionEntry [] {
                new ToggleActionEntry ("ToggleNotificationsAction", null,
                    Catalog.GetString ("_Show Notifications"), null,
                    Catalog.GetString ("Show notifications when item changes"), ToggleNotifications, ShowNotifications)
            });

            interface_action_service.AddActionGroup (actions);
            ui_manager_id = (int)interface_action_service.UIManager.AddUiFromResource ("NotificationAreaMenu.xml");

            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
               PlayerEvent.StartOfStream |
               PlayerEvent.EndOfStream |
               PlayerEvent.TrackInfoUpdated |
               PlayerEvent.StateChange);

            // Forcefully load this
            show_notifications = ShowNotifications;

            artwork_manager_service = ServiceManager.Get<ArtworkManager> ();
        }
Example #45
0
        public void LoadTrackToEditor()
        {
            TrackInfo       current_track = null;
            EditorTrackInfo editor_track  = LoadTrack(current_track_index, out current_track);

            if (editor_track == null)
            {
                return;
            }

            // Update the Header
            header_title_label.Text  = current_track.DisplayTrackTitle;
            header_artist_label.Text = current_track.DisplayArtistName;
            header_album_label.Text  = current_track.DisplayAlbumTitle;

            if (edit_notif_label != null)
            {
                edit_notif_label.Markup = String.Format(Catalog.GetString("<i>Editing {0} of {1} items</i>"),
                                                        CurrentTrackIndex + 1, TrackCount);
            }

            ArtworkManager artwork = ServiceManager.Get <ArtworkManager> ();

            Gdk.Pixbuf cover_art = artwork.LookupScalePixbuf(current_track.ArtworkId, 64);
            header_image.Pixbuf = cover_art;
            if (cover_art == null)
            {
                header_image.IconName         = "media-optical";
                header_image.PixelSize        = 64;
                header_image_frame.ShadowType = ShadowType.None;
            }
            else
            {
                header_image_frame.ShadowType = ShadowType.In;
            }

            // Disconnect all the undo adapters
            ForeachWidget <ICanUndo> (delegate(ICanUndo undoable) {
                undoable.DisconnectUndo();
            });

            foreach (ITrackEditorPage page in pages)
            {
                page.LoadTrack(editor_track);
            }

            // Connect all the undo adapters
            ForeachWidget <ICanUndo> (delegate(ICanUndo undoable) {
                undoable.ConnectUndo(editor_track);
            });

            // Update Navigation
            if (TrackCount > 0 && nav_backward_button != null && nav_forward_button != null)
            {
                nav_backward_button.Sensitive = CanGoBackward;
                nav_forward_button.Sensitive  = CanGoForward;
            }

            // If there was a widget focused already (eg the Title entry), GrabFocus on it,
            // which causes its text to be selected, ready for editing.
            Widget child = FocusChild;

            while (child != null)
            {
                Container container = child as Container;
                if (container != null)
                {
                    child = container.FocusChild;
                }
                else if (child != null)
                {
                    child.GrabFocus();
                    child = null;
                }
            }
        }