END_HANDLER COMBO_CHANGED(comboProxyType, http_proxy_auth) { LOG(("proxy auth: %d", nsoption_int(http_proxy_auth))); switch (nsoption_int(http_proxy_auth)) { case 0: nsoption_set_bool(http_proxy, false); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); break; case 1: nsoption_set_bool(http_proxy, true); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); break; case 2: nsoption_set_bool(http_proxy, true); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC); break; case 3: nsoption_set_bool(http_proxy, true); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NTLM); break; } gboolean sensitive = (!proxy_type == 0); gtk_widget_set_sensitive(entryProxyHost, sensitive); gtk_widget_set_sensitive(entryProxyPort, sensitive); gtk_widget_set_sensitive(entryProxyUser, sensitive); gtk_widget_set_sensitive(entryProxyPassword, sensitive); }
END_HANDLER BUTTON_CLICKED(setDefaultExportOptions) { nsoption_set_int(margin_top, DEFAULT_MARGIN_TOP_MM); nsoption_set_int(margin_bottom, DEFAULT_MARGIN_BOTTOM_MM); nsoption_set_int(margin_left, DEFAULT_MARGIN_LEFT_MM); nsoption_set_int(margin_right, DEFAULT_MARGIN_RIGHT_MM); nsoption_set_int(export_scale, DEFAULT_EXPORT_SCALE * 100); nsoption_set_bool(suppress_images, false); nsoption_set_bool(remove_backgrounds, false); nsoption_set_bool(enable_loosening, true); nsoption_set_bool(enable_PDF_compression, true); nsoption_set_bool(enable_PDF_password, false); SET_SPIN(spinMarginTop, nsoption_int(margin_top)); SET_SPIN(spinMarginBottom, nsoption_int(margin_bottom)); SET_SPIN(spinMarginLeft, nsoption_int(margin_left)); SET_SPIN(spinMarginRight, nsoption_int(margin_right)); SET_SPIN(spinExportScale, nsoption_int(export_scale)); SET_CHECK(checkSuppressImages, nsoption_bool(suppress_images)); SET_CHECK(checkRemoveBackgrounds, nsoption_bool(remove_backgrounds)); SET_CHECK(checkCompressPDF, nsoption_bool(enable_PDF_compression)); SET_CHECK(checkPasswordPDF, nsoption_bool(enable_PDF_password)); SET_CHECK(checkFitPage, nsoption_bool(enable_loosening)); }
HOOKF(void, ami_history_global_menu_item_project_snapshot, APTR, window, struct IntuiMessage *) { struct ami_corewindow *ami_cw; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw); nsoption_set_int(history_window_ypos, ami_cw->win->TopEdge); nsoption_set_int(history_window_xpos, ami_cw->win->LeftEdge); nsoption_set_int(history_window_xsize, ami_cw->win->Width); nsoption_set_int(history_window_ysize, ami_cw->win->Height); }
static void ami_menu_item_settings_snapshot(struct Hook *hook, APTR window, struct IntuiMessage *msg) { struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); nsoption_set_int(window_x, gwin->win->LeftEdge); nsoption_set_int(window_y, gwin->win->TopEdge); nsoption_set_int(window_width, gwin->win->Width); nsoption_set_int(window_height, gwin->win->Height); }
BOOL ami_print_event(struct ami_print_window *pw) { /* return TRUE if window destroyed */ ULONG result; uint16 code; struct hlcache_handle *c; int copies; int print_scale; int printer_unit; while((result = RA_HandleInput(pw->objects[OID_MAIN],&code)) != WMHI_LASTMSG) { switch(result & WMHI_CLASSMASK) // class { case WMHI_GADGETUP: switch(result & WMHI_GADGETMASK) { case PGID_PRINT: GetAttr(INTEGER_Number, pw->gadgets[PGID_SCALE], (ULONG *)&print_scale); GetAttr(INTEGER_Number, pw->gadgets[PGID_COPIES], (ULONG *)&copies); GetAttr(CHOOSER_Selected, pw->gadgets[PGID_PRINTER], (ULONG *)&printer_unit); nsoption_set_int(print_scale, print_scale); nsoption_set_int(printer_unit, printer_unit); c = pw->c; ami_print_close(pw); ami_print(c, copies); return TRUE; break; case PGID_CANCEL: ami_print_close(pw); return TRUE; break; } break; case WMHI_CLOSEWINDOW: ami_print_close(pw); return TRUE; break; } } return FALSE; }
static nserror nsgtk_option_init(int *pargc, char** argv) { nserror ret; char *choices = NULL; /* user options setup */ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default); if (ret != NSERROR_OK) { return ret; } /* Attempt to load the user choices */ ret = netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices"); if (ret == NSERROR_OK) { nsoption_read(choices, nsoptions); free(choices); } /* overide loaded options with those from commandline */ nsoption_commandline(pargc, argv, nsoptions); /* ensure all options fall within sensible bounds */ /* Attempt to handle nonsense status bar widths. These may exist * in people's Choices as the GTK front end used to abuse the * status bar width option by using it for an absolute value in px. * The GTK front end now correctly uses it as a proportion of window * width. Here we assume that a value of less than 15% is wrong * and set to the default two thirds. */ if (nsoption_int(toolbar_status_size) < 1500) { nsoption_set_int(toolbar_status_size, 6667); } return NSERROR_OK; }
bool ro_gui_options_fonts_ok(wimp_w w) { unsigned int i; nsoption_set_int(font_size, ro_gui_get_icon_decimal(w, FONT_DEFAULT_SIZE, 1)); nsoption_set_int(font_min_size, ro_gui_get_icon_decimal(w, FONT_MINIMUM_SIZE, 1)); if (nsoption_int(font_size) < nsoption_int(font_min_size)) { nsoption_set_int(font_size, nsoption_int(font_min_size)); ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, nsoption_int(font_size), 1); } nsoption_set_charp(font_sans, strdup(ro_gui_get_icon_string(w, FONT_SANS_FIELD))); nsoption_set_charp(font_serif, strdup(ro_gui_get_icon_string(w, FONT_SERIF_FIELD))); nsoption_set_charp(font_mono, strdup(ro_gui_get_icon_string(w, FONT_MONOSPACE_FIELD))); nsoption_set_charp(font_cursive, strdup(ro_gui_get_icon_string(w, FONT_CURSIVE_FIELD))); nsoption_set_charp(font_fantasy, strdup(ro_gui_get_icon_string(w, FONT_FANTASY_FIELD))); for (i = 0; i != 5; i++) { if (!strcmp(font_names[i], ro_gui_get_icon_string(w, FONT_DEFAULT_FIELD))) break; } if (i == 5) /* this should never happen, but still */ i = 0; nsoption_set_int(font_default, i); ro_gui_save_options(); return true; }
END_HANDLER static gboolean on_spinAnimationSpeed_changed(GtkWidget *widget, gpointer data) { LOG(("Signal emitted on '%s'", "spinAnimationSpeed")); nsoption_set_int(minimum_gif_delay, round(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)) * 100.0)); return FALSE; }
static void __CDECL menu_savewin(short item, short title, void *data) { LOG(("%s", __FUNCTION__)); if (input_window && input_window->browser) { GRECT rect; wind_get_grect(gemtk_wm_get_handle(input_window->root->win), WF_CURRXYWH, &rect); option_window_width = rect.g_w; option_window_height = rect.g_h; option_window_x = rect.g_x; option_window_y = rect.g_y; nsoption_set_int(window_width, rect.g_w); nsoption_set_int(window_height, rect.g_h); nsoption_set_int(window_x, rect.g_x); nsoption_set_int(window_y, rect.g_y); nsoption_write((const char*)&options); } }
/* Documented in desktop/options.h */ void gui_options_init_defaults(void) { /* Set defaults for absent option strings */ nsoption_setnull_charp(cookie_file, strdup("cookies")); if (nsoption_charp(cookie_file) == NULL) { die("Failed initialising string options"); } nsoption_set_int(min_reflow_period, 350); }
bool ro_gui_options_security_ok(wimp_w w) { nsoption_set_bool(send_referer, ro_gui_get_icon_selected_state(w, SECURITY_REFERRER)); nsoption_set_int(expire_url, ro_gui_get_icon_decimal(w,SECURITY_DURATION_FIELD, 0)); ro_gui_save_options(); return true; }
END_HANDLER COMBO_CHANGED(comboTabPosition, position_tab) { nsgtk_scaffolding *current = scaf_list; nsoption_set_int(button_type, nsoption_int(button_type) + 1); /* value of 0 is reserved for 'unset' */ while (current) { nsgtk_scaffolding_reset_offset(current); nsgtk_reflow_all_windows(); current = nsgtk_scaffolding_iterate(current); } }
bool ro_gui_options_image_ok(wimp_w w) { ro_gui_options_image_read(w, (unsigned int *)&nsoption_int(plot_bg_quality), (unsigned int *)&nsoption_int(plot_fg_quality)); nsoption_set_int(minimum_gif_delay, ro_gui_get_icon_decimal(w, IMAGE_SPEED_FIELD, 2)); nsoption_set_bool(animate_images, !ro_gui_get_icon_selected_state(w, IMAGE_DISABLE_ANIMATION)); ro_gui_save_options(); return true; }
gboolean on_entryProxyPort_changed(GtkWidget *widget, gpointer data) { long port; errno = 0; port = strtol((char *)gtk_entry_get_text(GTK_ENTRY(entryProxyPort)), NULL, 10) & 0xffff; if ((port != 0) && (errno == 0)) { nsoption_set_int(http_proxy_port, port); } else { char buf[32]; snprintf(buf, sizeof(buf), "%d", nsoption_int(http_proxy_port)); SET_ENTRY(entryProxyPort, buf); } return FALSE; }
END_HANDLER COMBO_CHANGED(comboButtonType, button_type) { nsgtk_scaffolding *current = scaf_list; nsoption_set_int(button_type, nsoption_int(button_type) + 1); /* value of 0 is reserved for 'unset' */ while (current) { nsgtk_scaffolding_reset_offset(current); switch(nsoption_int(button_type)) { case 1: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_ICONS); gtk_toolbar_set_icon_size( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_ICON_SIZE_SMALL_TOOLBAR); break; case 2: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_ICONS); gtk_toolbar_set_icon_size( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_ICON_SIZE_LARGE_TOOLBAR); break; case 3: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_BOTH); gtk_toolbar_set_icon_size( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_ICON_SIZE_LARGE_TOOLBAR); break; case 4: gtk_toolbar_set_style( GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)), GTK_TOOLBAR_TEXT); default: break; } current = nsgtk_scaffolding_iterate(current); } }
/** * Initialize font handling. * * Exits through die() on error. */ void nsfont_init(void) { const char *fallback; rufl_code code; nsfont_check_fonts(); LOG("Initialise RUfl"); code = rufl_init(); if (code != rufl_OK) { if (code == rufl_FONT_MANAGER_ERROR) LOG("rufl_init: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess); else LOG("rufl_init: 0x%x", code); die("The Unicode font library could not be initialized. " "Please report this to the developers."); } LOG("RUfl initialised"); if (rufl_family_list_entries == 0) die("No fonts could be found. At least one font must be " "installed."); fallback = nsfont_fallback_font(); nsfont_check_option(&nsoption_charp(font_sans), "Homerton", fallback); nsfont_check_option(&nsoption_charp(font_serif), "Trinity", fallback); nsfont_check_option(&nsoption_charp(font_mono), "Corpus", fallback); nsfont_check_option(&nsoption_charp(font_cursive), "Churchill", fallback); nsfont_check_option(&nsoption_charp(font_fantasy), "Sassoon", fallback); if (nsoption_int(font_default) != PLOT_FONT_FAMILY_SANS_SERIF && nsoption_int(font_default) != PLOT_FONT_FAMILY_SERIF && nsoption_int(font_default) != PLOT_FONT_FAMILY_MONOSPACE && nsoption_int(font_default) != PLOT_FONT_FAMILY_CURSIVE && nsoption_int(font_default) != PLOT_FONT_FAMILY_FANTASY) { nsoption_set_int(font_default, PLOT_FONT_FAMILY_SANS_SERIF); } }
static BOOL CALLBACK options_appearance_dialog_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lParam) { int len; char *temp, number[6]; HWND sub; LOG_WIN_MSG(hwnd, msg, wparam, lParam); switch (msg) { case WM_INITDIALOG: sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF); 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, (WPARAM) (nsoption_int(font_default) - 1), 0); if ((nsoption_charp(font_sans) != NULL) && (nsoption_charp(font_sans)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SANS); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_sans)); } if ((nsoption_charp(font_serif) != NULL) && (nsoption_charp(font_serif)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SERIF); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_serif)); } if ((nsoption_charp(font_mono) != NULL) && (nsoption_charp(font_mono)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_MONO); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_mono)); } if ((nsoption_charp(font_cursive) != NULL) && (nsoption_charp(font_cursive)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_cursive)); } if ((nsoption_charp(font_fantasy) != NULL) && (nsoption_charp(font_fantasy)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_fantasy)); } if (nsoption_int(font_min_size) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE); snprintf(number, 6, "%.1f", nsoption_int(font_min_size) / 10.0); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } if (nsoption_int(font_size) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE); snprintf(number, 6, "%.1f", nsoption_int(font_size) / 10.0); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } if (nsoption_int(max_fetchers) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS); snprintf(number, 6, "%d", nsoption_int(max_fetchers)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } if (nsoption_int(max_fetchers_per_host) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST); snprintf(number, 6, "%d", nsoption_int(max_fetchers_per_host)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } if (nsoption_int(max_cached_fetch_handles) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES); snprintf(number, 6, "%d", nsoption_int(max_cached_fetch_handles)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } /* animation */ sub = GetDlgItem(hwnd, IDC_PREFS_NOANIMATION); SendMessage(sub, BM_SETCHECK, (WPARAM)((nsoption_bool(animate_images)) ? BST_UNCHECKED : BST_CHECKED), 0); if (nsoption_int(minimum_gif_delay) != 0) { sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY); snprintf(number, 6, "%.1f", nsoption_int(minimum_gif_delay) / 100.0); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } break; case WM_NOTIFY: switch (((NMHDR FAR *)lParam)->code) { case PSN_APPLY: sub = GetDlgItem(hwnd, IDC_PREFS_FONT_SIZE); len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM) (len + 1), (LPARAM) temp); nsoption_int(font_size) = (int) (10 * strtod(temp, NULL)); free(temp); } sub = GetDlgItem(hwnd, IDC_PREFS_FONT_MINSIZE); len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM) (len + 1), (LPARAM) temp); nsoption_set_int(font_min_size, (int)(10 * strtod(temp, NULL))); free(temp); } /* animation */ nsoption_set_bool(animate_images, (IsDlgButtonChecked(hwnd, IDC_PREFS_NOANIMATION) == BST_CHECKED) ? true : false); sub = GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY); len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM) (len + 1), (LPARAM) temp); nsoption_set_int(minimum_gif_delay, (int)(100 * strtod(temp, NULL))); free(temp); } 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; case IDC_PREFS_ANIMATIONDELAY_SPIN: change_spinner(GetDlgItem(hwnd, IDC_PREFS_ANIMATIONDELAY), 0.1 * ud->iDelta, 0.1, 100.0); return TRUE; } } break; } case WM_COMMAND: LOG(("WM_COMMAND Identifier 0x%x",LOWORD(wparam))); switch(LOWORD(wparam)) { case IDC_PREFS_PROXYTYPE: sub = GetDlgItem(hwnd, IDC_PREFS_PROXYTYPE); nsoption_set_int(http_proxy_auth, SendMessage(sub, CB_GETCURSEL, 0, 0) - 1); nsoption_set_bool(http_proxy, (nsoption_int(http_proxy_auth) != -1)); nsoption_set_int(http_proxy_auth, nsoption_int(http_proxy_auth) + (nsoption_bool(http_proxy)) ? 0 : 1); break; case IDC_PREFS_SANS: { CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SWISS, hwnd); if (cf == NULL) { break; } if (ChooseFont(cf) == TRUE) { nsoption_set_charp(font_sans, strdup(cf->lpLogFont->lfFaceName)); } free(cf->lpLogFont); free(cf); if ((nsoption_charp(font_sans) != NULL) && (nsoption_charp(font_sans)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SANS); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_sans)); } break; } case IDC_PREFS_SERIF: { CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_ROMAN, hwnd); if (cf == NULL) { break; } if (ChooseFont(cf) == TRUE) { nsoption_set_charp(font_serif, strdup(cf->lpLogFont->lfFaceName)); } free(cf->lpLogFont); free(cf); if ((nsoption_charp(font_serif) != NULL) && (nsoption_charp(font_serif)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_SERIF); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_serif)); } break; } case IDC_PREFS_MONO: { CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_MODERN, hwnd); if (cf == NULL) { break; } if (ChooseFont(cf) == TRUE) { nsoption_set_charp(font_mono, strdup(cf->lpLogFont->lfFaceName)); } free(cf->lpLogFont); free(cf); if ((nsoption_charp(font_mono) != NULL) && (nsoption_charp(font_mono)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_MONO); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_mono)); } break; } case IDC_PREFS_CURSIVE: { CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_SCRIPT, hwnd); if (cf == NULL) { break; } if (ChooseFont(cf) == TRUE) { nsoption_set_charp(font_cursive, strdup(cf->lpLogFont->lfFaceName)); } free(cf->lpLogFont); free(cf); if ((nsoption_charp(font_cursive) != NULL) && (nsoption_charp(font_cursive)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_CURSIVE); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_cursive)); } break; } case IDC_PREFS_FANTASY: { CHOOSEFONT *cf = nsws_prefs_font_prepare(FF_DECORATIVE, hwnd); if (cf == NULL) { break; } if (ChooseFont(cf) == TRUE) { nsoption_set_charp(font_fantasy, strdup(cf->lpLogFont->lfFaceName)); } free(cf->lpLogFont); free(cf); if ((nsoption_charp(font_fantasy) != NULL) && (nsoption_charp(font_fantasy)[0] != '\0')) { sub = GetDlgItem(hwnd, IDC_PREFS_FANTASY); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(font_fantasy)); } break; } case IDC_PREFS_FONTDEF: sub = GetDlgItem(hwnd, IDC_PREFS_FONTDEF); nsoption_set_int(font_default, SendMessage(sub, CB_GETCURSEL, 0, 0) + 1); break; } break; } return FALSE; }
static gboolean nsgtk_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) { struct gui_window *gw = data; struct gui_window *z; struct rect clip; struct redraw_context ctx = { .interactive = true, .background_images = true, .plot = &nsgtk_plotters }; double x1; double y1; double x2; double y2; assert(gw); assert(gw->bw); for (z = window_list; z && z != gw; z = z->next) continue; assert(z); assert(GTK_WIDGET(gw->layout) == widget); current_widget = (GtkWidget *)gw->layout; current_cr = cr; GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(gw->layout); GtkAdjustment *hscroll = nsgtk_layout_get_hadjustment(gw->layout); cairo_clip_extents(cr, &x1, &y1, &x2, &y2); clip.x0 = x1; clip.y0 = y1; clip.x1 = x2; clip.y1 = y2; browser_window_redraw(gw->bw, -gtk_adjustment_get_value(hscroll), -gtk_adjustment_get_value(vscroll), &clip, &ctx); if (gw->careth != 0) { nsgtk_plot_caret(gw->caretx, gw->carety, gw->careth); } current_widget = NULL; return FALSE; } #else static gboolean nsgtk_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { struct gui_window *gw = data; struct gui_window *z; struct rect clip; struct redraw_context ctx = { .interactive = true, .background_images = true, .plot = &nsgtk_plotters }; assert(gw); assert(gw->bw); for (z = window_list; z && z != gw; z = z->next) continue; assert(z); assert(GTK_WIDGET(gw->layout) == widget); current_widget = (GtkWidget *)gw->layout; current_cr = gdk_cairo_create(nsgtk_layout_get_bin_window(gw->layout)); clip.x0 = event->area.x; clip.y0 = event->area.y; clip.x1 = event->area.x + event->area.width; clip.y1 = event->area.y + event->area.height; browser_window_redraw(gw->bw, 0, 0, &clip, &ctx); if (gw->careth != 0) { nsgtk_plot_caret(gw->caretx, gw->carety, gw->careth); } cairo_destroy(current_cr); current_widget = NULL; return FALSE; } #endif static gboolean nsgtk_window_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) { struct gui_window *g = data; bool shift = event->state & GDK_SHIFT_MASK; bool ctrl = event->state & GDK_CONTROL_MASK; if ((abs(event->x - g->last_x) < 5) && (abs(event->y - g->last_y) < 5)) { /* Mouse hasn't moved far enough from press coordinate for this * to be considered a drag. */ return FALSE; } else { /* This is a drag, ensure it's always treated as such, even if * we drag back over the press location */ g->last_x = INT_MIN; g->last_y = INT_MIN; } if (g->mouse.state & BROWSER_MOUSE_PRESS_1) { /* Start button 1 drag */ browser_window_mouse_click(g->bw, BROWSER_MOUSE_DRAG_1, g->mouse.pressed_x, g->mouse.pressed_y); /* Replace PRESS with HOLDING and declare drag in progress */ g->mouse.state ^= (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_HOLDING_1); g->mouse.state |= BROWSER_MOUSE_DRAG_ON; } else if (g->mouse.state & BROWSER_MOUSE_PRESS_2) { /* Start button 2 drag */ browser_window_mouse_click(g->bw, BROWSER_MOUSE_DRAG_2, g->mouse.pressed_x, g->mouse.pressed_y); /* Replace PRESS with HOLDING and declare drag in progress */ g->mouse.state ^= (BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_HOLDING_2); g->mouse.state |= BROWSER_MOUSE_DRAG_ON; } /* Handle modifiers being removed */ if (g->mouse.state & BROWSER_MOUSE_MOD_1 && !shift) g->mouse.state ^= BROWSER_MOUSE_MOD_1; if (g->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl) g->mouse.state ^= BROWSER_MOUSE_MOD_2; browser_window_mouse_track(g->bw, g->mouse.state, event->x / browser_window_get_scale(g->bw), event->y / browser_window_get_scale(g->bw)); return TRUE; } static gboolean nsgtk_window_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) { struct gui_window *g = data; gtk_widget_grab_focus(GTK_WIDGET(g->layout)); gtk_widget_hide(GTK_WIDGET(nsgtk_scaffolding_history_window( g->scaffold)->window)); g->mouse.pressed_x = event->x / browser_window_get_scale(g->bw); g->mouse.pressed_y = event->y / browser_window_get_scale(g->bw); switch (event->button) { case 1: /* Left button, usually. Pass to core as BUTTON 1. */ g->mouse.state = BROWSER_MOUSE_PRESS_1; break; case 2: /* Middle button, usually. Pass to core as BUTTON 2 */ g->mouse.state = BROWSER_MOUSE_PRESS_2; break; case 3: /* Right button, usually. Action button, context menu. */ browser_window_remove_caret(g->bw, true); nsgtk_scaffolding_popup_menu(g->scaffold, g->mouse.pressed_x, g->mouse.pressed_y); return TRUE; default: return FALSE; } /* Modify for double & triple clicks */ if (event->type == GDK_3BUTTON_PRESS) g->mouse.state |= BROWSER_MOUSE_TRIPLE_CLICK; else if (event->type == GDK_2BUTTON_PRESS) g->mouse.state |= BROWSER_MOUSE_DOUBLE_CLICK; /* Handle the modifiers too */ if (event->state & GDK_SHIFT_MASK) g->mouse.state |= BROWSER_MOUSE_MOD_1; if (event->state & GDK_CONTROL_MASK) g->mouse.state |= BROWSER_MOUSE_MOD_2; /* Record where we pressed, for use when determining whether to start * a drag in motion notify events. */ g->last_x = event->x; g->last_y = event->y; browser_window_mouse_click(g->bw, g->mouse.state, g->mouse.pressed_x, g->mouse.pressed_y); return TRUE; } static gboolean nsgtk_window_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) { struct gui_window *g = data; bool shift = event->state & GDK_SHIFT_MASK; bool ctrl = event->state & GDK_CONTROL_MASK; /* If the mouse state is PRESS then we are waiting for a release to emit * a click event, otherwise just reset the state to nothing */ if (g->mouse.state & BROWSER_MOUSE_PRESS_1) g->mouse.state ^= (BROWSER_MOUSE_PRESS_1 | BROWSER_MOUSE_CLICK_1); else if (g->mouse.state & BROWSER_MOUSE_PRESS_2) g->mouse.state ^= (BROWSER_MOUSE_PRESS_2 | BROWSER_MOUSE_CLICK_2); /* Handle modifiers being removed */ if (g->mouse.state & BROWSER_MOUSE_MOD_1 && !shift) g->mouse.state ^= BROWSER_MOUSE_MOD_1; if (g->mouse.state & BROWSER_MOUSE_MOD_2 && !ctrl) g->mouse.state ^= BROWSER_MOUSE_MOD_2; if (g->mouse.state & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) { browser_window_mouse_click(g->bw, g->mouse.state, event->x / browser_window_get_scale(g->bw), event->y / browser_window_get_scale(g->bw)); } else { browser_window_mouse_track(g->bw, 0, event->x / browser_window_get_scale(g->bw), event->y / browser_window_get_scale(g->bw)); } g->mouse.state = 0; return TRUE; } static gboolean nsgtk_window_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data) { struct gui_window *g = data; double value; double deltax = 0; double deltay = 0; GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(g->layout); GtkAdjustment *hscroll = nsgtk_layout_get_hadjustment(g->layout); GtkAllocation alloc; switch (event->direction) { case GDK_SCROLL_LEFT: deltax = -1.0; break; case GDK_SCROLL_UP: deltay = -1.0; break; case GDK_SCROLL_RIGHT: deltax = 1.0; break; case GDK_SCROLL_DOWN: deltay = 1.0; break; #if GTK_CHECK_VERSION(3,4,0) case GDK_SCROLL_SMOOTH: gdk_event_get_scroll_deltas((GdkEvent *)event, &deltax, &deltay); break; #endif default: LOG(("Unhandled mouse scroll direction")); return TRUE; } deltax *= nsgtk_adjustment_get_step_increment(hscroll); deltay *= nsgtk_adjustment_get_step_increment(vscroll); if (browser_window_scroll_at_point(g->bw, event->x / browser_window_get_scale(g->bw), event->y / browser_window_get_scale(g->bw), deltax, deltay) != true) { /* core did not handle event so change adjustments */ /* Horizontal */ if (deltax != 0) { value = gtk_adjustment_get_value(hscroll) + deltax; /* @todo consider gtk_widget_get_allocated_width() */ nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); if (value > nsgtk_adjustment_get_upper(hscroll) - alloc.width) { value = nsgtk_adjustment_get_upper(hscroll) - alloc.width; } if (value < nsgtk_adjustment_get_lower(hscroll)) { value = nsgtk_adjustment_get_lower(hscroll); } gtk_adjustment_set_value(hscroll, value); } /* Vertical */ if (deltay != 0) { value = gtk_adjustment_get_value(vscroll) + deltay; /* @todo consider gtk_widget_get_allocated_height */ nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); if (value > (nsgtk_adjustment_get_upper(vscroll) - alloc.height)) { value = nsgtk_adjustment_get_upper(vscroll) - alloc.height; } if (value < nsgtk_adjustment_get_lower(vscroll)) { value = nsgtk_adjustment_get_lower(vscroll); } gtk_adjustment_set_value(vscroll, value); } } return TRUE; } static gboolean nsgtk_window_keypress_event(GtkWidget *widget, GdkEventKey *event, gpointer data) { struct gui_window *g = data; uint32_t nskey = gtk_gui_gdkkey_to_nskey(event); if (browser_window_key_press(g->bw, nskey)) return TRUE; if ((event->state & 0x7) != 0) return TRUE; double value; GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(g->layout); GtkAdjustment *hscroll = nsgtk_layout_get_hadjustment(g->layout); GtkAllocation alloc; /* @todo consider gtk_widget_get_allocated_width() */ nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); switch (event->keyval) { case GDK_KEY(Home): case GDK_KEY(KP_Home): value = nsgtk_adjustment_get_lower(vscroll); gtk_adjustment_set_value(vscroll, value); break; case GDK_KEY(End): case GDK_KEY(KP_End): value = nsgtk_adjustment_get_upper(vscroll) - alloc.height; if (value < nsgtk_adjustment_get_lower(vscroll)) value = nsgtk_adjustment_get_lower(vscroll); gtk_adjustment_set_value(vscroll, value); break; case GDK_KEY(Left): case GDK_KEY(KP_Left): value = gtk_adjustment_get_value(hscroll) - nsgtk_adjustment_get_step_increment(hscroll); if (value < nsgtk_adjustment_get_lower(hscroll)) value = nsgtk_adjustment_get_lower(hscroll); gtk_adjustment_set_value(hscroll, value); break; case GDK_KEY(Up): case GDK_KEY(KP_Up): value = gtk_adjustment_get_value(vscroll) - nsgtk_adjustment_get_step_increment(vscroll); if (value < nsgtk_adjustment_get_lower(vscroll)) value = nsgtk_adjustment_get_lower(vscroll); gtk_adjustment_set_value(vscroll, value); break; case GDK_KEY(Right): case GDK_KEY(KP_Right): value = gtk_adjustment_get_value(hscroll) + nsgtk_adjustment_get_step_increment(hscroll); if (value > nsgtk_adjustment_get_upper(hscroll) - alloc.width) value = nsgtk_adjustment_get_upper(hscroll) - alloc.width; gtk_adjustment_set_value(hscroll, value); break; case GDK_KEY(Down): case GDK_KEY(KP_Down): value = gtk_adjustment_get_value(vscroll) + nsgtk_adjustment_get_step_increment(vscroll); if (value > nsgtk_adjustment_get_upper(vscroll) - alloc.height) value = nsgtk_adjustment_get_upper(vscroll) - alloc.height; gtk_adjustment_set_value(vscroll, value); break; case GDK_KEY(Page_Up): case GDK_KEY(KP_Page_Up): value = gtk_adjustment_get_value(vscroll) - nsgtk_adjustment_get_page_increment(vscroll); if (value < nsgtk_adjustment_get_lower(vscroll)) value = nsgtk_adjustment_get_lower(vscroll); gtk_adjustment_set_value(vscroll, value); break; case GDK_KEY(Page_Down): case GDK_KEY(KP_Page_Down): value = gtk_adjustment_get_value(vscroll) + nsgtk_adjustment_get_page_increment(vscroll); if (value > nsgtk_adjustment_get_upper(vscroll) - alloc.height) value = nsgtk_adjustment_get_upper(vscroll) - alloc.height; gtk_adjustment_set_value(vscroll, value); break; default: break; } return TRUE; } static gboolean nsgtk_window_size_allocate_event(GtkWidget *widget, GtkAllocation *allocation, gpointer data) { struct gui_window *g = data; g->bw->reformat_pending = true; browser_reformat_pending = true; return TRUE; } /** when the pane position is changed update the user option * * The slightly awkward implementation with the first allocation flag * is necessary because the initial window creation does not cause an * allocate-event signal so the position value in the pane is incorrect * and we cannot know what it should be until after the allocation * (which did not generate a signal) is done as the user position is a * percentage of pane total width not an absolute value. */ static void nsgtk_paned_notify__position(GObject *gobject, GParamSpec *pspec, gpointer data) { struct gui_window *g = data; GtkAllocation pane_alloc; gtk_widget_get_allocation(GTK_WIDGET(g->paned), &pane_alloc); if (g->paned_sized == false) { g->paned_sized = true; gtk_paned_set_position(g->paned, (nsoption_int(toolbar_status_size) * pane_alloc.width) / 10000); return; } nsoption_set_int(toolbar_status_size, ((gtk_paned_get_position(g->paned) * 10000) / (pane_alloc.width - 1))); } /** Set status bar / scroll bar proportion according to user option * when pane is resized. */ static gboolean nsgtk_paned_size_allocate_event(GtkWidget *widget, GtkAllocation *allocation, gpointer data) { gtk_paned_set_position(GTK_PANED(widget), (nsoption_int(toolbar_status_size) * allocation->width) / 10000); return TRUE; } /* destroy the browsing context as there is nothing to display it now */ static void window_destroy(GtkWidget *widget, gpointer data) { struct gui_window *gw = data; browser_window_destroy(gw->bw); } /* Core interface documented in desktop/gui.h to create a gui_window */ static struct gui_window * gui_window_create(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags) { struct gui_window *g; /**< what we're creating to return */ GError* error = NULL; bool tempback; GtkBuilder* xml; /* open builder file first to ease error handling on faliure */ xml = gtk_builder_new(); if (!gtk_builder_add_from_file(xml, glade_file_location->tabcontents, &error)) { g_warning ("Couldn't load builder file: %s", error->message); g_error_free(error); return NULL; } g = calloc(1, sizeof(*g)); if (!g) { warn_user("NoMemory", 0); g_object_unref(xml); return NULL; } LOG(("Creating gui window %p for browser window %p", g, bw)); g->bw = bw; g->mouse.state = 0; g->current_pointer = GUI_POINTER_DEFAULT; if (flags & GW_CREATE_CLONE) { assert(existing != NULL); bw->scale = existing->bw->scale; } else { bw->scale = nsoption_int(scale) / 100; } /* attach scaffold */ if (flags & GW_CREATE_TAB) { assert(existing != NULL); g->scaffold = existing->scaffold; } else { /* Now construct and attach a scaffold */ g->scaffold = nsgtk_new_scaffolding(g); } if (g->scaffold == NULL) { warn_user("NoMemory", 0); free(g); g_object_unref(xml); return NULL; } /* Construct our primary elements */ g->container = GTK_WIDGET(gtk_builder_get_object(xml, "tabContents")); g->layout = GTK_LAYOUT(gtk_builder_get_object(xml, "layout")); g->status_bar = GTK_LABEL(gtk_builder_get_object(xml, "status_bar")); g->paned = GTK_PANED(gtk_builder_get_object(xml, "hpaned1")); /* add new gui window to global list (push_top) */ if (window_list) { window_list->prev = g; } g->next = window_list; g->prev = NULL; window_list = g; /* set the events we're interested in receiving from the browser's * drawing area. */ gtk_widget_add_events(GTK_WIDGET(g->layout), GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_SCROLL_MASK); nsgtk_widget_set_can_focus(GTK_WIDGET(g->layout), TRUE); /* set the default background colour of the drawing area to white. */ nsgtk_widget_override_background_color(GTK_WIDGET(g->layout), GTK_STATE_NORMAL, 0, 0xffff, 0xffff, 0xffff); nsgtk_connect_draw_event(GTK_WIDGET(g->layout), G_CALLBACK(nsgtk_window_draw_event), g); /* layout signals */ CONNECT(g->layout, "motion-notify-event", nsgtk_window_motion_notify_event, g); g->signalhandler[NSGTK_WINDOW_SIGNAL_CLICK] = CONNECT(g->layout, "button-press-event", nsgtk_window_button_press_event, g); CONNECT(g->layout, "button-release-event", nsgtk_window_button_release_event, g); CONNECT(g->layout, "key-press-event", nsgtk_window_keypress_event, g); CONNECT(g->layout, "size-allocate", nsgtk_window_size_allocate_event, g); CONNECT(g->layout, "scroll-event", nsgtk_window_scroll_event, g); /* status pane signals */ CONNECT(g->paned, "size-allocate", nsgtk_paned_size_allocate_event, g); CONNECT(g->paned, "notify::position", nsgtk_paned_notify__position, g); /* gtk container destructor */ CONNECT(g->container, "destroy", window_destroy, g); /* add the tab container to the scaffold notebook */ switch (temp_open_background) { case -1: tempback = !(nsoption_bool(focus_new)); break; case 0: tempback = false; break; default: tempback = true; break; } nsgtk_tab_add(g, g->container, tempback); /* safe to drop the reference to the xml as the container is * referenced by the notebook now. */ g_object_unref(xml); return g; } void nsgtk_reflow_all_windows(void) { for (struct gui_window *g = window_list; g; g = g->next) { nsgtk_tab_options_changed( nsgtk_scaffolding_notebook(g->scaffold)); g->bw->reformat_pending = true; } browser_reformat_pending = true; } /** * Process pending reformats */ void nsgtk_window_process_reformats(void) { struct gui_window *g; GtkAllocation alloc; browser_reformat_pending = false; for (g = window_list; g; g = g->next) { if (!g->bw->reformat_pending) continue; g->bw->reformat_pending = false; /* @todo consider gtk_widget_get_allocated_width() */ nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); browser_window_reformat(g->bw, false, alloc.width, alloc.height); } } void nsgtk_window_destroy_browser(struct gui_window *gw) { /* remove tab */ gtk_widget_destroy(gw->container); }
static void check_options(char **respath) { char *hdir = getenv("HOME"); char buf[PATH_MAX]; nsoption_set_bool(core_select_menu, true); /* Attempt to handle nonsense status bar widths. These may exist * in people's Choices as the GTK front end used to abuse the * status bar width option by using it for an absolute value in px. * The GTK front end now correctly uses it as a proportion of window * width. Here we assume that a value of less than 15% is wrong * and set to the default two thirds. */ if (nsoption_int(toolbar_status_width) < 1500) { nsoption_set_int(toolbar_status_width, 6667); } /* user options should be stored in the users home directory */ snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir); options_file_location = strdup(buf); /* VRS - I do not beleive these setting should search the * resource path, they should just be set to the default * values! */ if (nsoption_charp(cookie_file) == NULL) { filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); LOG(("Using '%s' as Cookies file", buf)); nsoption_set_charp(cookie_file, strdup(buf)); } if (nsoption_charp(cookie_jar) == NULL) { filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/"); LOG(("Using '%s' as Cookie Jar file", buf)); nsoption_set_charp(cookie_jar, strdup(buf)); } if (nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar) == NULL) die("Failed initialising cookie options"); if (nsoption_charp(url_file) == NULL) { filepath_sfinddef(respath, buf, "URLs", "~/.netsurf/"); LOG(("Using '%s' as URL file", buf)); nsoption_set_charp(url_file, strdup(buf)); } if (nsoption_charp(ca_path) == NULL) { filepath_sfinddef(respath, buf, "certs", "/etc/ssl/"); LOG(("Using '%s' as certificate path", buf)); nsoption_set_charp(ca_path, strdup(buf)); } if (nsoption_charp(downloads_directory) == NULL) { LOG(("Using '%s' as download directory", hdir)); nsoption_set_charp(downloads_directory, strdup(hdir)); } filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/"); LOG(("Using '%s' as Tree icons dir", buf)); tree_set_icon_dir(strdup(buf)); if (nsoption_charp(hotlist_path) == NULL) { filepath_sfinddef(respath, buf, "Hotlist", "~/.netsurf/"); LOG(("Using '%s' as Hotlist file", buf)); nsoption_set_charp(hotlist_path, strdup(buf)); } if (nsoption_charp(hotlist_path) == NULL) die("Failed initialising hotlist option"); filepath_sfinddef(respath, buf, "Print", "~/.netsurf/"); LOG(("Using '%s' as Print Settings file", buf)); print_options_file_location = strdup(buf); /* check what the font settings are, setting them to a default font * if they're not set - stops Pango whinging */ #define SETFONTDEFAULT(OPTION,y) if (nsoption_charp(OPTION) == NULL) nsoption_set_charp(OPTION, strdup((y))) SETFONTDEFAULT(font_sans, "Sans"); SETFONTDEFAULT(font_serif, "Serif"); SETFONTDEFAULT(font_mono, "Monospace"); SETFONTDEFAULT(font_cursive, "Serif"); SETFONTDEFAULT(font_fantasy, "Serif"); }
static void apply_settings(void) { /* "Network" tab: */ nsoption_set_bool(http_proxy, OBJ_SELECTED(SETTINGS_CB_USE_PROXY)); if ( OBJ_SELECTED(SETTINGS_CB_PROXY_AUTH) ) { nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC); } else { nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); } nsoption_set_charp(http_proxy_auth_pass, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_PASSWORD)); nsoption_set_charp(http_proxy_auth_user, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_USERNAME)); nsoption_set_charp(http_proxy_host, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_HOST)); nsoption_set_int(http_proxy_port, atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_PROXY_PORT) )); nsoption_set_int(max_fetchers_per_host, atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_MAX_FETCHERS_PER_HOST))); nsoption_set_int(max_cached_fetch_handles, atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_MAX_CACHED_CONNECTIONS))); nsoption_set_int(max_fetchers, atoi( gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_MAX_FETCHERS) )); nsoption_set_bool(foreground_images, OBJ_SELECTED( SETTINGS_CB_FG_IMAGES )); nsoption_set_bool(background_images, OBJ_SELECTED( SETTINGS_CB_BG_IMAGES )); /* "Style" tab: */ nsoption_set_int(font_min_size, tmp_option_font_min_size); nsoption_set_int(font_size, tmp_option_font_size); /* "Rendering" tab: */ nsoption_set_charp(atari_font_driver, gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_FONT_RENDERER)); nsoption_set_bool(atari_transparency, OBJ_SELECTED(SETTINGS_CB_TRANSPARENCY)); nsoption_set_bool(animate_images, OBJ_SELECTED(SETTINGS_CB_ENABLE_ANIMATION)); nsoption_set_int(minimum_gif_delay, (int)(tmp_option_minimum_gif_delay*100+0.5)); /* nsoption_set_bool(incremental_reflow, OBJ_SELECTED(SETTINGS_CB_INCREMENTAL_REFLOW));*/ nsoption_set_int(min_reflow_period, tmp_option_min_reflow_period); nsoption_set_int(atari_font_monochrom, !OBJ_SELECTED( SETTINGS_CB_ANTI_ALIASING )); /* "Paths" tabs: */ nsoption_set_charp(ca_bundle, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_CA_BUNDLE)); nsoption_set_charp(ca_path, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_CA_CERTS_PATH)); nsoption_set_charp(homepage_url, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_CA_CERTS_PATH)); nsoption_set_charp(hotlist_file, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_HOTLIST_FILE)); nsoption_set_charp(atari_editor, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_EDITOR)); nsoption_set_charp(downloads_path, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_DOWNLOAD_PATH)); /* "Cache" tab: */ nsoption_set_int(memory_cache_size, tmp_option_memory_cache_size * 1000000); /* "Browser" tab: */ nsoption_set_bool(target_blank, !OBJ_SELECTED(SETTINGS_CB_DISABLE_POPUP_WINDOWS)); nsoption_set_bool(block_ads, OBJ_SELECTED(SETTINGS_CB_HIDE_ADVERTISEMENT)); nsoption_set_charp(accept_language, gemtk_obj_get_text(dlgtree, SETTINGS_BT_SEL_LOCALE)); nsoption_set_int(expire_url, atoi(gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_HISTORY_AGE))); nsoption_set_bool(send_referer, OBJ_SELECTED(SETTINGS_CB_SEND_HTTP_REFERRER)); nsoption_set_bool(do_not_track, OBJ_SELECTED(SETTINGS_CB_SEND_DO_NOT_TRACK)); nsoption_set_charp(homepage_url, gemtk_obj_get_text(dlgtree, SETTINGS_EDIT_HOMEPAGE)); }
END_HANDLER SPIN_CHANGED(spinMemoryCacheSize, memory_cache_size) { nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) << 20); }
static BOOL CALLBACK options_connections_dialog_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lParam) { int len; char *temp, number[6]; HWND sub; LOG_WIN_MSG(hwnd, msg, wparam, lParam); 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"); if (nsoption_bool(http_proxy)) { SendMessage(sub, CB_SETCURSEL, (WPARAM) (nsoption_int(http_proxy_auth) + 1), 0); } else { SendMessage(sub, CB_SETCURSEL, 0, 0); } sub = GetDlgItem(hwnd, IDC_PREFS_PROXYHOST); if ((nsoption_charp(http_proxy_host) != NULL) && (nsoption_charp(http_proxy_host)[0] != '\0')) SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(http_proxy_host)); sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPORT); if (nsoption_int(http_proxy_port) != 0) { snprintf(number, 6, "%d", nsoption_int(http_proxy_port)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); } sub = GetDlgItem(hwnd, IDC_PREFS_PROXYNAME); if ((nsoption_charp(http_proxy_auth_user) != NULL) && (nsoption_charp(http_proxy_auth_user)[0] != '\0')) SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(http_proxy_auth_user)); sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPASS); if ((nsoption_charp(http_proxy_auth_pass) != NULL) && (nsoption_charp(http_proxy_auth_pass)[0] != '\0')) SendMessage(sub, WM_SETTEXT, 0, (LPARAM)nsoption_charp(http_proxy_auth_pass)); sub = GetDlgItem(hwnd, IDC_PREFS_FETCHERS); snprintf(number, 6, "%d", nsoption_int(max_fetchers)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HOST); snprintf(number, 6, "%d", nsoption_int(max_fetchers_per_host)); SendMessage(sub, WM_SETTEXT, 0, (LPARAM)number); sub = GetDlgItem(hwnd, IDC_PREFS_FETCH_HANDLES); snprintf(number, 6, "%d", nsoption_int(max_cached_fetch_handles)); 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); len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); nsoption_set_charp(http_proxy_host, strdup(temp)); free(temp); } sub = GetDlgItem(hwnd, IDC_PREFS_PROXYPORT); len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); nsoption_set_int(http_proxy_port, atoi(temp)); free(temp); } sub = GetDlgItem(hwnd, IDC_PREFS_PROXYNAME); len = SendMessage(sub, WM_GETTEXTLENGTH, 0, 0); temp = malloc(len + 1); if (temp != NULL) { SendMessage(sub, WM_GETTEXT, (WPARAM)(len + 1), (LPARAM)temp); nsoption_set_charp(http_proxy_auth_user, strdup(temp)); free(temp); } 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); nsoption_set_charp(http_proxy_auth_pass, strdup(temp)); free(temp); } /* 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); nsoption_set_int(max_fetchers, atoi(temp)); free(temp); } 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); nsoption_set_int(max_fetchers_per_host, atoi(temp)); free(temp); } 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); nsoption_set_int(max_cached_fetch_handles, atoi(temp)); free(temp); } break; 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; } } break; } } return FALSE; }
END_HANDLER SPIN_CHANGED(spinMinimumSize, font_min_size) { nsoption_set_int(font_min_size, nsoption_int(font_min_size) * 10); }
END_HANDLER SPIN_CHANGED(spinDefaultSize, font_size) { nsoption_set_int(font_size, nsoption_int(font_size) * 10); }