<commit_before>#!/usr/bin/env perl
use strict;
use warnings;
# PODNAME: WICS-GUI.pl
# VERSION
# ABSTRACT: GUI frontent for converting ITS-decorated data

=head1 DESCRIPTION

This is a graphical interface for converting ITS-decorated
data into other formats. Currently it only supports XML->HTML
conversion.

Choose the file or files you would like to convert by clicking
"Choose file...". Execute the conversion process by clicking
"Convert". A frame with the log messages will pop up. Errors
are shown in red.

Converted files are written to the directory that the source
files exist in. They keep the name of their source file, but
with a different extension. If the "overwrite existing files"
box is not checked and a file with the given name and extension
already exists, then a number will be appended to the end of
the file name to make it unique.

=cut

package MyApp;
use Wx::Perl::Packager;
use Wx qw(
    :clipboard
    :misc
    :frame
    :textctrl
    :sizer
    :panel
    :window
    :id
    :filedialog
    :colour
);
use Wx::DND;
use Wx::Event qw(EVT_BUTTON);
use base 'Wx::App';
use Path::Tiny;
use Try::Tiny;
use Log::Any::Test;
use Log::Any qw($log);
use XML::ITS::WICS qw(xml2html);

sub OnInit {
    my( $self ) = @_;
    # create a new frame (a frame is a top level window)
    my $frame = Wx::Frame->new(
        undef,           # parent window
        -1,              # ID -1 means any
        'Convert ITS-Decorated Files',   # title
        [-1, -1],        # default position
        [350, 250],      # size
    );
    $self->{main_frame} = $frame;

    my $topsizer = Wx::BoxSizer->new(wxVERTICAL);
    # create Wx::Panel to use as a parent
    my $panel = Wx::Panel->new(
        $frame, -1, [-1,-1], [-1,-1],
        wxTAB_TRAVERSAL|wxBORDER_NONE
    );
    # create a text control with minimal size 100x60
    my $text = Wx::TextCtrl->new(
        $panel, -1, '',
        [-1,-1],[400,240],
        wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL
    );
    $topsizer->Add(
        $text,
        1,           # make vertically stretchable
        wxEXPAND |   # make horizontally stretchable
        wxALL,       # and make border all around
        10           # set border width to 10
    );
    my $choose_file_btn     = Wx::Button->new($panel, wxID_ANY, 'Choose File...');
    EVT_BUTTON( $self, $choose_file_btn, sub {
            my ($self, $event) = @_;
            $self->{file_paths} = _open_files($frame);
            $text->SetValue(join "\n",@{ $self->{file_paths} } );
        }
    );
    my $convert_btn     = Wx::Button->new($panel, wxID_OK, 'Convert');
    EVT_BUTTON( $self, $convert_btn, sub {
            my ($self, $event) = @_;
            $self->_convert_files;
        }
    );
    my $close_btn = Wx::Button->new($panel, wxID_CANCEL, 'Close');
    EVT_BUTTON( $self, $close_btn, sub {
            my ($self, $event) = @_;
            $frame->Destroy;
        }
    );
    my $buttonsizer = Wx::BoxSizer->new(wxHORIZONTAL);
    $buttonsizer->Add(
        $convert_btn,
        0,           # make horizontally unstretchable
        wxALL,       # make border all around (implicit top alignment)
        10           # set border width to 10
    );
    $buttonsizer->Add(
        $close_btn,
        0,           # make horizontally unstretchable
        wxALL,       # make border all around (implicit top alignment)
        10           # set border width to 10
    );
    $buttonsizer->Add(
        $choose_file_btn,
        0,           # make horizontally unstretchable
        wxALL,       # make border all around (implicit top alignment)
        10           # set border width to 10
    );
    $topsizer->Add(
        $buttonsizer,
        0,             # make vertically unstretchable
        wxALIGN_CENTER # no border and centre horizontally
    );
    # my $overwrite_checkbox = Wx::CheckBox->new(
    #     $frame, wxID_ANY, "overwrite existing files",
    #     wxDefaultPosition, wxDefaultSize, 0);
    # $topsizer->Add(
    #     $overwrite_checkbox,
    #     0,             # make vertically unstretchable
    #     wxALIGN_CENTER, # no border and centre horizontally
    #     10
    # );
    $panel->SetSizer( $topsizer );
    my $mainsizer = Wx::BoxSizer->new(wxVERTICAL);
    $mainsizer->Add($panel, 1, wxEXPAND|wxALL, 0);
    # use the sizer for layout and size frame
    # preventing it from being resized to a
    # smaller size;
    $frame->SetSizerAndFit($mainsizer);<commit_msg>Reorderd buttons so that they are grouped functionally<commit_after>#!/usr/bin/env perl
use strict;
use warnings;
# PODNAME: WICS-GUI.pl
# VERSION
# ABSTRACT: GUI frontent for converting ITS-decorated data

=head1 DESCRIPTION

This is a graphical interface for converting ITS-decorated
data into other formats. Currently it only supports XML->HTML
conversion.

Choose the file or files you would like to convert by clicking
"Choose file...". Execute the conversion process by clicking
"Convert". A frame with the log messages will pop up. Errors
are shown in red.

Converted files are written to the directory that the source
files exist in. They keep the name of their source file, but
with a different extension. If the "overwrite existing files"
box is not checked and a file with the given name and extension
already exists, then a number will be appended to the end of
the file name to make it unique.

=cut

package MyApp;
use Wx::Perl::Packager;
use Wx qw(
    :clipboard
    :misc
    :frame
    :textctrl
    :sizer
    :panel
    :window
    :id
    :filedialog
    :colour
);
use Wx::DND;
use Wx::Event qw(EVT_BUTTON);
use base 'Wx::App';
use Path::Tiny;
use Try::Tiny;
use Log::Any::Test;
use Log::Any qw($log);
use XML::ITS::WICS qw(xml2html);

sub OnInit {
    my( $self ) = @_;
    # create a new frame (a frame is a top level window)
    my $frame = Wx::Frame->new(
        undef,           # parent window
        -1,              # ID -1 means any
        'Convert ITS-Decorated Files',   # title
        [-1, -1],        # default position
        [350, 250],      # size
    );
    $self->{main_frame} = $frame;

    my $topsizer = Wx::BoxSizer->new(wxVERTICAL);
    # create Wx::Panel to use as a parent
    my $panel = Wx::Panel->new(
        $frame, -1, [-1,-1], [-1,-1],
        wxTAB_TRAVERSAL|wxBORDER_NONE
    );
    # create a text control with minimal size 100x60
    my $text = Wx::TextCtrl->new(
        $panel, -1, '',
        [-1,-1],[400,240],
        wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL
    );
    $topsizer->Add(
        $text,
        1,           # make vertically stretchable
        wxEXPAND |   # make horizontally stretchable
        wxALL,       # and make border all around
        10           # set border width to 10
    );
    my $convert_btn     = Wx::Button->new($panel, wxID_OK, 'Convert');
    EVT_BUTTON( $self, $convert_btn, sub {
            my ($self, $event) = @_;
            $self->_convert_files;
        }
    );
    my $choose_file_btn     = Wx::Button->new($panel, wxID_ANY, 'Choose File...');
    EVT_BUTTON( $self, $choose_file_btn, sub {
            my ($self, $event) = @_;
            $self->{file_paths} = _open_files($frame);
            $text->SetValue(join "\n",@{ $self->{file_paths} } );
        }
    );
    my $close_btn = Wx::Button->new($panel, wxID_CANCEL, 'Close');
    EVT_BUTTON( $self, $close_btn, sub {
            my ($self, $event) = @_;
            $frame->Destroy;
        }
    );
    my $buttonsizer = Wx::BoxSizer->new(wxHORIZONTAL);
    $buttonsizer->Add(
        $convert_btn,
        0,           # make horizontally unstretchable
        wxALL,       # make border all around (implicit top alignment)
        10           # set border width to 10
    );
    $buttonsizer->Add(
        $choose_file_btn,
        0,           # make horizontally unstretchable
        wxALL,       # make border all around (implicit top alignment)
        10           # set border width to 10
    );
    $buttonsizer->Add(
        $close_btn,
        0,           # make horizontally unstretchable
        wxALL,       # make border all around (implicit top alignment)
        10           # set border width to 10
    );
    $topsizer->Add(
        $buttonsizer,
        0,             # make vertically unstretchable
        wxALIGN_CENTER # no border and centre horizontally
    );
    # my $overwrite_checkbox = Wx::CheckBox->new(
    #     $frame, wxID_ANY, "overwrite existing files",
    #     wxDefaultPosition, wxDefaultSize, 0);
    # $topsizer->Add(
    #     $overwrite_checkbox,
    #     0,             # make vertically unstretchable
    #     wxALIGN_CENTER, # no border and centre horizontally
    #     10
    # );
    $panel->SetSizer( $topsizer );
    my $mainsizer = Wx::BoxSizer->new(wxVERTICAL);
    $mainsizer->Add($panel, 1, wxEXPAND|wxALL, 0);
    # use the sizer for layout and size frame
    # preventing it from being resized to a
    # smaller size;
    $frame->SetSizerAndFit($mainsizer);
{'fraction_non_alphanumeric': 0.11253768002679469, 'fraction_numerical': 0.012950764764988278, 'mean_word_length': 2.2598253275109172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '57295', 'n_tokens_mistral': 2958, 'n_tokens_neox': 2823, 'n_words': 878}