summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-03-17 06:22:14 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-03-17 06:22:14 +0000
commit0dccd307d189bf1e3fb98a85f5fbca8d4b1095e2 (patch)
treee3ada9b1bc326f1567fe03e9cdaa884f8505709c /plugins
parent8fed87c869ef9ca38d07f7d7c866ac9bd81a3f90 (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')
-rw-r--r--plugins/LangMan/langman_10.vcxproj3
-rw-r--r--plugins/LangMan/langman_10.vcxproj.filters5
-rw-r--r--plugins/LangMan/langman_12.vcxproj3
-rw-r--r--plugins/LangMan/langman_12.vcxproj.filters5
-rw-r--r--plugins/LangMan/res/reload.icobin1150 -> 1150 bytes
-rw-r--r--plugins/LangMan/res/resource.rc19
-rw-r--r--plugins/LangMan/src/langpack.cpp12
-rw-r--r--plugins/LangMan/src/langpack.h6
-rw-r--r--plugins/LangMan/src/main.cpp42
-rw-r--r--plugins/LangMan/src/resource.h6
10 files changed, 82 insertions, 19 deletions
diff --git a/plugins/LangMan/langman_10.vcxproj b/plugins/LangMan/langman_10.vcxproj
index 1d01ab5cb7..b795911dbb 100644
--- a/plugins/LangMan/langman_10.vcxproj
+++ b/plugins/LangMan/langman_10.vcxproj
@@ -209,6 +209,9 @@
<ResourceCompile Include="res\resource.rc" />
<ResourceCompile Include="res\version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\reload.ico" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/plugins/LangMan/langman_10.vcxproj.filters b/plugins/LangMan/langman_10.vcxproj.filters
index 31f26531ec..2355f86131 100644
--- a/plugins/LangMan/langman_10.vcxproj.filters
+++ b/plugins/LangMan/langman_10.vcxproj.filters
@@ -53,4 +53,9 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\reload.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/plugins/LangMan/langman_12.vcxproj b/plugins/LangMan/langman_12.vcxproj
index 860d6ce922..2de7b76c1a 100644
--- a/plugins/LangMan/langman_12.vcxproj
+++ b/plugins/LangMan/langman_12.vcxproj
@@ -212,6 +212,9 @@
<ResourceCompile Include="res\resource.rc" />
<ResourceCompile Include="res\version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\reload.ico" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/plugins/LangMan/langman_12.vcxproj.filters b/plugins/LangMan/langman_12.vcxproj.filters
index 31f26531ec..2355f86131 100644
--- a/plugins/LangMan/langman_12.vcxproj.filters
+++ b/plugins/LangMan/langman_12.vcxproj.filters
@@ -53,4 +53,9 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\reload.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/plugins/LangMan/res/reload.ico b/plugins/LangMan/res/reload.ico
index feadf04bf2..1a9ce67016 100644
--- a/plugins/LangMan/res/reload.ico
+++ b/plugins/LangMan/res/reload.ico
Binary files differ
diff --git a/plugins/LangMan/res/resource.rc b/plugins/LangMan/res/resource.rc
index ac2d4a14c2..034f77e1d9 100644
--- a/plugins/LangMan/res/resource.rc
+++ b/plugins/LangMan/res/resource.rc
@@ -75,6 +75,25 @@ END
/////////////////////////////////////////////////////////////////////////////
+// Russian (Russia) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_RELOAD ICON "reload.ico"
+#endif // Russian (Russia) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
// English (United Kingdom) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
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