Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 1 | /* 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 Åstrand | c359f36 | 2011-08-23 12:04:46 +0000 | [diff] [blame] | 19 | #ifdef HAVE_CONFIG_H |
| 20 | #include <config.h> |
| 21 | #endif |
| 22 | |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 23 | #include <stdlib.h> |
| 24 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 25 | #include <list> |
| 26 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 27 | #include <rdr/types.h> |
| 28 | #include <rfb/encodings.h> |
| 29 | |
| 30 | #ifdef HAVE_GNUTLS |
| 31 | #include <rfb/Security.h> |
| 32 | #include <rfb/SecurityClient.h> |
| 33 | #include <rfb/CSecurityTLS.h> |
| 34 | #endif |
| 35 | |
| 36 | #include "OptionsDialog.h" |
| 37 | #include "fltk_layout.h" |
| 38 | #include "i18n.h" |
Martin Koegler | 498ef46 | 2011-09-04 07:04:43 +0000 | [diff] [blame] | 39 | #include "menukey.h" |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 40 | #include "parameters.h" |
| 41 | |
DRC | b65bb93 | 2011-06-24 03:17:00 +0000 | [diff] [blame] | 42 | #include <FL/Fl_Tabs.H> |
| 43 | #include <FL/Fl_Button.H> |
Pierre Ossman | 769963f | 2014-01-20 14:43:52 +0100 | [diff] [blame] | 44 | #include <FL/Fl_Check_Button.H> |
DRC | b65bb93 | 2011-06-24 03:17:00 +0000 | [diff] [blame] | 45 | #include <FL/Fl_Return_Button.H> |
Pierre Ossman | 769963f | 2014-01-20 14:43:52 +0100 | [diff] [blame] | 46 | #include <FL/Fl_Round_Button.H> |
| 47 | #include <FL/Fl_Int_Input.H> |
| 48 | #include <FL/Fl_Choice.H> |
DRC | b65bb93 | 2011-06-24 03:17:00 +0000 | [diff] [blame] | 49 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 50 | using namespace std; |
| 51 | using namespace rdr; |
| 52 | using namespace rfb; |
| 53 | |
Pierre Ossman | 0c41e1d | 2011-05-17 09:36:04 +0000 | [diff] [blame] | 54 | std::map<OptionsCallback*, void*> OptionsDialog::callbacks; |
| 55 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 56 | OptionsDialog::OptionsDialog() |
| 57 | : Fl_Window(450, 450, _("VNC Viewer: Connection Options")) |
| 58 | { |
| 59 | int x, y; |
| 60 | Fl_Button *button; |
| 61 | |
| 62 | Fl_Tabs *tabs = new Fl_Tabs(OUTER_MARGIN, OUTER_MARGIN, |
| 63 | w() - OUTER_MARGIN*2, |
| 64 | h() - OUTER_MARGIN*2 - INNER_MARGIN - BUTTON_HEIGHT); |
| 65 | |
| 66 | { |
| 67 | int tx, ty, tw, th; |
| 68 | |
| 69 | tabs->client_area(tx, ty, tw, th, TABS_HEIGHT); |
| 70 | |
| 71 | createCompressionPage(tx, ty, tw, th); |
| 72 | createSecurityPage(tx, ty, tw, th); |
| 73 | createInputPage(tx, ty, tw, th); |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 74 | createScreenPage(tx, ty, tw, th); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 75 | createMiscPage(tx, ty, tw, th); |
| 76 | } |
| 77 | |
| 78 | tabs->end(); |
| 79 | |
| 80 | x = w() - BUTTON_WIDTH * 2 - INNER_MARGIN - OUTER_MARGIN; |
| 81 | y = h() - BUTTON_HEIGHT - OUTER_MARGIN; |
| 82 | |
| 83 | button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Cancel")); |
| 84 | button->callback(this->handleCancel, this); |
| 85 | |
| 86 | x += BUTTON_WIDTH + INNER_MARGIN; |
| 87 | |
| 88 | button = new Fl_Return_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("OK")); |
| 89 | button->callback(this->handleOK, this); |
| 90 | |
| 91 | callback(this->handleCancel, this); |
| 92 | |
| 93 | set_modal(); |
| 94 | } |
| 95 | |
| 96 | |
| 97 | OptionsDialog::~OptionsDialog() |
| 98 | { |
| 99 | } |
| 100 | |
| 101 | |
| 102 | void OptionsDialog::showDialog(void) |
| 103 | { |
| 104 | static OptionsDialog *dialog = NULL; |
| 105 | |
| 106 | if (!dialog) |
| 107 | dialog = new OptionsDialog(); |
| 108 | |
| 109 | if (dialog->shown()) |
| 110 | return; |
| 111 | |
| 112 | dialog->show(); |
| 113 | } |
| 114 | |
| 115 | |
Pierre Ossman | 0c41e1d | 2011-05-17 09:36:04 +0000 | [diff] [blame] | 116 | void OptionsDialog::addCallback(OptionsCallback *cb, void *data) |
| 117 | { |
| 118 | callbacks[cb] = data; |
| 119 | } |
| 120 | |
| 121 | |
| 122 | void OptionsDialog::removeCallback(OptionsCallback *cb) |
| 123 | { |
| 124 | callbacks.erase(cb); |
| 125 | } |
| 126 | |
| 127 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 128 | void OptionsDialog::show(void) |
| 129 | { |
Pierre Ossman | 33a233b | 2011-09-30 12:21:58 +0000 | [diff] [blame] | 130 | /* show() gets called for raise events as well */ |
| 131 | if (!shown()) |
| 132 | loadOptions(); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 133 | |
| 134 | Fl_Window::show(); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | void OptionsDialog::loadOptions(void) |
| 139 | { |
| 140 | /* Compression */ |
| 141 | autoselectCheckbox->value(autoSelect); |
| 142 | |
| 143 | int encNum = encodingNum(preferredEncoding); |
| 144 | |
| 145 | switch (encNum) { |
| 146 | case encodingTight: |
| 147 | tightButton->setonly(); |
| 148 | break; |
| 149 | case encodingZRLE: |
| 150 | zrleButton->setonly(); |
| 151 | break; |
| 152 | case encodingHextile: |
| 153 | hextileButton->setonly(); |
| 154 | break; |
| 155 | case encodingRaw: |
| 156 | rawButton->setonly(); |
| 157 | break; |
| 158 | } |
| 159 | |
| 160 | if (fullColour) |
| 161 | fullcolorCheckbox->setonly(); |
| 162 | else { |
| 163 | switch (lowColourLevel) { |
| 164 | case 0: |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 165 | verylowcolorCheckbox->setonly(); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 166 | break; |
| 167 | case 1: |
| 168 | lowcolorCheckbox->setonly(); |
| 169 | break; |
| 170 | case 2: |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 171 | mediumcolorCheckbox->setonly(); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 172 | break; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | char digit[2] = "0"; |
| 177 | |
| 178 | compressionCheckbox->value(customCompressLevel); |
| 179 | jpegCheckbox->value(!noJpeg); |
| 180 | digit[0] = '0' + compressLevel; |
| 181 | compressionInput->value(digit); |
| 182 | digit[0] = '0' + qualityLevel; |
| 183 | jpegInput->value(digit); |
| 184 | |
| 185 | handleAutoselect(autoselectCheckbox, this); |
| 186 | handleCompression(compressionCheckbox, this); |
| 187 | handleJpeg(jpegCheckbox, this); |
| 188 | |
| 189 | #ifdef HAVE_GNUTLS |
| 190 | /* Security */ |
| 191 | Security security(SecurityClient::secTypes); |
| 192 | |
| 193 | list<U8> secTypes; |
| 194 | list<U8>::iterator iter; |
| 195 | |
| 196 | list<U32> secTypesExt; |
| 197 | list<U32>::iterator iterExt; |
| 198 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 199 | encNoneCheckbox->value(false); |
| 200 | encTLSCheckbox->value(false); |
| 201 | encX509Checkbox->value(false); |
| 202 | |
| 203 | authNoneCheckbox->value(false); |
| 204 | authVncCheckbox->value(false); |
| 205 | authPlainCheckbox->value(false); |
| 206 | |
| 207 | secTypes = security.GetEnabledSecTypes(); |
| 208 | for (iter = secTypes.begin(); iter != secTypes.end(); ++iter) { |
| 209 | switch (*iter) { |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 210 | case secTypeNone: |
| 211 | encNoneCheckbox->value(true); |
| 212 | authNoneCheckbox->value(true); |
| 213 | break; |
| 214 | case secTypeVncAuth: |
| 215 | encNoneCheckbox->value(true); |
| 216 | authVncCheckbox->value(true); |
| 217 | break; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | secTypesExt = security.GetEnabledExtSecTypes(); |
| 222 | for (iterExt = secTypesExt.begin(); iterExt != secTypesExt.end(); ++iterExt) { |
| 223 | switch (*iterExt) { |
| 224 | case secTypePlain: |
| 225 | encNoneCheckbox->value(true); |
| 226 | authPlainCheckbox->value(true); |
| 227 | break; |
| 228 | case secTypeTLSNone: |
| 229 | encTLSCheckbox->value(true); |
| 230 | authNoneCheckbox->value(true); |
| 231 | break; |
| 232 | case secTypeTLSVnc: |
| 233 | encTLSCheckbox->value(true); |
| 234 | authVncCheckbox->value(true); |
| 235 | break; |
| 236 | case secTypeTLSPlain: |
| 237 | encTLSCheckbox->value(true); |
| 238 | authPlainCheckbox->value(true); |
| 239 | break; |
| 240 | case secTypeX509None: |
| 241 | encX509Checkbox->value(true); |
| 242 | authNoneCheckbox->value(true); |
| 243 | break; |
| 244 | case secTypeX509Vnc: |
| 245 | encX509Checkbox->value(true); |
| 246 | authVncCheckbox->value(true); |
| 247 | break; |
| 248 | case secTypeX509Plain: |
| 249 | encX509Checkbox->value(true); |
| 250 | authPlainCheckbox->value(true); |
| 251 | break; |
| 252 | } |
| 253 | } |
| 254 | |
Pierre Ossman | 3d2a84b | 2014-09-17 16:45:35 +0200 | [diff] [blame] | 255 | caInput->value(CSecurityTLS::X509CA); |
| 256 | crlInput->value(CSecurityTLS::X509CRL); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 257 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 258 | handleX509(encX509Checkbox, this); |
| 259 | #endif |
| 260 | |
| 261 | /* Input */ |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 262 | const char *menuKeyBuf; |
| 263 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 264 | viewOnlyCheckbox->value(viewOnly); |
| 265 | acceptClipboardCheckbox->value(acceptClipboard); |
| 266 | sendClipboardCheckbox->value(sendClipboard); |
Pierre Ossman | f7fef92 | 2015-12-10 21:24:08 +0100 | [diff] [blame^] | 267 | #if !defined(WIN32) && !defined(__APPLE__) |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 268 | sendPrimaryCheckbox->value(sendPrimary); |
Pierre Ossman | f7fef92 | 2015-12-10 21:24:08 +0100 | [diff] [blame^] | 269 | #endif |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 270 | systemKeysCheckbox->value(fullscreenSystemKeys); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 271 | |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 272 | menuKeyChoice->value(0); |
| 273 | |
| 274 | menuKeyBuf = menuKey; |
Martin Koegler | 498ef46 | 2011-09-04 07:04:43 +0000 | [diff] [blame] | 275 | for (int i = 0; i < getMenuKeySymbolCount(); i++) |
| 276 | if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf)) |
| 277 | menuKeyChoice->value(i + 1); |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 278 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 279 | /* Screen */ |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 280 | int width, height; |
| 281 | |
| 282 | if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2) { |
| 283 | desktopSizeCheckbox->value(false); |
| 284 | desktopWidthInput->value("1024"); |
| 285 | desktopHeightInput->value("768"); |
| 286 | } else { |
| 287 | char buf[32]; |
| 288 | desktopSizeCheckbox->value(true); |
| 289 | snprintf(buf, sizeof(buf), "%d", width); |
| 290 | desktopWidthInput->value(buf); |
| 291 | snprintf(buf, sizeof(buf), "%d", height); |
| 292 | desktopHeightInput->value(buf); |
| 293 | } |
Pierre Ossman | 9919701 | 2012-07-05 11:06:18 +0000 | [diff] [blame] | 294 | remoteResizeCheckbox->value(remoteResize); |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 295 | fullScreenCheckbox->value(fullScreen); |
Pierre Ossman | aae3891 | 2012-07-13 11:22:55 +0000 | [diff] [blame] | 296 | fullScreenAllMonitorsCheckbox->value(fullScreenAllMonitors); |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 297 | |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 298 | handleDesktopSize(desktopSizeCheckbox, this); |
| 299 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 300 | /* Misc. */ |
| 301 | sharedCheckbox->value(shared); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 302 | dotCursorCheckbox->value(dotWhenNoCursor); |
| 303 | } |
| 304 | |
| 305 | |
| 306 | void OptionsDialog::storeOptions(void) |
| 307 | { |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 308 | /* Compression */ |
| 309 | autoSelect.setParam(autoselectCheckbox->value()); |
| 310 | |
| 311 | if (tightButton->value()) |
| 312 | preferredEncoding.setParam(encodingName(encodingTight)); |
| 313 | else if (zrleButton->value()) |
| 314 | preferredEncoding.setParam(encodingName(encodingZRLE)); |
| 315 | else if (hextileButton->value()) |
| 316 | preferredEncoding.setParam(encodingName(encodingHextile)); |
| 317 | else if (rawButton->value()) |
| 318 | preferredEncoding.setParam(encodingName(encodingRaw)); |
| 319 | |
| 320 | fullColour.setParam(fullcolorCheckbox->value()); |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 321 | if (verylowcolorCheckbox->value()) |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 322 | lowColourLevel.setParam(0); |
| 323 | else if (lowcolorCheckbox->value()) |
| 324 | lowColourLevel.setParam(1); |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 325 | else if (mediumcolorCheckbox->value()) |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 326 | lowColourLevel.setParam(2); |
| 327 | |
| 328 | customCompressLevel.setParam(compressionCheckbox->value()); |
| 329 | noJpeg.setParam(!jpegCheckbox->value()); |
| 330 | compressLevel.setParam(atoi(compressionInput->value())); |
| 331 | qualityLevel.setParam(atoi(jpegInput->value())); |
| 332 | |
| 333 | #ifdef HAVE_GNUTLS |
| 334 | /* Security */ |
| 335 | Security security; |
| 336 | |
| 337 | /* Process security types which don't use encryption */ |
| 338 | if (encNoneCheckbox->value()) { |
| 339 | if (authNoneCheckbox->value()) |
| 340 | security.EnableSecType(secTypeNone); |
| 341 | if (authVncCheckbox->value()) |
| 342 | security.EnableSecType(secTypeVncAuth); |
Pierre Ossman | c1764bd | 2011-09-30 12:26:25 +0000 | [diff] [blame] | 343 | if (authPlainCheckbox->value()) |
| 344 | security.EnableSecType(secTypePlain); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 345 | } |
| 346 | |
Pierre Ossman | c1764bd | 2011-09-30 12:26:25 +0000 | [diff] [blame] | 347 | /* Process security types which use TLS encryption */ |
| 348 | if (encTLSCheckbox->value()) { |
| 349 | if (authNoneCheckbox->value()) |
| 350 | security.EnableSecType(secTypeTLSNone); |
| 351 | if (authVncCheckbox->value()) |
| 352 | security.EnableSecType(secTypeTLSVnc); |
| 353 | if (authPlainCheckbox->value()) |
| 354 | security.EnableSecType(secTypeTLSPlain); |
| 355 | } |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 356 | |
Pierre Ossman | c1764bd | 2011-09-30 12:26:25 +0000 | [diff] [blame] | 357 | /* Process security types which use X509 encryption */ |
| 358 | if (encX509Checkbox->value()) { |
| 359 | if (authNoneCheckbox->value()) |
| 360 | security.EnableSecType(secTypeX509None); |
| 361 | if (authVncCheckbox->value()) |
| 362 | security.EnableSecType(secTypeX509Vnc); |
| 363 | if (authPlainCheckbox->value()) |
| 364 | security.EnableSecType(secTypeX509Plain); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Pierre Ossman | 5535fe6 | 2011-09-30 12:11:52 +0000 | [diff] [blame] | 367 | SecurityClient::secTypes.setParam(security.ToString()); |
| 368 | |
Pierre Ossman | 3d2a84b | 2014-09-17 16:45:35 +0200 | [diff] [blame] | 369 | CSecurityTLS::X509CA.setParam(caInput->value()); |
| 370 | CSecurityTLS::X509CRL.setParam(crlInput->value()); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 371 | #endif |
| 372 | |
| 373 | /* Input */ |
| 374 | viewOnly.setParam(viewOnlyCheckbox->value()); |
| 375 | acceptClipboard.setParam(acceptClipboardCheckbox->value()); |
| 376 | sendClipboard.setParam(sendClipboardCheckbox->value()); |
Pierre Ossman | f7fef92 | 2015-12-10 21:24:08 +0100 | [diff] [blame^] | 377 | #if !defined(WIN32) && !defined(__APPLE__) |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 378 | sendPrimary.setParam(sendPrimaryCheckbox->value()); |
Pierre Ossman | f7fef92 | 2015-12-10 21:24:08 +0100 | [diff] [blame^] | 379 | #endif |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 380 | fullscreenSystemKeys.setParam(systemKeysCheckbox->value()); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 381 | |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 382 | if (menuKeyChoice->value() == 0) |
| 383 | menuKey.setParam(""); |
| 384 | else { |
Martin Koegler | 498ef46 | 2011-09-04 07:04:43 +0000 | [diff] [blame] | 385 | menuKey.setParam(menuKeyChoice->text()); |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 386 | } |
| 387 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 388 | /* Screen */ |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 389 | int width, height; |
| 390 | |
| 391 | if (desktopSizeCheckbox->value() && |
| 392 | (sscanf(desktopWidthInput->value(), "%d", &width) == 1) && |
| 393 | (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) { |
| 394 | char buf[64]; |
| 395 | snprintf(buf, sizeof(buf), "%dx%d", width, height); |
| 396 | desktopSize.setParam(buf); |
| 397 | } else { |
| 398 | desktopSize.setParam(""); |
| 399 | } |
Pierre Ossman | 9919701 | 2012-07-05 11:06:18 +0000 | [diff] [blame] | 400 | remoteResize.setParam(remoteResizeCheckbox->value()); |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 401 | fullScreen.setParam(fullScreenCheckbox->value()); |
Pierre Ossman | aae3891 | 2012-07-13 11:22:55 +0000 | [diff] [blame] | 402 | fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox->value()); |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 403 | |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 404 | /* Misc. */ |
| 405 | shared.setParam(sharedCheckbox->value()); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 406 | dotWhenNoCursor.setParam(dotCursorCheckbox->value()); |
Pierre Ossman | 0c41e1d | 2011-05-17 09:36:04 +0000 | [diff] [blame] | 407 | |
| 408 | std::map<OptionsCallback*, void*>::const_iterator iter; |
| 409 | |
| 410 | for (iter = callbacks.begin();iter != callbacks.end();++iter) |
| 411 | iter->first(iter->second); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | |
| 415 | void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th) |
| 416 | { |
| 417 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression")); |
| 418 | |
| 419 | int orig_tx, orig_ty; |
| 420 | int half_width, full_width; |
Pierre Ossman | eb95532 | 2015-03-03 16:10:53 +0100 | [diff] [blame] | 421 | int height; |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 422 | |
| 423 | tx += OUTER_MARGIN; |
| 424 | ty += OUTER_MARGIN; |
| 425 | |
| 426 | full_width = tw - OUTER_MARGIN * 2; |
| 427 | half_width = (full_width - INNER_MARGIN) / 2; |
| 428 | |
| 429 | /* AutoSelect checkbox */ |
| 430 | autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 431 | CHECK_MIN_WIDTH, |
| 432 | CHECK_HEIGHT, |
| 433 | _("Auto select"))); |
| 434 | autoselectCheckbox->callback(handleAutoselect, this); |
| 435 | ty += CHECK_HEIGHT + INNER_MARGIN; |
| 436 | |
| 437 | /* Two columns */ |
| 438 | orig_tx = tx; |
| 439 | orig_ty = ty; |
| 440 | |
| 441 | /* VNC encoding box */ |
| 442 | ty += GROUP_LABEL_OFFSET; |
| 443 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4; |
| 444 | encodingGroup = new Fl_Group(tx, ty, half_width, height, |
| 445 | _("Preferred encoding")); |
| 446 | encodingGroup->box(FL_ENGRAVED_BOX); |
| 447 | encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 448 | |
| 449 | { |
| 450 | tx += GROUP_MARGIN; |
| 451 | ty += GROUP_MARGIN; |
| 452 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 453 | tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 454 | RADIO_MIN_WIDTH, |
| 455 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 456 | "Tight")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 457 | tightButton->type(FL_RADIO_BUTTON); |
| 458 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 459 | |
| 460 | zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 461 | RADIO_MIN_WIDTH, |
| 462 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 463 | "ZRLE")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 464 | zrleButton->type(FL_RADIO_BUTTON); |
| 465 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 466 | |
| 467 | hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 468 | RADIO_MIN_WIDTH, |
| 469 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 470 | "Hextile")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 471 | hextileButton->type(FL_RADIO_BUTTON); |
| 472 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 473 | |
| 474 | rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 475 | RADIO_MIN_WIDTH, |
| 476 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 477 | "Raw")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 478 | rawButton->type(FL_RADIO_BUTTON); |
| 479 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 480 | } |
| 481 | |
| 482 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 483 | |
| 484 | encodingGroup->end(); |
| 485 | |
| 486 | /* Second column */ |
| 487 | tx = orig_tx + half_width + INNER_MARGIN; |
| 488 | ty = orig_ty; |
| 489 | |
| 490 | /* Color box */ |
| 491 | ty += GROUP_LABEL_OFFSET; |
| 492 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4; |
| 493 | colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level")); |
| 494 | colorlevelGroup->box(FL_ENGRAVED_BOX); |
| 495 | colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 496 | |
| 497 | { |
| 498 | tx += GROUP_MARGIN; |
| 499 | ty += GROUP_MARGIN; |
| 500 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 501 | fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 502 | RADIO_MIN_WIDTH, |
| 503 | RADIO_HEIGHT, |
| 504 | _("Full (all available colors)"))); |
| 505 | fullcolorCheckbox->type(FL_RADIO_BUTTON); |
| 506 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 507 | |
| 508 | mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 509 | RADIO_MIN_WIDTH, |
| 510 | RADIO_HEIGHT, |
| 511 | _("Medium (256 colors)"))); |
| 512 | mediumcolorCheckbox->type(FL_RADIO_BUTTON); |
| 513 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 514 | |
| 515 | lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 516 | RADIO_MIN_WIDTH, |
| 517 | RADIO_HEIGHT, |
| 518 | _("Low (64 colors)"))); |
| 519 | lowcolorCheckbox->type(FL_RADIO_BUTTON); |
| 520 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 521 | |
| 522 | verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 523 | RADIO_MIN_WIDTH, |
| 524 | RADIO_HEIGHT, |
| 525 | _("Very low (8 colors)"))); |
| 526 | verylowcolorCheckbox->type(FL_RADIO_BUTTON); |
| 527 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 528 | } |
| 529 | |
| 530 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 531 | |
| 532 | colorlevelGroup->end(); |
| 533 | |
| 534 | /* Back to normal */ |
| 535 | tx = orig_tx; |
| 536 | ty += INNER_MARGIN; |
| 537 | |
| 538 | /* Checkboxes */ |
| 539 | compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 540 | CHECK_MIN_WIDTH, |
| 541 | CHECK_HEIGHT, |
| 542 | _("Custom compression level:"))); |
| 543 | compressionCheckbox->callback(handleCompression, this); |
| 544 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 545 | |
| 546 | compressionInput = new Fl_Int_Input(tx + INDENT, ty, |
| 547 | INPUT_HEIGHT, INPUT_HEIGHT, |
DRC | ba7bc51 | 2011-08-17 02:30:34 +0000 | [diff] [blame] | 548 | _("level (1=fast, 6=best [4-6 are rarely useful])")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 549 | compressionInput->align(FL_ALIGN_RIGHT); |
| 550 | ty += INPUT_HEIGHT + INNER_MARGIN; |
| 551 | |
| 552 | jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 553 | CHECK_MIN_WIDTH, |
| 554 | CHECK_HEIGHT, |
| 555 | _("Allow JPEG compression:"))); |
| 556 | jpegCheckbox->callback(handleJpeg, this); |
| 557 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 558 | |
| 559 | jpegInput = new Fl_Int_Input(tx + INDENT, ty, |
| 560 | INPUT_HEIGHT, INPUT_HEIGHT, |
DRC | 41036ed | 2011-08-23 20:36:50 +0000 | [diff] [blame] | 561 | _("quality (0=poor, 9=best)")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 562 | jpegInput->align(FL_ALIGN_RIGHT); |
| 563 | ty += INPUT_HEIGHT + INNER_MARGIN; |
| 564 | |
| 565 | group->end(); |
| 566 | } |
| 567 | |
| 568 | |
| 569 | void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th) |
| 570 | { |
| 571 | #ifdef HAVE_GNUTLS |
| 572 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security")); |
| 573 | |
| 574 | int orig_tx; |
| 575 | int width, height; |
| 576 | |
| 577 | tx += OUTER_MARGIN; |
| 578 | ty += OUTER_MARGIN; |
| 579 | |
| 580 | width = tw - OUTER_MARGIN * 2; |
| 581 | |
| 582 | orig_tx = tx; |
| 583 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 584 | /* Encryption */ |
| 585 | ty += GROUP_LABEL_OFFSET; |
| 586 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2; |
| 587 | encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption")); |
| 588 | encryptionGroup->box(FL_ENGRAVED_BOX); |
| 589 | encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 590 | |
| 591 | { |
| 592 | tx += GROUP_MARGIN; |
| 593 | ty += GROUP_MARGIN; |
| 594 | |
| 595 | encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 596 | CHECK_MIN_WIDTH, |
| 597 | CHECK_HEIGHT, |
| 598 | _("None"))); |
| 599 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 600 | |
| 601 | encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 602 | CHECK_MIN_WIDTH, |
| 603 | CHECK_HEIGHT, |
| 604 | _("TLS with anonymous certificates"))); |
| 605 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 606 | |
| 607 | encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 608 | CHECK_MIN_WIDTH, |
| 609 | CHECK_HEIGHT, |
| 610 | _("TLS with X509 certificates"))); |
| 611 | encX509Checkbox->callback(handleX509, this); |
| 612 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 613 | |
| 614 | ty += INPUT_LABEL_OFFSET; |
| 615 | caInput = new Fl_Input(tx + INDENT, ty, |
| 616 | width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT, |
| 617 | _("Path to X509 CA certificate")); |
| 618 | caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 619 | ty += INPUT_HEIGHT + TIGHT_MARGIN; |
| 620 | |
| 621 | ty += INPUT_LABEL_OFFSET; |
| 622 | crlInput = new Fl_Input(tx + INDENT, ty, |
| 623 | width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT, |
| 624 | _("Path to X509 CRL file")); |
| 625 | crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 626 | ty += INPUT_HEIGHT + TIGHT_MARGIN; |
| 627 | } |
| 628 | |
| 629 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 630 | |
| 631 | encryptionGroup->end(); |
| 632 | |
| 633 | /* Back to normal */ |
| 634 | tx = orig_tx; |
| 635 | ty += INNER_MARGIN; |
| 636 | |
| 637 | /* Authentication */ |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 638 | ty += GROUP_LABEL_OFFSET; |
| 639 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3; |
| 640 | authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication")); |
| 641 | authenticationGroup->box(FL_ENGRAVED_BOX); |
| 642 | authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 643 | |
| 644 | { |
| 645 | tx += GROUP_MARGIN; |
| 646 | ty += GROUP_MARGIN; |
| 647 | |
| 648 | authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 649 | CHECK_MIN_WIDTH, |
| 650 | CHECK_HEIGHT, |
| 651 | _("None"))); |
| 652 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 653 | |
| 654 | authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 655 | CHECK_MIN_WIDTH, |
| 656 | CHECK_HEIGHT, |
| 657 | _("Standard VNC (insecure without encryption)"))); |
| 658 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 659 | |
| 660 | authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 661 | CHECK_MIN_WIDTH, |
| 662 | CHECK_HEIGHT, |
| 663 | _("Username and password (insecure without encryption)"))); |
| 664 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 665 | } |
| 666 | |
| 667 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 668 | |
| 669 | authenticationGroup->end(); |
| 670 | |
| 671 | /* Back to normal */ |
| 672 | tx = orig_tx; |
| 673 | ty += INNER_MARGIN; |
| 674 | |
| 675 | group->end(); |
| 676 | #endif |
| 677 | } |
| 678 | |
| 679 | |
| 680 | void OptionsDialog::createInputPage(int tx, int ty, int tw, int th) |
| 681 | { |
| 682 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input")); |
| 683 | |
| 684 | tx += OUTER_MARGIN; |
| 685 | ty += OUTER_MARGIN; |
| 686 | |
| 687 | viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 688 | CHECK_MIN_WIDTH, |
| 689 | CHECK_HEIGHT, |
| 690 | _("View only (ignore mouse and keyboard)"))); |
| 691 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 692 | |
| 693 | acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 694 | CHECK_MIN_WIDTH, |
| 695 | CHECK_HEIGHT, |
| 696 | _("Accept clipboard from server"))); |
| 697 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 698 | |
| 699 | sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 700 | CHECK_MIN_WIDTH, |
| 701 | CHECK_HEIGHT, |
| 702 | _("Send clipboard to server"))); |
| 703 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 704 | |
Pierre Ossman | f7fef92 | 2015-12-10 21:24:08 +0100 | [diff] [blame^] | 705 | #if !defined(WIN32) && !defined(__APPLE__) |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 706 | sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 707 | CHECK_MIN_WIDTH, |
| 708 | CHECK_HEIGHT, |
| 709 | _("Send primary selection and cut buffer as clipboard"))); |
| 710 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
Pierre Ossman | f7fef92 | 2015-12-10 21:24:08 +0100 | [diff] [blame^] | 711 | #endif |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 712 | |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 713 | systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 714 | CHECK_MIN_WIDTH, |
| 715 | CHECK_HEIGHT, |
| 716 | _("Pass system keys directly to server (full screen)"))); |
| 717 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 718 | |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 719 | menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key"))); |
| 720 | |
Pierre Ossman | 245c802 | 2015-02-25 11:27:49 +0100 | [diff] [blame] | 721 | fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER); |
Martin Koegler | 498ef46 | 2011-09-04 07:04:43 +0000 | [diff] [blame] | 722 | for (int i = 0; i < getMenuKeySymbolCount(); i++) |
Pierre Ossman | 245c802 | 2015-02-25 11:27:49 +0100 | [diff] [blame] | 723 | fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0); |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 724 | |
| 725 | ty += CHOICE_HEIGHT + TIGHT_MARGIN; |
| 726 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 727 | group->end(); |
| 728 | } |
| 729 | |
| 730 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 731 | void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th) |
| 732 | { |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 733 | int x; |
| 734 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 735 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen")); |
| 736 | |
| 737 | tx += OUTER_MARGIN; |
| 738 | ty += OUTER_MARGIN; |
| 739 | |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 740 | desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 741 | CHECK_MIN_WIDTH, |
| 742 | CHECK_HEIGHT, |
| 743 | _("Resize remote session on connect"))); |
| 744 | desktopSizeCheckbox->callback(handleDesktopSize, this); |
| 745 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 746 | |
| 747 | desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT); |
| 748 | x = desktopWidthInput->x() + desktopWidthInput->w() + \ |
| 749 | gui_str_len("x") + 3 * 2; |
| 750 | desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x"); |
| 751 | ty += INPUT_HEIGHT + TIGHT_MARGIN; |
| 752 | |
Pierre Ossman | 9919701 | 2012-07-05 11:06:18 +0000 | [diff] [blame] | 753 | remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 754 | CHECK_MIN_WIDTH, |
| 755 | CHECK_HEIGHT, |
| 756 | _("Resize remote session to the local window"))); |
| 757 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 758 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 759 | fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 760 | CHECK_MIN_WIDTH, |
| 761 | CHECK_HEIGHT, |
| 762 | _("Full-screen mode"))); |
| 763 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 764 | |
Pierre Ossman | aae3891 | 2012-07-13 11:22:55 +0000 | [diff] [blame] | 765 | fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty, |
| 766 | CHECK_MIN_WIDTH, |
| 767 | CHECK_HEIGHT, |
| 768 | _("Enable full-screen mode over all monitors"))); |
| 769 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 770 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 771 | group->end(); |
| 772 | } |
| 773 | |
| 774 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 775 | void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th) |
| 776 | { |
| 777 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc.")); |
| 778 | |
| 779 | tx += OUTER_MARGIN; |
| 780 | ty += OUTER_MARGIN; |
| 781 | |
| 782 | sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 783 | CHECK_MIN_WIDTH, |
| 784 | CHECK_HEIGHT, |
| 785 | _("Shared (don't disconnect other viewers)"))); |
| 786 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 787 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 788 | dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 789 | CHECK_MIN_WIDTH, |
| 790 | CHECK_HEIGHT, |
| 791 | _("Show dot when no cursor"))); |
| 792 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 793 | |
| 794 | group->end(); |
| 795 | } |
| 796 | |
| 797 | |
| 798 | void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data) |
| 799 | { |
| 800 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 801 | |
| 802 | if (dialog->autoselectCheckbox->value()) { |
| 803 | dialog->encodingGroup->deactivate(); |
| 804 | dialog->colorlevelGroup->deactivate(); |
| 805 | } else { |
| 806 | dialog->encodingGroup->activate(); |
| 807 | dialog->colorlevelGroup->activate(); |
| 808 | } |
| 809 | |
| 810 | // JPEG setting is also affected by autoselection |
| 811 | dialog->handleJpeg(dialog->jpegCheckbox, dialog); |
| 812 | } |
| 813 | |
| 814 | |
| 815 | void OptionsDialog::handleCompression(Fl_Widget *widget, void *data) |
| 816 | { |
| 817 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 818 | |
| 819 | if (dialog->compressionCheckbox->value()) |
| 820 | dialog->compressionInput->activate(); |
| 821 | else |
| 822 | dialog->compressionInput->deactivate(); |
| 823 | } |
| 824 | |
| 825 | |
| 826 | void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data) |
| 827 | { |
| 828 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 829 | |
| 830 | if (dialog->jpegCheckbox->value() && |
| 831 | !dialog->autoselectCheckbox->value()) |
| 832 | dialog->jpegInput->activate(); |
| 833 | else |
| 834 | dialog->jpegInput->deactivate(); |
| 835 | } |
| 836 | |
| 837 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 838 | void OptionsDialog::handleX509(Fl_Widget *widget, void *data) |
| 839 | { |
| 840 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 841 | |
| 842 | if (dialog->encX509Checkbox->value()) { |
| 843 | dialog->caInput->activate(); |
| 844 | dialog->crlInput->activate(); |
| 845 | } else { |
| 846 | dialog->caInput->deactivate(); |
| 847 | dialog->crlInput->deactivate(); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 852 | void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data) |
| 853 | { |
| 854 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 855 | |
| 856 | if (dialog->desktopSizeCheckbox->value()) { |
| 857 | dialog->desktopWidthInput->activate(); |
| 858 | dialog->desktopHeightInput->activate(); |
| 859 | } else { |
| 860 | dialog->desktopWidthInput->deactivate(); |
| 861 | dialog->desktopHeightInput->deactivate(); |
| 862 | } |
| 863 | } |
| 864 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 865 | void OptionsDialog::handleCancel(Fl_Widget *widget, void *data) |
| 866 | { |
| 867 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 868 | |
| 869 | dialog->hide(); |
| 870 | } |
| 871 | |
| 872 | |
| 873 | void OptionsDialog::handleOK(Fl_Widget *widget, void *data) |
| 874 | { |
| 875 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 876 | |
| 877 | dialog->hide(); |
| 878 | |
| 879 | dialog->storeOptions(); |
| 880 | } |