Author: bdonlan
Date: 2004-07-18 19:57:43 -0400 (Sun, 18 Jul 2004)
New Revision: 312
Added:
trunk/clients/haver-gtk/lib/Haver/UI/Gtk/PasswordPrompt.pm
Log:
* clients/haver-gtk/lib/Haver/UI/Gtk/PasswordPrompt.pm: new file
Added password prompt dialog, to be connected to haver-gtk eventually...
Added: trunk/clients/haver-gtk/lib/Haver/UI/Gtk/PasswordPrompt.pm
===================================================================
--- trunk/clients/haver-gtk/lib/Haver/UI/Gtk/PasswordPrompt.pm 2004-07-14
21:07:30 UTC (rev 311)
+++ trunk/clients/haver-gtk/lib/Haver/UI/Gtk/PasswordPrompt.pm 2004-07-18
23:57:43 UTC (rev 312)
@@ -0,0 +1,145 @@
+# vim: set ft=perl ts=4 sw=4:
+# Haver::UI::Gtk::PasswordPrompt - password prompt dialog
+#
+# Copyright (C) 2004 Bryan Donlan, Dylan William Hardison.
+#
+# This module is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This module is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this module; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package Haver::UI::Gtk::PasswordPrompt;
+
+use strict;
+use warnings;
+
+use constant {
+ TRUE => 1,
+ FALSE => 0,
+};
+
+use Gtk;
+use Carp;
+
+sub new {
+ my ($class, %options) = @_;
+
+ my $oksub = $options{on_OK} || croak "Missing required parameter on_OK";
+ my $cancelsub = $options{on_Cancel} || croak "Missing required
parameter on_Cancel";
+
+ my $dialog = new Gtk::Dialog;
+ $dialog->set_title("Retry login");
+ $dialog->set_modal(TRUE);
+
+ my %fields;
+ my $i;
+ my @fieldlist = qw(UID Password);
+ my $table = new Gtk::Table(@fieldlist + 1, 2, TRUE);
+
+ for ($i = 0; $i < @fieldlist; $i++) {
+ my $field = $fieldlist[$i];
+ my $label = new Gtk::Label("$field: ");
+ my $input = new Gtk::Entry();
+
+ # This dosen't work:
+# $label->set_justify('right');
+
+ my $hacky_box = new Gtk::HBox(FALSE, 0);
+ $hacky_box->pack_end($label, FALSE, FALSE, 0);
+ $hacky_box->show;
+
+ $fields{$field} = $input;
+ $table->attach(
+ $hacky_box, # $child
+ 0, # $left_attach
+ 1, # $right_attach
+ $i, # $top_attach
+ $i + 1, # $bottom_attach
+ [qw(fill shrink expand)], # $xoptions
+ [qw(fill shrink expand)], # $yoptions
+ 0, # $xpadding
+ 0, # $ypadding
+ );
+ $label->show;
+ $table->attach(
+ $input, # $child
+ 1, # $left_attach
+ 2, # $right_attach
+ $i, # $top_attach
+ $i + 1, # $bottom_attach
+ [qw(fill shrink expand)], # $xoptions
+ [qw(fill shrink expand)], # $yoptions
+ 0, # $xpadding
+ 0, # $ypadding
+ );
+ $input->show;
+ }
+
+ my $savepass = new Gtk::CheckButton('Save Password');
+
+ $table->attach(
+ $savepass,
+ 0,
+ 2,
+ $i,
+ $i + 1,
+ [qw(fill shrink expand)],
+ [qw(fill shrink expand)],
+ 0,
+ 0,
+ );
+
+ $savepass->show;
+
+ for (qw(UID Password)) {
+ next unless defined($options{$_});
+ $fields{$_}->set_text($options{$_});
+ }
+ $fields{Password}->set_visibility(FALSE);
+ $savepass->set_active($options{Save} || FALSE);
+
+ $dialog->vbox->pack_start($table, TRUE, TRUE, 0);
+
+ my $ok = new Gtk::Button('OK');
+ my $cancel = new Gtk::Button('Cancel');
+
+ $dialog->action_area->pack_start($ok, TRUE, TRUE, 0);
+ $dialog->action_area->pack_start($cancel, TRUE, TRUE, 0);
+
+ $ok->show;
+ $cancel->show;
+
+ $ok->signal_connect('clicked',
+ sub {
+ $oksub->(
+ UID => $uid->get_text(),
+ Password => $password->get_text(),
+ Save => $savepass->get_active(),
+ );
+ $dialog->destroy;
+ # Break possible circular reference. This is probably
paranoia
+ undef $ok;
+ undef $cancel;
+ }
+ );
+ $cancel->signal_connect('clicked',
+ sub {
+ $cancelsub->();
+ $dialog->destroy;
+ undef $ok;
+ undef $cancel;
+ }
+ );
+ $dialog->show;
+}
+
+1;
Property changes on: trunk/clients/haver-gtk/lib/Haver/UI/Gtk/PasswordPrompt.pm
___________________________________________________________________
Name: svn:eol-style
+ native