From 1afc22d2a5b40c9d635a992cfae6d1e36df8e192 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Sun, 3 Oct 2010 22:51:26 -0400 Subject: [PATCH] removed dependency on Gtk2::Glade --- Crypt/Monkeysphere/MSVA/MarginalUI.glade | 68 ------------------------ Crypt/Monkeysphere/MSVA/MarginalUI.pm | 49 ++++++++--------- 2 files changed, 23 insertions(+), 94 deletions(-) delete mode 100644 Crypt/Monkeysphere/MSVA/MarginalUI.glade diff --git a/Crypt/Monkeysphere/MSVA/MarginalUI.glade b/Crypt/Monkeysphere/MSVA/MarginalUI.glade deleted file mode 100644 index fe3bb9e..0000000 --- a/Crypt/Monkeysphere/MSVA/MarginalUI.glade +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - True - 5 - normal - False - - - True - vertical - 2 - - - True - True - - - 1 - - - - - True - end - - - gtk-yes - True - True - True - True - - - - False - False - 0 - - - - - gtk-no - True - True - True - True - - - - False - False - 1 - - - - - False - end - 0 - - - - - - diff --git a/Crypt/Monkeysphere/MSVA/MarginalUI.pm b/Crypt/Monkeysphere/MSVA/MarginalUI.pm index d544c24..b89ad0c 100755 --- a/Crypt/Monkeysphere/MSVA/MarginalUI.pm +++ b/Crypt/Monkeysphere/MSVA/MarginalUI.pm @@ -11,39 +11,36 @@ use strict; use warnings; - - my $resp = 0; + use Gtk2 '-init'; sub prompt { - use Gtk2 '-init'; # auto-initializes Gtk2 - use Gtk2::GladeXML; - - my $glade; - my $label; - - # populate UI from - $glade = Gtk2::GladeXML->new("Crypt/Monkeysphere/MSVA/MarginalUI.glade"); - - # Connect the signals - $glade->signal_autoconnect_from_package('Crypt::Monkeysphere::MSVA::MarginalUI'); - $label = $glade->get_widget('messageLabel'); - my $labeltxt = shift; - $label->set_text($labeltxt); - # Start it up - Gtk2->main; + # create a new dialog with some buttons - one stock, one not. + my $dialog = Gtk2::Dialog->new ('msva-perl prompt!', undef, qw( modal ), + 'gtk-cancel' => 'cancel', + 'Lemme at it!' => 'ok'); + my $label = Gtk2::Label->new($labeltxt); + $label->show(); + $dialog->get_content_area()->add($label); + my $resp = 0; + + $dialog->set_default_response ('cancel'); + + # show and interact modally -- blocks until the user + # activates a response. + my $response = $dialog->run(); + if ($response eq 'ok') { + $resp = 1; + } + + $dialog->hide(); + # activating a response does not destroy the window, + # that's up to you. + $dialog->destroy(); return $resp; } - sub on_yesButton_clicked { - $resp = 1; - Gtk2->main_quit; - } - sub on_noButton_clicked { - Gtk2->main_quit; - } - 1; } -- 2.26.2