예제 #1
0
        public MailMessage(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Conversations;

            string title = Utils.GetFirstPropertyOfParent(hit, "dc:title");

            if (title == null || title == String.Empty)
            {
                title = Catalog.GetString("(untitled)");
            }
            Subject.LabelProp = Title = title;

            From.LabelProp = "<b>" + GetAddress(hit) + "</b>";
            try {
                Timestamp      = StringFu.StringToDateTime(Utils.GetFirstPropertyOfParent(hit, "fixme:date"));
                Date.LabelProp = Utils.NiceShortDate(Timestamp);
            } catch {}

            if (Utils.GetFirstPropertyOfParent(Hit, "fixme:client") == "evolution")
            {
                AddAction(new TileAction(Catalog.GetString("Send in Mail"), SendInMail));
            }
            if ((Utils.GetFirstPropertyOfParent(hit, "fixme:isSent") == null))
            {
                AddAction(new TileAction(Catalog.GetString("Find Messages From Sender"), Gtk.Stock.Find, FindAllFromSender));
            }
        }
예제 #2
0
        public RSSFeed(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Feed;

            Title       = Hit ["dc:title"];
            Description = Hit ["dc:publisher"];
        }
예제 #3
0
        public static SafeProcess GetClientProcess(Beagle.Hit hit)
        {
            string      client = null;
            SafeProcess p      = null;

            if (hit.ParentUri != null)
            {
                client = Utils.GetFirstPropertyOfParent(hit, "fixme:client");
            }
            else
            {
                client = hit.GetFirstProperty("fixme:client");
            }

            if (client == "evolution")
            {
                p               = new SafeProcess();
                p.Arguments     = new string [2];
                p.Arguments [0] = "evolution";
                p.Arguments [1] = (hit.ParentUri != null ? hit.EscapedParentUri : hit.EscapedUri);
            }
#if ENABLE_THUNDERBIRD
            else if (client == "thunderbird")
            {
                p = Thunderbird.GetSafeProcess("-viewbeagle", hit.GetFirstProperty("fixme:uri"));
            }
#endif

            return(p);
        }
예제 #4
0
        public override bool Validate(Beagle.Hit hit)
        {
            if (!base.Validate(hit))
            {
                return(false);
            }

            if (hit ["beagle:HitType"] == "File")
            {
                // This handles a case when a file with the
                // message/rfc822 mimetype is indexed without
                // gmime. Thus we fail to extract any info and
                // this tile is useless.
                string subject = hit.GetFirstProperty("dc:title");

                if (subject != null && subject != "")
                {
                    return(true);
                }

                return(false);
            }

            return(true);
        }
예제 #5
0
        public Audio(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Audio;

            // FIXME: Show album art if any. Needs implementation in Beagle.Util

            string title = Hit.GetFirstProperty("dc:title");

            if (String.IsNullOrEmpty(title))
            {
                title = Hit.GetFirstProperty("fixme:title");
            }

            if (!String.IsNullOrEmpty(title))
            {
                Title = title;
            }

            string artist = Hit.GetFirstProperty("fixme:artist");

            if (!String.IsNullOrEmpty(artist))
            {
                Description = artist;
            }

            //AddAction (new TileAction (Catalog.GetString ("Add to Library"), AddToLibrary));
        }
예제 #6
0
        public static Tile MakeTile(Beagle.Hit hit, Beagle.Query query)
        {
            TileActivator best = null;

            try {
                foreach (TileActivator activator in activators)
                {
                    if (!activator.Validate(hit))
                    {
                        continue;
                    }

                    if (best == null)
                    {
                        best = activator;
                        continue;
                    }

                    if (activator.Weight > best.Weight)
                    {
                        best = activator;
                    }
                }

                if (best != null)
                {
                    return(best.BuildTile(hit, query));
                }
            } catch (Exception e) {
                Console.WriteLine("Error instantiating tile:\n{0}", e);
            }

            return(null);
        }
예제 #7
0
			public ThumbnailRequest (Gtk.Image image, string thumbnail_file, Beagle.Hit hit, int size)
			{
				Image = image;
				ThumbnailFile = thumbnail_file;
				Hit = hit;
				Size = size;
			}
