예제 #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"];
            }
        }
예제 #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
        }
예제 #3
0
        protected void OpenFromMime(Hit hit,
                                    string command_fallback,
                                    string args_fallback,
                                    bool expects_uris_fallback)
        {
            string argument;
            string command      = command_fallback;
            bool   expects_uris = expects_uris_fallback;

            // FIXME: This is evil.  Nautilus should be handling
            // inode/directory, not just x-directory/normal
            if (hit.MimeType == "inode/directory")
            {
                hit.MimeType = "x-directory/normal";
            }
#if ENABLE_DESKTOP_LAUNCH
            command      = "desktop-launch";
            expects_uris = true;
#else
            GnomeFu.VFSMimeApplication app;
            app = GnomeFu.GetDefaultAction(hit.MimeType);
            if (app.command != null)
            {
                command      = app.command;
                expects_uris = (app.expects_uris != GnomeFu.VFSMimeApplicationArgumentType.Path);
            }
#endif
            if (command == null)
            {
                LaunchError("Can't open MimeType '{0}'", hit.MimeType);
                return;
            }

            if (args_fallback != null)
            {
                argument = args_fallback;
            }
            else
            {
                argument = "";
            }

            if (expects_uris)
            {
                argument = String.Format("{0} '{1}'", argument, hit.Uri);
            }
            else
            {
                argument = String.Format("{0} {1}", argument, hit.PathQuoted);
            }

            // Sometimes the command is 'quoted'
            if (command.IndexOf('\'') == 0 && command.LastIndexOf('\'') == command.Length - 1)
            {
                command = command.Trim('\'');
            }

            // This won't work if a program really has a space in
            // the filename, but I think other things would break
            // with that too, and in practice it doesn't seem to
            // happen.
            int idx = command.IndexOf(' ');
            if (idx != -1)
            {
                argument = String.Format("{0} {1}", command.Substring(idx + 1), argument);
                command  = command.Substring(0, idx);
            }

            Console.WriteLine("Cmd: {0}", command);
            Console.WriteLine("Arg: {0}", argument);

            Process p = new Process();
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.FileName        = command;
            p.StartInfo.Arguments       = argument;

            try {
                p.Start();
            } catch (Exception e) {
                Console.WriteLine("Error in OpenFromMime: " + e);
            }
        }