Permalink
Browse files

PuTTy Tray 0.60 v3: Trayicon

  • Loading branch information...
1 parent 7385cb5 commit 0e56433b02a634366f2d976873e13ee54db25f36 @FauxFaux committed Feb 5, 2011
Showing with 803 additions and 72 deletions.
  1. +2 −0 Recipe
  2. +1 −1 config.c
  3. +9 −0 dialog.c
  4. +26 −1 dialog.h
  5. +35 −0 putty.h
  6. +28 −0 settings.c
  7. +59 −0 windows/pickicondialog.c
  8. +19 −0 windows/pickicondialog.h
  9. +58 −1 windows/wincfg.c
  10. +63 −0 windows/winctrls.c
  11. +10 −6 windows/windlg.c
  12. +443 −63 windows/window.c
  13. +50 −0 windows/winmisc.c
View
2 Recipe
@@ -250,6 +250,7 @@ TERMINAL = terminal wcwidth ldiscucs logging tree234 minibidi
# GUI front end and terminal emulator (putty, puttytel).
GUITERM = TERMINAL window windlg winctrls sizetip winucs winprint
+ winutils wincfg sercfg winhelp winjump
+ + pickicondialog
# Same thing on Unix.
UXTERM = TERMINAL uxcfg sercfg uxucs uxprint timing
@@ -321,6 +322,7 @@ puttygen : [G] winpgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
+ sshrand winnoise sshsha winstore misc winctrls sshrsa sshdss winmisc
+ sshpubk sshaes sshsh256 sshsh512 import winutils puttygen.res
+ tree234 notiming winhelp winnojmp LIBS wintime
+ + pickicondialog
pterm : [X] GTKTERM uxmisc misc ldisc settings uxpty uxsel BE_NONE uxstore
+ uxsignal CHARSET cmdline uxpterm version time xpmpterm xpmptcfg
View
@@ -1831,7 +1831,7 @@ void setup_config_box(struct controlbox *b, int midsession,
s = ctrl_getset(b, "Connection", "tcp",
"Low-level TCP connection options");
ctrl_checkbox(s, "Disable Nagle's algorithm (TCP_NODELAY option)",
- 'n', HELPCTX(connection_nodelay),
+ 'l', HELPCTX(connection_nodelay),
dlg_stdcheckbox_handler,
I(offsetof(Config,tcp_nodelay)));
ctrl_checkbox(s, "Enable TCP keepalives (SO_KEEPALIVE option)",
View
@@ -272,6 +272,15 @@ union control *ctrl_combobox(struct controlset *s, char *label, char shortcut,
}
/*
+ * HACK: PuttyTray / Session Icon
+ */
+union control *ctrl_icon(struct controlset *s, intorptr helpctx, intorptr context)
+{
+ union control *c = ctrl_new(s, CTRL_ICON, helpctx, NULL, context);
+ return c;
+};
+
+/*
* `ncolumns' is followed by (alternately) radio button titles and
* intorptrs, until a NULL in place of a title string is seen. Each
* title is expected to be followed by a shortcut _iff_ `shortcut'
View
@@ -35,7 +35,13 @@ enum {
CTRL_COLUMNS, /* divide window into columns */
CTRL_FILESELECT, /* label plus filename selector */
CTRL_FONTSELECT, /* label plus font selector */
- CTRL_TABDELAY /* see `tabdelay' below */
+ CTRL_TABDELAY, /* see `tabdelay' below */
+
+ /*
+ * HACK: PuttyTray / Session Icon
+ * Add ctrl_icon, ctrl_path, ctrl_sessionlistbox
+ */
+ CTRL_ICON /* static icon without label */
};
/*
@@ -404,6 +410,15 @@ union control {
STANDARD_PREFIX;
char shortcut;
} fontselect;
+
+ /*
+ * HACK: PuttyTray / Session Icon
+ */
+ struct {
+ STANDARD_PREFIX;
+ intorptr handle;
+ } icon;
+ //--------------
};
#undef STANDARD_PREFIX
@@ -522,6 +537,16 @@ union control *ctrl_checkbox(struct controlset *, char *label, char shortcut,
union control *ctrl_tabdelay(struct controlset *, union control *);
/*
+ * HACK: PuttyTray / Session Icon
+ */
+union control *ctrl_icon(struct controlset *, intorptr helpctx, intorptr context);
+
+// Should be somewhere below, but this is easier
+void dlg_icon_set(union control *ctrl, void *dlg, char const *icon);
+int dlg_pick_icon(void *dlg, char **iname, int inamesize, int *iindex);
+//------------------------------------
+
+/*
* Standard handler routines to cover most of the common cases in
* the config box.
*/
View
35 putty.h
@@ -137,6 +137,30 @@ typedef struct terminal_tag Terminal;
#define ATTR_DEFBG (258 << ATTR_BGSHIFT)
#define ATTR_DEFAULT (ATTR_DEFFG | ATTR_DEFBG)
+/*
+ * HACK: PuttyTray / Nutty
+ * Hyperlink stuff: define
+ */
+#define CHAR_MASK 0x000000FFUL
+
+/*
+ * HACK: PuttyTray / Nutty
+ * Hyperlink stuff: Underline settings
+ */
+enum {
+ URLHACK_UNDERLINE_ALWAYS,
+ URLHACK_UNDERLINE_HOVER,
+ URLHACK_UNDERLINE_NEVER
+};
+
+/*
+ * HACK: PuttyTray
+ * Tray options
+ */
+enum {
+ TRAY_NEVER, TRAY_NORMAL, TRAY_START, TRAY_ALWAYS
+};
+
struct sesslist {
int nsessions;
char **sessions;
@@ -683,6 +707,17 @@ struct config_tag {
* HACK: PuttyTray / PuTTY File
*/
int session_storagetype;
+ /*
+ * HACK: PuttyTray
+ */
+ int tray;
+ int start_tray;
+ int tray_restore;
+
+ /*
+ * HACK: PuttyTray / Session Icon
+ */
+ char win_icon[256];
};
/*
View
@@ -451,6 +451,20 @@ void save_open_settings(void *sesskey, Config *cfg)
*/
write_setting_i(sesskey, "StorageType", cfg->session_storagetype);
+ /*
+ * HACK: PuttyTray
+ * Save tray settings
+ */
+ write_setting_i(sesskey, "Tray", cfg->tray);
+ write_setting_i(sesskey, "StartTray", cfg->start_tray);
+ write_setting_i(sesskey, "TrayRestore", cfg->tray_restore);
+
+
+ /*
+ * HACK: PuttyTray / Session Icon
+ */
+ write_setting_s(sesskey, "WindowIcon", cfg->win_icon);
+
write_setting_i(sesskey, "AltF4", cfg->alt_f4);
write_setting_i(sesskey, "AltSpace", cfg->alt_space);
write_setting_i(sesskey, "AltOnly", cfg->alt_only);
@@ -790,6 +804,20 @@ void load_open_settings(void *sesskey, Config *cfg)
*/
gppi(sesskey, "StorageType", 0, &cfg->session_storagetype);
+ /*
+ * HACK: PuttyTray
+ * Save tray settings
+ */
+ gppi(sesskey, "Tray", TRAY_NEVER, &cfg->tray);
+ gppi(sesskey, "StartTray", 0, &cfg->start_tray);
+ gppi(sesskey, "TrayRestore", 0, &cfg->tray_restore);
+
+
+ /*
+ * HACK: PuttyTray / Session Icon
+ */
+ gpps(sesskey, "WindowIcon", "", cfg->win_icon, sizeof(cfg->win_icon));
+
gppi(sesskey, "AltF4", 1, &cfg->alt_f4);
gppi(sesskey, "AltSpace", 0, &cfg->alt_space);
gppi(sesskey, "AltOnly", 0, &cfg->alt_only);
View
@@ -0,0 +1,59 @@
+/*
+ * HACK: PuttyTray / Session Icon
+ * Added this file
+ */
+#include <windows.h>
+typedef WINSHELLAPI BOOL(WINAPI * fnPickIconDlg) (HWND hWndParent, LPTSTR pszFilename, LPDWORD pdwBufferSize, LPDWORD pdwIndex);
+
+BOOL SelectIconA(HWND hWndParent, LPSTR lpszFilename, DWORD dwBufferSize, DWORD * pdwIndex) {
+ BOOL result = FALSE;
+ OSVERSIONINFO versioninfo;
+ HMODULE hShell32 = LoadLibrary("shell32.dll");
+ versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&versioninfo);
+
+ if (hShell32) {
+ fnPickIconDlg PickIconDlg = (fnPickIconDlg) GetProcAddress(hShell32, (LPCSTR) 62);
+ if (PickIconDlg) {
+ if (versioninfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ LPWSTR pszWideName = (LPWSTR) malloc(dwBufferSize);
+ MultiByteToWideChar(CP_ACP, 0, lpszFilename, -1, pszWideName, dwBufferSize);
+ result = PickIconDlg(hWndParent, (LPTSTR) pszWideName, &dwBufferSize, pdwIndex);
+ WideCharToMultiByte(CP_ACP, 0, pszWideName, -1, lpszFilename, dwBufferSize, NULL, NULL);
+ free(pszWideName);
+ } else {
+ result = PickIconDlg(hWndParent, (LPTSTR) lpszFilename, &dwBufferSize, pdwIndex);
+ }
+ }
+ FreeLibrary(hShell32);
+ }
+
+ return result;
+}
+
+
+BOOL SelectIconW(HWND hWndParent, LPWSTR lpszFilename, DWORD dwBufferSize, DWORD * pdwIndex) {
+ BOOL result = FALSE;
+ OSVERSIONINFO versioninfo;
+ HMODULE hShell32 = LoadLibrary("shell32.dll");
+ versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&versioninfo);
+
+ if (hShell32) {
+ fnPickIconDlg PickIconDlg = (fnPickIconDlg) GetProcAddress(hShell32, (LPCSTR) 62);
+ if (PickIconDlg) {
+ if (versioninfo.dwPlatformId != VER_PLATFORM_WIN32_NT) {
+ LPSTR pszMBName = (LPSTR) malloc(dwBufferSize);
+ WideCharToMultiByte(CP_ACP, 0, lpszFilename, -1, pszMBName, dwBufferSize, NULL, NULL);
+ result = PickIconDlg(hWndParent, (LPTSTR) pszMBName, &dwBufferSize, pdwIndex);
+ MultiByteToWideChar(CP_ACP, 0, pszMBName, -1, lpszFilename, dwBufferSize);
+ free(pszMBName);
+ } else {
+ result = PickIconDlg(hWndParent, (LPTSTR) lpszFilename, &dwBufferSize, pdwIndex);
+ }
+ }
+ FreeLibrary(hShell32);
+ }
+
+ return result;
+}
View
@@ -0,0 +1,19 @@
+/*
+ * HACK: PuttyTray / Session Icon
+ * Added this file
+ */
+
+#ifndef _SELECTICON_H_
+#define _SELECTICON_H_
+
+BOOL SelectIconW(HWND hWndParent, LPWSTR lpszFilename, DWORD dwBufferSize, DWORD * pdwIndex);
+BOOL SelectIconA(HWND hWndParent, LPSTR lpszFilename, DWORD dwBufferSize, DWORD * pdwIndex);
+
+#ifdef _UNICODE
+#define SelectIcon SelectIconW
+#else
+#define SelectIcon SelectIconA
+#endif
+
+
+#endif
View
@@ -40,6 +40,33 @@ static void variable_pitch_handler(union control *ctrl, void *dlg,
}
}
+/*
+ * HACK: PuttyTray / Session Icon
+ */
+static void window_icon_handler(union control *ctrl, void *dlg, void *data, int event)
+{
+ Config *cfg = (Config *) data;
+
+ if (event == EVENT_ACTION) {
+ char buf[512], iname[512], *ipointer;
+ int iindex;
+
+ memset(&iname, 0, sizeof(iname));
+ memset(&buf, 0, sizeof(buf));
+ iindex = 0;
+ ipointer = iname;
+ if (dlg_pick_icon(dlg, &ipointer, sizeof(iname), &iindex) /*&& iname[0]*/) {
+ if (iname[0]) {
+ sprintf(buf, "%s,%d", iname, iindex);
+ } else {
+ sprintf(buf, "%s", iname);
+ }
+ dlg_icon_set((union control *) ctrl->button.context.p, dlg, buf);
+ strcpy(cfg->win_icon, buf);
+ };
+ };
+};
+
void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
int midsession, int protocol)
{
@@ -332,7 +359,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
ctrl_checkbox(s, "Window closes on ALT-F4", '4',
HELPCTX(behaviour_altf4),
dlg_stdcheckbox_handler, I(offsetof(Config,alt_f4)));
- ctrl_checkbox(s, "System menu appears on ALT-Space", 'y',
+ ctrl_checkbox(s, "System menu appears on ALT-Space", 'm',
HELPCTX(behaviour_altspace),
dlg_stdcheckbox_handler, I(offsetof(Config,alt_space)));
ctrl_checkbox(s, "System menu appears on ALT alone", 'l',
@@ -359,6 +386,36 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
ctrl_checkbox(s, "Attempt to reconnect on system wakeup", 'w', HELPCTX(no_help), dlg_stdcheckbox_handler, I(offsetof(Config,wakeup_reconnect)));
ctrl_checkbox(s, "Attempt to reconnect on connection failure", 'f', HELPCTX(no_help), dlg_stdcheckbox_handler, I(offsetof(Config,failure_reconnect)));
+ /*
+ * HACK: PuttyTray
+ */
+ ctrl_radiobuttons(s, "Show tray icon:", NO_SHORTCUT, 4,
+ HELPCTX(no_help),
+ dlg_stdradiobutton_handler,
+ I(offsetof(Config, tray)),
+ "Normal", 'n', I(TRAY_NORMAL),
+ "Always", 'y', I(TRAY_ALWAYS),
+ "Never", 'r', I(TRAY_NEVER),
+ "On start", 's', I(TRAY_START), NULL);
+ ctrl_checkbox(s, "Accept single-click to restore from tray", 't',
+ HELPCTX(no_help),
+ dlg_stdcheckbox_handler, I(offsetof(Config,tray_restore)));
+
+ /*
+ * HACK: PuttyTray / Session Icon
+ */
+ s = ctrl_getset(b, "Window/Behaviour", "icon", "Adjust the icon");
+ ctrl_columns(s, 3, 40, 20, 40);
+ c = ctrl_text(s, "Window / tray icon:", HELPCTX(appearance_title));
+ c->generic.column = 0;
+ c = ctrl_icon(s, HELPCTX(appearance_title),
+ I(offsetof(Config, win_icon)));
+ c->generic.column = 1;
+ c = ctrl_pushbutton(s, "Change Icon...", 'h', HELPCTX(appearance_title),
+ window_icon_handler, P(c));
+ c->generic.column = 2;
+ ctrl_columns(s, 1, 100);
+
/*
* Windows supports a local-command proxy. This also means we
* must adjust the text on the `Telnet command' control.
Oops, something went wrong.

0 comments on commit 0e56433

Please sign in to comment.