removed dependency on Gtk2::Glade
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 4 Oct 2010 02:51:26 +0000 (22:51 -0400)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 4 Oct 2010 02:51:26 +0000 (22:51 -0400)
Crypt/Monkeysphere/MSVA/MarginalUI.glade [deleted file]
Crypt/Monkeysphere/MSVA/MarginalUI.pm

diff --git a/Crypt/Monkeysphere/MSVA/MarginalUI.glade b/Crypt/Monkeysphere/MSVA/MarginalUI.glade
deleted file mode 100644 (file)
index fe3bb9e..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0"?>
-<glade-interface>
-  <!-- interface-requires gtk+ 2.16 -->
-  <!-- interface-naming-policy project-wide -->
-  <widget class="GtkDialog" id="dialog">
-    <property name="visible">True</property>
-    <property name="border_width">5</property>
-    <property name="type_hint">normal</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <widget class="GtkVBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
-        <child>
-          <widget class="GtkLabel" id="messageLabel">
-            <property name="visible">True</property>
-            <property name="use_markup">True</property>
-          </widget>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <widget class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="layout_style">end</property>
-            <child>
-              <widget class="GtkButton" id="yesButton">
-                <property name="label">gtk-yes</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="on_yesButton_clicked"/>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkButton" id="noButton">
-                <property name="label">gtk-no</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="on_noButton_clicked" object="no"/>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </widget>
-    </child>
-  </widget>
-</glade-interface>
index d544c2486929c0aa804bf574f93c83b8d9c9b908..b89ad0c5b8562414f279914d150084b4f7481158 100755 (executable)
 
   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;
 }