blob: 9d0d15729e139f8e891a8b078a55e7f371faf739 [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"
Pierre Ossmand463b572011-05-16 12:04:43 +000026#include "OptionsDialog.h"
27#include "fltk_layout.h"
Pierre Ossman561ff0c2011-05-13 14:04:59 +000028#include "i18n.h"
Pierre Ossman39ceb502011-07-12 15:54:25 +000029#include "vncviewer.h"
Pierre Ossman561ff0c2011-05-13 14:04:59 +000030
31ServerDialog::ServerDialog()
32 : Fl_Window(400, 112, _("VNC Viewer: Connection Details"))
33{
34 int width;
35 Fl_Button *button;
36
Pierre Ossmand463b572011-05-16 12:04:43 +000037 width = gui_str_len(_("VNC server:"));
Pierre Ossman561ff0c2011-05-13 14:04:59 +000038 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
Pierre Ossmand463b572011-05-16 12:04:43 +000045 button = new Fl_Button(20 + width*1, 20+25+20, width - 20, 27, _("Options..."));
46 button->callback(this->handleOptions, this);
47
Pierre Ossman561ff0c2011-05-13 14:04:59 +000048 button = new Fl_Button(20 + width*2, 20+25+20, width - 20, 27, _("Cancel"));
49 button->callback(this->handleCancel, this);
50
51 button = new Fl_Return_Button(20 + width*3, 20+25+20, width - 20, 27, _("OK"));
52 button->callback(this->handleOK, this);
53
54 callback(this->handleCancel, this);
55
56 set_modal();
57}
58
59
60ServerDialog::~ServerDialog()
61{
62}
63
64
65const char *ServerDialog::run()
66{
67 ServerDialog dialog;
68 static char buffer[256];
69
70 dialog.show();
71 while (dialog.shown()) Fl::wait();
72
73 if (dialog.serverName->value() == NULL)
74 return NULL;
75
76 strncpy(buffer, dialog.serverName->value(), sizeof(buffer));
77 buffer[sizeof(buffer)-1] = '\0';
78
79 return buffer;
80}
81
82
83void ServerDialog::handleAbout(Fl_Widget *widget, void *data)
84{
85 about_vncviewer();
86}
87
88
Pierre Ossmand463b572011-05-16 12:04:43 +000089void ServerDialog::handleOptions(Fl_Widget *widget, void *data)
90{
91 OptionsDialog::showDialog();
92}
93
94
Pierre Ossman561ff0c2011-05-13 14:04:59 +000095void ServerDialog::handleCancel(Fl_Widget *widget, void *data)
96{
97 ServerDialog *dialog = (ServerDialog*)data;
98
99 dialog->serverName->value(NULL);
100 dialog->hide();
101}
102
103
104void ServerDialog::handleOK(Fl_Widget *widget, void *data)
105{
106 ServerDialog *dialog = (ServerDialog*)data;
107
108 dialog->hide();
109}