diff options
Diffstat (limited to 'plugins/OpenFolder/src')
-rw-r--r-- | plugins/OpenFolder/src/openFolder.cpp | 127 | ||||
-rw-r--r-- | plugins/OpenFolder/src/openFolder.h | 22 | ||||
-rw-r--r-- | plugins/OpenFolder/src/resource.h | 18 |
3 files changed, 167 insertions, 0 deletions
diff --git a/plugins/OpenFolder/src/openFolder.cpp b/plugins/OpenFolder/src/openFolder.cpp new file mode 100644 index 0000000000..a39420ae73 --- /dev/null +++ b/plugins/OpenFolder/src/openFolder.cpp @@ -0,0 +1,127 @@ +#include "openFolder.h"
+
+int hLangpack = 0;
+HINSTANCE hInst;
+HANDLE hServiceOpenFolder, hButtonTopToolbar, hIconOpenFolder;
+
+PLUGININFOEX pluginInfoEx =
+{
+ sizeof( PLUGININFOEX ),
+ "Open Miranda Folder",
+ OPENFOLDER_VERSION,
+ OPENFOLDER_DESCRIPTION,
+ "jarvis, Kreisquadratur",
+ "jarvis@jabber.cz, djui@kreisquadratur.de",
+ "© 2008 jarvis, © 2004 Kreisquadratur",
+ "http://nightly.miranda.im/",
+ UNICODE_AWARE, //not transient
+ MIID_OPENFOLDER // {10896143-7249-4b36-A408-6501A6B6035A}
+};
+
+BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+static INT_PTR MenuCommand_OpenFolder(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR szMirandaPath[MAX_PATH];
+ GetModuleFileName( GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath));
+ TCHAR* p = _tcsrchr( szMirandaPath, '\\' );
+ if ( p && p + 1 )
+ *( p + 1 ) = 0;
+
+ if ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 )
+ ShellExecute(0, _T("explore"), szMirandaPath, 0, 0, SW_SHOWNORMAL);
+ else
+ ShellExecute(0, _T("open"), szMirandaPath, 0, 0, SW_SHOWNORMAL);
+
+ return 0;
+}
+
+// toptoolbar (if plugin is installed)
+static int ToptoolBarHook(WPARAM wParam, LPARAM lParam)
+{
+ TTBButton ttbb = { 0 };
+ ttbb.cbSize = sizeof( ttbb );
+ ttbb.hIconHandleUp = hIconOpenFolder;
+ ttbb.pszService = MS_OPENFOLDER_OPEN;
+ ttbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
+ ttbb.name = LPGEN("Open Folder");
+ TopToolbar_AddButton(&ttbb);
+ return 0;
+}
+
+static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR szFile[MAX_PATH];
+ GetModuleFileName( hInst, szFile, MAX_PATH );
+
+ char szSettingName[64];
+ mir_snprintf(szSettingName, sizeof( szSettingName ), "%s_%s", OPENFOLDER_MODULE_NAME, "open");
+
+ // icolib (0.7+)
+ SKINICONDESC sid = { 0 };
+ sid.cbSize = sizeof( SKINICONDESC );
+ sid.ptszDefaultFile = szFile;
+ sid.flags = SIDF_PATH_TCHAR;
+ sid.cx = sid.cy = 16;
+ sid.pszSection = LPGEN("Open Folder");
+ sid.pszName = szSettingName;
+ sid.pszDescription = LPGEN("Open Folder");
+ sid.iDefaultIndex = -IDI_FOLDER;
+ hIconOpenFolder = Skin_AddIcon(&sid);
+
+ // hotkeys service (0.8+)
+ HOTKEYDESC hotkey = { 0 };
+ hotkey.cbSize = sizeof( hotkey );
+ hotkey.pszName = LPGEN("Open Folder");
+ hotkey.pszDescription = LPGEN("Open Folder");
+ hotkey.pszSection = "Main";
+ hotkey.pszService = MS_OPENFOLDER_OPEN;
+ hotkey.DefHotKey = MAKEWORD( 'O', HOTKEYF_SHIFT | HOTKEYF_ALT );
+ Hotkey_Register(&hotkey);
+
+ CLISTMENUITEM mi = { 0 };
+ mi.cbSize = sizeof( mi );
+ mi.position = 0x7FFFFFFF;
+ mi.flags = CMIF_ICONFROMICOLIB;
+ mi.icolibItem = hIconOpenFolder;
+ mi.pszName = LPGEN("Open Folder");
+ mi.pszService = MS_OPENFOLDER_OPEN;
+ Menu_AddMainMenuItem(&mi);
+ return 0;
+}
+
+HICON LoadIconExEx( const char* IcoLibName, int NonIcoLibIcon )
+{
+ char szSettingName[64];
+ mir_snprintf( szSettingName, sizeof( szSettingName ), "%s_%s", OPENFOLDER_MODULE_NAME, IcoLibName );
+ return Skin_GetIcon(szSettingName);
+}
+
+extern "C" __declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD mirandaVersion )
+{
+ return &pluginInfoEx;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" int __declspec( dllexport ) Load()
+{
+ mir_getLP(&pluginInfoEx);
+
+ hServiceOpenFolder = CreateServiceFunction(MS_OPENFOLDER_OPEN, MenuCommand_OpenFolder);
+
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" int __declspec( dllexport ) Unload()
+{
+ DestroyServiceFunction(hServiceOpenFolder);
+ return 0;
+}
diff --git a/plugins/OpenFolder/src/openFolder.h b/plugins/OpenFolder/src/openFolder.h new file mode 100644 index 0000000000..d7eb02dad8 --- /dev/null +++ b/plugins/OpenFolder/src/openFolder.h @@ -0,0 +1,22 @@ +#include <windows.h>
+#include <commctrl.h>
+#include "resource.h"
+
+#include <newpluginapi.h>
+#include <m_clist.h>
+#include <m_icolib.h>
+#include <m_langpack.h>
+#include <m_skin.h>
+#include <m_system.h>
+#include <m_utils.h>
+#include <m_hotkeys.h>
+#include <m_toptoolbar.h>
+#include <win2k.h>
+
+#define MS_OPENFOLDER_OPEN "openFolder/Open"
+
+#define OPENFOLDER_VERSION PLUGIN_MAKE_VERSION( 1, 1, 0, 0 )
+#define OPENFOLDER_DESCRIPTION "Adds a menu/toobar item which opens the main Miranda IM folder."
+#define MIID_OPENFOLDER { 0x10896143, 0x7249, 0x4b36, { 0xa4, 0x8, 0x65, 0x1, 0xa6, 0xb6, 0x3, 0x5a } }
+//#define OPENFOLDER_DB_MODULENAME "openFolder"
+#define OPENFOLDER_MODULE_NAME "openfolder"
diff --git a/plugins/OpenFolder/src/resource.h b/plugins/OpenFolder/src/resource.h new file mode 100644 index 0000000000..599c82bbba --- /dev/null +++ b/plugins/OpenFolder/src/resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDI_FOLDER 101
+#define IDB_BITMAP1 103
+#define IDB_FOLDER 103
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
|