blob: fab1448c50a0849ad9a5bec28cc2a2d565ff66dc [file] [log] [blame]
Pierre Ossman561ff0c2011-05-13 14:04:59 +00001/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19#include <FL/Fl.H>
20#include <FL/Fl_Input.H>
21#include <FL/Fl_Button.H>
22#include <FL/Fl_Return_Button.H>
23#include <FL/fl_draw.H>
24
25#include "ServerDialog.h"
26#include "i18n.h"
27
28extern void about_vncviewer();
29
30ServerDialog::ServerDialog()
31 : Fl_Window(400, 112, _("VNC Viewer: Connection Details"))
32{
33 int width;
34 Fl_Button *button;
35
36 fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
37 width = fl_width(_("VNC server:"));
38 serverName = new Fl_Input(20 + width, 20, w() - 20*2 - width, 25, _("VNC server:"));
39
40 width = (w() - 20) / 4;
41
42 button = new Fl_Button(20 + width*0, 20+25+20, width - 20, 27, _("About..."));
43 button->callback(this->handleAbout, this);
44
45 button = new Fl_Button(20 + width*2, 20+25+20, width - 20, 27, _("Cancel"));
46 button->callback(this->handleCancel, this);
47
48 button = new Fl_Return_Button(20 + width*3, 20+25+20, width - 20, 27, _("OK"));
49 button->callback(this->handleOK, this);
50
51 callback(this->handleCancel, this);
52
53 set_modal();
54}
55
56
57ServerDialog::~ServerDialog()
58{
59}
60
61
62const char *ServerDialog::run()
63{
64 ServerDialog dialog;
65 static char buffer[256];
66
67 dialog.show();
68 while (dialog.shown()) Fl::wait();
69
70 if (dialog.serverName->value() == NULL)
71 return NULL;
72
73 strncpy(buffer, dialog.serverName->value(), sizeof(buffer));
74 buffer[sizeof(buffer)-1] = '\0';
75
76 return buffer;
77}
78
79
80void ServerDialog::handleAbout(Fl_Widget *widget, void *data)
81{
82 about_vncviewer();
83}
84
85
86void ServerDialog::handleCancel(Fl_Widget *widget, void *data)
87{
88 ServerDialog *dialog = (ServerDialog*)data;
89
90 dialog->serverName->value(NULL);
91 dialog->hide();
92}
93
94
95void ServerDialog::handleOK(Fl_Widget *widget, void *data)
96{
97 ServerDialog *dialog = (ServerDialog*)data;
98
99 dialog->hide();
100}