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 1372K of libraries. Click here for Pure Java version (16444L/94K).

!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, r { 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, r { dm_sendClipboardTo_verbose(p.computerID) });
      add(menuItems, "---");
    }
    addAll(menuItems, "VNC Viewer Connection Dialog", r { if (inProcess) launchVNCViewer_inProcess(); else launchVNCViewer() });
    addAll(menuItems, "Edit Profiles...", r 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 5 computer(s): cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1020554
Snippet name: VNC Viewer Tray Icon
Eternal ID of this version: #1020554/35
Text MD5: 3b172d85f5f3853c1ec963625608832c
Transpilation MD5: d08e1df7f00889da8b5d72c7c46629e8
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-15 01:40:33
Source code size: 2021 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 167 / 6753
Version history: 34 change(s)
Referenced in: [show references]

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