Author: bdonlan
Date: 2004-07-04 17:58:42 -0400 (Sun, 04 Jul 2004)
New Revision: 290
Added:
trunk/haver-gtk/lib/Haver/UI/Gtk/ServerDialog.pm
Log:
Add prototype server selection dialog.
Added: trunk/haver-gtk/lib/Haver/UI/Gtk/ServerDialog.pm
===================================================================
--- trunk/haver-gtk/lib/Haver/UI/Gtk/ServerDialog.pm 2004-07-03 18:36:46 UTC
(rev 289)
+++ trunk/haver-gtk/lib/Haver/UI/Gtk/ServerDialog.pm 2004-07-04 21:58:42 UTC
(rev 290)
@@ -0,0 +1,191 @@
+# vim: set ft=perl ts=4 sw=4:
+# Haver::UI::Gtk::ServerDialog - server connect window
+#
+# 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::ServerDialog;
+use strict;
+use warnings;
+
+use constant {
+ FALSE => 0,
+ TRUE => 1,
+};
+
+use Gtk;
+#use POE;
+
+sub new {
+ my ($class, $parent, $config) = @_;
+ $class = ref $class || $class;
+ my $self = {
+ parent => $parent,
+ config => $config,
+ };
+ bless $self, $class;
+
+ $self->{window} = new Gtk::Window("toplevel");
+ $self->{window}->set_title("Connect to server");
+
+ $self->{outer_box} = new Gtk::HBox(FALSE, 5);
+ $self->{window}->add(fixpad($self->{outer_box}, 5));
+
+ $self->{editbox} = $self->mkedit();
+ $self->{slist} = $self->mkslist();
+ $self->{slist}->show;
+ $self->{editbox}->show;
+
+ # XXX: slidable?
+# $self->{outer_box}->pack_start($self->{editbox}, FALSE, FALSE, 0);
+# $self->{outer_box}->pack_start($self->{slist}, TRUE, TRUE, 0);
+
+ $self->{editframe} = new Gtk::Frame('Server configuration');
+ $self->{editframe}->add(fixpad($self->{editbox}, 5));
+ $self->{editframe}->show;
+
+ $self->{listframe} = new Gtk::Frame('Server list');
+ $self->{listframe}->add(fixpad($self->{slist}, 5));
+ $self->{listframe}->show;
+
+ $self->{outer_box}->pack_start($self->{editframe}, FALSE, FALSE, 0);
+ $self->{outer_box}->pack_start($self->{listframe}, TRUE, TRUE, 0);
+
+ $self->{outer_box}->show;
+ $self->{window}->show;
+ return $self;
+}
+
+sub mkedit {
+ my $self = shift;
+ my @fieldlist = qw(UID Address Password);
+ my $fields = $self->{fields} = {};
+
+ $fields->{outer_box} = new Gtk::VBox(FALSE, 0);
+
+ $fields->{table} = new Gtk::Table(scalar @fieldlist, 0, FALSE);
+ $fields->{outer_box}->pack_start($fields->{table}, FALSE, FALSE, 0);
+
+ for (my $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;
+ $fields->{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;
+ $fields->{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;
+ }
+
+ $fields->{Password}->set_visibility(FALSE);
+
+ $fields->{table}->show;
+
+ $fields->{btn_box} = new Gtk::HBox(TRUE, 0);
+ $fields->{outer_box}->pack_end($fields->{btn_box}, FALSE, FALSE, 0);
+ $fields->{btn_box}->show;
+
+ $fields->{btn_connect} = new Gtk::Button('Connect');
+ $fields->{btn_box}->pack_start($fields->{btn_connect}, TRUE, TRUE, 0);
+ $fields->{btn_connect}->show;
+ # XXX: signals
+
+ $fields->{btn_close} = new Gtk::Button('Close');
+ $fields->{btn_box}->pack_start($fields->{btn_close}, TRUE, TRUE, 0);
+ $fields->{btn_close}->show;
+ # XXX: signals
+
+ return $fields->{outer_box};
+}
+
+sub mkslist {
+ my $self = shift;
+ my $slist = $self->{slist} = {};
+
+ $slist->{outer_box} = new Gtk::VBox(FALSE, 0);
+
+ $slist->{top_box} = new Gtk::HBox(FALSE, 0);
+ $slist->{outer_box}->pack_start($slist->{top_box}, FALSE, FALSE, 0);
+ $slist->{top_box}->show;
+
+ $slist->{sname} = new Gtk::Entry();
+ $slist->{top_box}->pack_start($slist->{sname}, TRUE, TRUE, 0);
+ $slist->{sname}->show;
+
+ $slist->{btn_add} = new Gtk::Button("Add");
+ $slist->{top_box}->pack_start($slist->{btn_add}, FALSE, FALSE, 0);
+ $slist->{btn_add}->show;
+ # TODO: signal
+
+ $slist->{btn_del} = new Gtk::Button("Del");
+ $slist->{top_box}->pack_start($slist->{btn_del}, FALSE, FALSE, 0);
+ $slist->{btn_del}->show;
+ # TODO: signal
+
+ $slist->{list} = new Gtk::List();
+ $slist->{list}->set_selection_mode('single');
+ $slist->{list}->show;
+
+ $slist->{sw} = new Gtk::ScrolledWindow(undef, undef);
+ $slist->{sw}->set_usize(250, 150); # XXX
+ $slist->{sw}->add_with_viewport($slist->{list});
+ $slist->{sw}->show;
+
+ $slist->{outer_box}->pack_start($slist->{sw}, TRUE, TRUE, 0);
+ # TODO: signal
+
+ return $slist->{outer_box};
+}
+
+sub fixpad {
+ my ($object, $pad) = @_;
+ my $vbox = new Gtk::VBox(FALSE, 0);
+ my $hbox = new Gtk::HBox(FALSE, 0);
+ $hbox->pack_start($object, TRUE, TRUE, $pad);
+ $vbox->pack_start($hbox, TRUE, TRUE, $pad);
+ $hbox->show;
+ $vbox->show;
+ return $vbox;
+}
+1;
Property changes on: trunk/haver-gtk/lib/Haver/UI/Gtk/ServerDialog.pm
___________________________________________________________________
Name: svn:eol-style
+ native