diff options
author | Tor Andersson <tor@ghostscript.com> | 2005-03-31 17:11:52 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2005-03-31 17:11:52 +0200 |
commit | 71147425af91535ba76b4a49f8527cb3b0fc1a21 (patch) | |
tree | 7ab8fa087763a2c38d70f16aac169ee9d47f8029 /apps/windows | |
parent | 8eabfe9fa4f3907caf8c9f30ccb7de488f8e9a72 (diff) | |
download | mupdf-71147425af91535ba76b4a49f8527cb3b0fc1a21.tar.xz |
associate with .pdf for windows ghostpdf. change some key commands.
Diffstat (limited to 'apps/windows')
-rw-r--r-- | apps/windows/pdfdoc.ico | bin | 0 -> 2238 bytes | |||
-rw-r--r-- | apps/windows/win_main.c | 97 | ||||
-rw-r--r-- | apps/windows/win_res.rc | 3 |
3 files changed, 94 insertions, 6 deletions
diff --git a/apps/windows/pdfdoc.ico b/apps/windows/pdfdoc.ico Binary files differnew file mode 100644 index 00000000..ecf22c4b --- /dev/null +++ b/apps/windows/pdfdoc.ico diff --git a/apps/windows/win_main.c b/apps/windows/win_main.c index 997221c6..4fb97ed3 100644 --- a/apps/windows/win_main.c +++ b/apps/windows/win_main.c @@ -58,6 +58,78 @@ static fz_renderer *rast; static fz_pixmap *image; /* + * Associate GhostPDF with PDF files. + */ + +void associateme(char *argv0) +{ + char tmp[256]; + char *name = "Adobe PDF Document"; + HKEY key, kicon, kshell, kopen, kcmd; + DWORD disp; + + /* HKEY_CLASSES_ROOT\.pdf */ + + if (RegCreateKeyEx(HKEY_CLASSES_ROOT, + ".pdf", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, &key, &disp)) + return; + + if (RegSetValueEx(key, "", 0, REG_SZ, "GhostPDF", strlen("GhostPDF")+1)) + return; + + RegCloseKey(key); + + /* HKEY_CLASSES_ROOT\GhostPDF */ + + if (RegCreateKeyEx(HKEY_CLASSES_ROOT, + "GhostPDF", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, &key, &disp)) + return; + + if (RegSetValueEx(key, "", 0, REG_SZ, name, strlen(name)+1)) + return; + + /* HKEY_CLASSES_ROOT\GhostPDF\DefaultIcon */ + + if (RegCreateKeyEx(key, + "DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, &kicon, &disp)) + return; + + sprintf(tmp, "%s,1", argv0); + if (RegSetValueEx(kicon, "", 0, REG_SZ, tmp, strlen(tmp)+1)) + return; + + RegCloseKey(kicon); + + /* HKEY_CLASSES_ROOT\GhostPDF\Shell\Open\Command */ + + if (RegCreateKeyEx(key, + "shell", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, &kshell, &disp)) + return; + if (RegCreateKeyEx(kshell, + "open", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, &kopen, &disp)) + return; + if (RegCreateKeyEx(kopen, + "command", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, &kcmd, &disp)) + return; + + sprintf(tmp, "\"%s\" \"%%1\"", argv0); + if (RegSetValueEx(kcmd, "", 0, REG_SZ, tmp, strlen(tmp)+1)) + return; + + RegCloseKey(kcmd); + RegCloseKey(kopen); + RegCloseKey(kshell); + + RegCloseKey(key); +} + +/* * Dialog boxes */ @@ -193,7 +265,7 @@ void winopen() wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = GetModuleHandle(NULL); - wc.hIcon = LoadIcon(wc.hInstance, "IDI_ICONGHOST"); + wc.hIcon = LoadIcon(wc.hInstance, "IDI_ICONAPPL"); wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL;//(HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; @@ -444,8 +516,6 @@ void handlekey(int c) // case 'o': drawlinks(); break; case VK_LEFT: - case VK_UP: - case VK_PRIOR: case '\b': case 'b': pageno--; @@ -457,9 +527,24 @@ void handlekey(int c) if (pageno < 1) pageno = 1; break; - case VK_RIGHT: - case VK_DOWN: + + case VK_PRIOR: + pany += image->h; + case VK_UP: + pany += image->h / 10; + constrainpan(&panx, &pany); + winrepaint(); + break; + case VK_NEXT: + pany -= image->h; + case VK_DOWN: + pany -= image->h / 10; + constrainpan(&panx, &pany); + winrepaint(); + break; + + case VK_RIGHT: case ' ': case 'f': pageno++; @@ -918,6 +1003,8 @@ int main(int argc, char **argv) int benchmark = 0; + associateme(argv[0]); + while ((c = getopt(argc, argv, "hbz:r:p:u:")) != -1) { switch (c) diff --git a/apps/windows/win_res.rc b/apps/windows/win_res.rc index 2a458af4..17643c33 100644 --- a/apps/windows/win_res.rc +++ b/apps/windows/win_res.rc @@ -1,4 +1,5 @@ -IDI_ICONGHOST ICON "gswin16.ico" +IDI_ICONAPPL ICON "gswin.ico" +IDI_ICONDOCU ICON "pdfdoc.ico" IDD_DLOGPASS DIALOG 100, 100, 204, 60 //STYLE DS_MODALFRAME | WS_POPUP |