From 8f7e820a0165c64fd1c496e54588b87b2cfe2469 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 3 Nov 2015 23:00:59 +0100 Subject: [PATCH] Display a warning when no USB/serial printers were configured --- lib/Slic3r/GUI/Controller.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Controller.pm b/lib/Slic3r/GUI/Controller.pm index 5eb2606f6..c73f2140b 100644 --- a/lib/Slic3r/GUI/Controller.pm +++ b/lib/Slic3r/GUI/Controller.pm @@ -14,8 +14,17 @@ sub new { $self->SetScrollbars(0, 1, 0, 1); $self->{sizer} = my $sizer = Wx::BoxSizer->new(wxVERTICAL); + # warning to show when there are no printers configured { - my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/add.png", wxBITMAP_TYPE_PNG), + $self->{text_no_printers} = Wx::StaticText->new($self, -1, + "No printers were configured for USB/serial control.", + wxDefaultPosition, wxDefaultSize); + $self->{sizer}->Add($self->{text_no_printers}, 0, wxTOP | wxLEFT, 30); + } + + # button for adding new printer panels + { + my $btn = $self->{btn_add} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/add.png", wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, Wx::wxBORDER_NONE); $btn->SetToolTipString("Add printer…") if $btn->can('SetToolTipString'); @@ -118,6 +127,12 @@ sub OnActivate { } $self->add_printer($_, $presets{$_}) for sort keys %active; + # show/hide the warning about no printers + $self->{text_no_printers}->Show(!%presets); + + # show/hide the Add button + $self->{btn_add}->Show(keys %presets != keys %active); + $self->Layout; # we need this in order to trigger the OnSize event of wxScrolledWindow which