diff --git a/gtk_prueba.pl b/gtk_prueba.pl index 5374f78..11aec16 100644 --- a/gtk_prueba.pl +++ b/gtk_prueba.pl @@ -1,73 +1,36 @@ -use 5.30.0; +use v5.30.0; use strict; use warnings; -use Glib::Object::Introspection; -use Cairo::GObject; -use Data::Dumper; - -Glib::Object::Introspection->setup( - basename => 'Gtk', - version => '4.0', - package => 'Gtk4', -); - -Glib::Object::Introspection->setup( - basename => 'Gio', - version => '2.0', - package => 'G', -); - -Glib::Object::Introspection->setup( - basename => 'Gdk', - version => '4.0', - package => 'Gtk4::Gdk', -); - -Glib::Object::Introspection->_register_boxed_synonym( - "cairo", "RectangleInt", - "gdk_rectangle_get_type" -); +use MangaReader; my $application = Gtk4::Application->new( 'me.sergiotarxz.manga', 'G_APPLICATION_FLAGS_NONE' ); -$application->signal_connect( +say $application->signal_connect( activate => sub { - my $window = Gtk4::ApplicationWindow->new($application); - my $grid = Gtk4::Grid->new; - $window->set_title('Sergiotarxz\'s Manga Reader'); - my $scroll = Gtk4::ScrolledWindow->new; - $window->set_child($scroll); - my $scroll_image = Gtk4::Viewport->new(); - $scroll->set_child($grid); - my $image = Gtk4::Picture->new_for_file( - G::File::new_for_path( - '/home/sergio/2020-05-06-235314_636x1023_scrot.png') - ); - $image->set_can_shrink(0); - $image->set_keep_aspect_ratio(1); - $scroll_image->set_child($image); - - $grid->attach( $scroll_image, 1, 1, 1, 1 ); - $window->signal_connect( - 'state-flags-changed' => sub { - my $allocation = $window->get_allocation; - my $paintable = $image->get_paintable; - return if grep { !$_ } $allocation->@{ 'width', 'height' }; - my $new_width = $allocation->{width}; - my ($old_width, $old_height) = $image->get_allocation->@{ 'width', 'height' }; - my $new_height = $new_width / $old_width * $old_height; - $scroll_image->set_size_request($new_width, $new_height); - $grid->set_size_request($new_width, $new_height); - $image->set_size_request($new_width, $new_height); - print Data::Dumper::Dumper $paintable->compute_concrete_size( - $new_width, $new_height, $new_width, $new_height - ); - $window->show; - } - ); - $window->show; + MangaReader::ApplicationStart($application); } ); $application->run( \@ARGV ); + +# sub ShowImage { +# my $scroll_image = Gtk4::Viewport->new(); +# $scroll->set_child($grid); +# my $image = Gtk4::Picture->new_for_file( +# G::File::new_for_path( +# '/home/sergio/2020-05-06-235314_636x1023_scrot.png') +# ); +# $image->set_can_shrink(1); +# $image->set_keep_aspect_ratio(1); +# $scroll_image->set_child($image); +# +# $grid->attach( $scroll_image, 1, 1, 1, 1 ); +# $window->signal_connect( +# 'state-flags-changed' => sub { +# WindowResize( $window, $image, $scroll_image, $grid ); +# } +# ); +# $window->show; +# } +