Beispiel #1
0
        /// <summary>
        /// To add ArtItem into GUI
        /// </summary>
        /// <param name="type">ArtType to update</param>
        /// <param name="store">Store</param>
        /// <param name="iter">Iter to be defined</param>
        /// <returns>numbers remaining item</returns>
        public int AddArt(ArtType type, ref TreeStore store)
        {
            TreeIter iter;                                      // = new TreeIter();

            Gdk.Pixbuf imagePreview;                            // Thumbnail
            int        remainingArt = 0;                        // Number of remaining item
            ArtItem    item         = null;
            String     description  = "Description unvailable"; // Default description

            if (_xml.InitGetArt(type) != 0)
            {
                item = _xml.GetArtItem(out remainingArt);
                Console.WriteLine("Remaining Art to fetch : " + remainingArt);
            }
            else
            {
                return(0);
            }

            if (item != null)
            {
                try {
                    imagePreview = new Gdk.Pixbuf(item.ThumbnailFile);
                }
                catch (GLib.GException e) {
                    Console.WriteLine("Error with " + item.Url + " : " + e.Message);
                    imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png");
                }

                /*catch (System.NullReferenceException ex) {
                 *      Console.WriteLine ("Error with " + item.Url + " : " + ex.Message);
                 *      imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png" );
                 * }*/

                try {
                    Console.WriteLine("Description :" + item.Description + " " + type);
                    description = item.Description;
                }
                catch (System.NullReferenceException ex) {}
            }
            else
            {
                Console.Error.WriteLine("No ArtItem available");
                imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png");
            }

            iter = store.AppendValues(imagePreview, description);

            _guiArts.Add(iter, item);               // Insert the corresponding ArtItem into an Hashtable

            return(remainingArt);
        }
Beispiel #2
0
        /// <summary>
        /// Parse one element of the xml and return the ArtItem generated.
        /// </summary>
        /// <param name="Remaining">Number of ArtItem remaining in the xml. Decresed by 1 each time this method is called.</param>
        /// <returns>an ArtItem corresponding to the current ArtType.</returns>
        public ArtItem GetArtItem(out int remaining)
        {
            remaining = _remaingElmt;

            if (remaining == 0)
            {
                return(null);
            }

            // Read the xml until the begining of the next ArtItem declaration

            /*Console.WriteLine("Depth 1 :" + _xmlRd.Depth );
            *  _xmlRd.Read();
            *  Console.WriteLine("Depth 1.5 :" + _xmlRd.Depth );
            *  while (_xmlRd.NodeType != XmlNodeType.Element && _xmlRd.Depth != 1)
            *  {
            *       Console.WriteLine("Depth :" + _xmlRd.Depth );
            *       if (!_xmlRd.Read())
            *       {
            *               Console.WriteLine("No more nodes to read");
            *               remaining = -1;
            *               return null;
            *       }
            *  }
            *  Console.WriteLine("Depth 2 :" + _xmlRd.Depth );*/

            /*
             * At this point what we read in the xml concern the ArtItem we want to fill.
             * We just have to call a private method to do this
             */
            ArtItem Item = this.FillArtItem();

            // Decrease the number of remaining Elements in the xml.
            if (_xmlRd.EOF)
            {
                remaining = 0;
            }
            else
            {
                _remaingElmt--;
                remaining = _remaingElmt;
            }

            return(Item);
        }
