hhctrl.ocx: Implement Sync button functionality.
This commit is contained in:
parent
deda1b2c4e
commit
16b35e00ed
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright 2007 Jacek Caban for CodeWeavers
|
||||
* Copyright 2011 Owen Rudge for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -312,3 +313,18 @@ void ReleaseContent(HHInfo *info)
|
|||
{
|
||||
free_content_item(info->content);
|
||||
}
|
||||
|
||||
void ActivateContentTopic(HWND hWnd, LPCWSTR filename, ContentItem *item)
|
||||
{
|
||||
if (lstrcmpiW(item->local, filename) == 0)
|
||||
{
|
||||
SendMessageW(hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM) item->id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item->next)
|
||||
ActivateContentTopic(hWnd, filename, item->next);
|
||||
|
||||
if (item->child)
|
||||
ActivateContentTopic(hWnd, filename, item->child);
|
||||
}
|
||||
|
|
|
@ -111,21 +111,15 @@ BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl)
|
|||
return ret;
|
||||
}
|
||||
|
||||
BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
||||
BOOL AppendFullPathURL(LPCWSTR file, LPWSTR buf, LPCWSTR index)
|
||||
{
|
||||
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
||||
WCHAR full_path[MAX_PATH];
|
||||
LPWSTR ptr;
|
||||
|
||||
static const WCHAR url_format[] =
|
||||
{'m','k',':','@','M','S','I','T','S','t','o','r','e',':','%','s',':',':','%','s','%','s',0};
|
||||
static const WCHAR slash[] = {'/',0};
|
||||
static const WCHAR empty[] = {0};
|
||||
WCHAR full_path[MAX_PATH];
|
||||
|
||||
TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
|
||||
|
||||
if (!info->web_browser)
|
||||
return FALSE;
|
||||
TRACE("%s %p %s\n", debugstr_w(file), buf, debugstr_w(index));
|
||||
|
||||
if(!GetFullPathNameW(file, sizeof(full_path)/sizeof(full_path[0]), full_path, NULL)) {
|
||||
WARN("GetFullPathName failed: %u\n", GetLastError());
|
||||
|
@ -133,6 +127,18 @@ BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
|||
}
|
||||
|
||||
wsprintfW(buf, url_format, full_path, (!index || index[0] == '/') ? empty : slash, index);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
||||
{
|
||||
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
||||
LPWSTR ptr;
|
||||
|
||||
TRACE("%p %s %s\n", info, debugstr_w(file), debugstr_w(index));
|
||||
|
||||
if ((!info->web_browser) || !AppendFullPathURL(file, buf, index))
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: HACK */
|
||||
if((ptr = strchrW(buf, '#')))
|
||||
|
@ -141,6 +147,42 @@ BOOL NavigateToChm(HHInfo *info, LPCWSTR file, LPCWSTR index)
|
|||
return SUCCEEDED(navigate_url(info, buf));
|
||||
}
|
||||
|
||||
static void DoSync(HHInfo *info)
|
||||
{
|
||||
WCHAR buf[INTERNET_MAX_URL_LENGTH];
|
||||
HRESULT hres;
|
||||
DWORD len;
|
||||
BSTR url;
|
||||
|
||||
hres = IWebBrowser2_get_LocationURL(info->web_browser, &url);
|
||||
|
||||
if (FAILED(hres))
|
||||
{
|
||||
WARN("get_LocationURL failed: %08x\n", hres);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we're not currently viewing a page in the active .chm file, abort */
|
||||
if ((!AppendFullPathURL(info->pszFile, buf, NULL)) || (len = lstrlenW(buf) > lstrlenW(url)))
|
||||
{
|
||||
SysFreeString(url);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lstrcmpiW(buf, url) > 0)
|
||||
{
|
||||
static const WCHAR delimW[] = {':',':','/',0};
|
||||
const WCHAR *index;
|
||||
|
||||
index = strstrW(url, delimW);
|
||||
|
||||
if (index)
|
||||
ActivateContentTopic(info->tabs[TAB_CONTENTS].hwnd, index + 3, info->content); /* skip over ::/ */
|
||||
}
|
||||
|
||||
SysFreeString(url);
|
||||
}
|
||||
|
||||
/* Size Bar */
|
||||
|
||||
#define SIZEBAR_WIDTH 4
|
||||
|
@ -654,6 +696,8 @@ static void TB_OnClick(HWND hWnd, DWORD dwID)
|
|||
ExpandContract(info);
|
||||
break;
|
||||
case IDTB_SYNC:
|
||||
DoSync(info);
|
||||
break;
|
||||
case IDTB_OPTIONS:
|
||||
case IDTB_BROWSE_FWD:
|
||||
case IDTB_BROWSE_BACK:
|
||||
|
|
|
@ -169,6 +169,7 @@ void DoPageAction(HHInfo*,DWORD);
|
|||
|
||||
void InitContent(HHInfo*);
|
||||
void ReleaseContent(HHInfo*);
|
||||
void ActivateContentTopic(HWND,LPCWSTR,ContentItem *);
|
||||
|
||||
void InitIndex(HHInfo*);
|
||||
void ReleaseIndex(HHInfo*);
|
||||
|
|
Loading…
Reference in New Issue