mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-06-14 03:16:38 +10:00
Added option to customize Pinned folder location
Items can be pinned to directories that require administative privileges (such as Open-Shell's default installation directory), so long as users take ownership of the pinned folder. Also adds a command to Open-Shell's context menu that opens the current pinned folder. Adds general support for directory-based settings by creating a new setting type called TYPE_DIRECTORY which uses a new bool added to BrowseLinkHelper, called bFoldersOnly. START_MENU_PINNED_ROOT has been removed, and all instances of both it and BrowseLinkHelper have been adjusted accordingly. To create your own directory-based settings, use CSetting::TYPE_DIRECTORY. Empty directory paths are reset to their default value as they can cause unexpected behavior.
This commit is contained in:
committed by
Ibuprophen
parent
27e5c2bc74
commit
8031739110
@@ -589,7 +589,7 @@ void CItemManager::Init( void )
|
||||
|
||||
m_RootGames=L"::{ED228FDF-9EA8-4870-83B1-96B02CFE0D52}\\";
|
||||
wchar_t text[_MAX_PATH];
|
||||
Strcpy(text,_countof(text),START_MENU_PINNED_ROOT L"\\");
|
||||
Sprintf(text,_countof(text),L"%s\\",GetSettingString(L"PinnedItemsPath"));
|
||||
DoEnvironmentSubst(text,_countof(text));
|
||||
m_RootStartMenu3=text;
|
||||
StringUpper(m_RootStartMenu3);
|
||||
@@ -2867,7 +2867,8 @@ void CItemManager::PreloadItemsThread( void )
|
||||
else if (g_CacheFolders[i].folder==FOLDERID_ClassicPinned)
|
||||
{
|
||||
if (GetSettingInt(L"PinnedPrograms")!=PINNED_PROGRAMS_PINNED) continue;
|
||||
wchar_t path[_MAX_PATH]=START_MENU_PINNED_ROOT;
|
||||
wchar_t path[_MAX_PATH];
|
||||
Strcpy(path,_countof(path),GetSettingString(L"PinnedItemsPath"));
|
||||
DoEnvironmentSubst(path,_countof(path));
|
||||
if (FAILED(SHParseDisplayName(path,NULL,&pidl,0,NULL)) || !pidl) continue;
|
||||
if (FAILED(SHCreateItemFromIDList(pidl,IID_IShellItem,(void**)&pFolder)) || !pFolder) continue;
|
||||
|
||||
@@ -470,7 +470,6 @@ STDAPI ShGetKnownFolderItem(REFKNOWNFOLDERID rfid, IShellItem **ppItem );
|
||||
HBITMAP ColorizeMonochromeImage(HBITMAP bitmap, DWORD color);
|
||||
|
||||
#define TASKBAR_PINNED_ROOT L"%APPDATA%\\Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar"
|
||||
#define START_MENU_PINNED_ROOT L"%APPDATA%\\OpenShell\\Pinned"
|
||||
#define STARTSCREEN_COMMAND L"startscreen.lnk"
|
||||
#define USERASSIST_LINKS_KEY L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\UserAssist\\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\\Count"
|
||||
#define USERASSIST_APPIDS_KEY L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\UserAssist\\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\\Count"
|
||||
|
||||
@@ -8068,7 +8068,8 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t path[_MAX_PATH]=START_MENU_PINNED_ROOT;
|
||||
wchar_t path[_MAX_PATH];
|
||||
Strcpy(path,_countof(path),GetSettingString(L"PinnedItemsPath"));
|
||||
DoEnvironmentSubst(path,_countof(path));
|
||||
SHCreateDirectory(NULL,path);
|
||||
s_PinFolder=path;
|
||||
@@ -8080,7 +8081,8 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
|
||||
{
|
||||
bool bPinned=GetSettingInt(L"PinnedPrograms")==PINNED_PROGRAMS_PINNED;
|
||||
bool bShortcut=GetSettingBool(L"StartScreenShortcut");
|
||||
wchar_t path[_MAX_PATH]=START_MENU_PINNED_ROOT L"\\" STARTSCREEN_COMMAND;
|
||||
wchar_t path[_MAX_PATH];
|
||||
Sprintf(path,_countof(path),L"%s\\%s",GetSettingString(L"PinnedItemsPath"),STARTSCREEN_COMMAND);
|
||||
DoEnvironmentSubst(path,_countof(path));
|
||||
if (bPinned)
|
||||
{
|
||||
|
||||
@@ -639,7 +639,8 @@ void CSearchManager::SearchThread( void )
|
||||
// pinned folder
|
||||
if (searchRequest.bPinnedFolder)
|
||||
{
|
||||
wchar_t path[_MAX_PATH]=START_MENU_PINNED_ROOT;
|
||||
wchar_t path[_MAX_PATH];
|
||||
Strcpy(path,_countof(path),GetSettingString(L"PinnedItemsPath"));
|
||||
DoEnvironmentSubst(path,_MAX_PATH);
|
||||
CComPtr<IShellItem> pFolder;
|
||||
if (SUCCEEDED(SHCreateItemFromParsingName(path,NULL,IID_IShellItem,(void**)&pFolder)))
|
||||
|
||||
@@ -1742,7 +1742,7 @@ LRESULT CEditMenuDlg::OnBrowseLink( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
|
||||
{
|
||||
wchar_t text[_MAX_PATH];
|
||||
GetDlgItemText(IDC_COMBOLINK,text,_countof(text));
|
||||
if (BrowseLinkHelper(m_hWnd,text))
|
||||
if (BrowseLinkHelper(m_hWnd,text,false))
|
||||
{
|
||||
SetDlgItemText(IDC_COMBOLINK,text);
|
||||
SendMessage(WM_COMMAND,MAKEWPARAM(IDC_COMBOLINK,CBN_KILLFOCUS));
|
||||
@@ -2437,7 +2437,7 @@ LRESULT CEditMenuDlg7::OnBrowseLink( WORD wNotifyCode, WORD wID, HWND hWndCtl, B
|
||||
{
|
||||
wchar_t text[_MAX_PATH];
|
||||
GetDlgItemText(IDC_EDITLINK2,text,_countof(text));
|
||||
if (BrowseLinkHelper(m_hWnd,text))
|
||||
if (BrowseLinkHelper(m_hWnd,text,false))
|
||||
{
|
||||
SetDlgItemText(IDC_EDITLINK2,text);
|
||||
SendMessage(WM_COMMAND,MAKEWPARAM(IDC_EDITLINK2,EN_KILLFOCUS));
|
||||
@@ -4280,6 +4280,7 @@ CSetting g_Settings[]={
|
||||
{L"PinnedPrograms",CSetting::TYPE_INT,IDS_PINNED_PROGRAMS,IDS_PINNED_PROGRAMS_TIP,PINNED_PROGRAMS_PINNED},
|
||||
{L"FastItems",CSetting::TYPE_RADIO,IDS_FAST_ITEMS,IDS_FAST_ITEMS_TIP},
|
||||
{L"PinnedItems",CSetting::TYPE_RADIO,IDS_PINNED_ITEMS,IDS_PINNED_ITEMS_TIP},
|
||||
{L"PinnedItemsPath",CSetting::TYPE_DIRECTORY,IDS_PINNED_PATH,IDS_PINNED_PATH_TIP,L"%APPDATA%\\OpenShell\\Pinned",0,L"PinnedPrograms=1",L"PinnedItems"},
|
||||
{L"RecentPrograms",CSetting::TYPE_INT,IDS_RECENT_PROGRAMS,IDS_RECENT_PROGRAMS_TIP,RECENT_PROGRAMS_RECENT,CSetting::FLAG_BASIC},
|
||||
{L"None",CSetting::TYPE_RADIO,IDS_NO_RECENT,IDS_NO_RECENT_TIP},
|
||||
{L"Recent",CSetting::TYPE_RADIO,IDS_SHOW_RECENT,IDS_SHOW_RECENT_TIP},
|
||||
|
||||
@@ -3856,6 +3856,7 @@ if (!g_bTrimHooks)
|
||||
CMD_OPEN,
|
||||
CMD_OPEN_ALL,
|
||||
CMD_EXPLORER,
|
||||
CMD_OPEN_PINNED,
|
||||
};
|
||||
|
||||
// right-click on the start button - open the context menu (Settings, Help, Exit)
|
||||
@@ -3876,6 +3877,8 @@ if (!g_bTrimHooks)
|
||||
AppendMenu(menu,MF_STRING,CMD_OPEN,FindTranslation(L"Menu.Open",L"&Open"));
|
||||
if (!SHRestricted(REST_NOCOMMONGROUPS))
|
||||
AppendMenu(menu,MF_STRING,CMD_OPEN_ALL,FindTranslation(L"Menu.OpenAll",L"O&pen All Users"));
|
||||
if (GetSettingInt(L"PinnedPrograms")==PINNED_PROGRAMS_PINNED)
|
||||
AppendMenu(menu,MF_STRING,CMD_OPEN_PINNED,FindTranslation(L"Menu.OpenPinned",L"O&pen Pinned"));
|
||||
AppendMenu(menu,MF_SEPARATOR,0,0);
|
||||
}
|
||||
if (GetSettingBool(L"EnableSettings"))
|
||||
@@ -3922,6 +3925,16 @@ if (!g_bTrimHooks)
|
||||
if (SUCCEEDED(ShGetKnownFolderPath((res==CMD_OPEN)?FOLDERID_StartMenu:FOLDERID_CommonStartMenu,&pPath)))
|
||||
ShellExecute(NULL,L"open",pPath,NULL,NULL,SW_SHOWNORMAL);
|
||||
}
|
||||
if (res==CMD_OPEN_PINNED) // open pinned folder
|
||||
{
|
||||
SHELLEXECUTEINFO execute={sizeof(execute)};
|
||||
CString path=GetSettingString(L"PinnedItemsPath");
|
||||
execute.lpVerb=L"open";
|
||||
execute.lpFile=path;
|
||||
execute.nShow=SW_SHOWNORMAL;
|
||||
execute.fMask=SEE_MASK_DOENVSUBST;
|
||||
ShellExecuteEx(&execute);
|
||||
}
|
||||
if (res==CMD_EXPLORER)
|
||||
{
|
||||
CString path=GetSettingString(L"ExplorerPath");
|
||||
|
||||
@@ -1044,7 +1044,7 @@ BEGIN
|
||||
IDS_FOLDERS_FIRST "Show folders first"
|
||||
IDS_FOLDERS_FIRST_TIP "When this is checked, the All Programs tree will show the folders first and the programs last"
|
||||
IDS_PINNED_PROGRAMS "Pinned Programs folder"
|
||||
IDS_PINNED_PROGRAMS_TIP "Select the location to store the pinned programs"
|
||||
IDS_PINNED_PROGRAMS_TIP "Select the location to store pinned programs. After updating this setting, close this window in order to pin items through the context menu again"
|
||||
IDS_FAST_ITEMS "Use Start Menu folder"
|
||||
END
|
||||
|
||||
@@ -1319,6 +1319,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_OPEN_TRUE_PATH "Open pinned folders to their true path"
|
||||
IDS_OPEN_TRUE_PATH_TIP "When this is checked, pinned folders will open to their true path instead of the path to their shortcut in the Pinned Programs folder"
|
||||
IDS_PINNED_PATH "Pinned folder path"
|
||||
IDS_PINNED_PATH_TIP "The path to use as the Pinned folder. If the path does not exist, it will be created (if possible) after opening the start menu. Close this window after updating this setting to update your context menu.\n\nNote: If you do not have permissions for the selected path, you will not be able to pin items until you take ownership of the new folder"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
|
||||
@@ -778,6 +778,8 @@
|
||||
#define IDS_ITEM_LINKS_TIP 3681
|
||||
#define IDS_OPEN_TRUE_PATH 3682
|
||||
#define IDS_OPEN_TRUE_PATH_TIP 3683
|
||||
#define IDS_PINNED_PATH 3684
|
||||
#define IDS_PINNED_PATH_TIP 3685
|
||||
#define IDS_STRING7001 7001
|
||||
#define IDS_STRING7002 7002
|
||||
#define IDS_STRING7003 7003
|
||||
|
||||
@@ -91,7 +91,7 @@ STDMETHODIMP CStartMenuExt::Initialize( PCIDLIST_ABSOLUTE pidlFolder, IDataObjec
|
||||
bUsePinned=(setting==1);
|
||||
if (bUsePinned)
|
||||
{
|
||||
Strcpy(m_PinFolder1,_countof(m_PinFolder1),L"%APPDATA%\\OpenShell\\Pinned\\");
|
||||
Sprintf(m_PinFolder1,_countof(m_PinFolder1),L"%s\\",GetSettingString(L"PinnedItemsPath"));
|
||||
DoEnvironmentSubst(m_PinFolder1,_countof(m_PinFolder1));
|
||||
m_PinFolder2[0]=0;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ CSetting g_Settings[]={
|
||||
{L"DisablePinExt",CSetting::TYPE_BOOL,0,0,0},
|
||||
{L"FolderStartMenu",CSetting::TYPE_STRING,0,0,L""},
|
||||
{L"FolderCommonStartMenu",CSetting::TYPE_STRING,0,0,L""},
|
||||
{L"PinnedItemsPath",CSetting::TYPE_DIRECTORY,0,0,L"%APPDATA%\\OpenShell\\Pinned"},
|
||||
|
||||
{L"Language",CSetting::TYPE_GROUP},
|
||||
{L"Language",CSetting::TYPE_STRING,0,0,L"",CSetting::FLAG_COLD|CSetting::FLAG_SHARED},
|
||||
|
||||
Reference in New Issue
Block a user