aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2015-03-04 09:57:06 +0100
committerPierre Ossman <ossman@cendio.se>2015-03-04 09:58:18 +0100
commita71a276637ddc2c48cf4a7089a44667ab5c4ae78 (patch)
treea67faab38d00715e8b97bda86f1d4e2f586b8c35 /vncviewer
parent8d713a92af919eabad37c540b728eda1ebb34e38 (diff)
downloadtigervnc-a71a276637ddc2c48cf4a7089a44667ab5c4ae78.tar.gz
tigervnc-a71a276637ddc2c48cf4a7089a44667ab5c4ae78.zip
Add a OS X system menu so that new viewer windows can be started
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/vncviewer.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index 34bc3be4..3f51dd3c 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -30,6 +30,7 @@
#include <signal.h>
#include <locale.h>
#include <fcntl.h>
+#include <unistd.h>
#include <sys/stat.h>
#ifdef WIN32
@@ -58,6 +59,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Widget.H>
#include <FL/Fl_PNG_Image.H>
+#include <FL/Fl_Sys_Menu_Bar.H>
#include <FL/fl_ask.H>
#include <FL/x.H>
@@ -67,6 +69,7 @@
#include "ServerDialog.h"
#include "UserDialog.h"
#include "vncviewer.h"
+#include "fltk_layout.h"
#ifdef WIN32
#include "resource.h"
@@ -83,6 +86,8 @@ static char aboutText[1024];
char vncServerName[VNCSERVERNAMELEN] = { '\0' };
+static const char *argv0 = NULL;
+
static bool exitMainloop = false;
static const char *exitError = NULL;
@@ -107,6 +112,29 @@ static void about_callback(Fl_Widget *widget, void *data)
{
about_vncviewer();
}
+
+static void new_connection_cb(Fl_Widget *widget, void *data)
+{
+ const char *argv[2];
+ pid_t pid;
+
+ pid = fork();
+ if (pid == -1) {
+ vlog.error(_("Error starting new TigerVNC Viewer: %s"), strerror(errno));
+ return;
+ }
+
+ if (pid != 0)
+ return;
+
+ argv[0] = argv0;
+ argv[1] = NULL;
+
+ execvp(argv[0], (char * const *)argv);
+
+ vlog.error(_("Error starting new TigerVNC Viewer: %s"), strerror(errno));
+ _exit(1);
+}
#endif
static void CleanupSignalHandler(int sig)
@@ -239,6 +267,16 @@ static void init_fltk()
Fl_Mac_App_Menu::show = _("Show All");
fl_mac_set_about(about_callback, NULL);
+
+ Fl_Sys_Menu_Bar *menubar;
+ char buffer[1024];
+ menubar = new Fl_Sys_Menu_Bar(0, 0, 500, 25);
+ // Fl_Sys_Menu_Bar overrides methods without them being virtual,
+ // which means we cannot use our generic Fl_Menu_ helpers.
+ if (fltk_menu_escape(_("&File"), buffer, sizeof(buffer)) < sizeof(buffer))
+ menubar->add(buffer, 0, 0, 0, FL_SUBMENU);
+ if (fltk_menu_escape(_("&New Connection"), buffer, sizeof(buffer)) < sizeof(buffer))
+ menubar->insert(1, buffer, FL_COMMAND | 'n', new_connection_cb);
#endif
}
@@ -375,6 +413,8 @@ int main(int argc, char** argv)
{
UserDialog dlg;
+ argv0 = argv[0];
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE_NAME, LOCALE_DIR);
textdomain(PACKAGE_NAME);