예제 #8
0
        public IMLog(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Conversations;

            Subject.LabelProp = Catalog.GetString("IM Conversation");

            string alias = hit.GetFirstProperty("fixme:speakingto_alias");
            string name  = hit.GetFirstProperty("fixme:speakingto");

            if (alias != null && alias != "")
            {
                From.LabelProp = "<b>" + alias + "</b>";
            }
            else if (name != null && name != "")
            {
                From.LabelProp = "<b>" + name + "</b>";
            }
            else
            {
                From.LabelProp = "(unknown)";
            }

            try {
                string starttime = hit.GetFirstProperty("fixme:starttime");

                if (!String.IsNullOrEmpty(starttime))
                {
                    Timestamp = StringFu.StringToDateTime(starttime);
                }

                Date.LabelProp = Utils.NiceShortDate(Timestamp);
            } catch {}
        }
예제 #9
0
 public ThumbnailRequest(Gtk.Image image, string thumbnail_file, Beagle.Hit hit, int size)
 {
     Image         = image;
     ThumbnailFile = thumbnail_file;
     Hit           = hit;
     Size          = size;
 }
예제 #10
0
        public Presentation(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Documents;

            if (Hit ["fixme:slide-count"] != null)
            {
                int count = Int32.Parse(Hit ["fixme:slide-count"]);
                Description = String.Format(Catalog.GetPluralString("{0} slide", "{0} slides", count), count);
            }
        }
예제 #11
0
        public Task(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Calendar;

            Title = hit.GetFirstProperty("fixme:summary");

            if (!String.IsNullOrEmpty(hit.GetFirstProperty("fixme:description")))
            {
                Description = Utils.TrimFirstLine(hit.GetFirstProperty("fixme:description"));
            }
        }
예제 #12
0
 public static string GetFirstPropertyOfParent(Beagle.Hit hit, string prop)
 {
     if (hit.ParentUri == null)
     {
         return(hit.GetFirstProperty(prop));
     }
     else
     {
         return(hit.GetFirstProperty("parent:" + prop));
     }
 }
예제 #13
0
        public Contact(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Contact;

            Title       = hit.GetFirstProperty("fixme:Name");
            Description = hit.GetFirstProperty("fixme:Email");

            if (Hit.GetFirstProperty("fixme:Email") != null)
            {
                AddAction(new TileAction(Catalog.GetString("Send Mail"), SendMail));
            }
        }
예제 #14
0
        protected static string GetTitle(Beagle.Hit hit)
        {
            string title;

            title = hit.GetFirstProperty("dc:title");

            if (String.IsNullOrEmpty(title))
            {
                title = hit.GetFirstProperty("beagle:ExactFilename");
            }

            return(title);
        }
예제 #15
0
        public TextDocument(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Documents;

            if (Hit ["fixme:page-count"] != null)
            {
                int count = Int32.Parse(Hit ["fixme:page-count"]);
                Description = String.Format(Catalog.GetPluralString("{0} page", "{0} pages", count), count);
            }

            // These files generally have a default title or an auto-generated title.
            // So use the filename for these types of files.
            Title = hit.GetFirstProperty("beagle:ExactFilename");
        }
예제 #16
0
        public Calendar(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Calendar;

            string summary = hit.GetFirstProperty("fixme:summary");
            string time    = Utils.NiceShortDate(hit.GetFirstProperty("fixme:starttime"));

            Title = (time == "") ? summary : time + ": " + summary;

            if (!String.IsNullOrEmpty(hit.GetFirstProperty("fixme:description")))
            {
                Description = Utils.TrimFirstLine(hit.GetFirstProperty("fixme:description"));
            }
        }
예제 #17
0
        public Video(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Video;

            Title = Hit ["beagle:ExactFilename"];

            if (!String.IsNullOrEmpty(Hit ["fixme:video:codec"]))
            {
                Description = Hit ["fixme:video:codec"];
            }

            if (!String.IsNullOrEmpty(Hit ["fixme:video:width"]))
            {
                Description += String.Format(" ({0}x{1})", Hit ["fixme:video:width"], Hit ["fixme:video:height"]);
            }
        }
예제 #18
0
        public WebHistory(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Website;

            string title = hit.GetFirstProperty("dc:title");

            if (String.IsNullOrEmpty(title))
            {
                title = Hit.Uri.Host;
            }

            Title       = title;
            Description = hit.Uri.ToString();

            AddAction(new TileAction("Find more from same host", Gtk.Stock.Find, FindFromHost));
        }
