|
40 | 40 | */ |
41 | 41 | int SVInput::handle (int evt) |
42 | 42 | { |
| 43 | + // save and close the quicknote editor |
| 44 | + if (evt == FL_KEYUP && app->quickNoteWindow != 0) |
| 45 | + { |
| 46 | + if (Fl::event_key() == FL_Enter) |
| 47 | + { |
| 48 | + // get currently selected list item |
| 49 | + int curLine = app->hostList->value(); |
| 50 | + |
| 51 | + if (curLine > 0) |
| 52 | + { |
| 53 | + HostItem * itm = static_cast<HostItem *>(app->hostList->data(curLine)); |
| 54 | + |
| 55 | + if (itm != NULL) |
| 56 | + { |
| 57 | + itm->quickNote = app->quickNoteInput->value(); |
| 58 | + app->quickNote->copy_label(itm->quickNote.c_str()); |
| 59 | + app->quickNoteInput->value(""); |
| 60 | + app->quickNoteWindow->hide(); |
| 61 | + svConfigWrite(); |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | + return 1; |
| 66 | + } |
| 67 | + |
43 | 68 | static bool inMenu; |
44 | 69 |
|
45 | 70 | // handle child window input controls right-click |
@@ -148,6 +173,56 @@ int SVSecretInput::handle (int evt) |
148 | 173 | } |
149 | 174 |
|
150 | 175 |
|
| 176 | +/* handle method for SVBox |
| 177 | + * (instance method) |
| 178 | + */ |
| 179 | +int SVQuickNoteBox::handle (int evt) |
| 180 | +{ |
| 181 | + // get currently selected list item |
| 182 | + int curLine = app->hostList->value(); |
| 183 | + |
| 184 | + // handle quicknote click if an item is selected |
| 185 | + if (evt == FL_PUSH && curLine > 0) |
| 186 | + { |
| 187 | + // create a quicknote window if it doesn't exist |
| 188 | + if (app->quickNoteWindow == NULL) |
| 189 | + { |
| 190 | + app->quickNoteWindow = new Fl_Window(0, 0, 110, 32); |
| 191 | + |
| 192 | + Fl_Group * inputGroup = new Fl_Group(3, 3, 100, 24); |
| 193 | + inputGroup->box(FL_THIN_DOWN_BOX); |
| 194 | + app->quickNoteInput = new SVInput(0, 0, 100, 24); |
| 195 | + inputGroup->end(); |
| 196 | + |
| 197 | + app->quickNoteWindow->end(); |
| 198 | + app->quickNoteWindow->clear_border(); |
| 199 | + app->quickNoteWindow->xclass("spiritvncfltktextentry"); |
| 200 | + app->quickNoteWindow->callback(svHandleQuickNoteWindowEvents); |
| 201 | + } |
| 202 | + |
| 203 | + // show the editor if there's a selected item |
| 204 | + if (curLine > 0) |
| 205 | + { |
| 206 | + HostItem * itm = static_cast<HostItem *>(app->hostList->data(curLine)); |
| 207 | + |
| 208 | + if (itm != NULL && itm->name != "") |
| 209 | + { |
| 210 | + app->quickNoteWindow->position(app->mainWin->x_root() + app->quickNote->x(), |
| 211 | + app->mainWin->y_root() + app->quickNote->y()); |
| 212 | + app->quickNoteWindow->size(app->quickNote->w(), app->quickNoteWindow->h()); |
| 213 | + app->quickNoteWindow->set_modal(); |
| 214 | + |
| 215 | + app->quickNoteInput->size(app->quickNote->w(), app->quickNoteWindow->h()); |
| 216 | + app->quickNoteInput->value(itm->quickNote.c_str()); |
| 217 | + |
| 218 | + app->quickNoteWindow->show(); |
| 219 | + } |
| 220 | + } |
| 221 | + } |
| 222 | + |
| 223 | + return Fl_Box::handle(evt); |
| 224 | +} |
| 225 | + |
151 | 226 | /* |
152 | 227 | child window 'OK' button callback - closes child windows (settings, options, etc |
153 | 228 | (Fl_Widget * is unused, so parameter name removed according to 'best practices') |
@@ -262,6 +337,15 @@ void svConfigReadCreateHostList () |
262 | 337 | app->nDeadTimeout = w; |
263 | 338 | } |
264 | 339 |
|
| 340 | + // ssh command |
| 341 | + if (strProp == "sshcommand") |
| 342 | + { |
| 343 | + app->sshCommand = strVal; |
| 344 | + |
| 345 | + if (app->sshCommand == "") |
| 346 | + app->sshCommand = "ssh"; |
| 347 | + } |
| 348 | + |
265 | 349 | // starting local port number for ssh |
266 | 350 | if (strProp == "startinglocalport") |
267 | 351 | { |
@@ -485,6 +569,10 @@ void svConfigReadCreateHostList () |
485 | 569 | // center y? |
486 | 570 | if (strProp == "centery") |
487 | 571 | itm->centerY = svConvertStringToBoolean(strVal); |
| 572 | + |
| 573 | + // quicknote |
| 574 | + if (strProp == "quicknote") |
| 575 | + itm->quickNote = base64Decode(strVal); |
488 | 576 | } |
489 | 577 | } |
490 | 578 | else |
@@ -554,6 +642,9 @@ void svConfigWrite () |
554 | 642 | // starting local port number (+99) for ssh connections |
555 | 643 | ofs << "startinglocalport=" << app->nStartingLocalPort << std::endl; |
556 | 644 |
|
| 645 | + // ssh command |
| 646 | + ofs << "sshcommand=" << app->sshCommand << std::endl; |
| 647 | + |
557 | 648 | // show tool tips |
558 | 649 | ofs << "showtooltips=" << svConvertBooleanToString(app->showTooltips) << std::endl; |
559 | 650 |
|
@@ -613,6 +704,8 @@ void svConfigWrite () |
613 | 704 | ofs << "ignoreinactive=" << svConvertBooleanToString(itm->ignoreInactive) << std::endl; |
614 | 705 | ofs << "centerx=" << svConvertBooleanToString(itm->centerX) << std::endl; |
615 | 706 | ofs << "centery=" << svConvertBooleanToString(itm->centerY) << std::endl; |
| 707 | + ofs << "quicknote=" << base64Encode(reinterpret_cast<const unsigned char *> |
| 708 | + (itm->quickNote.c_str()), itm->quickNote.size()) << std::endl; |
616 | 709 |
|
617 | 710 | ofs << std::endl; |
618 | 711 | } |
@@ -813,7 +906,7 @@ void svCreateGUI () |
813 | 906 |
|
814 | 907 | app->packButtons = new Fl_Pack(0, 0, 1, nBtnSize); |
815 | 908 | app->packButtons->type(Fl_Pack::HORIZONTAL); |
816 | | - app->packButtons->begin(); |
| 909 | + //app->packButtons->begin(); |
817 | 910 |
|
818 | 911 | app->btnListAdd = new Fl_Button(0, 0, nBtnSize, nBtnSize); |
819 | 912 | app->btnListAdd->clear_visible_focus(); |
@@ -851,19 +944,41 @@ void svCreateGUI () |
851 | 944 |
|
852 | 945 | app->packButtons->end(); |
853 | 946 |
|
| 947 | + // create host list |
| 948 | + app->hostList = new Fl_Hold_Browser(0, 0, 0, 0); |
| 949 | + app->hostList->clear_visible_focus(); |
| 950 | + app->hostList->callback(svHandleHostListEvents, NULL); |
| 951 | + app->hostList->box(FL_THIN_DOWN_BOX); |
| 952 | + |
| 953 | + // *** quicknote *** |
| 954 | + |
| 955 | + // quicknote group |
| 956 | + app->quickNoteGroup = new Fl_Group(0, 0, 100, 68); |
| 957 | + |
| 958 | + // quicknote label - item name |
| 959 | + app->quickNoteLabel = new Fl_Box(0, 0, 100, 18); |
| 960 | + app->quickNoteLabel->labelsize(app->nAppFontSize); |
| 961 | + app->quickNoteLabel->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE); |
| 962 | + app->quickNoteLabel->labelfont(1); |
| 963 | + app->quickNoteLabel->box(FL_THIN_DOWN_BOX); |
| 964 | + |
| 965 | + // quicknote - very brief item info |
| 966 | + app->quickNote = new SVQuickNoteBox(0, 22, 100, 50); |
| 967 | + app->quickNote->labelsize(app->nAppFontSize); |
| 968 | + app->quickNote->align(FL_ALIGN_TOP_LEFT | FL_ALIGN_INSIDE); |
| 969 | + app->quickNote->box(FL_THIN_DOWN_BOX); |
| 970 | + //// app->quickNote->labelfont(1); |
| 971 | + |
| 972 | + app->quickNoteGroup->end(); |
| 973 | + |
854 | 974 | // create scrolling window we will add viewers to |
855 | 975 | app->scroller = new Fl_Scroll(0, 0, 0, 0); |
856 | 976 | app->vncViewer = new VncViewer(0, 0, 0, 0); |
857 | 977 | app->scroller->box(FL_FLAT_BOX); |
858 | 978 | app->scroller->type(0); |
859 | 979 | app->scroller->end(); |
860 | 980 |
|
861 | | - // create host list |
862 | | - app->hostList = new Fl_Hold_Browser(0, 0, 0, 0); |
863 | | - app->hostList->clear_visible_focus(); |
864 | | - app->hostList->callback(svHandleHostListEvents, NULL); |
865 | | - app->hostList->box(FL_THIN_DOWN_BOX); |
866 | | - |
| 981 | + // set resizable widget for whole app |
867 | 982 | app->mainWin->resizable(app->scroller); |
868 | 983 | } |
869 | 984 |
|
@@ -1086,6 +1201,9 @@ void svHandleAppOptionsButtons (Fl_Widget * widget, void *) |
1086 | 1201 | if (strName == "spinDeadTimeout") |
1087 | 1202 | app->nDeadTimeout = static_cast<Fl_Spinner *>(wid)->value(); |
1088 | 1203 |
|
| 1204 | + if (strName == "inSSHCommand") |
| 1205 | + app->sshCommand = static_cast<SVInput *>(wid)->value(); |
| 1206 | + |
1089 | 1207 | if (strName == "inAppFontSize") |
1090 | 1208 | app->nAppFontSize = atoi(static_cast<SVInput *>(wid)->value()); |
1091 | 1209 |
|
@@ -1354,12 +1472,22 @@ void svHandleHostListEvents (Fl_Widget *, void *) |
1354 | 1472 | HostItem * itm = static_cast<HostItem *>(app->hostList->data(nHostItemNum)); |
1355 | 1473 |
|
1356 | 1474 | if (itm == NULL) |
| 1475 | + { |
| 1476 | + // set itm's quicknote text, if any |
| 1477 | + app->quickNoteLabel->label(""); |
| 1478 | + app->quickNote->label(""); |
| 1479 | + |
1357 | 1480 | return; |
| 1481 | + } |
1358 | 1482 |
|
1359 | 1483 | VncObject * vnc = itm->vnc; |
1360 | 1484 |
|
1361 | 1485 | static bool menuUp; |
1362 | 1486 |
|
| 1487 | + // set itm's quicknote text, if any |
| 1488 | + app->quickNoteLabel->copy_label(itm->name.c_str()); |
| 1489 | + app->quickNote->copy_label(itm->quickNote.c_str()); |
| 1490 | + |
1363 | 1491 | // *** DO *NOT* CHECK vnc FOR NULL HERE!!! *** |
1364 | 1492 | // *** IT'S OKAY IF vnc IS NULL AT THIS POINT!!! *** |
1365 | 1493 |
|
@@ -1903,20 +2031,49 @@ void svHandleMainWindowEvents (Fl_Widget * window, void *) |
1903 | 2031 | } |
1904 | 2032 |
|
1905 | 2033 |
|
| 2034 | +/* handle quicknote's box events (mostly clicks) */ |
| 2035 | +void svHandleQuickNoteWindowEvents (Fl_Widget *, void *) |
| 2036 | +{ |
| 2037 | + int event = app->quickNoteWindow->when(); |
| 2038 | + |
| 2039 | + // window is closing |
| 2040 | + if (event == FL_LEAVE) |
| 2041 | + { |
| 2042 | + app->quickNoteInput->value(""); |
| 2043 | + app->quickNoteWindow->hide(); |
| 2044 | + } |
| 2045 | +} |
| 2046 | + |
| 2047 | + |
1906 | 2048 | /* |
1907 | 2049 | * handle app and main window events, such as resize, move, etc |
1908 | 2050 | * and resize gui elements |
1909 | 2051 | */ |
1910 | 2052 | void svPositionWidgets () |
1911 | 2053 | { |
1912 | | - // only continue if main window geometry changes |
1913 | 2054 | svDebugLog("svPositionWidgets - Resizing GUI elements"); |
1914 | 2055 |
|
1915 | 2056 | // resize the host list vertically if the main window resizes |
1916 | | - app->hostList->size(app->hostList->w(), app->mainWin->h() - 26); |
| 2057 | + app->hostList->size(app->hostList->w(), |
| 2058 | + app->mainWin->h() - //155); //26); |
| 2059 | + app->quickNoteGroup->h() - |
| 2060 | + //app->quickNoteLabel->h() - app->quickNote->h() - |
| 2061 | + app->packButtons->h()); |
| 2062 | + |
| 2063 | + // position QuickNote stuff |
| 2064 | + app->quickNoteGroup->size(app->hostList->w(), app->quickNoteGroup->h() - 3); |
| 2065 | + app->quickNoteGroup->position(0, app->hostList->y() + app->hostList->h() + 3); |
| 2066 | + |
| 2067 | + app->quickNoteLabel->size(app->hostList->w(), app->quickNoteLabel->h() - 3); |
| 2068 | + //app->quickNoteLabel->position(0, app->hostList->y() + app->hostList->h() + 3); |
| 2069 | + |
| 2070 | + app->quickNote->size(app->hostList->w(), app->quickNote->h() - 3); |
| 2071 | + //app->quickNote->position(0, app->quickNoteLabel->y() + app->quickNoteLabel->h() + 3); |
1917 | 2072 |
|
1918 | 2073 | // set list buttons position |
1919 | | - app->packButtons->position(3, app->hostList->x() + app->hostList->h() + 3); |
| 2074 | + // app->packButtons->position(3, app->hostList->x() + app->hostList->h() + 3); |
| 2075 | + app->packButtons->position(0, app->quickNote->y() + app->quickNote->h() |
| 2076 | + + 3); |
1920 | 2077 |
|
1921 | 2078 | // don't allow host list width to be smaller than right-most button's x+w |
1922 | 2079 | if (app->hostList->w() < (app->packButtons->x() + app->packButtons->w())) |
@@ -2603,17 +2760,8 @@ void svShowAppOptions () |
2603 | 2760 | // create window |
2604 | 2761 | Fl_Window * winAppOpts = new Fl_Window(nX, nY, nWinWidth, nWinHeight, "Application Options"); //NULL); |
2605 | 2762 | winAppOpts->set_non_modal(); |
2606 | | - //winAppOpts->box(FL_GTK_UP_BOX); |
2607 | 2763 | app->childWindowBeingDisplayed = winAppOpts; |
2608 | 2764 |
|
2609 | | - //// add main top label, showing itm name |
2610 | | - //Fl_Box * bxTopLabel = new Fl_Box(0, 0, nWinWidth, 28, "Application Options"); |
2611 | | - //bxTopLabel->align(FL_ALIGN_CENTER); |
2612 | | - //bxTopLabel->labelfont(1); |
2613 | | - //bxTopLabel->labelsize(app->nAppFontSize); |
2614 | | - //bxTopLabel->box(FL_GTK_UP_BOX); |
2615 | | - //bxTopLabel->color(17); |
2616 | | - |
2617 | 2765 | // add itm value editors / selectors |
2618 | 2766 | int nXPos = 300; |
2619 | 2767 | int nYStep = 31; |
@@ -2666,6 +2814,16 @@ void svShowAppOptions () |
2666 | 2814 | spinDeadTimeout->tooltip("This is the time, in seconds, SpiritVNC waits before" |
2667 | 2815 | " disconnecting a remote host due to inactivity"); |
2668 | 2816 |
|
| 2817 | + // ssh command |
| 2818 | + SVInput * inSSHCommand = new SVInput(nXPos, nYPos += nYStep, 210, 28, |
| 2819 | + "SSH command (eg: ssh or /usr/bin/ssh) "); |
| 2820 | + inSSHCommand->textsize(app->nAppFontSize); |
| 2821 | + inSSHCommand->labelsize(app->nAppFontSize); |
| 2822 | + inSSHCommand->user_data(SV_OPTS_SSH_COMMAND); |
| 2823 | + inSSHCommand->value(app->sshCommand.c_str()); |
| 2824 | + if (app->showTooltips == true) |
| 2825 | + inSSHCommand->tooltip("This is the command to start the SSH client on" |
| 2826 | + " your system"); |
2669 | 2827 |
|
2670 | 2828 | Fl_Box * lblSep01 = new Fl_Box(nXPos, nYPos += nYStep + 14, 100, 28, "Appearance Options"); |
2671 | 2829 | lblSep01->labelsize(app->nAppFontSize); |
|
0 commit comments