2010-01-31 03:36:02 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* win32 preferences dialog implementation.
|
|
|
|
*/
|
|
|
|
|
2012-08-11 01:22:59 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
2011-03-17 01:19:44 +03:00
|
|
|
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2010-01-31 03:36:02 +03:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
2016-10-19 13:12:19 +03:00
|
|
|
#include "utils/file.h"
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
#include "windows/gui.h"
|
|
|
|
#include "windows/prefs.h"
|
|
|
|
#include "windows/resourceid.h"
|
2011-03-07 02:27:09 +03:00
|
|
|
#include "windows/windbg.h"
|
2010-01-31 03:36:02 +03:00
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
/** Preferences dialog width */
|
2010-01-31 03:36:02 +03:00
|
|
|
#define NSWS_PREFS_WINDOW_WIDTH 600
|
2017-02-17 23:44:37 +03:00
|
|
|
/** Preferences dialog height */
|
2010-01-31 03:36:02 +03:00
|
|
|
#define NSWS_PREFS_WINDOW_HEIGHT 400
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare preferences dialog font tab
|
|
|
|
*
|
|
|
|
* \param fontfamily The font family
|
|
|
|
* \param parent The parent window win32 handle
|
|
|
|
* \return The selected font or NULL on error
|
|
|
|
*/
|
2011-03-07 02:27:09 +03:00
|
|
|
static CHOOSEFONT *nsws_prefs_font_prepare(int fontfamily, HWND parent)
|
2010-01-31 03:36:02 +03:00
|
|
|
{
|
2011-03-07 02:27:09 +03:00
|
|
|
CHOOSEFONT *cf = malloc(sizeof(CHOOSEFONT));
|
|
|
|
if (cf == NULL) {
|
2016-04-28 00:41:59 +03:00
|
|
|
win32_warning(messages_get("NoMemory"),0);
|
2011-03-07 02:27:09 +03:00
|
|
|
return NULL;
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
LOGFONT *lf = malloc(sizeof(LOGFONT));
|
|
|
|
if (lf == NULL) {
|
2016-04-28 00:41:59 +03:00
|
|
|
win32_warning(messages_get("NoMemory"),0);
|
2011-03-07 02:27:09 +03:00
|
|
|
free(cf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
switch(fontfamily) {
|
|
|
|
case FF_ROMAN:
|
|
|
|
snprintf(lf->lfFaceName, LF_FACESIZE, "%s",
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_charp(font_serif));
|
2011-03-07 02:27:09 +03:00
|
|
|
break;
|
|
|
|
case FF_MODERN:
|
|
|
|
snprintf(lf->lfFaceName, LF_FACESIZE, "%s",
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_charp(font_mono));
|
2011-03-07 02:27:09 +03:00
|
|
|
break;
|
|
|
|
case FF_SCRIPT:
|
|
|
|
snprintf(lf->lfFaceName, LF_FACESIZE, "%s",
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_charp(font_cursive));
|
2011-03-07 02:27:09 +03:00
|
|
|
break;
|
|
|
|
case FF_DECORATIVE:
|
|
|
|
snprintf(lf->lfFaceName, LF_FACESIZE, "%s",
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_charp(font_fantasy));
|
2011-03-07 02:27:09 +03:00
|
|
|
break;
|
|
|
|
case FF_SWISS:
|
|
|
|
default:
|
|
|
|
snprintf(lf->lfFaceName, LF_FACESIZE, "%s",
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_charp(font_sans));
|
2011-03-07 02:27:09 +03:00
|
|
|
break;
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
cf->lStructSize = sizeof(CHOOSEFONT);
|
|
|
|
cf->hwndOwner = parent;
|
|
|
|
cf->lpLogFont = lf;
|
|
|
|
cf->Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_LIMITSIZE;
|
|
|
|
cf->nSizeMin = 16;
|
|
|
|
cf->nSizeMax = 24;
|
2010-01-31 03:36:02 +03:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
return cf;
|
|
|
|
}
|
2010-01-31 03:36:02 +03:00
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update value in spinner control when it is changed
|
|
|
|
*
|
|
|
|
* \param sub The window handle of the spinner control
|
|
|
|
* \param change The amount the control changed by
|
|
|
|
* \param minval The minimum allowed value of the control
|
|
|
|
* \param maxval The maximum allowed value of the control
|
|
|
|
*/
|
2011-03-07 02:27:09 +03:00
|
|
|
static void change_spinner(HWND sub, double change, double minval, double maxval)
|
2010-01-31 03:36:02 +03:00
|
|
|
{
|
|
|
|
char *temp, number[6];
|
|
|
|
int len;
|
2011-03-07 02:27:09 +03:00
|
|
|
double value = 0;
|
|
|
|
|
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
if (temp == NULL) {
|
2011-03-07 02:27:09 +03:00
|
|
|
return;
|
2017-02-17 23:44:37 +03:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM) temp);
|
|
|
|
|
|
|
|
value = strtod(temp, NULL) - change;
|
|
|
|
|
|
|
|
free(temp);
|
|
|
|
value = max(value, minval);
|
|
|
|
value = min(value, maxval);
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
if ((change == 1.0) || (change == -1.0)) {
|
2011-03-07 02:27:09 +03:00
|
|
|
snprintf(number, 6, "%.0f", value);
|
2017-02-17 23:44:37 +03:00
|
|
|
} else {
|
2011-03-07 02:27:09 +03:00
|
|
|
snprintf(number, 6, "%.1f", value);
|
2017-02-17 23:44:37 +03:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
/**
|
|
|
|
* Handle messages to the appearance preference dialog
|
|
|
|
*
|
|
|
|
* \param hwnd The win32 handle of the appearance dialog
|
|
|
|
* \param msg The message code
|
|
|
|
* \param wparam The message w parameter
|
|
|
|
* \param lParam The message l parameter
|
|
|
|
* \return result appropriate for message
|
|
|
|
*/
|
2011-03-07 02:27:09 +03:00
|
|
|
static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd,
|
2017-02-17 23:44:37 +03:00
|
|
|
UINT msg,
|
|
|
|
WPARAM wparam,
|
|
|
|
LPARAM lParam)
|
2011-03-07 02:27:09 +03:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *temp, number[6];
|
|
|
|
HWND sub;
|
|
|
|
|
2011-03-30 00:38:40 +04:00
|
|
|
LOG_WIN_MSG(hwnd, msg, wparam, lParam);
|
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Sans serif");
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Serif");
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Monospace");
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Cursive");
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Fantasy");
|
|
|
|
SendMessage(sub, CB_SETCURSEL,
|
2012-03-22 13:34:34 +04:00
|
|
|
(WPARAM) (nsoption_int(font_default) - 1), 0);
|
2011-03-07 02:27:09 +03:00
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_sans) != NULL) &&
|
|
|
|
(nsoption_charp(font_sans)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_SANS);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_sans));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_serif) != NULL) &&
|
|
|
|
(nsoption_charp(font_serif)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_SERIF);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_serif));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_mono) != NULL) &&
|
|
|
|
(nsoption_charp(font_mono)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_MONO);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_mono));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_cursive) != NULL) &&
|
|
|
|
(nsoption_charp(font_cursive)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_cursive));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_fantasy) != NULL) &&
|
|
|
|
(nsoption_charp(font_fantasy)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_fantasy));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_int(font_min_size) != 0) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE);
|
2012-03-22 13:34:34 +04:00
|
|
|
snprintf(number, 6, "%.1f", nsoption_int(font_min_size) / 10.0);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_int(font_size) != 0) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE);
|
2012-03-22 13:34:34 +04:00
|
|
|
snprintf(number, 6, "%.1f", nsoption_int(font_size) / 10.0);
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_int(max_fetchers) != 0) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS);
|
2012-03-22 13:34:34 +04:00
|
|
|
snprintf(number, 6, "%d", nsoption_int(max_fetchers));
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_int(max_fetchers_per_host) != 0) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST);
|
|
|
|
snprintf(number, 6, "%d",
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_int(max_fetchers_per_host));
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_int(max_cached_fetch_handles) != 0) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES);
|
2010-01-31 03:36:02 +03:00
|
|
|
snprintf(number, 6, "%d",
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_int(max_cached_fetch_handles));
|
2010-01-31 03:36:02 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* animation */
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_NOANIMATION);
|
2012-03-22 13:34:34 +04:00
|
|
|
SendMessage(sub, BM_SETCHECK, (WPARAM)((nsoption_bool(animate_images))
|
2017-02-17 23:44:37 +03:00
|
|
|
? BST_UNCHECKED : BST_CHECKED), 0);
|
2011-03-07 02:27:09 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((NMHDR FAR *)lParam)->code) {
|
|
|
|
case PSN_APPLY:
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE);
|
2010-01-31 03:36:02 +03:00
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)
|
2011-03-07 02:27:09 +03:00
|
|
|
(len + 1), (LPARAM) temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_int(font_size) = (int)
|
2011-03-07 02:27:09 +03:00
|
|
|
(10 * strtod(temp, NULL));
|
2010-01-31 03:36:02 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE);
|
2010-01-31 03:36:02 +03:00
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)
|
2011-03-07 02:27:09 +03:00
|
|
|
(len + 1), (LPARAM) temp);
|
2017-02-17 23:44:37 +03:00
|
|
|
nsoption_set_int(font_min_size,
|
2012-03-22 13:34:34 +04:00
|
|
|
(int)(10 * strtod(temp, NULL)));
|
2010-01-31 03:36:02 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
/* animation */
|
2017-02-17 23:44:37 +03:00
|
|
|
nsoption_set_bool(animate_images,
|
2012-03-22 13:34:34 +04:00
|
|
|
(IsDlgButtonChecked(hwnd, IDC_PREFS_NOANIMATION) == BST_CHECKED) ? true : false);
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UDN_DELTAPOS: {
|
|
|
|
NMUPDOWN *ud = (NMUPDOWN *)lParam;
|
|
|
|
switch(((NMHDR *)lParam)->idFrom) {
|
|
|
|
case IDC_PREFS_FONT_SIZE_SPIN:
|
|
|
|
change_spinner(GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE), 0.1 * ud->iDelta, 1.0, 50.0);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case IDC_PREFS_FONT_MINSIZE_SPIN:
|
|
|
|
change_spinner(GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE), 0.1 * ud->iDelta, 1.0, 50.0);
|
|
|
|
return TRUE;
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-03-07 02:27:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "WM_COMMAND Identifier 0x%x",
|
|
|
|
LOWORD(wparam));
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
switch(LOWORD(wparam)) {
|
|
|
|
case IDC_PREFS_PROXYTYPE:
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYTYPE);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_int(http_proxy_auth,
|
|
|
|
SendMessage(sub, CB_GETCURSEL, 0, 0) - 1);
|
|
|
|
nsoption_set_bool(http_proxy,
|
|
|
|
(nsoption_int(http_proxy_auth) != -1));
|
2017-02-17 23:44:37 +03:00
|
|
|
nsoption_set_int(http_proxy_auth,
|
|
|
|
nsoption_int(http_proxy_auth) +
|
2012-03-22 13:34:34 +04:00
|
|
|
(nsoption_bool(http_proxy)) ? 0 : 1);
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
case IDC_PREFS_SANS: {
|
2012-03-22 13:34:34 +04:00
|
|
|
CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SWISS, hwnd);
|
|
|
|
if (cf == NULL) {
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2012-03-22 13:34:34 +04:00
|
|
|
}
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
if (ChooseFont(cf) == TRUE) {
|
2017-02-17 23:44:37 +03:00
|
|
|
nsoption_set_charp(font_sans,
|
2012-03-22 13:34:34 +04:00
|
|
|
strdup(cf->lpLogFont->lfFaceName));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
free(cf->lpLogFont);
|
|
|
|
free(cf);
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_sans) != NULL) &&
|
|
|
|
(nsoption_charp(font_sans)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_SANS);
|
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_sans));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
case IDC_PREFS_SERIF: {
|
2012-03-22 13:34:34 +04:00
|
|
|
CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_ROMAN, hwnd);
|
|
|
|
if (cf == NULL) {
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2012-03-22 13:34:34 +04:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
if (ChooseFont(cf) == TRUE) {
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(font_serif,
|
|
|
|
strdup(cf->lpLogFont->lfFaceName));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
free(cf->lpLogFont);
|
|
|
|
free(cf);
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_serif) != NULL) &&
|
|
|
|
(nsoption_charp(font_serif)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_SERIF);
|
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_serif));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
case IDC_PREFS_MONO: {
|
2012-03-22 13:34:34 +04:00
|
|
|
CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_MODERN, hwnd);
|
|
|
|
if (cf == NULL) {
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2012-03-22 13:34:34 +04:00
|
|
|
}
|
2010-01-31 03:36:02 +03:00
|
|
|
|
|
|
|
if (ChooseFont(cf) == TRUE) {
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(font_mono,
|
|
|
|
strdup(cf->lpLogFont->lfFaceName));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
free(cf->lpLogFont);
|
|
|
|
free(cf);
|
2012-03-22 13:34:34 +04:00
|
|
|
|
|
|
|
if ((nsoption_charp(font_mono) != NULL) &&
|
|
|
|
(nsoption_charp(font_mono)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_MONO);
|
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_mono));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
case IDC_PREFS_CURSIVE: {
|
2012-03-22 13:34:34 +04:00
|
|
|
CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SCRIPT, hwnd);
|
|
|
|
if (cf == NULL) {
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2012-03-22 13:34:34 +04:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
if (ChooseFont(cf) == TRUE) {
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(font_cursive,
|
|
|
|
strdup(cf->lpLogFont->lfFaceName));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
free(cf->lpLogFont);
|
|
|
|
free(cf);
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_cursive) != NULL) &&
|
|
|
|
(nsoption_charp(font_cursive)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE);
|
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_cursive));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
case IDC_PREFS_FANTASY: {
|
2012-03-22 13:34:34 +04:00
|
|
|
CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_DECORATIVE, hwnd);
|
|
|
|
if (cf == NULL) {
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2012-03-22 13:34:34 +04:00
|
|
|
}
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
if (ChooseFont(cf) == TRUE) {
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(font_fantasy,
|
|
|
|
strdup(cf->lpLogFont->lfFaceName));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
free(cf->lpLogFont);
|
|
|
|
free(cf);
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(font_fantasy) != NULL) &&
|
|
|
|
(nsoption_charp(font_fantasy)[0] != '\0')) {
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY);
|
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(font_fantasy));
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
case IDC_PREFS_FONTDEF:
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_int(font_default,
|
|
|
|
SendMessage(sub, CB_GETCURSEL, 0, 0) + 1);
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2017-02-17 23:44:37 +03:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle messages to the connections preference dialog
|
|
|
|
*
|
|
|
|
* \param hwnd The win32 handle of the connections dialog
|
|
|
|
* \param msg The message code
|
|
|
|
* \param wparam The message w parameter
|
|
|
|
* \param lParam The message l parameter
|
|
|
|
* \return result appropriate for message
|
|
|
|
*/
|
2011-03-07 02:27:09 +03:00
|
|
|
static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd,
|
2017-02-17 23:44:37 +03:00
|
|
|
UINT msg,
|
|
|
|
WPARAM wparam,
|
|
|
|
LPARAM lParam)
|
2011-03-07 02:27:09 +03:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *temp, number[6];
|
|
|
|
HWND sub;
|
|
|
|
|
2011-03-30 00:38:40 +04:00
|
|
|
LOG_WIN_MSG(hwnd, msg, wparam, lParam);
|
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYTYPE);
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"None");
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Simple");
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"Basic Auth");
|
|
|
|
SendMessage(sub, CB_ADDSTRING, 0, (LPARAM)"NTLM Auth");
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_bool(http_proxy)) {
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, CB_SETCURSEL, (WPARAM)
|
2012-03-22 13:34:34 +04:00
|
|
|
(nsoption_int(http_proxy_auth) + 1), 0);
|
|
|
|
} else {
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, CB_SETCURSEL, 0, 0);
|
2012-03-22 13:34:34 +04:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYHOST);
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(http_proxy_host) != NULL) &&
|
|
|
|
(nsoption_charp(http_proxy_host)[0] != '\0'))
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(http_proxy_host));
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPORT);
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_int(http_proxy_port) != 0) {
|
|
|
|
snprintf(number, 6, "%d", nsoption_int(http_proxy_port));
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYNAME);
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(http_proxy_auth_user) != NULL) &&
|
|
|
|
(nsoption_charp(http_proxy_auth_user)[0] != '\0'))
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(http_proxy_auth_user));
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPASS);
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_charp(http_proxy_auth_pass) != NULL) &&
|
|
|
|
(nsoption_charp(http_proxy_auth_pass)[0] != '\0'))
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0,
|
2012-03-22 13:34:34 +04:00
|
|
|
(LPARAM)nsoption_charp(http_proxy_auth_pass));
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS);
|
2012-03-22 13:34:34 +04:00
|
|
|
snprintf(number, 6, "%d", nsoption_int(max_fetchers));
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST);
|
2012-03-22 13:34:34 +04:00
|
|
|
snprintf(number, 6, "%d", nsoption_int(max_fetchers_per_host));
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES);
|
2012-03-22 13:34:34 +04:00
|
|
|
snprintf(number, 6, "%d", nsoption_int(max_cached_fetch_handles));
|
2011-03-07 02:27:09 +03:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((NMHDR FAR *)lParam)->code) {
|
|
|
|
case PSN_APPLY:
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYHOST);
|
2010-01-31 03:36:02 +03:00
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
2011-03-07 02:27:09 +03:00
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
|
|
|
|
(LPARAM)temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(http_proxy_host, strdup(temp));
|
2011-03-07 02:27:09 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPORT);
|
2010-01-31 03:36:02 +03:00
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
2011-03-07 02:27:09 +03:00
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
|
|
|
|
(LPARAM)temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_int(http_proxy_port, atoi(temp));
|
2011-03-07 02:27:09 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYNAME);
|
2010-01-31 03:36:02 +03:00
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
2011-03-07 02:27:09 +03:00
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
|
|
|
|
(LPARAM)temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(http_proxy_auth_user, strdup(temp));
|
2010-01-31 03:36:02 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPASS);
|
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
|
|
|
|
(LPARAM)temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(http_proxy_auth_pass, strdup(temp));
|
2010-01-31 03:36:02 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
/* fetchers */
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS);
|
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
|
|
|
|
(LPARAM)temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_int(max_fetchers, atoi(temp));
|
2010-01-31 03:36:02 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST);
|
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
|
|
|
|
(LPARAM)temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_int(max_fetchers_per_host, atoi(temp));
|
2011-03-07 02:27:09 +03:00
|
|
|
free(temp);
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES);
|
|
|
|
len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
temp = malloc(len + 1);
|
|
|
|
if (temp != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1),
|
|
|
|
(LPARAM)temp);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_int(max_cached_fetch_handles, atoi(temp));
|
2011-03-07 02:27:09 +03:00
|
|
|
free(temp);
|
|
|
|
}
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
case UDN_DELTAPOS: {
|
|
|
|
NMUPDOWN *ud = (NMUPDOWN *)lParam;
|
|
|
|
switch(((NMHDR *)lParam)->idFrom) {
|
|
|
|
case IDC_PREFS_FETCHERS_SPIN:
|
|
|
|
change_spinner(GetDlgItem(hwnd, IDC_PREFS_FETCHERS), 1.0 * ud->iDelta, 1.0, 100.0);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case IDC_PREFS_FETCH_HOST_SPIN:
|
|
|
|
change_spinner(GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST), 1.0 * ud->iDelta, 1.0, 100.0);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case IDC_PREFS_FETCH_HANDLES_SPIN:
|
|
|
|
change_spinner(GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES), 1.0 * ud->iDelta, 1.0, 100.0);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2011-03-07 02:27:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle messages to the general preference dialog
|
|
|
|
*
|
|
|
|
* \param hwnd The win32 handle of the general dialog
|
|
|
|
* \param msg The message code
|
|
|
|
* \param wparam The message w parameter
|
|
|
|
* \param lParam The message l parameter
|
|
|
|
* \return result appropriate for message
|
|
|
|
*/
|
2011-03-07 02:27:09 +03:00
|
|
|
static BOOL CALLBACK options_general_dialog_handler(HWND hwnd,
|
2017-02-17 23:44:37 +03:00
|
|
|
UINT msg,
|
|
|
|
WPARAM wparam,
|
|
|
|
LPARAM lParam)
|
2011-03-07 02:27:09 +03:00
|
|
|
{
|
|
|
|
HWND sub;
|
|
|
|
|
2011-03-30 00:38:40 +04:00
|
|
|
LOG_WIN_MSG(hwnd, msg, wparam, lParam);
|
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
/* homepage url */
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_HOMEPAGE);
|
2012-03-22 13:34:34 +04:00
|
|
|
SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(homepage_url));
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
/* Display images */
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_IMAGES);
|
2017-02-17 23:44:37 +03:00
|
|
|
SendMessage(sub, BM_SETCHECK,
|
|
|
|
(WPARAM) ((nsoption_bool(suppress_images)) ?
|
|
|
|
BST_CHECKED : BST_UNCHECKED), 0);
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
/* advert blocking */
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_ADVERTS);
|
2017-02-17 23:44:37 +03:00
|
|
|
SendMessage(sub, BM_SETCHECK,
|
|
|
|
(WPARAM) ((nsoption_bool(block_advertisements)) ?
|
|
|
|
BST_CHECKED : BST_UNCHECKED), 0);
|
2011-03-07 02:27:09 +03:00
|
|
|
|
|
|
|
/* Referrer sending */
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_REFERER);
|
2017-02-17 23:44:37 +03:00
|
|
|
SendMessage(sub, BM_SETCHECK,
|
2012-03-22 13:34:34 +04:00
|
|
|
(WPARAM)((nsoption_bool(send_referer)) ?
|
2017-02-17 23:44:37 +03:00
|
|
|
BST_CHECKED : BST_UNCHECKED), 0);
|
2011-03-07 02:27:09 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((NMHDR FAR *)lParam)->code) {
|
|
|
|
case PSN_APPLY:
|
|
|
|
/* homepage */
|
|
|
|
sub = GetDlgItem(hwnd, IDC_PREFS_HOMEPAGE);
|
|
|
|
if (sub != NULL) {
|
|
|
|
int text_length;
|
|
|
|
char *text;
|
2017-02-17 23:44:37 +03:00
|
|
|
text_length = SendMessage(sub,
|
|
|
|
WM_GETTEXTLENGTH, 0, 0);
|
2011-03-07 02:27:09 +03:00
|
|
|
text = malloc(text_length + 1);
|
|
|
|
if (text != NULL) {
|
|
|
|
SendMessage(sub, WM_GETTEXT,
|
|
|
|
(WPARAM)text_length + 1,
|
|
|
|
(LPARAM)text);
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(homepage_url, text);
|
2011-03-07 02:27:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_bool(suppress_images,
|
|
|
|
(IsDlgButtonChecked(hwnd, IDC_PREFS_IMAGES) == BST_CHECKED) ? true : false);
|
2011-03-07 02:27:09 +03:00
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
nsoption_set_bool(block_advertisements,
|
|
|
|
(IsDlgButtonChecked(hwnd, IDC_PREFS_ADVERTS) == BST_CHECKED) ? true : false);
|
2011-03-07 02:27:09 +03:00
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
nsoption_set_bool(send_referer,
|
|
|
|
(IsDlgButtonChecked(hwnd, IDC_PREFS_REFERER) == BST_CHECKED) ? true : false);
|
2011-03-07 02:27:09 +03:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
break;
|
2017-02-17 23:44:37 +03:00
|
|
|
|
2011-03-07 02:27:09 +03:00
|
|
|
}
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2011-03-07 02:27:09 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
|
2016-10-19 13:12:19 +03:00
|
|
|
/* exported interface documented in windows/prefs.h */
|
|
|
|
nserror nsws_prefs_save(void)
|
|
|
|
{
|
|
|
|
/* user saved changes */
|
|
|
|
char *choices = NULL;
|
|
|
|
nserror res;
|
|
|
|
|
2019-12-11 01:48:42 +03:00
|
|
|
res = netsurf_mkpath(&choices, NULL, 2, G_config_path, "Choices");
|
2016-10-19 13:12:19 +03:00
|
|
|
if (res == NSERROR_OK) {
|
|
|
|
nsoption_write(choices, NULL, NULL);
|
|
|
|
free(choices);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2017-02-17 23:44:37 +03:00
|
|
|
|
2016-10-19 13:12:19 +03:00
|
|
|
/* exported interface documented in windows/prefs.h */
|
2011-03-07 02:27:09 +03:00
|
|
|
void nsws_prefs_dialog_init(HINSTANCE hinst, HWND parent)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
PROPSHEETPAGE psp[3];
|
|
|
|
PROPSHEETHEADER psh;
|
|
|
|
|
|
|
|
psp[0].dwSize = sizeof(PROPSHEETPAGE);
|
2011-03-30 00:38:40 +04:00
|
|
|
psp[0].dwFlags = 0;/*PSP_USEICONID*/
|
2011-03-07 02:27:09 +03:00
|
|
|
psp[0].hInstance = hinst;
|
2018-08-16 19:28:11 +03:00
|
|
|
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS_GENERAL);
|
2011-03-07 02:27:09 +03:00
|
|
|
psp[0].pfnDlgProc = options_general_dialog_handler;
|
|
|
|
psp[0].lParam = 0;
|
|
|
|
psp[0].pfnCallback = NULL;
|
|
|
|
|
|
|
|
psp[1].dwSize = sizeof(PROPSHEETPAGE);
|
2011-03-30 00:38:40 +04:00
|
|
|
psp[1].dwFlags = 0;/*PSP_USEICONID*/
|
2011-03-07 02:27:09 +03:00
|
|
|
psp[1].hInstance = hinst;
|
2018-08-16 19:28:11 +03:00
|
|
|
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS_CONNECTIONS);
|
2011-03-07 02:27:09 +03:00
|
|
|
psp[1].pfnDlgProc = options_connections_dialog_handler;
|
|
|
|
psp[1].lParam = 0;
|
|
|
|
psp[1].pfnCallback = NULL;
|
|
|
|
|
|
|
|
psp[2].dwSize = sizeof(PROPSHEETPAGE);
|
2011-03-30 00:38:40 +04:00
|
|
|
psp[2].dwFlags = 0;/*PSP_USEICONID*/
|
2011-03-07 02:27:09 +03:00
|
|
|
psp[2].hInstance = hinst;
|
2018-08-16 19:28:11 +03:00
|
|
|
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS_APPERANCE);
|
2011-03-07 02:27:09 +03:00
|
|
|
psp[2].pfnDlgProc = options_appearance_dialog_handler;
|
|
|
|
psp[2].lParam = 0;
|
|
|
|
psp[2].pfnCallback = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
|
|
|
psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEICONID | PSH_PROPSHEETPAGE;
|
|
|
|
psh.hwndParent = parent;
|
|
|
|
psh.hInstance = hinst;
|
2011-03-30 00:38:40 +04:00
|
|
|
psh.pszIcon = MAKEINTRESOURCE(IDR_NETSURF_ICON);
|
2011-03-07 02:27:09 +03:00
|
|
|
psh.pszCaption = (LPSTR) "NetSurf Options";
|
|
|
|
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
|
|
|
psh.nStartPage = 0;
|
|
|
|
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
|
|
|
|
psh.pfnCallback = NULL;
|
|
|
|
|
|
|
|
ret = PropertySheet(&psh);
|
|
|
|
if (ret == -1) {
|
|
|
|
win_perror("PropertySheet");
|
|
|
|
} else if (ret > 0) {
|
2016-10-19 13:12:19 +03:00
|
|
|
nsws_prefs_save();
|
2011-03-07 02:27:09 +03:00
|
|
|
}
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|