<commit_before>//
// HomeView.cs
//
// Authors:
//   <NAME> <<EMAIL>>
//
// Copyright (C) 2009 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections.Generic;
using System.Linq;

using Mono.Unix;
using Gtk;

using Hyena.Collections;
using Hyena.Data.Sqlite;

using Hyena.Data;
using Hyena.Data.Gui;
using Hyena.Widgets;

using Banshee.Base;
using Banshee.Collection;
using Banshee.Collection.Gui;
using Banshee.Collection.Database;
using Banshee.Configuration;
using Banshee.Database;
using Banshee.Gui;
using Banshee.Library;
using Banshee.MediaEngine;
using Banshee.PlaybackController;
using Banshee.Playlist;
using Banshee.Preferences;
using Banshee.ServiceStack;
using Banshee.Sources;
using Banshee.Widgets;

using IA=InternetArchive;

namespace Banshee.InternetArchive
{
    public class HomeView : Gtk.HBox, Banshee.Sources.Gui.ISourceContents
    {
        private HomeSource source;

        public HomeView (HomeSource source)
        {
            this.source = source;

            //var sw = new Gtk.ScrolledWindow ();
            //sw.BorderWidth = 4;
            //sw.AddWithViewport (Build ());

            var frame = new Hyena.Widgets.RoundedFrame ();
            frame.Child = Build ();

            PackStart (frame, true, true, 0);
            ShowAll ();
        }

        private Widget Build ()
        {
            var hbox = new HBox () { Spacing = 8, BorderWidth = 4 };

            hbox.PackStart (BuildTiles (), false, false, 0);
            hbox.PackStart (BuildCenter (), true, true, 0);

            return hbox;
        }

        private Widget BuildCenter ()
        {
            var vbox = new VBox () { Spacing = 2 };

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

            // Make the search entry text nice and big
            var font = entry.InnerEntry.Style.FontDescription;
            font.Size = (int) (font.Size * Pango.Scale.XLarge);
            entry.InnerEntry.ModifyFont (font);

            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),<commit_msg>[InternetArchive] Make a copy of the FontDescription before changing it<commit_after>//
// HomeView.cs
//
// Authors:
//   <NAME> <<EMAIL>>
//
// Copyright (C) 2009 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections.Generic;
using System.Linq;

using Mono.Unix;
using Gtk;

using Hyena.Collections;
using Hyena.Data.Sqlite;

using Hyena.Data;
using Hyena.Data.Gui;
using Hyena.Widgets;

using Banshee.Base;
using Banshee.Collection;
using Banshee.Collection.Gui;
using Banshee.Collection.Database;
using Banshee.Configuration;
using Banshee.Database;
using Banshee.Gui;
using Banshee.Library;
using Banshee.MediaEngine;
using Banshee.PlaybackController;
using Banshee.Playlist;
using Banshee.Preferences;
using Banshee.ServiceStack;
using Banshee.Sources;
using Banshee.Widgets;

using IA=InternetArchive;

namespace Banshee.InternetArchive
{
    public class HomeView : Gtk.HBox, Banshee.Sources.Gui.ISourceContents
    {
        private HomeSource source;

        public HomeView (HomeSource source)
        {
            this.source = source;

            //var sw = new Gtk.ScrolledWindow ();
            //sw.BorderWidth = 4;
            //sw.AddWithViewport (Build ());

            var frame = new Hyena.Widgets.RoundedFrame ();
            frame.Child = Build ();

            PackStart (frame, true, true, 0);
            ShowAll ();
        }

        private Widget Build ()
        {
            var hbox = new HBox () { Spacing = 8, BorderWidth = 4 };

            hbox.PackStart (BuildTiles (), false, false, 0);
            hbox.PackStart (BuildCenter (), true, true, 0);

            return hbox;
        }

        private Widget BuildCenter ()
        {
            var vbox = new VBox () { Spacing = 2 };

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

            // Make the search entry text nice and big
            var font = entry.InnerEntry.Style.FontDescription.Copy ();
            font.Size = (int) (font.Size * Pango.Scale.XLarge);
            entry.InnerEntry.ModifyFont (font);

            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),
{'fraction_non_alphanumeric': 0.10349397590361446, 'fraction_numerical': 0.0038554216867469878, 'mean_word_length': 2.6536091549295775, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2017620', 'n_tokens_mistral': 2380, 'n_tokens_neox': 2232, 'n_words': 782}