[Ttssh2-commit] [4463] SSH 接続時以外は "SSH SCP" メニューをグレイアウトするようにした。

svnno****@sourc***** svnno****@sourc*****
2011年 4月 28日 (木) 15:27:03 JST


Revision: 4463
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4463
Author:   doda
Date:     2011-04-28 15:27:03 +0900 (Thu, 28 Apr 2011)

Log Message:
-----------
SSH 接続時以外は "SSH SCP" メニューをグレイアウトするようにした。

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/ttssh2/ttxssh/ttxssh.c
    trunk/ttssh2/ttxssh/ttxssh.h


-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2011-04-27 09:48:36 UTC (rev 4462)
+++ trunk/doc/en/html/about/history.html	2011-04-28 06:27:03 UTC (rev 4463)
@@ -1694,6 +1694,7 @@
         </ul></li>
       <li>added support for SSH2 MAC algorithms: hmac-sha1-96, hmac-md5-96, hmac-****@opens*****</li>
       <li>added the elapsed time and the transmit speed on the SCP dialog.</li>
+      <!-- li>SSH Ú‘±‚µ‚Ä‚¢‚È‚¢Žž‚Í SSH SCP ƒƒjƒ…[‚ð‘I‘ðo—ˆ‚È‚­‚È‚é‚悤‚É‚µ‚½B</li -->
     </ul>
   </li>
 

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2011-04-27 09:48:36 UTC (rev 4462)
+++ trunk/doc/ja/html/about/history.html	2011-04-28 06:27:03 UTC (rev 4463)
@@ -1695,6 +1695,7 @@
         </ul></li>
       <li>SSH2 ‚Ì MAC ƒAƒ‹ƒSƒŠƒYƒ€‚Æ‚µ‚Ä hmac-sha1-96, hmac-md5-96, hmac-****@opens***** ‚ðƒTƒ|[ƒg‚µ‚½B</li>
       <li>SCP ƒtƒ@ƒCƒ‹“]‘—ŽžAƒ_ƒCƒAƒƒO‚ÉŒo‰ßŽžŠÔ, “]‘—‘¬“x, ƒvƒƒOƒŒƒXƒo[‚ð•\Ž¦‚·‚é‚悤‚É‚µ‚½B</li>
+      <li>SSH Ú‘±‚µ‚Ä‚¢‚È‚¢Žž‚Í SSH SCP ƒƒjƒ…[‚ð‘I‘ðo—ˆ‚È‚­‚È‚é‚悤‚É‚µ‚½B</li>
     </ul>
   </li>
 

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2011-04-27 09:48:36 UTC (rev 4462)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2011-04-28 06:27:03 UTC (rev 4463)
@@ -2189,8 +2189,36 @@
 	}
 }
 
+#define GetFileMenu(menu)       GetSubMenuByChildID(menu, 50110) // ID_FILE_NEWCONNECTION
+#define GetEditMenu(menu)       GetSubMenuByChildID(menu, 50210) // ID_EDIT_COPY2
+#define GetSetupMenu(menu)      GetSubMenuByChildID(menu, 50310) // ID_SETUP_TERMINAL
+#define GetControlMenu(menu)    GetSubMenuByChildID(menu, 50410) // ID_CONTROL_RESETTERMINAL
+#define GetHelpMenu(menu)       GetSubMenuByChildID(menu, 50990) // ID_HELP_ABOUT
+
+HMENU GetSubMenuByChildID(HMENU menu, UINT id) {
+  int i, j, items, subitems, cur_id;
+  HMENU m;
+
+  items = GetMenuItemCount(menu);
+
+  for (i=0; i<items; i++) {
+    if (m = GetSubMenu(menu, i)) {
+      subitems = GetMenuItemCount(m);
+      for (j=0; j<subitems; j++) {
+        cur_id = GetMenuItemID(m, j);
+        if (cur_id == id) {
+          return m;
+        }
+      }
+    }
+  }
+  return NULL;
+}
+
 static void PASCAL FAR TTXModifyMenu(HMENU menu)
 {
+	pvar->FileMenu = GetFileMenu(menu);
+
 	/* inserts before ID_HELP_ABOUT */
 	UTIL_get_lang_msg("MENU_ABOUT", pvar, "About &TTSSH...");
 	insertMenuBeforeItem(menu, 50990, MF_ENABLED, ID_ABOUTMENU, pvar->ts->UIMsg);
@@ -2209,9 +2237,18 @@
 
 	/* inserts before ID_FILE_CHANGEDIR */
 	UTIL_get_lang_msg("MENU_SSH_SCP", pvar, "SS&H SCP...");
-	insertMenuBeforeItem(menu, 50170, MF_ENABLED, ID_SSHSCPMENU, pvar->ts->UIMsg);
+	insertMenuBeforeItem(menu, 50170, MF_GRAYED, ID_SSHSCPMENU, pvar->ts->UIMsg);
 }
 
+static void PASCAL FAR TTXModifyPopupMenu(HMENU menu) {
+	if (menu == pvar->FileMenu) {
+		if (pvar->cv->Ready && pvar->settings.Enabled)
+			EnableMenuItem(menu, ID_SSHSCPMENU, MF_BYCOMMAND | MF_ENABLED);
+		else
+			EnableMenuItem(menu, ID_SSHSCPMENU, MF_BYCOMMAND | MF_GRAYED);
+	}
+}
+
 static void append_about_text(HWND dlg, char FAR * prefix, char FAR * msg)
 {
 	SendDlgItemMessage(dlg, IDC_ABOUTTEXT, EM_REPLACESEL, 0,
@@ -4960,7 +4997,7 @@
 	TTXCloseTCP,
 	TTXSetWinSize,
 	TTXModifyMenu,
-	NULL,
+	TTXModifyPopupMenu,
 	TTXProcessCommand,
 	TTXEnd,
 	TTXSetCommandLine

Modified: trunk/ttssh2/ttxssh/ttxssh.h
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.h	2011-04-27 09:48:36 UTC (rev 4462)
+++ trunk/ttssh2/ttxssh/ttxssh.h	2011-04-28 06:27:03 UTC (rev 4463)
@@ -169,6 +169,8 @@
 	PWriteIniFile WriteIniFile;
 	PParseParam ParseParam;
 
+	HMENU FileMenu;
+
 	SOCKET socket;
 	HWND NotificationWindow;
 	unsigned int notification_msg;



Ttssh2-commit メーリングリストの案内