예제 #19
0
        protected TileFlat(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Subject = WidgetFu.NewLabel();
            WidgetFu.EllipsizeLabel(Subject, 40);
            HBox.PackStart(Subject, true, true, 3);

            From           = WidgetFu.NewLabel();
            From.UseMarkup = true;
            WidgetFu.EllipsizeLabel(From, 20);
            HBox.PackStart(From, false, false, 3);

            Date = WidgetFu.NewLabel();
            HBox.PackStart(Date, false, false, 3);

            HBox.ShowAll();
        }
예제 #20
0
        public override bool Validate(Beagle.Hit hit)
        {
            if (!base.Validate(hit))
            {
                return(false);
            }

            if (hit ["beagle:FileType"] != "documentation")
            {
                return(false);
            }

            Weight += 2;

            return(true);
        }
예제 #21
0
        private static string GetAddress(Beagle.Hit hit)
        {
            bool   sent    = (Utils.GetFirstPropertyOfParent(hit, "fixme:isSent") != null);
            string address = sent ? Utils.GetFirstPropertyOfParent(hit, "fixme:to") : Utils.GetFirstPropertyOfParent(hit, "fixme:from");

            if (address == null)
            {
                return("");
            }
            if (address.IndexOf(" <") != -1)
            {
                address = address.Substring(0, address.IndexOf(" <"));
            }

            return(address);
        }
예제 #22
0
        public MailAttachment(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Documents;
            Title = Hit ["fixme:attachment_title"];

            if (String.IsNullOrEmpty(Title))
            {
                Title = Catalog.GetString(String.Format("Attachment to \"{0}\"", Hit ["parent:dc:title"]));
            }

            Description = Catalog.GetString("Mail attachment");

            if ((Utils.GetFirstPropertyOfParent(hit, "fixme:isSent") == null))
            {
                AddAction(new TileAction(Catalog.GetString("Find Messages From Sender"), Gtk.Stock.Find, FindAllFromSender));
            }
        }
예제 #23
0
        public override bool Validate(Beagle.Hit hit)
        {
            if (!base.Validate(hit))
            {
                return(false);
            }

            string str = hit.GetFirstProperty("fixme:inside_archive");

            if (hit.ParentUri == null || str == null || str == "false")
            {
                return(false);
            }

            Weight += 1;

            return(true);
        }
예제 #24
0
        public override Tile BuildTile(Beagle.Hit hit, Beagle.Query query)
        {
            if (ditem == IntPtr.Zero)
            {
                return(null);
            }

            if (hit ["fixme:NoDisplay"] == "true")
            {
                return(null);
            }

            string notshow = gnome_desktop_item_get_string(ditem, "NotShowIn");

            if (notshow != null && notshow.IndexOf("GNOME") != -1)
            {
                return(null);
            }

            string onlyshow = gnome_desktop_item_get_string(ditem, "OnlyShowIn");

            if (onlyshow != null && onlyshow.IndexOf("GNOME") == -1)
            {
                return(null);
            }


            if (!checked_gconf)
            {
                CheckLockdown();
            }

            if (disable_command_line)
            {
                string[] categories = hit.GetProperties("fixme:Categories");

                if (categories != null && Array.IndexOf(categories, "TerminalEmulator") != -1)
                {
                    return(null);
                }
            }

            return(new Application(hit, query, ditem));
        }
예제 #25
0
        public Docbook(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            if (!String.IsNullOrEmpty(hit.GetFirstProperty("dc:title")))
            {
                Title = hit.GetFirstProperty("dc:title");
            }
            else
            {
                Title = hit.GetFirstProperty("beagle:ExactFilename");
            }

            if (hit ["beagle:IsChild"] == "true")
            {
                Description = hit.GetFirstProperty("parent:beagle:Filename");
            }
            else
            {
                Description = hit.GetFirstProperty("beagle:Filename");
            }
        }
