<commit_before>﻿using System;
using Gtk;
using Newtonsoft.Json;
using crown_tests.tests;

public partial class MainWindow : Gtk.Window
{
  public MainWindow(): base(Gtk.WindowType.Toplevel)
  {
    //Glade.XML gxml = new Glade.XML("main1.glade", "MyWindow", null);
    //gxml.Autoconnect(this);
    Title = "Test Browser";
    SetSizeRequest(500, 300);
    
    // Create a column for the artist name
    Gtk.TreeViewColumn artistColumn = new Gtk.TreeViewColumn();
    artistColumn.Title = "Name";

    // Create a column for the song title
    Gtk.TreeViewColumn songColumn = new Gtk.TreeViewColumn();
    songColumn.Title = "Description";

    // Add the columns to the TreeView
    Gtk.TreeView treeview1 = new Gtk.TreeView();
    Add(treeview1);
    treeview1.AppendColumn(artistColumn);
    treeview1.AppendColumn(songColumn);

    treeview1.Model = LoadData();

    Gtk.CellRendererText testNameCell = new Gtk.CellRendererText();
    artistColumn.PackStart(testNameCell, true);

    Gtk.CellRendererText testDescriptionCell = new Gtk.CellRendererText();
    songColumn.PackStart(testDescriptionCell, true);

    // Tell the Cell Renderers which items in the model to display
    artistColumn.AddAttribute(testNameCell, "text", 0);
    songColumn.AddAttribute(testDescriptionCell, "text", 1);

    LoadData();
  }

  private Gtk.TreeStore LoadData()
  {
    var container = JsonConvert.DeserializeObject<TestContainer>(System.IO.File.ReadAllText("tests.json"));

    Gtk.TreeStore testsStore = new Gtk.TreeStore(typeof(string), typeof(string));
    foreach (var category in container.Categories)
    {
      var iter = testsStore.AppendValues(category.Name);
      foreach (var test in category.Tests)
      {
        testsStore.AppendValues(iter, test.Name, test.Description);
      }
    }
    return testsStore;
  }

  protected override bool OnDeleteEvent(Gdk.Event evnt)
  {
    Application.Quit();
    return base.OnDeleteEvent(evnt);
  }
}<commit_msg>Shorter Treeview creation<commit_after>﻿using System;
using Gtk;
using Newtonsoft.Json;
using crown_tests.tests;

public partial class MainWindow : Gtk.Window
{
  public MainWindow(): base(Gtk.WindowType.Toplevel)
  {
    //Glade.XML gxml = new Glade.XML("main1.glade", "MyWindow", null);
    //gxml.Autoconnect(this);
    Title = "Test Browser";
    SetSizeRequest(500, 300);
    
    Gtk.TreeView treeview1 = new Gtk.TreeView();
    treeview1.AppendColumn("Name", new Gtk.CellRendererText(), "text", 0);
    treeview1.AppendColumn("Description", new Gtk.CellRendererText(), "text", 1);
    treeview1.Model = LoadData();
    Add(treeview1);

    LoadData();
  }

  private Gtk.TreeStore LoadData()
  {
    var container = JsonConvert.DeserializeObject<TestContainer>(System.IO.File.ReadAllText("tests.json"));

    Gtk.TreeStore testsStore = new Gtk.TreeStore(typeof(string), typeof(string));
    foreach (var category in container.Categories)
    {
      var iter = testsStore.AppendValues(category.Name);
      foreach (var test in category.Tests)
      {
        testsStore.AppendValues(iter, test.Name, test.Description);
      }
    }
    return testsStore;
  }

  protected override bool OnDeleteEvent(Gdk.Event evnt)
  {
    Application.Quit();
    return base.OnDeleteEvent(evnt);
  }
}
{'fraction_non_alphanumeric': 0.11663597298956414, 'fraction_numerical': 0.008594229588704727, 'mean_word_length': 3.709537572254335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6595443', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1006, 'n_words': 221}