Adding search to make easier manipulate flags.

This commit is contained in:
sergiotarxz 2024-03-02 09:44:18 +01:00
parent 5595cb9f8b
commit 50d460be9f
1 changed files with 82 additions and 54 deletions

View File

@ -136,28 +136,50 @@ sub start_editing_file {
my $current_save_index = find_current_save_index(@$saves);
my $save = $saves->[$current_save_index];
my %flags = @Rsaves::Constants::Emerald::Flags::FLAGS;
my $box_flags = Gtk4::Box->new( 'vertical', 0 );
my $box_app = Gtk4::Box->new( 'vertical', 0 );
my $superdata = get_first_super_data($save);
my $search = Gtk4::SearchBar->new;
my $entry = Gtk4::Entry->new;
$search->set_child($entry);
$search->set_search_mode(1);
$box_app->append($search);
$box_app->set_property( 'vexpand', 1 );
my $scroll = Gtk4::ScrolledWindow->new;
$scroll->set_property( 'vexpand', 1 );
my $populate_func = sub {
my $box_flags = Gtk4::Box->new( 'vertical', 0 );
for my $rematch_id (
sort { $a <=> $b }
grep { $_ =~ /^\d+$/ } keys %rematches
)
{
my $toggle =
Gtk4::ToggleButton->new_with_label( $rematches{$rematch_id} );
$toggle->set_active( check_rematch( $save, $superdata, $rematch_id ) );
my $buffer = $entry->get_buffer;
my $search_text = uc( $buffer->get_text );
my $text = $rematches{$rematch_id};
next unless index( $text, $search_text ) >= 0;
my $toggle = Gtk4::ToggleButton->new_with_label($text);
$toggle->set_active(
check_rematch( $save, $superdata, $rematch_id ) );
$toggle->signal_connect(
toggled => sub {
my $active = $toggle->get_active;
Rsaves::set_rematch( $save, $superdata, $rematch_id, $active );
Rsaves::set_rematch( $save, $superdata, $rematch_id,
$active );
Rsaves::set_first_super_data( $save, $superdata );
}
);
$box_flags->append($toggle);
}
for my $flag_id ( sort { $a <=> $b } grep { $_ =~ /^\d+$/ } keys %flags ) {
my $toggle = Gtk4::ToggleButton->new_with_label( $flags{$flag_id} );
for
my $flag_id ( sort { $a <=> $b } grep { $_ =~ /^\d+$/ } keys %flags )
{
my $buffer = $entry->get_buffer;
my $search_text = uc( $buffer->get_text );
my $text = $flags{$flag_id};
next unless index( $text, $search_text ) >= 0;
my $toggle = Gtk4::ToggleButton->new_with_label($text);
$toggle->set_active( check_flag_id( $save, $superdata, $flag_id ) );
$toggle->signal_connect(
toggled => sub {
@ -169,9 +191,14 @@ sub start_editing_file {
$box_flags->append($toggle);
}
my $scroll = Gtk4::ScrolledWindow->new;
$scroll->set_child($box_flags);
$win->set_child($scroll);
};
$populate_func->();
$entry->signal_connect( activate => sub {
$populate_func->();
});
$box_app->append($scroll);
$win->set_child($box_app);
$save_as->set_enabled(1);
}
@ -179,15 +206,16 @@ sub start_editing_file {
sub activate_about {
my $about = Gtk4::AboutDialog->new;
$about->set_program_name('GEmeTool');
$about->set_copyright( "© Sergio Iglesias (2024)");
$about->set_copyright("© Sergio Iglesias (2024)");
$about->set_license_type('gpl-3-0');
$about->add_credit_section('Ideas:', ['SpectreSpecs']);
$about->set_authors(['Sergio Iglesias']);
$about->add_credit_section( 'Ideas:', ['SpectreSpecs'] );
$about->set_authors( ['Sergio Iglesias'] );
$about->set_website('https://git.owlcode.tech/sergiotarxz/GEmeTool');
$about->set_website_label('https://git.owlcode.tech/sergiotarxz/GEmeTool');
# my $header_bar = Gtk4::HeaderBar->new;
# $header_bar->set_property(
# 'title-widget' => Gtk4::Label->new('About GEmeTool') );
# $about->set_titlebar($header_bar);
# my $header_bar = Gtk4::HeaderBar->new;
# $header_bar->set_property(
# 'title-widget' => Gtk4::Label->new('About GEmeTool') );
# $about->set_titlebar($header_bar);
$about->present;
}