Exemplo n.º 1
0
        protected override void PopulateTemplate()
        {
            base.PopulateTemplate();

            if (Hit.FileInfo == null)
            {
                Console.WriteLine("FileInfo is null");
                return;
            }

            string quoted_uri = StringFu.PathToQuotedFileUri(Hit.Uri.LocalPath);
            string thumbnail  = Thumbnail.PathForUri(quoted_uri, ThumbnailSize.Normal);

            if (File.Exists(thumbnail))
            {
                Template ["Icon"] = Images.GetHtmlSource(thumbnail, Hit.MimeType);
            }
            else
            {
                Pixbuf   pix = thumb_factory.GenerateThumbnail(quoted_uri, Hit.MimeType);
                FileInfo fi  = new FileInfo(Hit.Uri.LocalPath);
                if (pix == null)
                {
                    thumb_factory.CreateFailedThumbnail(quoted_uri, fi.LastWriteTime);

                    string path = GnomeFu.GetMimeIconPath(Hit.MimeType);
                    string icon = Images.GetHtmlSource(path, Hit.MimeType);

                    if (icon != null)
                    {
                        Template ["Icon"] = icon;
                    }
                    else
                    {
                        Template ["Icon"] = Images.GetHtmlSource("document", "image/png");
                    }
                }
                else
                {
                    thumb_factory.SaveThumbnail(pix, quoted_uri, DateTime.Now);
                    Template ["Icon"] = Images.GetHtmlSource(thumbnail, Hit.MimeType);
                }
            }

            Template["Title"] = Hit ["dc:title"];

            if (Template["Title"] == null)
            {
                Template["Title"] = Template["FileName"];
            }
        }
Exemplo n.º 2
0
        protected override void PopulateTemplate()
        {
            base.PopulateTemplate();

            bool   sent = (GetHitProperty(Hit, "fixme:isSent") != null);
            string str  = GetHitProperty(Hit, "dc:title");

            if (str == null)
            {
                str = String.Format("<i>{0}</i>", Catalog.GetString("No Subject"));
            }

            if (GetHitProperty(Hit, "_IsDeleted") != null)
            {
                str = "<strike>" + str + "</strike>";
            }

            Template["Icon"]    = GetMailIcon();
            Template["Subject"] = str;
            Template["ToFrom"]  = sent ? Catalog.GetString("To") : Catalog.GetString("From");

            // Limit the number of recipients to 3, so the
            // tile doesn't look terrible.
            if (sent)
            {
                string[] values = Hit.GetProperties("fixme:to");

                if (values != null)
                {
                    StringBuilder sb = new StringBuilder();
                    int           i;

                    for (i = 0; i < 3 && i < values.Length; i++)
                    {
                        if (i != 0)
                        {
                            sb.Append(", ");
                        }

                        sb.Append(values [i]);
                    }

                    if (i < values.Length)
                    {
                        sb.Append(", ...");
                    }

                    Template["Who"] = sb.ToString();
                }
            }
            else
            {
                Template["Who"] = GetHitProperty(Hit, "fixme:from");
            }

            Template["Folder"]       = GetHitProperty(Hit, "fixme:folder");
            Template["Account"]      = GetHitProperty(Hit, "fixme:account");
            Template["SentReceived"] = sent ? Catalog.GetString("Sent") : Catalog.GetString("Received");
            Template["When"]         = GetHitProperty(Hit, "fixme:date");

            if (GetHitProperty(Hit, "fixme:client") == "evolution")
            {
                Template ["CanReply"] = "";
            }

            // FIXME: Gross attachment rendering
            if (IsAttachment(Hit))
            {
                Template["Subject"]      = Hit ["fixme:attachment_title"] + " [" + Catalog.GetString("Email attachment") + "]";
                Template["EmailSubject"] = str;
                string path = GnomeFu.GetMimeIconPath(Hit.MimeType);
                Template["Icon"] = Images.GetHtmlSource(path, Hit.MimeType);
            }

            if (GetHitProperty(Hit, "fixme:isFlagged") != null)
            {
                Template["FollowupIcon"] = Images.GetHtmlSourceForStock("stock_mail-priority-high", 16);
            }
            if (GetHitProperty(Hit, "fixme:hasAttachments") != null)
            {
                Template["AttachmentIcon"] = Images.GetHtmlSourceForStock("stock_attach", 16);
            }

#if ENABLE_EVO_SHARP
            GetImNames(Template["Who"]);

            if (aim_name != null)
            {
                Template["CanSendIm"] = "";
            }
#endif

#if ENABLE_GALAGO
#if ENABLE_EVO_SHARP
            if (aim_name != null)
            {
                string status = GalagoTools.GetPresence("aim", aim_name);
                if (status != null && status != "")
                {
                    Template ["Presence"] = status;
                }
            }
#endif
#endif
        }