« blib/lib/App/Asciio/GTK/Asciio/stripes/editable_arrow2.pm
↑ Summary
blib/lib/App/Asciio/GTK/Asciio/stripes/section_wirl_arrow.pm »
| 1 | |||
| 2 | package App::Asciio::stripes::exec_box ; | ||
| 3 | use parent qw/App::Asciio::stripes::editable_box2/ ; | ||
| 4 | |||
| 5 | use App::Asciio::GTK::Asciio::Boxfuncs ; | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | use Glib qw(TRUE FALSE); | ||
| 11 | |||
| 12 | #----------------------------------------------------------------------------- | ||
| 13 | |||
| 14 | sub display_box_edit_dialog | ||
| 15 | { | ||
| 16 | my ($self, $title, $text, $asciio) = @_ ; | ||
| 17 | |||
| 18 | my $rows = $self->{BOX_TYPE} ; | ||
| 19 | |||
| 20 | my $window = new Gtk3::Window() ; | ||
| 21 | |||
| 22 | my $dialog = Gtk3::Dialog->new('Box attributes', $window, 'destroy-with-parent') ; | ||
| 23 | $dialog->set_position("mouse"); | ||
| 24 | $dialog->set_border_width(0); | ||
| 25 | $dialog->set_default_size(450, 450); | ||
| 26 | $dialog->add_button('gtk-ok' => 'ok'); | ||
| 27 | |||
| 28 | my $vbox = Gtk3::Box->new( 'vertical', 8 ); | ||
| 29 | $vbox->add(Gtk3::Label->new ("")); | ||
| 30 | |||
| 31 | my $treeview = Gtk3::TreeView->new_with_model(create_model($rows)); | ||
| 32 | $treeview->set_rules_hint(TRUE); | ||
| 33 | $treeview->get_selection->set_mode('single'); | ||
| 34 | add_columns($treeview, $rows); | ||
| 35 | |||
| 36 | $vbox->add($treeview); | ||
| 37 | |||
| 38 | # box title | ||
| 39 | my $titleview = Gtk3::TextView->new; | ||
| 40 | $titleview->modify_font(Pango::FontDescription->from_string ($asciio->get_font_as_string())); | ||
| 41 | my $title_buffer = $titleview->get_buffer ; | ||
| 42 | $title_buffer->insert($title_buffer->get_end_iter, $title); | ||
| 43 | |||
| 44 | $vbox->add($titleview); | ||
| 45 | |||
| 46 | $titleview->show(); | ||
| 47 | |||
| 48 | # box text | ||
| 49 | my $textview = Gtk3::TextView->new; | ||
| 50 | $textview->modify_font(Pango::FontDescription->from_string ($asciio->get_font_as_string())); | ||
| 51 | |||
| 52 | my $text_buffer = $textview->get_buffer; | ||
| 53 | $text_buffer->insert($text_buffer->get_end_iter, $text); | ||
| 54 | |||
| 55 | my $text_scroller = Gtk3::ScrolledWindow->new(); | ||
| 56 | $text_scroller->set_hexpand(TRUE); | ||
| 57 | $text_scroller->set_vexpand(TRUE); | ||
| 58 | $text_scroller->add($textview); | ||
| 59 | $vbox->add($text_scroller); | ||
| 60 | |||
| 61 | $textview->show(); | ||
| 62 | $text_scroller->show(); | ||
| 63 | |||
| 64 | #Focus and select, code by Tian | ||
| 65 | $text_buffer->select_range($text_buffer->get_start_iter, $text_buffer->get_end_iter); | ||
| 66 | $textview->grab_focus() ; | ||
| 67 | |||
| 68 | $treeview->show() ; | ||
| 69 | $vbox->show() ; | ||
| 70 | |||
| 71 | $dialog->get_content_area()->add($vbox) ; | ||
| 72 | $dialog->run() ; | ||
| 73 | |||
| 74 | my $new_text = $textview->get_buffer->get_text($text_buffer->get_start_iter, $text_buffer->get_end_iter, TRUE) ; | ||
| 75 | my $new_title = $titleview->get_buffer->get_text($title_buffer->get_start_iter, $title_buffer->get_end_iter, TRUE) ; | ||
| 76 | |||
| 77 | $dialog->destroy ; | ||
| 78 | |||
| 79 | return($new_text, $new_title) ; | ||
| 80 | } | ||
| 81 | |||
| 82 | #----------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | 1 ; |