« Curie/Component/DocumentPropertiesWindow.pm
↑ Summary
Curie/Component/JacquardCanvas/Role/MouseCursor.pm »
| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Renard::Curie::Component::FileChooser; | ||
| 3 | # ABSTRACT: Component that implements a file chooser dialog | ||
| 4 | $Renard::Curie::Component::FileChooser::VERSION = '0.005'; | ||
| 5 | use Moo; | ||
| 6 | use Intertangle::API::Gtk3::Helper; | ||
| 7 | use Renard::Incunabula::Common::Types qw(InstanceOf); | ||
| 8 | |||
| 9 | has all_filter => ( | ||
| 10 | is => 'lazy', # _build_all_filter | ||
| 11 | isa => InstanceOf['Gtk3::FileFilter'], | ||
| 12 | ); | ||
| 13 | |||
| 14 | has pdf_filter => ( | ||
| 15 | is => 'lazy', # _build_pdf_filter | ||
| 16 | isa => InstanceOf['Gtk3::FileFilter'], | ||
| 17 | ); | ||
| 18 | |||
| 19 | method _build_all_filter() :ReturnType(InstanceOf['Gtk3::FileFilter']) { | ||
| 20 | my $filter = Gtk3::FileFilter->new; | ||
| 21 | $filter->set_name("All files"); | ||
| 22 | $filter->add_pattern("*"); | ||
| 23 | |||
| 24 | return $filter; | ||
| 25 | } | ||
| 26 | |||
| 27 | method _build_pdf_filter() :ReturnType(InstanceOf['Gtk3::FileFilter']) { | ||
| 28 | my $filter = Gtk3::FileFilter->new; | ||
| 29 | $filter->set_name("PDF files"); | ||
| 30 | $filter->add_mime_type("application/pdf"); | ||
| 31 | |||
| 32 | return $filter; | ||
| 33 | } | ||
| 34 | |||
| 35 | method get_open_file_dialog() :ReturnType(InstanceOf['Gtk3::FileChooserDialog']) { | ||
| 36 | my $dialog = Gtk3::FileChooserDialog->new( | ||
| 37 | "Open File", | ||
| 38 | $self->main_window->window, | ||
| 39 | 'GTK_FILE_CHOOSER_ACTION_OPEN', | ||
| 40 | 'gtk-cancel' => 'cancel', | ||
| 41 | 'gtk-open' => 'accept', | ||
| 42 | ); | ||
| 43 | |||
| 44 | return $dialog; | ||
| 45 | } | ||
| 46 | |||
| 47 | method get_open_file_dialog_with_filters() :ReturnType(InstanceOf['Gtk3::FileChooserDialog']) { | ||
| 48 | my $dialog = $self->get_open_file_dialog; | ||
| 49 | |||
| 50 | $dialog->add_filter( $self->pdf_filter ); | ||
| 51 | $dialog->add_filter( $self->all_filter ); | ||
| 52 | |||
| 53 | return $dialog; | ||
| 54 | } | ||
| 55 | |||
| 56 | with qw( | ||
| 57 | Renard::Curie::Component::Role::HasParentMainWindow | ||
| 58 | ); | ||
| 59 | |||
| 60 | 1; | ||
| 61 | |||
| 62 | __END__ |