Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

61
LINES

< > BotCompany Repo | #1020554 - VNC Viewer Tray Icon

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1419K of libraries. Click here for Pure Java version (16406L/93K).

!7

concept Profile {
  S name, options;
  S computerID; // to send clipboard (optional)
}

cmodule VNCViewerTrayIcon > DynCRUD<Profile> {
  transient TrayIcon trayIcon;
  switchable bool inProcess; // don't think true works yet
  transient ReliableSingleThread rstMakeTrayIcon = dm_rst(this, r makeTrayIcon);
  
  start {
    db();
    onConceptsChangeAndNow(r { doLater(2.0, rstMakeTrayIcon) });
  }

  void makeTrayIcon enter {
    disposeTrayIcon(trayIcon);
    new L menuItems; // no left-click action
    for (Profile p : sortConceptsByID(list(Profile)))
      if (nemptyAfterTrim(p.options))
        addAll(menuItems, p.name, rThread { launch(p) });
    add(menuItems, "---");
    L<Profile> withComputerID = whereFieldNempty computerID(list(Profile));
    if (nempty(withComputerID)) {
      for (Profile p : withComputerID)
        addAll(menuItems, "Send clipboard to " + p.name, rThread { dm_sendClipboardTo_verbose(p.computerID) });
      add(menuItems, "---");
    }
    addAll(menuItems, "VNC Viewer Connection Dialog", rThread { if (inProcess) launchVNCViewer_inProcess(); else launchVNCViewer() });
    addAll(menuItems, "Edit Profiles...", rThread dm_activateOSAndModule);
    trayIcon = installTrayIcon(#1101468, "Start VNC Viewer", menuItems);
  }
  
  afterVisualize {
    // TODO: disable when at beginning/end of list
    addSelectionDependentButton("Move Up", r {
      Profile a = selected(), b = itemBefore(list(), a);
      if (a != null && b != null)
        swapConceptIDs(a, b);
    });
    addSelectionDependentButton("Move Down", r {
      Profile a = selected(), b = itemAfter(list(), a);
      if (a != null && b != null)
        swapConceptIDs(a, b);
    });
    addSelectionDependentButton("Connect", rThread {
      launch(selected());
    });
  }

  void cleanMeUp {
    disposeTrayIcon(trayIcon);
  }

  void launch(Profile p) {
    if (p == null) ret;
    if (inProcess) launchVNCViewer_inProcess(p.options); else launchVNCViewer(p.options);
  }
}

download  show line numbers  debug dex   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1020554
Snippet name: VNC Viewer Tray Icon
Eternal ID of this version: #1020554/37
Text MD5: 75eb4f721c23ff3f7693552fc1ca90b3
Transpilation MD5: 37b33878d92e0e6f92382242d35c1152
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-27 17:30:32
Source code size: 2046 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 195 / 7568
Version history: 36 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1020554 & http://1020554.tinybrain.de