2006-07-23 22:26:11 +04:00
|
|
|
/*
|
2006-11-27 18:35:18 +03:00
|
|
|
* This file is part of NetSurf, http://netsurf-browser.org/
|
2006-07-23 22:26:11 +04:00
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2006 Rob Kendrick <rjek@rjek.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glade/glade.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "desktop/options.h"
|
|
|
|
#include "gtk/options.h"
|
|
|
|
#include "gtk/gtk_gui.h"
|
|
|
|
#include "gtk/gtk_scaffolding.h"
|
|
|
|
#include "gtk/gtk_options.h"
|
|
|
|
#include "gtk/gtk_window.h"
|
2006-07-23 22:26:11 +04:00
|
|
|
|
|
|
|
GtkWindow *wndChoices;
|
|
|
|
|
|
|
|
static GtkWidget *entryHomePageURL,
|
|
|
|
*checkHideAdverts,
|
|
|
|
*checkDisablePopups,
|
|
|
|
*checkDisablePlugins,
|
|
|
|
*spinHistoryAge,
|
|
|
|
*checkHoverURLs,
|
|
|
|
*checkRequestOverwrite,
|
|
|
|
*checkDisplayRecentURLs,
|
|
|
|
*checkSendReferer,
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-07-23 22:26:11 +04:00
|
|
|
*comboProxyType,
|
|
|
|
*entryProxyHost,
|
|
|
|
*entryProxyPort,
|
|
|
|
*entryProxyUser,
|
|
|
|
*entryProxyPassword,
|
|
|
|
*spinMaxFetchers,
|
|
|
|
*spinFetchesPerHost,
|
|
|
|
*spinCachedConnections,
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-07-23 22:26:11 +04:00
|
|
|
*checkUseCairo,
|
|
|
|
*checkResampleImages,
|
|
|
|
*spinAnimationSpeed,
|
|
|
|
*checkDisableAnimations,
|
|
|
|
|
|
|
|
*fontSansSerif,
|
|
|
|
*fontSerif,
|
|
|
|
*fontMonospace,
|
|
|
|
*fontCursive,
|
|
|
|
*fontFantasy,
|
|
|
|
*comboDefault,
|
|
|
|
*spinDefaultSize,
|
|
|
|
*spinMinimumSize,
|
|
|
|
|
|
|
|
*spinMemoryCacheSize,
|
|
|
|
*spinDiscCacheAge;
|
|
|
|
|
|
|
|
#define FIND_WIDGET(x) (x) = glade_xml_get_widget(gladeWindows, #x); if ((x) == NULL) LOG(("Unable to find widget '%s'!", #x))
|
|
|
|
|
|
|
|
void nsgtk_options_init(void) {
|
|
|
|
wndChoices = GTK_WINDOW(glade_xml_get_widget(gladeWindows,
|
|
|
|
"wndChoices"));
|
|
|
|
|
|
|
|
/* get widget objects */
|
|
|
|
FIND_WIDGET(entryHomePageURL);
|
|
|
|
FIND_WIDGET(checkHideAdverts);
|
|
|
|
FIND_WIDGET(checkDisablePopups);
|
|
|
|
FIND_WIDGET(checkDisablePlugins);
|
|
|
|
FIND_WIDGET(spinHistoryAge);
|
|
|
|
FIND_WIDGET(checkHoverURLs);
|
|
|
|
FIND_WIDGET(checkRequestOverwrite);
|
|
|
|
FIND_WIDGET(checkDisplayRecentURLs);
|
|
|
|
FIND_WIDGET(checkSendReferer);
|
|
|
|
|
|
|
|
FIND_WIDGET(comboProxyType);
|
|
|
|
FIND_WIDGET(entryProxyHost);
|
|
|
|
FIND_WIDGET(entryProxyPort);
|
|
|
|
FIND_WIDGET(entryProxyUser);
|
|
|
|
FIND_WIDGET(entryProxyPassword);
|
|
|
|
FIND_WIDGET(spinMaxFetchers);
|
|
|
|
FIND_WIDGET(spinFetchesPerHost);
|
|
|
|
FIND_WIDGET(spinCachedConnections);
|
|
|
|
|
|
|
|
FIND_WIDGET(checkUseCairo);
|
|
|
|
FIND_WIDGET(checkResampleImages);
|
|
|
|
FIND_WIDGET(spinAnimationSpeed);
|
|
|
|
FIND_WIDGET(checkDisableAnimations);
|
|
|
|
|
|
|
|
FIND_WIDGET(fontSansSerif);
|
|
|
|
FIND_WIDGET(fontSerif);
|
|
|
|
FIND_WIDGET(fontMonospace);
|
|
|
|
FIND_WIDGET(fontCursive);
|
|
|
|
FIND_WIDGET(fontFantasy);
|
|
|
|
FIND_WIDGET(comboDefault);
|
|
|
|
FIND_WIDGET(spinDefaultSize);
|
|
|
|
FIND_WIDGET(spinMinimumSize);
|
|
|
|
|
|
|
|
FIND_WIDGET(spinMemoryCacheSize);
|
|
|
|
FIND_WIDGET(spinDiscCacheAge);
|
|
|
|
|
|
|
|
/* set the widgets to reflect the current options */
|
|
|
|
nsgtk_options_load();
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SET_ENTRY(x, y) gtk_entry_set_text(GTK_ENTRY((x)), (y))
|
2006-07-24 02:32:33 +04:00
|
|
|
#define SET_SPIN(x, y) gtk_spin_button_set_value(GTK_SPIN_BUTTON((x)), (y))
|
2006-08-17 23:20:13 +04:00
|
|
|
#define SET_CHECK(x, y) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((x)), (y))
|
2006-08-18 00:14:22 +04:00
|
|
|
#define SET_COMBO(x, y) gtk_combo_box_set_active(GTK_COMBO_BOX((x)), (y))
|
2006-08-18 00:31:24 +04:00
|
|
|
#define SET_FONT(x, y) gtk_font_button_set_font_name(GTK_FONT_BUTTON((x)), (y))
|
2006-07-23 22:26:11 +04:00
|
|
|
|
|
|
|
void nsgtk_options_load(void) {
|
2006-08-17 23:20:13 +04:00
|
|
|
char b[20];
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2007-01-27 22:29:28 +03:00
|
|
|
SET_ENTRY(entryHomePageURL,
|
|
|
|
option_homepage_url ? option_homepage_url : "");
|
2006-07-23 22:26:11 +04:00
|
|
|
SET_CHECK(checkHideAdverts, option_block_ads);
|
2006-07-28 19:57:00 +04:00
|
|
|
SET_CHECK(checkDisplayRecentURLs, option_url_suggestion);
|
2006-07-23 22:26:11 +04:00
|
|
|
SET_CHECK(checkSendReferer, option_send_referer);
|
|
|
|
|
2006-08-18 04:38:35 +04:00
|
|
|
SET_COMBO(comboProxyType, option_http_proxy_auth);
|
2007-01-27 22:29:28 +03:00
|
|
|
SET_ENTRY(entryProxyHost,
|
|
|
|
option_http_proxy_host ? option_http_proxy_host : "");
|
2006-07-23 22:26:11 +04:00
|
|
|
snprintf(b, 20, "%d", option_http_proxy_port);
|
|
|
|
SET_ENTRY(entryProxyPort, b);
|
2007-01-27 22:29:28 +03:00
|
|
|
SET_ENTRY(entryProxyUser, option_http_proxy_auth_user ?
|
|
|
|
option_http_proxy_auth_user : "");
|
|
|
|
SET_ENTRY(entryProxyPassword, option_http_proxy_auth_pass ?
|
|
|
|
option_http_proxy_auth_pass : "");
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-07-23 22:26:11 +04:00
|
|
|
SET_SPIN(spinMaxFetchers, option_max_fetchers);
|
|
|
|
SET_SPIN(spinFetchesPerHost, option_max_fetchers_per_host);
|
|
|
|
SET_SPIN(spinCachedConnections, option_max_cached_fetch_handles);
|
|
|
|
|
2006-07-24 02:32:33 +04:00
|
|
|
SET_CHECK(checkUseCairo, option_render_cairo);
|
2006-08-18 04:38:35 +04:00
|
|
|
SET_CHECK(checkResampleImages, option_render_resample);
|
2006-07-23 22:26:11 +04:00
|
|
|
SET_SPIN(spinAnimationSpeed, option_minimum_gif_delay);
|
|
|
|
SET_CHECK(checkDisableAnimations, !option_animate_images);
|
|
|
|
|
2006-08-18 00:31:24 +04:00
|
|
|
SET_FONT(fontSansSerif, option_font_sans);
|
|
|
|
SET_FONT(fontSerif, option_font_serif);
|
|
|
|
SET_FONT(fontMonospace, option_font_mono);
|
|
|
|
SET_FONT(fontCursive, option_font_cursive);
|
|
|
|
SET_FONT(fontFantasy, option_font_fantasy);
|
2006-08-18 00:14:22 +04:00
|
|
|
SET_COMBO(comboDefault, option_font_default - 1);
|
2006-07-23 22:26:11 +04:00
|
|
|
SET_SPIN(spinDefaultSize, option_font_size / 10);
|
|
|
|
SET_SPIN(spinMinimumSize, option_font_min_size / 10);
|
|
|
|
|
|
|
|
SET_SPIN(spinMemoryCacheSize, option_memory_cache_size);
|
|
|
|
SET_SPIN(spinDiscCacheAge, option_disc_cache_age);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GET_ENTRY(x, y) if ((y)) free((y)); \
|
|
|
|
(y) = strdup(gtk_entry_get_text(GTK_ENTRY((x))))
|
2006-08-17 23:20:13 +04:00
|
|
|
#define GET_CHECK(x, y) (y) = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON((x)))
|
2006-08-18 00:14:22 +04:00
|
|
|
#define GET_SPIN(x, y) (y) = gtk_spin_button_get_value(GTK_SPIN_BUTTON((x)))
|
|
|
|
#define GET_COMBO(x, y) (y) = gtk_combo_box_get_active(GTK_COMBO_BOX((x)))
|
2006-08-18 00:31:24 +04:00
|
|
|
#define GET_FONT(x, y) if ((y)) free((y)); \
|
|
|
|
(y) = strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON((x))))
|
2006-07-23 22:26:11 +04:00
|
|
|
|
|
|
|
void nsgtk_options_save(void) {
|
2006-08-18 04:38:35 +04:00
|
|
|
char *b = NULL;
|
|
|
|
int i;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-07-23 22:26:11 +04:00
|
|
|
GET_ENTRY(entryHomePageURL, option_homepage_url);
|
2006-07-28 19:57:00 +04:00
|
|
|
GET_CHECK(checkDisplayRecentURLs, option_url_suggestion);
|
2006-07-23 22:26:11 +04:00
|
|
|
|
2006-08-18 04:38:35 +04:00
|
|
|
GET_COMBO(comboProxyType, i);
|
|
|
|
option_http_proxy = (i > 0) ? true : false;
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_BASIC;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NTLM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-08-18 04:38:35 +04:00
|
|
|
GET_ENTRY(entryProxyHost, option_http_proxy_host);
|
|
|
|
GET_ENTRY(entryProxyPort, b);
|
|
|
|
option_http_proxy_port = atoi(b);
|
|
|
|
free(b);
|
|
|
|
GET_ENTRY(entryProxyUser, option_http_proxy_auth_user);
|
|
|
|
GET_ENTRY(entryProxyPassword, option_http_proxy_auth_pass);
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-08-18 04:38:35 +04:00
|
|
|
GET_SPIN(spinMaxFetchers, option_max_fetchers);
|
|
|
|
GET_SPIN(spinFetchesPerHost, option_max_fetchers_per_host);
|
2006-11-27 18:35:18 +03:00
|
|
|
GET_SPIN(spinCachedConnections, option_max_cached_fetch_handles);
|
2006-08-18 04:38:35 +04:00
|
|
|
|
2006-07-24 02:32:33 +04:00
|
|
|
GET_CHECK(checkUseCairo, option_render_cairo);
|
2006-07-24 02:44:42 +04:00
|
|
|
GET_CHECK(checkResampleImages, option_render_resample);
|
2006-08-18 04:38:35 +04:00
|
|
|
GET_SPIN(spinAnimationSpeed, option_minimum_gif_delay);
|
|
|
|
option_minimum_gif_delay *= 10;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-08-18 00:31:24 +04:00
|
|
|
GET_FONT(fontSansSerif, option_font_sans);
|
|
|
|
GET_FONT(fontSerif, option_font_serif);
|
|
|
|
GET_FONT(fontMonospace, option_font_mono);
|
|
|
|
GET_FONT(fontCursive, option_font_cursive);
|
|
|
|
GET_FONT(fontFantasy, option_font_fantasy);
|
2006-08-18 00:14:22 +04:00
|
|
|
GET_COMBO(comboDefault, option_font_default);
|
|
|
|
option_font_default++;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-08-17 23:41:14 +04:00
|
|
|
GET_SPIN(spinDefaultSize, option_font_size);
|
|
|
|
option_font_size *= 10;
|
|
|
|
GET_SPIN(spinMinimumSize, option_font_min_size);
|
|
|
|
option_font_min_size *= 10;
|
2006-07-23 22:26:11 +04:00
|
|
|
|
|
|
|
options_write(options_file_location);
|
2006-08-18 00:03:28 +04:00
|
|
|
nsgtk_reflow_all_windows();
|
2006-07-23 22:26:11 +04:00
|
|
|
}
|
|
|
|
|