예제 #26
0
        public Image(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group = TileGroup.Image;

            Title = Hit ["beagle:ExactFilename"];

            if (Hit ["beagle:FilenameExtension"] != null && Hit ["beagle:FilenameExtension"].Length > 0)
            {
                Description = Hit ["beagle:FilenameExtension"].Substring(1).ToUpper();
            }

            if (Hit ["fixme:width"] != null && Hit ["fixme:width"] != "")
            {
                Description += String.Format(" {0}x{1}", Hit ["fixme:width"], Hit ["fixme:height"]);
            }

            Description += String.Format(" ({0})", StringFu.FileLengthToString(Hit.FileInfo.Length));

            // AddAction (new TileAction (Catalog.GetString ("Add to Library"), Gtk.Stock.Add, AddToLibrary));
            AddAction(new TileAction(Catalog.GetString("Set as Wallpaper"), SetAsWallpaper));
        }
예제 #27
0
        public Manpage(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            if (!String.IsNullOrEmpty(hit.GetFirstProperty("dc:title")))
            {
                Title = hit.GetFirstProperty("dc:title");
            }
            else
            {
                Title = hit.GetFirstProperty("beagle:ExactFilename");
            }

            if (hit ["beagle:IsChild"] == "true")
            {
                path = hit.ParentUri.LocalPath;
            }
            else
            {
                path = hit.Uri.LocalPath;
            }

            Description = hit.GetFirstProperty("dc:subject") ?? Catalog.GetString("Manual page");
        }
예제 #28
0
        public Folder(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Group          = TileGroup.Folder;
            Title          = Hit ["beagle:ExactFilename"];
            EnableOpenWith = true;

            int n = Hit.DirectoryInfo.GetFileSystemInfos().Length;

            if (n == 0)
            {
                Description = Catalog.GetString("Empty");
            }
            else
            {
                Description = String.Format(Catalog.GetPluralString("Contains {0} Item",
                                                                    "Contains {0} Items", n), n);
            }

            // FIXME: s/"gtk-info"/Gtk.Stock.Info/ when we can depend on gtk# 2.8
            //AddAction (new TileAction (Catalog.GetString ("Show Information"), "gtk-info", ShowInformation));
            AddAction(new TileAction(Catalog.GetString("Move to Trash"), Gtk.Stock.Delete, MoveToTrash));
        }
예제 #29
0
        public TileTemplate(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Alignment alignment = new Alignment(0.0f, 0.5f, 1.0f, 0.0f);

            HBox.PackStart(alignment, true, true, 0);

            VBox vbox = new VBox(false, 0);

            alignment.Add(vbox);

            title_label          = WidgetFu.NewLabel();
            title_label.LineWrap = true;
            WidgetFu.EllipsizeLabel(title_label, 30);
            vbox.PackStart(title_label, false, false, 0);

            desc_label           = WidgetFu.NewGrayLabel();
            desc_label.NoShowAll = true;
            WidgetFu.EllipsizeLabel(desc_label, 30);
            vbox.PackStart(desc_label, false, false, 0);

            alignment.ShowAll();
        }
예제 #30
0
        public TileFile(Beagle.Hit hit, Beagle.Query query) : base(hit, query)
        {
            Title = GetTitle(hit);

            if (Hit.FileInfo != null)
            {
                Timestamp   = Hit.FileInfo.LastWriteTimeUtc;
                Description = Utils.NiceShortDate(Timestamp);
            }

            AddAction(new TileAction(Catalog.GetString("Reveal in Folder"), RevealInFolder));
            AddAction(new TileAction(Catalog.GetString("E-Mail"), Email));
            // AddAction (new TileAction (Catalog.GetString ("Instant-Message"), InstantMessage));
            AddAction(new TileAction(Catalog.GetString("Move to Trash"), Gtk.Stock.Delete, MoveToTrash));

            if (!String.IsNullOrEmpty(Hit.GetFirstProperty("dc:author")))
            {
                AddAction(new TileAction(Catalog.GetString("Find Documents From Same Author"), Gtk.Stock.Find, FindSameAuthor));
            }

            EnableOpenWith = true;
        }
예제 #31
0
        public virtual bool Validate(Beagle.Hit hit)
        {
            if (flavors.Count < 1)
            {
                return(false);
            }

            Weight = 0;

            HitFlavor best = null;

            foreach (HitFlavor flavor in flavors)
            {
                if (!flavor.IsMatch(hit))
                {
                    continue;
                }

                if (best == null)
                {
                    best = flavor;
                    continue;
                }

                if (flavor.Weight > best.Weight)
                {
                    best = flavor;
                }
            }

            if (best != null)
            {
                Weight += best.Weight;
                return(true);
            }

            return(false);
        }