Exemplo n.º 1
0
            // Delegate Functions :: MainLoopIdle (ThreadBase)
            /// <summary>
            ///	Adds the covers from the queue to their
            ///	associated albums.
            /// </summary>
            /// <remarks>
            ///	This runs from GLib's main loop.
            /// </remarks>
            /// <returns>
            ///	True if the loop should continue,
            ///	False if it should stop.
            /// </returns>
            protected override bool MainLoopIdle()
            {
                if (queue.Count == 0)
                {
                    if (thread_done)
                    {
                        Global.CoverDB.EmitDoneLoading();
                        return(false);
                    }

                    return(true);
                }

                LoadedCover lc = (LoadedCover)queue.Dequeue();

                lc.Item.CoverImage = lc.Pixbuf;

                return(true);
            }
Exemplo n.º 2
0
            // Delegate Functions :: DecodeFunction
            //   (Database.DecodeFunctionDelegate)
            /// <summary>
            ///	Delegate to decode the data in the database.
            /// </summary>
            /// <param name="key">
            ///	The album key.
            /// </param>
            /// <param name="data">
            ///	An <see cref="IntPtr" /> to the data.
            /// </param>
            private void DecodeFunction(string key, IntPtr data)
            {
                IntPtr p = data;

                bool being_checked;

                p = Database.UnpackBool(p, out being_checked);

                Pixbuf pixbuf = null;

                if (!being_checked)
                {
                    IntPtr pix_handle;
                    p      = Database.UnpackPixbuf(p, out pix_handle);
                    pixbuf = new Pixbuf(pix_handle);
                }

                if (Global.CoverDB.Covers.Contains(key))
                {
                    if (being_checked)
                    {
                        return;
                    }

                    // stored covers take priority
                    Global.CoverDB.Covers.Remove(key);
                }

                // Add independent of whether item is null or not,
                // this way manually set covers will stay for
                // removable devices.
                if (!being_checked)
                {
                    Global.CoverDB.Covers.Add(key, pixbuf);
                }

                Item item = Global.DB.GetAlbum(key);

                if (item == null)
                {
                    item = Global.DB.GetSong(key);
                }

                if (item != null)
                {
                    if (being_checked)
                    {
                        // false, as we don't want to write to the db
                        // while we're loading
                        Album album = (Album)item;

                        pixbuf =
                            Global.CoverDB.Getter.GetAmazon(album, false);

                        Global.CoverDB.Covers.Add(key, null);
                    }

                    LoadedCover lc = new LoadedCover(item, pixbuf);
                    queue.Enqueue(lc);
                }
            }