Beispiel #3
0
        /// <summary>
        /// Fill and return an ArtItem depending on the current ArtType. Read the xml to complete informations of the ArtItem.
        /// </summary>
        /// <returns>a fully operationnal ArtItem</returns>
        private ArtItem FillArtItem()
        {
            String downloadStartTimestamp = null,
                   name           = null,
                   description    = null,
                   category       = null,
                   author         = null,
                   license        = null,
                   thumbnail      = null,
                   smallThumbnail = null,
                   url            = null,
                   resolution     = null;

            ArtItem item = null;

            _xmlRd.Read();              // move to the first node - Depth = 1

            //  fill variables with data from the xml
            while (
                !_xmlRd.EOF &&
                !(_xmlRd.Name == "theme" || _xmlRd.Name == "background") ||
                _xmlRd.NodeType != XmlNodeType.EndElement
                )
            {
                _xmlRd.Read();
                while (_xmlRd.NodeType == XmlNodeType.Whitespace)
                {
                    _xmlRd.Read();
                }

                if ((_xmlRd.Name == "theme" || _xmlRd.Name == "background") && _xmlRd.NodeType == XmlNodeType.Element)
                {
                    downloadStartTimestamp = _xmlRd.GetAttribute("download_start_timestamp");
                }
                else if (_xmlRd.Name == "name")
                {
                    name = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "description")
                {
                    description = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "category")
                {
                    category = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "author")
                {
                    author = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "license")
                {
                    license = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "thumbnail")
                {
                    thumbnail = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "small_thumbnail")
                {
                    smallThumbnail = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "url")
                {
                    url = _xmlRd.ReadString();
                }
                else if (_xmlRd.Name == "resolution")
                {
                    resolution = _xmlRd.ReadString();
                }
            }

            switch (_curArtType)
            {
            case ArtType.BackgroundAll:
                Console.WriteLine("Create BackgroundAll");
                item = new ArtBackground(ArtType.BackgroundAll, resolution, downloadStartTimestamp, "", name, description, author, url, thumbnail);
                break;

            case ArtType.BackgroundAbstract:
                Console.WriteLine("Create BackgroundAbstract");
                item = new ArtBackground(ArtType.BackgroundAbstract, resolution, downloadStartTimestamp, "", name, description, author, url, thumbnail);
                break;

            case ArtType.BackgroundGnome:
                Console.WriteLine("Create BackgroundGnome");
                item = new ArtBackground(ArtType.BackgroundGnome, resolution, downloadStartTimestamp, "", name, description, author, url, thumbnail);
                break;

            case ArtType.BackgroundNature:
                Console.WriteLine("Create BackgroundNature");
                item = new ArtBackground(ArtType.BackgroundNature, resolution, downloadStartTimestamp, "", name, description, author, url, thumbnail);
                break;

            case ArtType.BackgroundOther:
                Console.WriteLine("Create BackgroundOther");
                item = new ArtBackground(ArtType.BackgroundOther, resolution, downloadStartTimestamp, "", name, description, author, url, thumbnail);
                break;

            case ArtType.ThemesGDM:
                Console.WriteLine("Create ThemesGDM");
                item = new ArtLoginManager(downloadStartTimestamp, "", name, description, author, url, thumbnail, smallThumbnail);
                break;

            case ArtType.ThemesSplashs:
                Console.WriteLine("Create ThemesSplash");
                item = new ArtSplashScreen(downloadStartTimestamp, "", name, description, author, url, thumbnail, smallThumbnail);
                break;

            case ArtType.ThemesGTKEngines:
                Console.WriteLine("Create ThemesGTKEngine");
                item = new ArtGtkEngine(downloadStartTimestamp, "", name, description, author, url, thumbnail);
                break;

            case ArtType.ThemesIcons:
                Console.WriteLine("Create ThemesIcon");
                item = new ArtIcon(downloadStartTimestamp, "", name, description, author, url, thumbnail, smallThumbnail);
                break;

            case ArtType.ThemesApplications:
                Console.WriteLine("Create ThemeApplication");
                item = new ArtGtkGnome(downloadStartTimestamp, "", name, description, author, url, thumbnail, smallThumbnail);
                Console.WriteLine("Thumbnail url :" + smallThumbnail);
                break;

            case ArtType.ThemesWindowsBorders:
                Console.WriteLine("Create WindowsBorder");
                item = new ArtDesktop(downloadStartTimestamp, "", name, description, author, url, thumbnail, smallThumbnail);
                break;

            case ArtType.All:
                break;

            default:
                break;
            }

            return(item);
        }