summaryrefslogtreecommitdiffstats
path: root/perl-install/my_gtk.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-07-02 09:25:48 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-07-02 09:25:48 +0000
commit755e511024f29df150d9d150d19c849e59c1e216 (patch)
tree008a780c08366ce366c55cc3bbe0d49703f544d6 /perl-install/my_gtk.pm
parente82688c8b8f639705356d25c180ffe754c2b2c34 (diff)
downloaddrakx-755e511024f29df150d9d150d19c849e59c1e216.tar
drakx-755e511024f29df150d9d150d19c849e59c1e216.tar.gz
drakx-755e511024f29df150d9d150d19c849e59c1e216.tar.bz2
drakx-755e511024f29df150d9d150d19c849e59c1e216.tar.xz
drakx-755e511024f29df150d9d150d19c849e59c1e216.zip
*** empty log message ***
Diffstat (limited to 'perl-install/my_gtk.pm')
-rw-r--r--perl-install/my_gtk.pm30
1 files changed, 18 insertions, 12 deletions
diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm
index 1205a7eda..7d92617ad 100644
--- a/perl-install/my_gtk.pm
+++ b/perl-install/my_gtk.pm
@@ -6,7 +6,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK);
@ISA = qw(Exporter);
%EXPORT_TAGS = (
- all => [ qw(ask_warn ask_yesorno ask_from_entry ask_from_list create_yesorno createScrolledWindow create_menu create_notebook create_packtable create_hbox create_adjustment gtksignal_connect gtkpack gtkpack_ gtkappend gtkadd gtkset_usize gtkset_justify gtkshow gtkdestroy) ],
+ all => [ qw(ask_warn ask_okcancel ask_yesorno ask_from_entry ask_from_list create_okcancel createScrolledWindow create_menu create_notebook create_packtable create_hbox create_adjustment gtksignal_connect gtkpack gtkpack_ gtkappend gtkadd gtkset_usize gtkset_justify gtkshow gtkdestroy) ],
);
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
@@ -26,13 +26,17 @@ sub new {
$o->{window} = $o->_create_window($title);
$o;
}
-sub main($) {
- my $o = shift;
- $o->{window}->show;
- Gtk->main;
+sub main($;$) {
+ my ($o, $f) = @_;
+ $o->show;
+ do { Gtk->main } while ($o->{retval} && $f && !&$f());
$o->destroy;
$o->{retval}
}
+sub show($) {
+ my ($o) = @_;
+ $o->{window}->show;
+}
sub destroy($) {
my ($o) = @_;
$o->{window}->destroy;
@@ -114,12 +118,12 @@ sub gtkadd($@) {
# these functions return a widget
################################################################################
-sub create_yesorno($) {
- my ($w) = @_;
+sub create_okcancel($;$$) {
+ my ($w, $ok, $cancel) = @_;
gtkadd(create_hbox(),
- gtksignal_connect($w->{ok} = new Gtk::Button("Ok"), "clicked" => sub { $w->{retval} = 1; Gtk->main_quit }),
- gtksignal_connect(new Gtk::Button("Cancel"), "clicked" => sub { $w->{retval} = 0; Gtk->main_quit }),
+ gtksignal_connect($w->{ok} = new Gtk::Button($ok || "Ok"), "clicked" => sub { $w->{retval} = 1; Gtk->main_quit }),
+ gtksignal_connect(new Gtk::Button($cancel || "Cancel"), "clicked" => sub { $w->{retval} = 0; Gtk->main_quit }),
);
}
@@ -210,7 +214,8 @@ sub _create_window($$) {
################################################################################
sub ask_warn { my $w = my_gtk->new(shift @_); $w->_ask_warn(@_); main($w); }
-sub ask_yesorno { my $w = my_gtk->new(shift @_); $w->_ask_yesorno(@_, "Is it ok?"); main($w); }
+sub ask_yesorno { my $w = my_gtk->new(shift @_); $w->_ask_okcancel(@_, "Yes", "No"); main($w); }
+sub ask_okcancel { my $w = my_gtk->new(shift @_); $w->_ask_okcancel(@_, "Is it ok?", "Ok", "Cancel"); main($w); }
sub ask_from_entry { my $w = my_gtk->new(shift @_); $w->_ask_from_entry(@_); main($w); }
sub ask_from_list { my $w = my_gtk->new(shift @_); $w->_ask_from_list(pop @_, @_); main($w); }
@@ -254,12 +259,13 @@ sub _ask_warn($@) {
$w->grab_focus();
}
-sub _ask_yesorno($@) {
+sub _ask_okcancel($@) {
my ($o, @msgs) = @_;
+ my ($ok, $cancel) = splice @msgs, -2;
gtkadd($o->{window},
gtkpack(create_box_with_title($o, @msgs),
- create_yesorno($o),
+ create_okcancel($o, $ok, $cancel),
)
);
$o->{ok}->grab_focus();