diff --git a/images/printer-1.jpg b/images/printer-1.jpg new file mode 100644 index 0000000..1dc4b6f Binary files /dev/null and b/images/printer-1.jpg differ diff --git a/images/printer-2.jpg b/images/printer-2.jpg new file mode 100644 index 0000000..9d989d8 Binary files /dev/null and b/images/printer-2.jpg differ diff --git a/images/roll-1.jpg b/images/roll-1.jpg new file mode 100644 index 0000000..9c30a04 Binary files /dev/null and b/images/roll-1.jpg differ diff --git a/images/roll-2.jpg b/images/roll-2.jpg new file mode 100644 index 0000000..b7ad824 Binary files /dev/null and b/images/roll-2.jpg differ diff --git a/images/roll-3.jpg b/images/roll-3.jpg new file mode 100644 index 0000000..ebb5437 Binary files /dev/null and b/images/roll-3.jpg differ diff --git a/lib/Exd/Gui/Instance.pm b/lib/Exd/Gui/Instance.pm index b6a26be..7bce335 100644 --- a/lib/Exd/Gui/Instance.pm +++ b/lib/Exd/Gui/Instance.pm @@ -25,7 +25,7 @@ has device => ( is => 'rw' ); has _pay_url => ( is => 'lazy' ); has _activated => ( is => 'rw' ); has _last_valid_preview_file => ( is => 'rw' ); -has _is_showing_paywall => (is => 'rw'); +has _is_showing_paywall => ( is => 'rw' ); has file_format => ( is => 'rw', default => sub { @@ -395,6 +395,9 @@ sub _create_popover_menu( $self, $box ) { Glib::IO::SimpleAction->new( 'save-as.' . $self->instance_id, undef ); my $about_action = Glib::IO::SimpleAction->new( 'about.' . $self->instance_id, undef ); + my $good_printers_action = + Glib::IO::SimpleAction->new( 'good-printers.' . $self->instance_id, + undef ); my $app = $self->app->_app; $about_action->signal_connect( 'activate', @@ -402,6 +405,11 @@ sub _create_popover_menu( $self, $box ) { $self->_show_about_dialog; } ); + $good_printers_action->signal_connect( + activate => sub { + $self->_show_recommended_printers; + } + ); $open_action->signal_connect( 'activate', sub { @@ -424,16 +432,118 @@ sub _create_popover_menu( $self, $box ) { $app->add_action($save_action); $app->add_action($save_as_action); $app->add_action($about_action); + $app->add_action($good_printers_action); $file_menu->append( 'Open', 'app.open.' . $self->instance_id ); $file_menu->append( 'Save', 'app.save.' . $self->instance_id ); $file_menu->append( 'Save as', 'app.save-as.' . $self->instance_id ); $help_menu->append( 'About', 'app.about.' . $self->instance_id ); + $help_menu->append( 'Recommended printers and supplies', + 'app.good-printers.' . $self->instance_id ); $menu_model->append_submenu( 'File', $file_menu ); $menu_model->append_submenu( 'Help', $help_menu ); my $popover = Gtk4::PopoverMenuBar->new_from_model($menu_model); $box->append($popover); } +sub _show_recommended_printers($self) { + my $win = Gtk4::Window->new; + $win->set_title('Recommended printers and supplies'); + $win->set_default_size(1000, 700); + + my $scroll = Gtk4::ScrolledWindow->new; + my $box = Gtk4::Box->new('vertical', 1); + $scroll->set_child($box); + + my $explain = Gtk4::Label->new(undef); + my @products = ( + { + url => 'https://amzn.to/3V7oV7p', + country => 'USA', + description => 'Tested printer, uses standard protocol, advertised as only working by bluetooth but the model I got works by usb too. Perfectly supported', + image => 'images/printer-1.jpg', + }, + { + url => 'https://amzn.to/3ULFuFz', + country => 'USA', + description => 'Rolls of normal thermal papel', + image => 'images/roll-3.jpg', + }, + { + url => 'https://amzn.to/3O3DGEd', + country => 'Europe', + description => 'Advertised as having bluetooth and usb support, works fine, Perfectly supported', + image => 'images/printer-2.jpg', + }, + { + url => 'https://amzn.to/3YXWjj1', + country => 'Europe', + description => 'Tested printer, uses standard protocol, advertised as only working by bluetooth but the model I got works by usb too. Perfectly supported', + image => 'images/printer-1.jpg', + }, + { + url => 'https://amzn.to/4elBYZC', + country => 'Europe', + description => 'Rolls of normal thermal papel', + image => 'images/roll-1.jpg', + }, + { + url => 'https://amzn.to/4eno7BK', + country => 'Europe', + description => 'Rolls of sticker thermal papel', + image => 'images/roll-2.jpg', + }, + ); + $explain->set_markup( + 'Recommended products: + +I get a comission each time you buy one of those using these links.' + ); + + $box->append($explain); + + for my $product (@products) { + my $product_box = Gtk4::Box->new('horizontal', 10); + my $image_file = path(__FILE__)->parent->parent->parent->parent->child($product->{image}); + my $image = Gtk4::Image->new_from_file($image_file); + $image->set_pixel_size(256); + $product_box->append($image); + my $right_side_product_box = Gtk4::Box->new('vertical', 10); + my $label_available_in = Gtk4::Label->new(undef); + $label_available_in->set_halign('start'); + $label_available_in->set_markup('Available in: '.$product->{country}.''); + $right_side_product_box->append($label_available_in); + my @lines = split /\n/, $product->{description}; + for (my $i = 0; 1 ; $i++) { + if (!($i < scalar @lines)) { + last; + } + my $line = $lines[$i]; + my $size_line = 60; + if (length $line > $size_line) { + splice @lines, $i, 1, substr($line, 0, $size_line), substr($line, $size_line); + } + } + $product->{description} = join "\n", @lines; + my $label_description = Gtk4::Label->new($product->{description}); + $label_description->set_halign('start'); + $right_side_product_box->append($label_description); + my $buy_button = Gtk4::Button->new_with_label('Buy now'); + $buy_button->set_halign('end'); + $buy_button->signal_connect(clicked => sub{ + my $launcher = Gtk4::UriLauncher->new( $product->{url} ); + $launcher->launch( $self->window, undef, undef ); + }); + $right_side_product_box->append($buy_button); + $product_box->append($right_side_product_box); + $box->append($product_box); + } + + + $win->set_child($scroll); + $win->set_transient_for( $self->window ); + $win->present; +} + sub _populate_editor( $self, $box_editor_preview ) { my $editor = Gtk4::Source::View->new; $self->_editor($editor); diff --git a/me.sergiotarxz.Exd.metainfo.xml b/me.sergiotarxz.Exd.metainfo.xml index f816d7b..5299503 100644 --- a/me.sergiotarxz.Exd.metainfo.xml +++ b/me.sergiotarxz.Exd.metainfo.xml @@ -30,6 +30,11 @@ + + +

Adding recommended products to use with the IDE

+
+

Fixing brand color dark theme