39#include "atari/res/netsurf.rsh"
46#include "atari/gemtk/gemtk.h"
71#ifdef WITH_FREETYPE_FONT_DRIVER
75#ifdef WITH_INTERNAL_FONT_DRIVER
79#ifdef WITH_VDI_FONT_DRIVER
89#define OBJ_SELECTED(idx) ((bool)((dlgtree[idx].ob_state & OS_SELECTED)!=0))
91#define OBJ_CHECK(idx) (dlgtree[idx].ob_state |= (OS_SELECTED));
93#define OBJ_UNCHECK(idx) (dlgtree[idx].ob_state &= ~(OS_SELECTED));
95#define OBJ_REDRAW(idx) gemtk_wm_exec_redraw(settings_guiwin, \
96 gemtk_obj_screen_rect(dlgtree, idx));
98#define DISABLE_OBJ(idx) (dlgtree[idx].ob_state |= OS_DISABLED); \
99 gemtk_wm_exec_redraw(settings_guiwin, \
100 gemtk_obj_screen_rect(dlgtree, idx));
102#define ENABLE_OBJ(idx) (dlgtree[idx].ob_state &= ~(OS_DISABLED)); \
103 gemtk_wm_exec_redraw(settings_guiwin, \
104 gemtk_obj_screen_rect(dlgtree, idx));
106#define FORMEVENT(idx) form_event(idx, 0);
108#define INPUT_HOMEPAGE_URL_MAX_LEN 44
109#define INPUT_LOCALE_MAX_LEN 6
110#define INPUT_PROXY_HOST_MAX_LEN 31
111#define INPUT_PROXY_USERNAME_MAX_LEN 36
112#define INPUT_PROXY_PASSWORD_MAX_LEN 36
113#define INPUT_PROXY_PORT_MAX_LEN 5
114#define INPUT_MIN_REFLOW_PERIOD_MAX_LEN 4
115#define LABEL_FONT_RENDERER_MAX_LEN 8
116#define LABEL_PATH_MAX_LEN 40
117#define LABEL_ICONSET_MAX_LEN 8
118#define INPUT_TOOLBAR_COLOR_MAX_LEN 6
122static void form_event(
int index,
int external);
134 strncpy(spare,
text, 254);
139 set_string(
dlgtree, idx, spare);
155 FORMEVENT(SETTINGS_BT_SEL_FONT_RENDERER);
164 FILE * fp_locales = NULL;
168 fp_locales = fopen(buf,
"r");
170 if (fp_locales == NULL) {
174 NSLOG(netsurf, INFO,
"Reading locales from: %s...", buf);
179 while (fgets(tmp_locale, 16, fp_locales) != NULL) {
187 while (fgets(tmp_locale, 16, fp_locales) != NULL) {
188 int len = strlen(tmp_locale);
189 tmp_locale[len-1] = 0;
193 snprintf(
locales[i], 16,
"%s", tmp_locale);
210 form_alert(1,
"[1][Some options require an netsurf restart!][OK]");
226 OBJ_CHECK( SETTINGS_CB_HIDE_ADVERTISEMENT );
233 OBJ_CHECK( SETTINGS_CB_DISABLE_POPUP_WINDOWS );
236 OBJ_CHECK( SETTINGS_CB_SEND_HTTP_REFERRER );
241 OBJ_CHECK( SETTINGS_CB_SEND_DO_NOT_TRACK );
250 sprintf(spare,
"%d",
nsoption_int(atari_gui_poll_timeout));
251 set_text(SETTINGS_BT_GUI_TOUT, spare, 2);
254 snprintf( spare, 255,
"%02d",
nsoption_int(expire_url) );
255 set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 3);
260 set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 4 );
264 set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 4 );
268 set_text( SETTINGS_EDIT_CACHE_AGE, spare, 3 );
285 SET_BIT(
dlgtree[SETTINGS_CB_TRANSPARENCY].ob_state,
286 OS_SELECTED,
nsoption_int(atari_transparency) ? 1 : 0 );
287 SET_BIT(
dlgtree[SETTINGS_CB_ENABLE_ANIMATION].ob_state,
289 SET_BIT(
dlgtree[SETTINGS_CB_FG_IMAGES].ob_state,
291 SET_BIT(
dlgtree[SETTINGS_CB_BG_IMAGES].ob_state,
299 SET_BIT(
dlgtree[SETTINGS_CB_ANTI_ALIASING].ob_state,
300 OS_SELECTED,
nsoption_int(atari_font_monochrom) ? 0 : 1 );
306 set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare,
313 snprintf( spare, 255,
"%5d",
nsoption_int(http_proxy_port) );
314 set_text( SETTINGS_EDIT_PROXY_PORT, spare,
321 SET_BIT(
dlgtree[SETTINGS_CB_USE_PROXY].ob_state,
323 SET_BIT(
dlgtree[SETTINGS_CB_PROXY_AUTH].ob_state,
327 snprintf( spare, 255,
"%2d",
nsoption_int(max_cached_fetch_handles) );
328 set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare , 2 );
331 snprintf( spare, 255,
"%2d",
nsoption_int(max_fetchers) );
332 set_text( SETTINGS_EDIT_MAX_FETCHERS, spare , 2 );
335 snprintf( spare, 255,
"%2d",
nsoption_int(max_fetchers_per_host) );
336 set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare , 2 );
341 snprintf( spare, 255,
"%3d",
nsoption_int(font_min_size) );
342 set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare , 3 );
346 set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare , 3 );
353 bool require_path =
false;
354 bool is_folder =
false;
356 const char * title =
"";
357 const char *
path = NULL;
363 case SETTINGS_BT_SEL_DOWNLOAD_DIR:
364 title =
"Select Download Directory:";
365 rsc_te = SETTINGS_EDIT_DOWNLOAD_PATH;
369 case SETTINGS_BT_SEL_HOTLIST:
370 title =
"Select Hotlist File:";
371 rsc_te = SETTINGS_EDIT_HOTLIST_FILE;
374 case SETTINGS_BT_SEL_CA_BUNDLE:
375 title =
"Select CA Bundle File:";
376 rsc_te = SETTINGS_EDIT_CA_BUNDLE;
379 case SETTINGS_BT_SEL_CA_CERTS:
380 title =
"Select Certs Directory:";
381 rsc_te = SETTINGS_EDIT_CA_CERTS_PATH;
385 case SETTINGS_BT_SEL_EDITOR:
386 title =
"Select Editor Application:";
387 rsc_te = SETTINGS_EDIT_EDITOR;
396 if (require_path ==
false) {
409 if ((is_folder ==
false) && (
path != NULL)) {
410 gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
"Folder Required!");
412 }
while ((is_folder ==
false) && (
path != NULL));
414 if ((is_folder ==
true) && (
path != NULL)) {
427 bool is_button =
false;
430 MENU pop_menu, me_data;
437 case SETTINGS_CB_USE_PROXY:
451 case SETTINGS_CB_PROXY_AUTH:
452 if( checked &&
OBJ_SELECTED( SETTINGS_CB_USE_PROXY ) ) {
461 case SETTINGS_CB_ENABLE_ANIMATION:
464 case SETTINGS_BT_SEL_FONT_RENDERER:
466 objc_offset(
dlgtree, SETTINGS_BT_SEL_FONT_RENDERER, &x, &y);
467 tmp = gemtk_obj_get_text(
dlgtree, SETTINGS_BT_SEL_FONT_RENDERER);
469 pop_menu.mn_tree = gemtk_obj_create_popup_tree(
font_engines,
473 assert(pop_menu.mn_tree != NULL);
475 pop_menu.mn_menu = 0;
476 pop_menu.mn_item = 1;
477 pop_menu.mn_scroll = SCROLL_NO;
478 pop_menu.mn_keystate = 0;
481 menu_popup(&pop_menu, x, y, &me_data);
482 choice = me_data.mn_item;
486 get_string(pop_menu.mn_tree, choice, spare);
487 set_text(SETTINGS_BT_SEL_FONT_RENDERER,
493 gemtk_obj_destroy_popup_tree(pop_menu.mn_tree);
495 tmp = gemtk_obj_get_text(
dlgtree, SETTINGS_BT_SEL_FONT_RENDERER);
496 if (strcasecmp(tmp,
"freetype") == 0) {
503 case SETTINGS_BT_SEL_LOCALE:
504 objc_offset(
dlgtree, SETTINGS_BT_SEL_LOCALE, &x, &y);
513 pop_menu.mn_tree = gemtk_obj_get_tree(POP_LANGUAGE);
514 pop_menu.mn_item = POP_LANGUAGE_CS;
517 tmp = gemtk_obj_get_text(
dlgtree, SETTINGS_BT_SEL_LOCALE);
518 pop_menu.mn_tree = gemtk_obj_create_popup_tree((
const char**)
locales,
522 pop_menu.mn_item = 0;
525 pop_menu.mn_menu = 0;
526 pop_menu.mn_scroll = SCROLL_YES;
527 pop_menu.mn_keystate = 0;
530 menu_popup(&pop_menu, x, y, &me_data);
533 choice = me_data.mn_item;
535 get_string(pop_menu.mn_tree, choice, spare);
536 set_text(SETTINGS_BT_SEL_LOCALE, (
char*)&spare[2], 5);
539 gemtk_obj_destroy_popup_tree(pop_menu.mn_tree);
544 case SETTINGS_BT_GUI_TOUT:
545 objc_offset(
dlgtree, SETTINGS_BT_GUI_TOUT, &x, &y);
546 tmp = gemtk_obj_get_text(
dlgtree, SETTINGS_BT_GUI_TOUT);
547 pop_menu.mn_tree = gemtk_obj_create_popup_tree(
gui_timeouts,
551 pop_menu.mn_item = 0;
552 pop_menu.mn_menu = 0;
553 pop_menu.mn_scroll = SCROLL_NO;
554 pop_menu.mn_keystate = 0;
557 menu_popup(&pop_menu, x, y, &me_data);
560 choice = me_data.mn_item;
562 get_string(pop_menu.mn_tree, choice, spare);
563 set_text(SETTINGS_BT_GUI_TOUT, (
char*)&spare[2], 5);
566 gemtk_obj_destroy_popup_tree(pop_menu.mn_tree);
571 case SETTINGS_BT_SEL_DOWNLOAD_DIR:
572 case SETTINGS_BT_SEL_HOTLIST:
573 case SETTINGS_BT_SEL_CA_BUNDLE:
574 case SETTINGS_BT_SEL_CA_CERTS:
575 case SETTINGS_BT_SEL_EDITOR:
579 case SETTINGS_INC_MEM_CACHE:
580 case SETTINGS_DEC_MEM_CACHE:
581 if( index == SETTINGS_DEC_MEM_CACHE )
591 set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 5 );
596 case SETTINGS_INC_DISC_CACHE:
597 case SETTINGS_DEC_DISC_CACHE:
598 if( index == SETTINGS_DEC_DISC_CACHE )
608 set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 5 );
613 case SETTINGS_INC_CACHE_AGE:
614 case SETTINGS_DEC_CACHE_AGE:
615 if( index == SETTINGS_INC_CACHE_AGE )
624 set_text( SETTINGS_EDIT_CACHE_AGE, spare, 2 );
629 case SETTINGS_INC_CACHED_CONNECTIONS:
630 case SETTINGS_DEC_CACHED_CONNECTIONS:
631 if( index == SETTINGS_INC_CACHED_CONNECTIONS )
639 set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 );
641 OBJ_REDRAW(SETTINGS_EDIT_MAX_CACHED_CONNECTIONS);
644 case SETTINGS_INC_MAX_FETCHERS:
645 case SETTINGS_DEC_MAX_FETCHERS:
646 if( index == SETTINGS_INC_MAX_FETCHERS )
654 set_text( SETTINGS_EDIT_MAX_FETCHERS, spare, 2 );
659 case SETTINGS_INC_MAX_FETCHERS_PER_HOST:
660 case SETTINGS_DEC_MAX_FETCHERS_PER_HOST:
661 if( index == SETTINGS_INC_MAX_FETCHERS_PER_HOST )
669 set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 );
671 OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS_PER_HOST);
674 case SETTINGS_INC_HISTORY_AGE:
675 case SETTINGS_DEC_HISTORY_AGE:
676 if( index == SETTINGS_INC_HISTORY_AGE )
685 set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 );
690 case SETTINGS_INC_MIN_FONT_SIZE:
691 case SETTINGS_DEC_MIN_FONT_SIZE:
692 if( index == SETTINGS_INC_MIN_FONT_SIZE )
703 set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare, 3 );
708 case SETTINGS_INC_DEF_FONT_SIZE:
709 case SETTINGS_DEC_DEF_FONT_SIZE:
710 if( index == SETTINGS_INC_DEF_FONT_SIZE )
721 set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare, 3 );
726 case SETTINGS_INC_INCREMENTAL_REFLOW:
727 case SETTINGS_DEC_INCREMENTAL_REFLOW:
728 if( index == SETTINGS_INC_INCREMENTAL_REFLOW )
737 set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, 4 );
764 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_PROXY_PASSWORD));
766 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_PROXY_USERNAME));
768 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_PROXY_HOST));
770 atoi( gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_PROXY_PORT) ));
772 atoi( gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_MAX_FETCHERS_PER_HOST)));
774 atoi( gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_MAX_CACHED_CONNECTIONS)));
776 atoi( gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_MAX_FETCHERS) ));
788 gemtk_obj_get_text(
dlgtree, SETTINGS_BT_SEL_FONT_RENDERER));
801 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_CA_BUNDLE));
803 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_CA_CERTS_PATH));
805 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_CA_CERTS_PATH));
807 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_HOTLIST_FILE));
809 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_EDITOR));
811 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_DOWNLOAD_PATH));
815 SETTINGS_STR_MAX_MEM_CACHE));
817 SETTINGS_EDIT_HISTORY_AGE));
819 SETTINGS_STR_MAX_DISC_CACHE));
821 SETTINGS_EDIT_CACHE_AGE));
838 gemtk_obj_get_text(
dlgtree, SETTINGS_BT_SEL_LOCALE));
840 atoi(gemtk_obj_get_text(
dlgtree, SETTINGS_BT_GUI_TOUT)));
846 gemtk_obj_get_text(
dlgtree, SETTINGS_EDIT_HOMEPAGE));
849static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out,
short msg[8])
853 if ((ev_out->emo_events & MU_MESAG) != 0) {
866 gemtk_wm_update_slider(win, GEMTK_WM_VH_SLIDER);
874 case TOOLBAR_SETTINGS_SAVE:
878 case TOOLBAR_SETTINGS_ABORT:
886 case GEMTK_WM_WM_FORM_CLICK:
895 if ((ev_out->emo_events & MU_KEYBD) != 0) {
898 if ((ev_out->emo_events & MU_BUTTON) != 0) {
909 OBJECT * toolbartree;
910 struct gemtk_wm_scroll_info_s *slid;
911 uint32_t kind = CLOSER | NAME | MOVER | VSLIDE | HSLIDE | UPARROW
912 | DNARROW | LFARROW | RTARROW | SIZER;
914 dlgtree = gemtk_obj_get_tree(SETTINGS);
915 toolbartree = gemtk_obj_get_tree(TOOLBAR_SETTINGS);
916 area.g_x = area.g_y = 0;
919 wind_calc_grect(WC_BORDER, kind, &area, &area);
920 h_aes_win = wind_create_grect(kind, &area);
921 wind_set_str(
h_aes_win, WF_NAME,
"Settings");
927 curr.g_y = (
desk_area.g_h / 2) - (curr.g_h / 2);
929 wind_calc_grect(WC_BORDER, kind, &curr, &curr);
946 (
dlgtree->ob_width/slid->x_unit_px),
947 (
dlgtree->ob_height/slid->y_unit_px));
954 NSLOG(netsurf, INFO,
"closing");
960 NSLOG(netsurf, INFO,
"Done");
char * atari_find_resource(char *buf, const char *filename, const char *def)
const char * file_select(const char *title, const char *name)
Show default file selector.
nserror atari_warn_user(const char *warning, const char *detail)
Warn the user of an event.
directory traversal and entry
#define NOF_ELEMENTS(array)
Atari bitmap handling implementation.
#define NSLOG(catname, level, logmsg, args...)
plotter style interfaces, generic styles and style colour helpers.
static const char * font_engines[]
static unsigned int tmp_option_min_reflow_period
static void form_event(int index, int external)
static unsigned int tmp_option_max_fetchers
static const char * gui_timeouts[]
static unsigned tmp_option_memory_cache_size
static void toggle_objects(void)
Toogle all objects which are directly influenced by other GUI elements ( like checkbox )
static void save_settings(void)
static unsigned int tmp_option_max_fetchers_per_host
#define INPUT_PROXY_HOST_MAX_LEN
static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
static void set_text(short idx, char *text, int len)
static GUIWIN * settings_guiwin
static unsigned int tmp_option_disc_cache_size
static unsigned int tmp_option_disc_cache_age
#define INPUT_PROXY_PORT_MAX_LEN
void close_settings(void)
#define LABEL_FONT_RENDERER_MAX_LEN
static unsigned int tmp_option_expire_url
#define INPUT_LOCALE_MAX_LEN
#define INPUT_PROXY_PASSWORD_MAX_LEN
static void display_settings(void)
#define INPUT_MIN_REFLOW_PERIOD_MAX_LEN
static void handle_filesystem_select_button(short rsc_bt)
static unsigned int tmp_option_max_cached_fetch_handles
#define OBJ_SELECTED(idx)
static unsigned int tmp_option_font_min_size
static char ** read_locales(void)
#define INPUT_HOMEPAGE_URL_MAX_LEN
#define INPUT_PROXY_USERNAME_MAX_LEN
static void apply_settings(void)
static unsigned int tmp_option_font_size
#define LABEL_PATH_MAX_LEN
Interface to utility string handling.
Interface to time operations.
nserror nsoption_read(const char *path, struct nsoption_s *opts)
Read choices file and set them in the passed table.
nserror nsoption_write(const char *path, struct nsoption_s *opts, struct nsoption_s *defs)
Write options that have changed from the defaults to a file.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
@ OPTION_HTTP_PROXY_AUTH_NONE
@ OPTION_HTTP_PROXY_AUTH_BASIC
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Interface to a number of general purpose functionality.
bool is_dir(const char *path)
Check if a directory exists.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.