blob: 4f21eb1c331df4f6808495b32d135f9b918de64c [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
Peter Åstrandc359f362011-08-23 12:04:46 +000019#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
22
Pierre Ossman561ff0c2011-05-13 14:04:59 +000023#include <FL/Fl.H>
24#include <FL/Fl_Input.H>
25#include <FL/Fl_Button.H>
26#include <FL/Fl_Return_Button.H>
27#include <FL/fl_draw.H>
28
29#include "ServerDialog.h"
Pierre Ossmand463b572011-05-16 12:04:43 +000030#include "OptionsDialog.h"
31#include "fltk_layout.h"
Pierre Ossman561ff0c2011-05-13 14:04:59 +000032#include "i18n.h"
Pierre Ossman39ceb502011-07-12 15:54:25 +000033#include "vncviewer.h"
Pierre Ossman561ff0c2011-05-13 14:04:59 +000034
35ServerDialog::ServerDialog()
36 : Fl_Window(400, 112, _("VNC Viewer: Connection Details"))
37{
38 int width;
39 Fl_Button *button;
40
Pierre Ossmand463b572011-05-16 12:04:43 +000041 width = gui_str_len(_("VNC server:"));
Pierre Ossman561ff0c2011-05-13 14:04:59 +000042 serverName = new Fl_Input(20 + width, 20, w() - 20*2 - width, 25, _("VNC server:"));
43
44 width = (w() - 20) / 4;
45
46 button = new Fl_Button(20 + width*0, 20+25+20, width - 20, 27, _("About..."));
47 button->callback(this->handleAbout, this);
48
Pierre Ossmand463b572011-05-16 12:04:43 +000049 button = new Fl_Button(20 + width*1, 20+25+20, width - 20, 27, _("Options..."));
50 button->callback(this->handleOptions, this);
51
Pierre Ossman561ff0c2011-05-13 14:04:59 +000052 button = new Fl_Button(20 + width*2, 20+25+20, width - 20, 27, _("Cancel"));
53 button->callback(this->handleCancel, this);
54
55 button = new Fl_Return_Button(20 + width*3, 20+25+20, width - 20, 27, _("OK"));
56 button->callback(this->handleOK, this);
57
58 callback(this->handleCancel, this);
59
60 set_modal();
61}
62
63
64ServerDialog::~ServerDialog()
65{
66}
67
68
69const char *ServerDialog::run()
70{
71 ServerDialog dialog;
72 static char buffer[256];
73
74 dialog.show();
75 while (dialog.shown()) Fl::wait();
76
77 if (dialog.serverName->value() == NULL)
78 return NULL;
79
80 strncpy(buffer, dialog.serverName->value(), sizeof(buffer));
81 buffer[sizeof(buffer)-1] = '\0';
82
83 return buffer;
84}
85
86
87void ServerDialog::handleAbout(Fl_Widget *widget, void *data)
88{
89 about_vncviewer();
90}
91
92
Pierre Ossmand463b572011-05-16 12:04:43 +000093void ServerDialog::handleOptions(Fl_Widget *widget, void *data)
94{
95 OptionsDialog::showDialog();
96}
97
98
Pierre Ossman561ff0c2011-05-13 14:04:59 +000099void ServerDialog::handleCancel(Fl_Widget *widget, void *data)
100{
101 ServerDialog *dialog = (ServerDialog*)data;
102
103 dialog->serverName->value(NULL);
104 dialog->hide();
105}
106
107
108void ServerDialog::handleOK(Fl_Widget *widget, void *data)
109{
110 ServerDialog *dialog = (ServerDialog*)data;
111
112 dialog->hide();
113}