Revision: 4412
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4412&view=rev
Author:   ossman_
Date:     2011-05-13 14:04:59 +0000 (Fri, 13 May 2011)

Log Message:
-----------
Implement connection dialog based on unix vncviewer.

Modified Paths:
--------------
    trunk/vncviewer/CMakeLists.txt
    trunk/vncviewer/vncviewer.cxx

Added Paths:
-----------
    trunk/vncviewer/ServerDialog.cxx
    trunk/vncviewer/ServerDialog.h

Modified: trunk/vncviewer/CMakeLists.txt
===================================================================
--- trunk/vncviewer/CMakeLists.txt      2011-05-13 12:47:54 UTC (rev 4411)
+++ trunk/vncviewer/CMakeLists.txt      2011-05-13 14:04:59 UTC (rev 4412)
@@ -6,6 +6,7 @@
   CConn.cxx
   DesktopWindow.cxx
   UserDialog.cxx
+  ServerDialog.cxx
   Viewport.cxx
   parameters.cxx
   keysym2ucs.c

Added: trunk/vncviewer/ServerDialog.cxx
===================================================================
--- trunk/vncviewer/ServerDialog.cxx                            (rev 0)
+++ trunk/vncviewer/ServerDialog.cxx    2011-05-13 14:04:59 UTC (rev 4412)
@@ -0,0 +1,100 @@
+/* Copyright 2011 Pierre Ossman <oss...@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 "i18n.h"
+
+extern void about_vncviewer();
+
+ServerDialog::ServerDialog()
+  : Fl_Window(400, 112, _("VNC Viewer: Connection Details"))
+{
+  int width;
+  Fl_Button *button;
+
+  fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
+  width = fl_width(_("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*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::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();
+}

Added: trunk/vncviewer/ServerDialog.h
===================================================================
--- trunk/vncviewer/ServerDialog.h                              (rev 0)
+++ trunk/vncviewer/ServerDialog.h      2011-05-13 14:04:59 UTC (rev 4412)
@@ -0,0 +1,42 @@
+/* Copyright 2011 Pierre Ossman <oss...@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.
+ */
+
+#ifndef __SERVERDIALOG_H__
+#define __SERVERDIALOG_H__
+
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Input.H>
+
+class ServerDialog : public Fl_Window {
+protected:
+  ServerDialog();
+  ~ServerDialog();
+
+public:
+  static const char *run();
+
+protected:
+  static void handleAbout(Fl_Widget *widget, void *data);
+  static void handleCancel(Fl_Widget *widget, void *data);
+  static void handleOK(Fl_Widget *widget, void *data);
+
+protected:
+  Fl_Input *serverName;
+};
+
+#endif

Modified: trunk/vncviewer/vncviewer.cxx
===================================================================
--- trunk/vncviewer/vncviewer.cxx       2011-05-13 12:47:54 UTC (rev 4411)
+++ trunk/vncviewer/vncviewer.cxx       2011-05-13 14:04:59 UTC (rev 4412)
@@ -49,6 +49,7 @@
 #include "i18n.h"
 #include "parameters.h"
 #include "CConn.h"
+#include "ServerDialog.h"
 #include "UserDialog.h"
 
 rfb::LogWriter vlog("main");
@@ -162,7 +163,7 @@
 
 int main(int argc, char** argv)
 {
-  char* vncServerName = 0;
+  const char* vncServerName = NULL;
   UserDialog dlg;
 
   const char englishAbout[] = N_("TigerVNC Viewer version %s\n"
@@ -247,6 +248,12 @@
   CSecurityTLS::msg = &dlg;
 #endif
 
+  if (vncServerName == NULL) {
+    vncServerName = ServerDialog::run();
+    if ((vncServerName == NULL) || (vncServerName[0] == '\0'))
+      return 1;
+  }
+
   CConn cc(vncServerName);
 
   while (!exitMainloop) {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Tigervnc-commits mailing list
Tigervnc-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to