diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-03-17 06:22:14 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-03-17 06:22:14 +0000 |
commit | 0dccd307d189bf1e3fb98a85f5fbca8d4b1095e2 (patch) | |
tree | e3ada9b1bc326f1567fe03e9cdaa884f8505709c /plugins/LangMan/src | |
parent | 8fed87c869ef9ca38d07f7d7c866ac9bd81a3f90 (diff) |
LangMan:
- reverted reload menu item
- when plugin is disabled, selected langpack will be moved to root folder
git-svn-id: http://svn.miranda-ng.org/main/trunk@8646 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/LangMan/src')
-rw-r--r-- | plugins/LangMan/src/langpack.cpp | 12 | ||||
-rw-r--r-- | plugins/LangMan/src/langpack.h | 6 | ||||
-rw-r--r-- | plugins/LangMan/src/main.cpp | 42 | ||||
-rw-r--r-- | plugins/LangMan/src/resource.h | 6 |
4 files changed, 47 insertions, 19 deletions
diff --git a/plugins/LangMan/src/langpack.cpp b/plugins/LangMan/src/langpack.cpp index cab1a6d116..e292c16c74 100644 --- a/plugins/LangMan/src/langpack.cpp +++ b/plugins/LangMan/src/langpack.cpp @@ -135,7 +135,7 @@ static void CleanupLastModifiedUsing(char *szLastModifiedUsing, int nSize) // pack struct should be initialized to zero before call
// pack->szFileName needs to be filled in before call
-static BOOL LoadPackData(LANGPACK_INFO *pack, BOOL fEnabledPacks, const char *pszFileVersionHeader)
+static BOOL LoadPackData(LANGPACK_INFO *pack, BOOL useRootFolder, const char *pszFileVersionHeader)
{
FILE *fp;
TCHAR szFileName[MAX_PATH];
@@ -153,7 +153,7 @@ static BOOL LoadPackData(LANGPACK_INFO *pack, BOOL fEnabledPacks, const char *ps X-Version: 1.2.3.4 (non-standard extension)
see 'LangMan-Translation.txt' for some header quidelines
*/
- if ( !GetPackPath( szFileName, SIZEOF(szFileName), fEnabledPacks, pack->szFileName))
+ if ( !GetPackPath( szFileName, SIZEOF(szFileName), useRootFolder, pack->szFileName))
return FALSE;
fp = _tfopen(szFileName, _T("rt"));
@@ -236,7 +236,7 @@ static BOOL LoadPackData(LANGPACK_INFO *pack, BOOL fEnabledPacks, const char *ps /************************* Enum ***************************************/
-BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL fEnabledPacks, const TCHAR *pszFile)
+BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL useRootFolder, const TCHAR *pszFile)
{
TCHAR *p;
/* main path */
@@ -244,7 +244,7 @@ BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL fEnabledPacks, const TCHAR *psz p = _tcsrchr(pszPath, _T('\\'));
if (p!=NULL) *(p+1) = _T('\0');
/* subdirectory */
- if (!fEnabledPacks) {
+ if (!useRootFolder) {
if (nSize<(lstrlen(pszPath)+10)) return FALSE;
lstrcat(pszPath, _T("Languages\\"));
}
@@ -268,7 +268,7 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const mir_ptr<TCHAR> langpack(db_get_tsa(NULL, "LangMan", "Langpack"));
- /* enabled packs */
+ /* langpacks in root folder */
if (GetPackPath(pack.szFileName, SIZEOF(pack.szFileName), TRUE, pszFilePattern)) {
hFind = FindFirstFile(pack.szFileName, &wfd);
if (hFind!=INVALID_HANDLE_VALUE) {
@@ -294,7 +294,7 @@ BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const }
}
- /* disabled packs */
+ /* langpacks in languages folder */
if (GetPackPath(pack.szFileName, SIZEOF(pack.szFileName), FALSE, pszFilePattern)) {
hFind = FindFirstFile(pack.szFileName, &wfd);
if (hFind!=INVALID_HANDLE_VALUE) {
diff --git a/plugins/LangMan/src/langpack.h b/plugins/LangMan/src/langpack.h index 0468340c55..01280c757e 100644 --- a/plugins/LangMan/src/langpack.h +++ b/plugins/LangMan/src/langpack.h @@ -39,8 +39,10 @@ typedef struct { BYTE flags; /* see LPIF_* flags */
} LANGPACK_INFO;
+BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL useRootFolder, const TCHAR *pszFile);
+
+void MovePacks(const TCHAR *pszFilePattern);
+
/* Enum */
-BOOL GetPackPath(TCHAR *pszPath, int nSize, BOOL fEnabledPacks, const TCHAR *pszFile);
typedef BOOL (*ENUM_PACKS_CALLBACK)(LANGPACK_INFO *pack, WPARAM wParam, LPARAM lParam);
BOOL EnumPacks(ENUM_PACKS_CALLBACK callback, const TCHAR *pszFilePattern, const char *pszFileVersionHeader, WPARAM wParam, LPARAM lParam);
-void MovePacks(const TCHAR *pszFilePattern);
\ No newline at end of file diff --git a/plugins/LangMan/src/main.cpp b/plugins/LangMan/src/main.cpp index 124a35427f..7e471e4849 100644 --- a/plugins/LangMan/src/main.cpp +++ b/plugins/LangMan/src/main.cpp @@ -21,9 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "common.h"
-HINSTANCE hInst;
-
int hLangpack;
+HINSTANCE hInst;
static PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
@@ -99,25 +98,32 @@ extern "C" __declspec(dllexport) int Load(void) {
mir_getLP( &pluginInfo );
- if (!IsRunAsAdmin())
- MovePacks(_T("langpack_*.txt"));
+ //if (!IsRunAsAdmin())
+ MovePacks(_T("langpack_*.txt"));
/*INITCOMMONCONTROLSEX icc;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_TREEVIEW_CLASSES|ICC_USEREX_CLASSES;
InitCommonControlsEx(&icc);*/
- TCHAR *langpack = db_get_tsa(NULL, "LangMan", "Langpack");
+ /* menu item */
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.position = 2000089999;
+ mi.icolibItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RELOAD));
+ mi.pszName = LPGEN("Reload langpack");
+ mi.pszService = MS_LANGPACK_RELOAD;
+ Menu_AddMainMenuItem(&mi);
+
+ /* reset langpack */
+ mir_ptr<TCHAR> langpack(db_get_tsa(NULL, "LangMan", "Langpack"));
if (langpack)
{
- TCHAR szPath[MAX_PATH], szFile[MAX_PATH];
- mir_sntprintf(szFile, MAX_PATH, _T("Languages\\%s"), langpack);
- GetPackPath(szPath, SIZEOF(szPath), TRUE, CharLower(szFile));
+ TCHAR szPath[MAX_PATH];
+ GetPackPath(szPath, SIZEOF(szPath), FALSE, langpack);
DWORD dwAttrib = GetFileAttributes(szPath);
if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
CallService(MS_LANGPACK_RELOAD, 0, (LPARAM)szPath);
- mir_free(langpack);
}
InitOptions();
@@ -129,5 +135,23 @@ extern "C" __declspec(dllexport) int Unload(void) {
UninitOptions();
+ /* move default langpack to root */
+ mir_ptr<TCHAR> langpack(db_get_tsa(NULL, "LangMan", "Langpack"));
+ if (langpack)
+ {
+ TCHAR szFrom[MAX_PATH], szDest[MAX_PATH];
+ GetPackPath(szFrom, SIZEOF(szFrom), FALSE, langpack);
+
+ DWORD dwAttrib = GetFileAttributes(szFrom);
+ if (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ GetPackPath(szDest, SIZEOF(szDest), TRUE, langpack);
+ if (!MoveFile(szFrom, szDest) && GetLastError() == ERROR_ALREADY_EXISTS) {
+ DeleteFile(szDest);
+ MoveFile(szFrom, szDest);
+ }
+ }
+ }
+
return 0;
}
\ No newline at end of file diff --git a/plugins/LangMan/src/resource.h b/plugins/LangMan/src/resource.h index bc7f8958ec..30e82b3fc0 100644 --- a/plugins/LangMan/src/resource.h +++ b/plugins/LangMan/src/resource.h @@ -1,10 +1,12 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by E:\Projects\C++\MirandaNG\plugins\LangMan\res\resource.rc
+// Used by d:\Projects\CPlusPlus\MirandaNG\plugins\LangMan\res\resource.rc
//
#define IDD_OPT_LANG 101
#define IDD_UPDATENOTIFY 102
#define IDD_DOWNLOADLANG 103
+#define IDI_ICON1 104
+#define IDI_RELOAD 104
#define IDC_LANGLIST 1001
#define IDC_LANGINFOFRAME 1002
#define IDC_LANGAUTHORSLABEL 1003
@@ -42,7 +44,7 @@ #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1029
#define _APS_NEXT_SYMED_VALUE 2001
|