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 | |
| 255 | caInput->value(CSecurityTLS::x509ca); |
| 256 | crlInput->value(CSecurityTLS::x509crl); |
| 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); |
| 267 | sendPrimaryCheckbox->value(sendPrimary); |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 268 | systemKeysCheckbox->value(fullscreenSystemKeys); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 269 | |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 270 | menuKeyChoice->value(0); |
| 271 | |
| 272 | menuKeyBuf = menuKey; |
Martin Koegler | 498ef46 | 2011-09-04 07:04:43 +0000 | [diff] [blame] | 273 | for (int i = 0; i < getMenuKeySymbolCount(); i++) |
| 274 | if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf)) |
| 275 | menuKeyChoice->value(i + 1); |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 276 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 277 | /* Screen */ |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 278 | int width, height; |
| 279 | |
| 280 | if (sscanf(desktopSize.getValueStr(), "%dx%d", &width, &height) != 2) { |
| 281 | desktopSizeCheckbox->value(false); |
| 282 | desktopWidthInput->value("1024"); |
| 283 | desktopHeightInput->value("768"); |
| 284 | } else { |
| 285 | char buf[32]; |
| 286 | desktopSizeCheckbox->value(true); |
| 287 | snprintf(buf, sizeof(buf), "%d", width); |
| 288 | desktopWidthInput->value(buf); |
| 289 | snprintf(buf, sizeof(buf), "%d", height); |
| 290 | desktopHeightInput->value(buf); |
| 291 | } |
Pierre Ossman | 9919701 | 2012-07-05 11:06:18 +0000 | [diff] [blame] | 292 | remoteResizeCheckbox->value(remoteResize); |
Pierre Ossman | 2441e82 | 2012-07-10 11:11:23 +0000 | [diff] [blame] | 293 | #ifdef HAVE_FLTK_FULLSCREEN |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 294 | fullScreenCheckbox->value(fullScreen); |
Pierre Ossman | aae3891 | 2012-07-13 11:22:55 +0000 | [diff] [blame] | 295 | #ifdef HAVE_FLTK_FULLSCREEN_SCREENS |
| 296 | fullScreenAllMonitorsCheckbox->value(fullScreenAllMonitors); |
| 297 | #endif // HAVE_FLTK_FULLSCREEN_SCREENS |
Pierre Ossman | 2441e82 | 2012-07-10 11:11:23 +0000 | [diff] [blame] | 298 | #endif // HAVE_FLTK_FULLSCREEN |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 299 | |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 300 | handleDesktopSize(desktopSizeCheckbox, this); |
| 301 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 302 | /* Misc. */ |
| 303 | sharedCheckbox->value(shared); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 304 | dotCursorCheckbox->value(dotWhenNoCursor); |
| 305 | } |
| 306 | |
| 307 | |
| 308 | void OptionsDialog::storeOptions(void) |
| 309 | { |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 310 | /* Compression */ |
| 311 | autoSelect.setParam(autoselectCheckbox->value()); |
| 312 | |
| 313 | if (tightButton->value()) |
| 314 | preferredEncoding.setParam(encodingName(encodingTight)); |
| 315 | else if (zrleButton->value()) |
| 316 | preferredEncoding.setParam(encodingName(encodingZRLE)); |
| 317 | else if (hextileButton->value()) |
| 318 | preferredEncoding.setParam(encodingName(encodingHextile)); |
| 319 | else if (rawButton->value()) |
| 320 | preferredEncoding.setParam(encodingName(encodingRaw)); |
| 321 | |
| 322 | fullColour.setParam(fullcolorCheckbox->value()); |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 323 | if (verylowcolorCheckbox->value()) |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 324 | lowColourLevel.setParam(0); |
| 325 | else if (lowcolorCheckbox->value()) |
| 326 | lowColourLevel.setParam(1); |
Pierre Ossman | cf836f2 | 2011-07-14 14:34:09 +0000 | [diff] [blame] | 327 | else if (mediumcolorCheckbox->value()) |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 328 | lowColourLevel.setParam(2); |
| 329 | |
| 330 | customCompressLevel.setParam(compressionCheckbox->value()); |
| 331 | noJpeg.setParam(!jpegCheckbox->value()); |
| 332 | compressLevel.setParam(atoi(compressionInput->value())); |
| 333 | qualityLevel.setParam(atoi(jpegInput->value())); |
| 334 | |
| 335 | #ifdef HAVE_GNUTLS |
| 336 | /* Security */ |
| 337 | Security security; |
| 338 | |
| 339 | /* Process security types which don't use encryption */ |
| 340 | if (encNoneCheckbox->value()) { |
| 341 | if (authNoneCheckbox->value()) |
| 342 | security.EnableSecType(secTypeNone); |
| 343 | if (authVncCheckbox->value()) |
| 344 | security.EnableSecType(secTypeVncAuth); |
Pierre Ossman | c1764bd | 2011-09-30 12:26:25 +0000 | [diff] [blame] | 345 | if (authPlainCheckbox->value()) |
| 346 | security.EnableSecType(secTypePlain); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 347 | } |
| 348 | |
Pierre Ossman | c1764bd | 2011-09-30 12:26:25 +0000 | [diff] [blame] | 349 | /* Process security types which use TLS encryption */ |
| 350 | if (encTLSCheckbox->value()) { |
| 351 | if (authNoneCheckbox->value()) |
| 352 | security.EnableSecType(secTypeTLSNone); |
| 353 | if (authVncCheckbox->value()) |
| 354 | security.EnableSecType(secTypeTLSVnc); |
| 355 | if (authPlainCheckbox->value()) |
| 356 | security.EnableSecType(secTypeTLSPlain); |
| 357 | } |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 358 | |
Pierre Ossman | c1764bd | 2011-09-30 12:26:25 +0000 | [diff] [blame] | 359 | /* Process security types which use X509 encryption */ |
| 360 | if (encX509Checkbox->value()) { |
| 361 | if (authNoneCheckbox->value()) |
| 362 | security.EnableSecType(secTypeX509None); |
| 363 | if (authVncCheckbox->value()) |
| 364 | security.EnableSecType(secTypeX509Vnc); |
| 365 | if (authPlainCheckbox->value()) |
| 366 | security.EnableSecType(secTypeX509Plain); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 367 | } |
| 368 | |
Pierre Ossman | 5535fe6 | 2011-09-30 12:11:52 +0000 | [diff] [blame] | 369 | SecurityClient::secTypes.setParam(security.ToString()); |
| 370 | |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 371 | CSecurityTLS::x509ca.setParam(caInput->value()); |
| 372 | CSecurityTLS::x509crl.setParam(crlInput->value()); |
| 373 | #endif |
| 374 | |
| 375 | /* Input */ |
| 376 | viewOnly.setParam(viewOnlyCheckbox->value()); |
| 377 | acceptClipboard.setParam(acceptClipboardCheckbox->value()); |
| 378 | sendClipboard.setParam(sendClipboardCheckbox->value()); |
| 379 | sendPrimary.setParam(sendPrimaryCheckbox->value()); |
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 | 2441e82 | 2012-07-10 11:11:23 +0000 | [diff] [blame] | 401 | #ifdef HAVE_FLTK_FULLSCREEN |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 402 | fullScreen.setParam(fullScreenCheckbox->value()); |
Pierre Ossman | aae3891 | 2012-07-13 11:22:55 +0000 | [diff] [blame] | 403 | #ifdef HAVE_FLTK_FULLSCREEN_SCREENS |
| 404 | fullScreenAllMonitors.setParam(fullScreenAllMonitorsCheckbox->value()); |
| 405 | #endif // HAVE_FLTK_FULLSCREEN_SCREENS |
Pierre Ossman | 2441e82 | 2012-07-10 11:11:23 +0000 | [diff] [blame] | 406 | #endif // HAVE_FLTK_FULLSCREEN |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 407 | |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 408 | /* Misc. */ |
| 409 | shared.setParam(sharedCheckbox->value()); |
Pierre Ossman | 61fd486 | 2011-05-16 12:46:51 +0000 | [diff] [blame] | 410 | dotWhenNoCursor.setParam(dotCursorCheckbox->value()); |
Pierre Ossman | 0c41e1d | 2011-05-17 09:36:04 +0000 | [diff] [blame] | 411 | |
| 412 | std::map<OptionsCallback*, void*>::const_iterator iter; |
| 413 | |
| 414 | for (iter = callbacks.begin();iter != callbacks.end();++iter) |
| 415 | iter->first(iter->second); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | |
| 419 | void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th) |
| 420 | { |
| 421 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Compression")); |
| 422 | |
| 423 | int orig_tx, orig_ty; |
| 424 | int half_width, full_width; |
| 425 | int width, height; |
| 426 | |
| 427 | tx += OUTER_MARGIN; |
| 428 | ty += OUTER_MARGIN; |
| 429 | |
| 430 | full_width = tw - OUTER_MARGIN * 2; |
| 431 | half_width = (full_width - INNER_MARGIN) / 2; |
| 432 | |
| 433 | /* AutoSelect checkbox */ |
| 434 | autoselectCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 435 | CHECK_MIN_WIDTH, |
| 436 | CHECK_HEIGHT, |
| 437 | _("Auto select"))); |
| 438 | autoselectCheckbox->callback(handleAutoselect, this); |
| 439 | ty += CHECK_HEIGHT + INNER_MARGIN; |
| 440 | |
| 441 | /* Two columns */ |
| 442 | orig_tx = tx; |
| 443 | orig_ty = ty; |
| 444 | |
| 445 | /* VNC encoding box */ |
| 446 | ty += GROUP_LABEL_OFFSET; |
| 447 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4; |
| 448 | encodingGroup = new Fl_Group(tx, ty, half_width, height, |
| 449 | _("Preferred encoding")); |
| 450 | encodingGroup->box(FL_ENGRAVED_BOX); |
| 451 | encodingGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 452 | |
| 453 | { |
| 454 | tx += GROUP_MARGIN; |
| 455 | ty += GROUP_MARGIN; |
| 456 | |
| 457 | width = encodingGroup->w() - GROUP_MARGIN * 2; |
| 458 | |
| 459 | tightButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 460 | RADIO_MIN_WIDTH, |
| 461 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 462 | "Tight")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 463 | tightButton->type(FL_RADIO_BUTTON); |
| 464 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 465 | |
| 466 | zrleButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 467 | RADIO_MIN_WIDTH, |
| 468 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 469 | "ZRLE")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 470 | zrleButton->type(FL_RADIO_BUTTON); |
| 471 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 472 | |
| 473 | hextileButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 474 | RADIO_MIN_WIDTH, |
| 475 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 476 | "Hextile")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 477 | hextileButton->type(FL_RADIO_BUTTON); |
| 478 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 479 | |
| 480 | rawButton = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 481 | RADIO_MIN_WIDTH, |
| 482 | RADIO_HEIGHT, |
Peter Åstrand | 4c44600 | 2011-08-15 12:33:06 +0000 | [diff] [blame] | 483 | "Raw")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 484 | rawButton->type(FL_RADIO_BUTTON); |
| 485 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 486 | } |
| 487 | |
| 488 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 489 | |
| 490 | encodingGroup->end(); |
| 491 | |
| 492 | /* Second column */ |
| 493 | tx = orig_tx + half_width + INNER_MARGIN; |
| 494 | ty = orig_ty; |
| 495 | |
| 496 | /* Color box */ |
| 497 | ty += GROUP_LABEL_OFFSET; |
| 498 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 3 + RADIO_HEIGHT * 4; |
| 499 | colorlevelGroup = new Fl_Group(tx, ty, half_width, height, _("Color level")); |
| 500 | colorlevelGroup->box(FL_ENGRAVED_BOX); |
| 501 | colorlevelGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 502 | |
| 503 | { |
| 504 | tx += GROUP_MARGIN; |
| 505 | ty += GROUP_MARGIN; |
| 506 | |
| 507 | width = colorlevelGroup->w() - GROUP_MARGIN * 2; |
| 508 | |
| 509 | fullcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 510 | RADIO_MIN_WIDTH, |
| 511 | RADIO_HEIGHT, |
| 512 | _("Full (all available colors)"))); |
| 513 | fullcolorCheckbox->type(FL_RADIO_BUTTON); |
| 514 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 515 | |
| 516 | mediumcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 517 | RADIO_MIN_WIDTH, |
| 518 | RADIO_HEIGHT, |
| 519 | _("Medium (256 colors)"))); |
| 520 | mediumcolorCheckbox->type(FL_RADIO_BUTTON); |
| 521 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 522 | |
| 523 | lowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 524 | RADIO_MIN_WIDTH, |
| 525 | RADIO_HEIGHT, |
| 526 | _("Low (64 colors)"))); |
| 527 | lowcolorCheckbox->type(FL_RADIO_BUTTON); |
| 528 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 529 | |
| 530 | verylowcolorCheckbox = new Fl_Round_Button(LBLRIGHT(tx, ty, |
| 531 | RADIO_MIN_WIDTH, |
| 532 | RADIO_HEIGHT, |
| 533 | _("Very low (8 colors)"))); |
| 534 | verylowcolorCheckbox->type(FL_RADIO_BUTTON); |
| 535 | ty += RADIO_HEIGHT + TIGHT_MARGIN; |
| 536 | } |
| 537 | |
| 538 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 539 | |
| 540 | colorlevelGroup->end(); |
| 541 | |
| 542 | /* Back to normal */ |
| 543 | tx = orig_tx; |
| 544 | ty += INNER_MARGIN; |
| 545 | |
| 546 | /* Checkboxes */ |
| 547 | compressionCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 548 | CHECK_MIN_WIDTH, |
| 549 | CHECK_HEIGHT, |
| 550 | _("Custom compression level:"))); |
| 551 | compressionCheckbox->callback(handleCompression, this); |
| 552 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 553 | |
| 554 | compressionInput = new Fl_Int_Input(tx + INDENT, ty, |
| 555 | INPUT_HEIGHT, INPUT_HEIGHT, |
DRC | ba7bc51 | 2011-08-17 02:30:34 +0000 | [diff] [blame] | 556 | _("level (1=fast, 6=best [4-6 are rarely useful])")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 557 | compressionInput->align(FL_ALIGN_RIGHT); |
| 558 | ty += INPUT_HEIGHT + INNER_MARGIN; |
| 559 | |
| 560 | jpegCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 561 | CHECK_MIN_WIDTH, |
| 562 | CHECK_HEIGHT, |
| 563 | _("Allow JPEG compression:"))); |
| 564 | jpegCheckbox->callback(handleJpeg, this); |
| 565 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 566 | |
| 567 | jpegInput = new Fl_Int_Input(tx + INDENT, ty, |
| 568 | INPUT_HEIGHT, INPUT_HEIGHT, |
DRC | 41036ed | 2011-08-23 20:36:50 +0000 | [diff] [blame] | 569 | _("quality (0=poor, 9=best)")); |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 570 | jpegInput->align(FL_ALIGN_RIGHT); |
| 571 | ty += INPUT_HEIGHT + INNER_MARGIN; |
| 572 | |
| 573 | group->end(); |
| 574 | } |
| 575 | |
| 576 | |
| 577 | void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th) |
| 578 | { |
| 579 | #ifdef HAVE_GNUTLS |
| 580 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security")); |
| 581 | |
| 582 | int orig_tx; |
| 583 | int width, height; |
| 584 | |
| 585 | tx += OUTER_MARGIN; |
| 586 | ty += OUTER_MARGIN; |
| 587 | |
| 588 | width = tw - OUTER_MARGIN * 2; |
| 589 | |
| 590 | orig_tx = tx; |
| 591 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 592 | /* Encryption */ |
| 593 | ty += GROUP_LABEL_OFFSET; |
| 594 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 4 + CHECK_HEIGHT * 3 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 2; |
| 595 | encryptionGroup = new Fl_Group(tx, ty, width, height, _("Encryption")); |
| 596 | encryptionGroup->box(FL_ENGRAVED_BOX); |
| 597 | encryptionGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 598 | |
| 599 | { |
| 600 | tx += GROUP_MARGIN; |
| 601 | ty += GROUP_MARGIN; |
| 602 | |
| 603 | encNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 604 | CHECK_MIN_WIDTH, |
| 605 | CHECK_HEIGHT, |
| 606 | _("None"))); |
| 607 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 608 | |
| 609 | encTLSCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 610 | CHECK_MIN_WIDTH, |
| 611 | CHECK_HEIGHT, |
| 612 | _("TLS with anonymous certificates"))); |
| 613 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 614 | |
| 615 | encX509Checkbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 616 | CHECK_MIN_WIDTH, |
| 617 | CHECK_HEIGHT, |
| 618 | _("TLS with X509 certificates"))); |
| 619 | encX509Checkbox->callback(handleX509, this); |
| 620 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 621 | |
| 622 | ty += INPUT_LABEL_OFFSET; |
| 623 | caInput = new Fl_Input(tx + INDENT, ty, |
| 624 | width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT, |
| 625 | _("Path to X509 CA certificate")); |
| 626 | caInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 627 | ty += INPUT_HEIGHT + TIGHT_MARGIN; |
| 628 | |
| 629 | ty += INPUT_LABEL_OFFSET; |
| 630 | crlInput = new Fl_Input(tx + INDENT, ty, |
| 631 | width - GROUP_MARGIN*2 - INDENT, INPUT_HEIGHT, |
| 632 | _("Path to X509 CRL file")); |
| 633 | crlInput->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 634 | ty += INPUT_HEIGHT + TIGHT_MARGIN; |
| 635 | } |
| 636 | |
| 637 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 638 | |
| 639 | encryptionGroup->end(); |
| 640 | |
| 641 | /* Back to normal */ |
| 642 | tx = orig_tx; |
| 643 | ty += INNER_MARGIN; |
| 644 | |
| 645 | /* Authentication */ |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 646 | ty += GROUP_LABEL_OFFSET; |
| 647 | height = GROUP_MARGIN * 2 + TIGHT_MARGIN * 2 + CHECK_HEIGHT * 3; |
| 648 | authenticationGroup = new Fl_Group(tx, ty, width, height, _("Authentication")); |
| 649 | authenticationGroup->box(FL_ENGRAVED_BOX); |
| 650 | authenticationGroup->align(FL_ALIGN_LEFT | FL_ALIGN_TOP); |
| 651 | |
| 652 | { |
| 653 | tx += GROUP_MARGIN; |
| 654 | ty += GROUP_MARGIN; |
| 655 | |
| 656 | authNoneCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 657 | CHECK_MIN_WIDTH, |
| 658 | CHECK_HEIGHT, |
| 659 | _("None"))); |
| 660 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 661 | |
| 662 | authVncCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 663 | CHECK_MIN_WIDTH, |
| 664 | CHECK_HEIGHT, |
| 665 | _("Standard VNC (insecure without encryption)"))); |
| 666 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 667 | |
| 668 | authPlainCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 669 | CHECK_MIN_WIDTH, |
| 670 | CHECK_HEIGHT, |
| 671 | _("Username and password (insecure without encryption)"))); |
| 672 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 673 | } |
| 674 | |
| 675 | ty += GROUP_MARGIN - TIGHT_MARGIN; |
| 676 | |
| 677 | authenticationGroup->end(); |
| 678 | |
| 679 | /* Back to normal */ |
| 680 | tx = orig_tx; |
| 681 | ty += INNER_MARGIN; |
| 682 | |
| 683 | group->end(); |
| 684 | #endif |
| 685 | } |
| 686 | |
| 687 | |
| 688 | void OptionsDialog::createInputPage(int tx, int ty, int tw, int th) |
| 689 | { |
| 690 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Input")); |
| 691 | |
| 692 | tx += OUTER_MARGIN; |
| 693 | ty += OUTER_MARGIN; |
| 694 | |
| 695 | viewOnlyCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 696 | CHECK_MIN_WIDTH, |
| 697 | CHECK_HEIGHT, |
| 698 | _("View only (ignore mouse and keyboard)"))); |
| 699 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 700 | |
| 701 | acceptClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 702 | CHECK_MIN_WIDTH, |
| 703 | CHECK_HEIGHT, |
| 704 | _("Accept clipboard from server"))); |
| 705 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 706 | |
| 707 | sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 708 | CHECK_MIN_WIDTH, |
| 709 | CHECK_HEIGHT, |
| 710 | _("Send clipboard to server"))); |
| 711 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 712 | |
| 713 | sendPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 714 | CHECK_MIN_WIDTH, |
| 715 | CHECK_HEIGHT, |
| 716 | _("Send primary selection and cut buffer as clipboard"))); |
| 717 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 718 | |
Pierre Ossman | 407a5c3 | 2011-05-26 14:48:29 +0000 | [diff] [blame] | 719 | systemKeysCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 720 | CHECK_MIN_WIDTH, |
| 721 | CHECK_HEIGHT, |
| 722 | _("Pass system keys directly to server (full screen)"))); |
| 723 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 724 | |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 725 | menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key"))); |
| 726 | |
| 727 | menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER); |
Martin Koegler | 498ef46 | 2011-09-04 07:04:43 +0000 | [diff] [blame] | 728 | for (int i = 0; i < getMenuKeySymbolCount(); i++) |
| 729 | menuKeyChoice->add(getMenuKeySymbols()[i].name, 0, NULL, 0, 0); |
Pierre Ossman | 4e7271e | 2011-05-24 12:47:12 +0000 | [diff] [blame] | 730 | |
| 731 | ty += CHOICE_HEIGHT + TIGHT_MARGIN; |
| 732 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 733 | group->end(); |
| 734 | } |
| 735 | |
| 736 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 737 | void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th) |
| 738 | { |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 739 | int x; |
| 740 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 741 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen")); |
| 742 | |
| 743 | tx += OUTER_MARGIN; |
| 744 | ty += OUTER_MARGIN; |
| 745 | |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 746 | desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 747 | CHECK_MIN_WIDTH, |
| 748 | CHECK_HEIGHT, |
| 749 | _("Resize remote session on connect"))); |
| 750 | desktopSizeCheckbox->callback(handleDesktopSize, this); |
| 751 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 752 | |
| 753 | desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT); |
| 754 | x = desktopWidthInput->x() + desktopWidthInput->w() + \ |
| 755 | gui_str_len("x") + 3 * 2; |
| 756 | desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x"); |
| 757 | ty += INPUT_HEIGHT + TIGHT_MARGIN; |
| 758 | |
Pierre Ossman | 9919701 | 2012-07-05 11:06:18 +0000 | [diff] [blame] | 759 | remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 760 | CHECK_MIN_WIDTH, |
| 761 | CHECK_HEIGHT, |
| 762 | _("Resize remote session to the local window"))); |
| 763 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 764 | |
Pierre Ossman | 2441e82 | 2012-07-10 11:11:23 +0000 | [diff] [blame] | 765 | #ifdef HAVE_FLTK_FULLSCREEN |
| 766 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 767 | fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 768 | CHECK_MIN_WIDTH, |
| 769 | CHECK_HEIGHT, |
| 770 | _("Full-screen mode"))); |
| 771 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 772 | |
Pierre Ossman | aae3891 | 2012-07-13 11:22:55 +0000 | [diff] [blame] | 773 | #ifdef HAVE_FLTK_FULLSCREEN_SCREENS |
| 774 | |
| 775 | fullScreenAllMonitorsCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty, |
| 776 | CHECK_MIN_WIDTH, |
| 777 | CHECK_HEIGHT, |
| 778 | _("Enable full-screen mode over all monitors"))); |
| 779 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 780 | |
| 781 | #endif // HAVE_FLTK_FULLSCREEN_SCREENS |
| 782 | |
Pierre Ossman | 2441e82 | 2012-07-10 11:11:23 +0000 | [diff] [blame] | 783 | #endif // HAVE_FLTK_FULLSCREEN |
| 784 | |
Pierre Ossman | 1c2189b | 2012-07-05 09:23:03 +0000 | [diff] [blame] | 785 | group->end(); |
| 786 | } |
| 787 | |
| 788 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 789 | void OptionsDialog::createMiscPage(int tx, int ty, int tw, int th) |
| 790 | { |
| 791 | Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Misc.")); |
| 792 | |
| 793 | tx += OUTER_MARGIN; |
| 794 | ty += OUTER_MARGIN; |
| 795 | |
| 796 | sharedCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 797 | CHECK_MIN_WIDTH, |
| 798 | CHECK_HEIGHT, |
| 799 | _("Shared (don't disconnect other viewers)"))); |
| 800 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 801 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 802 | dotCursorCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, |
| 803 | CHECK_MIN_WIDTH, |
| 804 | CHECK_HEIGHT, |
| 805 | _("Show dot when no cursor"))); |
| 806 | ty += CHECK_HEIGHT + TIGHT_MARGIN; |
| 807 | |
| 808 | group->end(); |
| 809 | } |
| 810 | |
| 811 | |
| 812 | void OptionsDialog::handleAutoselect(Fl_Widget *widget, void *data) |
| 813 | { |
| 814 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 815 | |
| 816 | if (dialog->autoselectCheckbox->value()) { |
| 817 | dialog->encodingGroup->deactivate(); |
| 818 | dialog->colorlevelGroup->deactivate(); |
| 819 | } else { |
| 820 | dialog->encodingGroup->activate(); |
| 821 | dialog->colorlevelGroup->activate(); |
| 822 | } |
| 823 | |
| 824 | // JPEG setting is also affected by autoselection |
| 825 | dialog->handleJpeg(dialog->jpegCheckbox, dialog); |
| 826 | } |
| 827 | |
| 828 | |
| 829 | void OptionsDialog::handleCompression(Fl_Widget *widget, void *data) |
| 830 | { |
| 831 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 832 | |
| 833 | if (dialog->compressionCheckbox->value()) |
| 834 | dialog->compressionInput->activate(); |
| 835 | else |
| 836 | dialog->compressionInput->deactivate(); |
| 837 | } |
| 838 | |
| 839 | |
| 840 | void OptionsDialog::handleJpeg(Fl_Widget *widget, void *data) |
| 841 | { |
| 842 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 843 | |
| 844 | if (dialog->jpegCheckbox->value() && |
| 845 | !dialog->autoselectCheckbox->value()) |
| 846 | dialog->jpegInput->activate(); |
| 847 | else |
| 848 | dialog->jpegInput->deactivate(); |
| 849 | } |
| 850 | |
| 851 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 852 | void OptionsDialog::handleX509(Fl_Widget *widget, void *data) |
| 853 | { |
| 854 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 855 | |
| 856 | if (dialog->encX509Checkbox->value()) { |
| 857 | dialog->caInput->activate(); |
| 858 | dialog->crlInput->activate(); |
| 859 | } else { |
| 860 | dialog->caInput->deactivate(); |
| 861 | dialog->crlInput->deactivate(); |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | |
Pierre Ossman | 9ff733a | 2012-07-05 11:01:23 +0000 | [diff] [blame] | 866 | void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data) |
| 867 | { |
| 868 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 869 | |
| 870 | if (dialog->desktopSizeCheckbox->value()) { |
| 871 | dialog->desktopWidthInput->activate(); |
| 872 | dialog->desktopHeightInput->activate(); |
| 873 | } else { |
| 874 | dialog->desktopWidthInput->deactivate(); |
| 875 | dialog->desktopHeightInput->deactivate(); |
| 876 | } |
| 877 | } |
| 878 | |
Pierre Ossman | d463b57 | 2011-05-16 12:04:43 +0000 | [diff] [blame] | 879 | void OptionsDialog::handleCancel(Fl_Widget *widget, void *data) |
| 880 | { |
| 881 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 882 | |
| 883 | dialog->hide(); |
| 884 | } |
| 885 | |
| 886 | |
| 887 | void OptionsDialog::handleOK(Fl_Widget *widget, void *data) |
| 888 | { |
| 889 | OptionsDialog *dialog = (OptionsDialog*)data; |
| 890 | |
| 891 | dialog->hide(); |
| 892 | |
| 893 | dialog->storeOptions(); |
| 894 | } |