1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2 * Copyright (C) 2003-2004 Martin Baehr
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * $Id: gtklogin.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
26 void do_login(array w, object widget)
28 string name = w[1]->get_text();
29 string passwd = w[2]->get_text()||"";
31 if(w[3](name, passwd, @w[4..] )) // login successfull
37 GTK.Alert("login failed");
40 string _(string message)
45 void get_login(string label, string username, mixed ... args)
48 werror("get_login, %O\n", args);
49 object pwin, plabel, pentry, llabel, lentry;
50 object pbox, lbox, ok, cancel, vbox, frame, bbox;
53 pwin = GTK.Window( GTK.WINDOW_TOPLEVEL );
55 pwin->set_policy(1,1,0);
56 pwin->set_title(_("sTeam application launcher ")+label);
57 pwin->set_usize(300, 150);
58 frame = GTK.Frame(_("Enter login for ")+label);
60 llabel = GTK.Label(_("Username: "));
63 vbox->border_width(5);
67 lbox->pack_start(llabel,0,0,0);
68 lbox->pack_end(lentry,1,1,1);
69 vbox->pack_start(lbox,0,0,0);
71 username && lentry->set_text(username);
72 plabel = GTK.Label(_("Password: "));
74 pentry->set_visibility(0);
76 pbox->pack_start(plabel,0,0,0);
77 pbox->pack_end(pentry,1,1,1);
78 vbox->pack_start(pbox,0,0,0);
80 !username&&lentry->signal_connect("activate", do_login,
81 ({ pwin, lentry, pentry, @args }));
82 pentry->signal_connect("activate", do_login,
83 ({ pwin, lentry, pentry, @args }));
84 ok = GTK.Button(_("Login"));
85 cancel = GTK.Button(_("Cancel"));
86 ok->signal_connect("clicked", do_login, ({ pwin, lentry, pentry, @args }));
88 cancel->signal_connect("clicked", exit, 0);
90 bbox = GTK.HbuttonBox();
92 ->set_layout(GTK.BUTTONBOX_SPREAD)
93 ->pack_start(ok, 0,0,0)
94 ->pack_end(cancel, 0,0,0);
96 vbox->pack_end(bbox,0,0,0);
99 frame->border_width(5);
101 tbox = GTK.Vbox(0,0);
102 tbox->pack_start(frame, 1,1,1);