From 604deb114bf992137e1027980f8d94edd734e250 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 15 Feb 2005 16:35:17 +0000 Subject: add FileChooser creation and rollback ugly ->run thing (hopefully now unneeded) --- perl-install/mygtk2.pm | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/perl-install/mygtk2.pm b/perl-install/mygtk2.pm index c1dcb2b0c..e45994098 100644 --- a/perl-install/mygtk2.pm +++ b/perl-install/mygtk2.pm @@ -501,6 +501,28 @@ sub _gtk__FileSelection { $w; } +sub _gtk__FileChooser { + my ($w, $opts) = @_; + + #- no nice way to have a {file_ref} on a FileChooser since selection_changed only works for browsing, not file/folder creation + + if (!$w) { + my $action = delete $opts->{action} || internal_error("missing action for FileChooser"); + $w = Gtk2::FileChooserWidget->new($action); + + my $file = $opts->{file} && delete $opts->{file}; + + if (my $dir = delete $opts->{directory} || $file && dirname($file)) { + $w->set_current_folder($dir); + } + if ($file) { + my $meth = $action =~ /save|create/ ? 'set_current_name' : 'set_filename'; + $w->$meth($file); + } + } + $w; +} + sub _gtk__VBox { &_gtk_any_Box } sub _gtk__HBox { &_gtk_any_Box } sub _gtk_any_Box { @@ -816,13 +838,7 @@ sub main { my $destroyed; $window->signal_connect(destroy => sub { $destroyed = 1 }); $window->show; - do { - if ($window->isa('Gtk2::FileSelection')) { - $window->run; - } else { - Gtk2->main; - } - } while (!$destroyed && $o_verif && !$o_verif->()); + do { Gtk2->main } while (!$destroyed && $o_verif && !$o_verif->()); may_destroy($window); flush(); } -- cgit v1.2.1