aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/ServerDialog.cxx
blob: e65cbadb247a0b71d6ffff717b1d5ff3abd98151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
 * 
 * This 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 software 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 software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 * USA.
 */

#include <FL/Fl.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Return_Button.H>
#include <FL/fl_draw.H>

#include "ServerDialog.h"
#include "OptionsDialog.h"
#include "fltk_layout.h"
#include "i18n.h"

extern void about_vncviewer();

ServerDialog::ServerDialog()
  : Fl_Window(400, 112, _("VNC Viewer: Connection Details"))
{
  int width;
  Fl_Button *button;

  width = gui_str_len(_("VNC server:"));
  serverName = new Fl_Input(20 + width, 20, w() - 20*2 - width, 25, _("VNC server:"));

  width = (w() - 20) / 4;

  button = new Fl_Button(20 + width*0, 20+25+20, width - 20, 27, _("About..."));
  button->callback(this->handleAbout, this);

  button = new Fl_Button(20 + width*1, 20+25+20, width - 20, 27, _("Options..."));
  button->callback(this->handleOptions, this);

  button = new Fl_Button(20 + width*2, 20+25+20, width - 20, 27, _("Cancel"));
  button->callback(this->handleCancel, this);

  button = new Fl_Return_Button(20 + width*3, 20+25+20, width - 20, 27, _("OK"));
  button->callback(this->handleOK, this);

  callback(this->handleCancel, this);

  set_modal();
}


ServerDialog::~ServerDialog()
{
}


const char *ServerDialog::run()
{
  ServerDialog dialog;
  static char buffer[256];

  dialog.show();
  while (dialog.shown()) Fl::wait();

  if (dialog.serverName->value() == NULL)
    return NULL;

  strncpy(buffer, dialog.serverName->value(), sizeof(buffer));
  buffer[sizeof(buffer)-1] = '\0';

  return buffer;
}


void ServerDialog::handleAbout(Fl_Widget *widget, void *data)
{
  about_vncviewer();
}


void ServerDialog::handleOptions(Fl_Widget *widget, void *data)
{
  OptionsDialog::showDialog();
}


void ServerDialog::handleCancel(Fl_Widget *widget, void *data)
{
  ServerDialog *dialog = (ServerDialog*)data;

  dialog->serverName->value(NULL);
  dialog->hide();
}


void ServerDialog::handleOK(Fl_Widget *widget, void *data)
{
  ServerDialog *dialog = (ServerDialog*)data;

  dialog->hide();
}