<commit_before>///* /home/eosten/Summa/Summa/FeedView.cs
// *
// * Copyright (C) 2008  <NAME>
// *
// * This library is free software: you can redistribute it and/or modify
// * it under the terms of the GNU Lesser General Public License as published by
// * the Free Software Foundation, either version 2.1 of the License, or
// * (at your option) any later version.
// *
// * This library is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// * GNU Lesser General Public License for more details.
// *
// * You should have received a copy of the GNU Lesser General Public License
// * along with this library.  If not, see <http://www.gnu.org/licenses/>.
// *
// * Author:
// *     <NAME> <<EMAIL>>
// */
//

using System;
using Gtk;
using System.Collections;
using Gdk;
using System.Linq;
using Pango;

namespace Summa {
    public class FeedView : Gtk.TreeView{
        public Gtk.ListStore store;
        private Gtk.IconTheme icon_theme;
        public string SetTag;
        
        private ArrayList feeds;
        
        public Gtk.TreeIter iter;
        public Gtk.TreeModel selectmodel;
        GLib.Value retval;
        
        // a NewsKitFeed representing the feed selected
        // note that if no feed is selected, trying to get this will cause you
        // some problems.
        public NewsKit.Feed Selected {
            get {
                if ( Selection.CountSelectedRows() != 0 ) {
                    Selection.GetSelected(out selectmodel, out iter);
                } else { store.GetIterFirst(out iter); }
                
                string val = (string)store.GetValue(iter, 2);
                
                return NewsKit.Daemon.RegisterFeed(val);
            }
        }
        
        private Gtk.CellRendererText trender;
        
        public FeedView() {
            // set up the liststore for the view
            store = new Gtk.ListStore(typeof(Gdk.Pixbuf),    // the icon
                                      typeof(string),        // the name
                                      typeof(string),        // the url
                                      typeof(bool));            // unread?
            Model = store;
            trender = new Gtk.CellRendererText();
            trender.Ellipsize = Pango.EllipsizeMode.End;
            
            // set up the columns for the view
            InsertColumn(-1, "Read", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
            InsertColumn(-1, "Name", trender, "text", 1);
            
            // set up the icon theme so that we can make stuff pretty
            icon_theme = Gtk.IconTheme.Default;
        }
        
        public void Populate(string tag) {
            switch(tag) {
                case "All feeds":
                    PopulateWithFeeds("All");<commit_msg>First run at sorting columns in FeedView<commit_after>///* /home/eosten/Summa/Summa/FeedView.cs
// *
// * Copyright (C) 2008  <NAME>
// *
// * This library is free software: you can redistribute it and/or modify
// * it under the terms of the GNU Lesser General Public License as published by
// * the Free Software Foundation, either version 2.1 of the License, or
// * (at your option) any later version.
// *
// * This library is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// * GNU Lesser General Public License for more details.
// *
// * You should have received a copy of the GNU Lesser General Public License
// * along with this library.  If not, see <http://www.gnu.org/licenses/>.
// *
// * Author:
// *     <NAME> <<EMAIL>>
// */
//

using System;
using Gtk;
using System.Collections;
using Gdk;
using System.Linq;
using Pango;

namespace Summa {
    public class FeedView : Gtk.TreeView{
        public Gtk.ListStore store;
        private Gtk.IconTheme icon_theme;
        public string SetTag;
        
        private ArrayList feeds;
        
        public Gtk.TreeIter iter;
        public Gtk.TreeModel selectmodel;
        GLib.Value retval;
        
        // a NewsKitFeed representing the feed selected
        // note that if no feed is selected, trying to get this will cause you
        // some problems.
        public NewsKit.Feed Selected {
            get {
                if ( Selection.CountSelectedRows() != 0 ) {
                    Selection.GetSelected(out selectmodel, out iter);
                } else { store.GetIterFirst(out iter); }
                
                string val = (string)store.GetValue(iter, 2);
                
                return NewsKit.Daemon.RegisterFeed(val);
            }
        }
        
        private Gtk.CellRendererText trender;
        
        public FeedView() {
            // set up the liststore for the view
            store = new Gtk.ListStore(typeof(Gdk.Pixbuf),    // the icon
                                      typeof(string),        // the name
                                      typeof(string),        // the url
                                      typeof(bool));            // unread?
            Model = store;
            trender = new Gtk.CellRendererText();
            trender.Ellipsize = Pango.EllipsizeMode.End;
            
            // set up the columns for the view
            TreeViewColumn column_Read = new Gtk.TreeViewColumn("Read", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
            column_Read.SortColumnId = 0;
            column_Read.SortIndicator = true;
            AppendColumn(column_Read);

            InsertColumn(-1, "Name", trender, "text", 1);
            
            HeadersClickable = true;
            RulesHint = true;
            store.SetSortColumnId(0, Gtk.SortType.Descending);

            // set up the icon theme so that we can make stuff pretty
            icon_theme = Gtk.IconTheme.Default;
        }
        
        public void Populate(string tag) {
            switch(tag) {
                case "All feeds":
                    PopulateWithFeeds("All");
{'fraction_non_alphanumeric': 0.09154132298237101, 'fraction_numerical': 0.004043344654698367, 'mean_word_length': 1.6404782237403928, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5134927', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1572, 'n_words': 546}