Browse Source

Add automatic refresh and Refresh command

master
boisso 7 years ago
parent
commit
ededd719c5
  1. 2
      k-meleon/ie_favorites/ie_favorites.h
  2. 40
      k-meleon/ie_favorites/ie_plugin.cpp
  3. 17
      k-meleon/ie_favorites/ie_utils.cpp

2
k-meleon/ie_favorites/ie_favorites.h

@ -53,6 +53,7 @@ void quicksort(char *a, size_t n, size_t es, cmp_t *cmp, unsigned int flag);
#define IMAGE_FOLDER_SPECIAL_CLOSED 4
#define IMAGE_FOLDER_SPECIAL_OPEN 5
#define WM_FAVORITE_NOTIFICATION WM_USER+450
#ifdef WHERE
CBookmarkNode gFavoritesRoot(0, _T(""), _T(""), BOOKMARK_FOLDER, 0);
@ -68,6 +69,7 @@ int CreateFavorite(CBookmarkNode *newNode);
int GetFavoritesPath(void);
int ReadFavorites(TCHAR *szRoot, TCHAR *szPath, CBookmarkNode &newFavoritesNode);
void BuildMenu(HMENU menu, CBookmarkNode *node, BOOL isContinuation);
void RefreshFavorites();
void RebuildMenu();
void BuildRebar(HWND hWndTB);
void CopyRebar(HWND hWndNewTB, HWND hWndOldTB);

40
k-meleon/ie_favorites/ie_plugin.cpp

@ -26,6 +26,7 @@
# include "../missing.h"
#endif
#include <ShlObj.h>
#define KMELEON_PLUGIN_EXPORTS
#include "../kmeleon_plugin.h"
#include "../Utils.h"
@ -133,6 +134,9 @@ long DoMessage(const char *to, const char *from, const char *subject, long data1
else if (stricmp(subject, "Setup") == 0) {
Setup();
}
else if (stricmp(subject, "Refresh") == 0) {
RefreshFavorites();
}
else return 0;
return 1;
@ -195,18 +199,48 @@ int Load(){
bTitleSet = false;
}
ReadFavorites(gFavoritesPath, _T(""), gFavoritesRoot);
ReadFavorites(gFavoritesPath, _T(""), gFavoritesRoot);
return true;
}
HWND gNotifWindow = nullptr;
ULONG gNotifID = 0;
void RegisterNotification(HWND hwnd) {
if (!gNotifWindow) {
LPITEMIDLIST ppidl = 0;
SHGetFolderLocation(NULL, CSIDL_FAVORITES, NULL, 0, &ppidl);
if (!ppidl) return;
SHChangeNotifyEntry entry = {ppidl,TRUE};
gNotifID = SHChangeNotifyRegister(hwnd,
SHCNRF_InterruptLevel | SHCNRF_RecursiveInterrupt,
SHCNE_UPDATEDIR | SHCNE_CREATE | SHCNE_DELETE | SHCNE_UPDATEITEM | SHCNE_RENAMEITEM | SHCNE_RENAMEFOLDER | SHCNE_RMDIR,
WM_FAVORITE_NOTIFICATION,1,
&entry);
CoTaskMemFree(ppidl);
gNotifWindow = hwnd;
}
}
void Create(HWND parent){
KMeleonWndProc = (void *) GetWindowLong(parent, GWL_WNDPROC);
SetWindowLong(parent, GWL_WNDPROC, (LONG)WndProc);
RegisterNotification(parent);
pNewTB = create_TB(parent);
}
void Destroy(HWND hWnd){
if (find_TB(hWnd))
remove_TB(hWnd);
if (gNotifWindow == hWnd) {
SHChangeNotifyDeregister(gNotifID);
gNotifWindow = nullptr;
HWND hwnd = 0;
if (kPlugin.kFuncs->GetWindowsList(&hwnd, 1))
RegisterNotification(hwnd);
}
}
// Preferences Dialog function
BOOL CALLBACK PrefDlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
int nTmp;

17
k-meleon/ie_favorites/ie_utils.cpp

@ -451,10 +451,14 @@ void OpenURL(TCHAR *aUrl)
kPlugin.kFuncs->NavigateTo(url, OPEN_NORMAL, NULL);
}
void Destroy(HWND hWnd){
if (find_TB(hWnd))
remove_TB(hWnd);
void RefreshFavorites()
{
delete gFavoritesRoot.child;
delete gFavoritesRoot.next;
gFavoritesRoot.child = NULL;
gFavoritesRoot.next = NULL;
ReadFavorites(gFavoritesPath, _T(""), gFavoritesRoot);
RebuildMenu();
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
@ -462,7 +466,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static NMTOOLBAR tbhdr;
static NMHDR hdr;
if (message == WM_COMMAND) {
if (message == WM_FAVORITE_NOTIFICATION) {
RefreshFavorites();
}
else if (message == WM_COMMAND) {
WORD command = LOWORD(wParam);
if (command == nConfigCommand){

Loading…
Cancel
Save