Пример #1
0
        private Widget BuildCenter()
        {
            var vbox = new VBox()
            {
                Spacing = 2
            };

            // Search entry/button
            var search_box = new HBox()
            {
                Spacing = 6, BorderWidth = 4
            };
            var entry = new SearchEntry()
            {
                Visible      = true,
                EmptyMessage = String.Format(Catalog.GetString("Search..."))
            };

            source.Properties.Set <SearchEntry> ("Nereid.SearchEntry", entry);

            // Make the search entry text nice and big
            var font = entry.StyleContext.GetFont(StateFlags.Normal).Copy();

            font.Size = (int)(font.Size * Pango.Scale.XLarge);
            entry.OverrideFont(font);
            font.Dispose();

            var button = new Hyena.Widgets.ImageButton(Catalog.GetString("_Go"), Stock.Find);

            entry.Activated += (o, a) => { button.Activate(); };
            button.Clicked  += (o, a) => source.SetSearch(new SearchDescription(null, entry.Query, IA.Sort.DownloadsDesc, null));

            search_box.PackStart(entry, true, true, 0);
            search_box.PackStart(button, false, false, 0);

            var example_searches = new SearchDescription [] {
                new SearchDescription(Catalog.GetString("Staff Picks"), "pick:1", IA.Sort.WeekDesc, null),
                new SearchDescription(Catalog.GetString("Creative Commons"), "license:creativecommons", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("History"), "subject:history", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("Classic Cartoons"), "", IA.Sort.DateCreatedAsc, IA.MediaType.Get("animationandcartoons")),
                new SearchDescription(Catalog.GetString("Speeches"), "subject:speeches OR title:speech", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("For Children"), "subject:children", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("Poetry"), "subject:poetry", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("Creator is United States"), "creator:\"United States\"", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("Old Movies"), "", IA.Sort.DateCreatedAsc, IA.MediaType.Get("moviesandfilms")),
                new SearchDescription(Catalog.GetString("New From LibriVox"), "publisher:LibriVox", IA.Sort.DateAddedDesc, IA.MediaType.Get("audio")),
                new SearchDescription(Catalog.GetString("Old Texts"), "", IA.Sort.DateCreatedAsc, IA.MediaType.Get("texts")),
                new SearchDescription(Catalog.GetString("Charlie Chaplin"), "\"Charlie Chaplin\"", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("NASA"), "NASA", IA.Sort.DownloadsDesc, null),
                new SearchDescription(Catalog.GetString("Library of Congress"), "creator:\"Library of Congress\"", IA.Sort.DownloadsDesc, null)
            };

            var examples = new FlowBox()
            {
                Spacing = 0
            };

            examples.Add(PaddingBox(new Label()
            {
                Markup = Catalog.GetString("Examples:")
            }));

            foreach (var search in example_searches)
            {
                var this_search = search;
                var link        = CreateLink(search.Name, search.Query);
                link.TooltipText = search.Query;
                link.Clicked    += (o, a) => source.SetSearch(this_search);
                examples.Add(link);
            }

            // Intro text and visit button
            var intro_label = new Hyena.Widgets.WrapLabel()
            {
                Markup = Catalog.GetString("The Internet Archive, a 501(c)(3) non-profit, is building a digital library of Internet sites and other cultural artifacts in digital form. Like a paper library, we provide free access to researchers, historians, scholars, and the general public.")
            };

            var visit_button = new LinkButton("http://archive.org/", Catalog.GetString("Visit the Internet Archive online at archive.org"));

            visit_button.Clicked += (o, a) => Banshee.Web.Browser.Open("http://archive.org/");
            visit_button.Xalign   = 0f;
            var visit_box = new HBox();

            visit_box.PackStart(visit_button, false, false, 0);
            visit_box.PackStart(new Label()
            {
                Visible = true
            }, true, true, 0);

            // Packing
            vbox.PackStart(search_box, false, false, 0);
            vbox.PackStart(examples, false, false, 0);
            vbox.PackStart(PaddingBox(new HSeparator()), false, false, 6);
            vbox.PackStart(PaddingBox(intro_label), false, false, 0);
            vbox.PackStart(visit_box, false, false, 0);

            return(vbox);
        }