2006-04-06 21:51:25 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Richard Wilson <info@tinct.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* 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/>.
|
2006-04-06 21:51:25 +04:00
|
|
|
*/
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
#include <stdbool.h>
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/dialog.h"
|
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
|
|
|
#include "riscos/configure.h"
|
|
|
|
#include "riscos/configure/configure.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
2006-04-06 21:51:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
#define CONTENT_BLOCK_ADVERTISEMENTS 2
|
|
|
|
#define CONTENT_BLOCK_POPUPS 3
|
|
|
|
#define CONTENT_NO_PLUGINS 4
|
2006-09-02 19:52:41 +04:00
|
|
|
#define CONTENT_TARGET_BLANK 7
|
|
|
|
#define CONTENT_DEFAULT_BUTTON 8
|
|
|
|
#define CONTENT_CANCEL_BUTTON 9
|
|
|
|
#define CONTENT_OK_BUTTON 10
|
2012-12-15 20:59:00 +04:00
|
|
|
#define CONTENT_NO_JAVASCRIPT 11
|
2006-04-06 21:51:25 +04:00
|
|
|
|
|
|
|
static void ro_gui_options_content_default(wimp_pointer *pointer);
|
|
|
|
static bool ro_gui_options_content_ok(wimp_w w);
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_options_content_initialise(wimp_w w)
|
|
|
|
{
|
2006-04-06 21:51:25 +04:00
|
|
|
/* set the current values */
|
2006-11-27 18:35:18 +03:00
|
|
|
ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_ADVERTISEMENTS,
|
2013-05-27 17:18:01 +04:00
|
|
|
nsoption_bool(block_advertisements));
|
2006-11-27 18:35:18 +03:00
|
|
|
ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_POPUPS,
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_bool(block_popups));
|
2006-11-27 18:35:18 +03:00
|
|
|
ro_gui_set_icon_selected_state(w, CONTENT_NO_PLUGINS,
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_bool(no_plugins));
|
2006-11-27 18:35:18 +03:00
|
|
|
ro_gui_set_icon_selected_state(w, CONTENT_TARGET_BLANK,
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_bool(target_blank));
|
2012-12-15 20:59:00 +04:00
|
|
|
ro_gui_set_icon_selected_state(w, CONTENT_NO_JAVASCRIPT,
|
|
|
|
!nsoption_bool(enable_javascript));
|
2006-04-06 21:51:25 +04:00
|
|
|
|
|
|
|
/* initialise all functions for a newly created window */
|
|
|
|
ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_ADVERTISEMENTS);
|
|
|
|
ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_POPUPS);
|
|
|
|
ro_gui_wimp_event_register_checkbox(w, CONTENT_NO_PLUGINS);
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_wimp_event_register_checkbox(w, CONTENT_TARGET_BLANK);
|
2012-12-15 20:59:00 +04:00
|
|
|
ro_gui_wimp_event_register_checkbox(w, CONTENT_NO_JAVASCRIPT);
|
2006-04-06 21:51:25 +04:00
|
|
|
ro_gui_wimp_event_register_button(w, CONTENT_DEFAULT_BUTTON,
|
|
|
|
ro_gui_options_content_default);
|
|
|
|
ro_gui_wimp_event_register_cancel(w, CONTENT_CANCEL_BUTTON);
|
|
|
|
ro_gui_wimp_event_register_ok(w, CONTENT_OK_BUTTON,
|
|
|
|
ro_gui_options_content_ok);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(w, "HelpContentConfig");
|
|
|
|
ro_gui_wimp_event_memorise(w);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_options_content_default(wimp_pointer *pointer)
|
|
|
|
{
|
2006-04-06 21:51:25 +04:00
|
|
|
/* set the default values */
|
|
|
|
ro_gui_set_icon_selected_state(pointer->w, CONTENT_BLOCK_ADVERTISEMENTS,
|
|
|
|
false);
|
|
|
|
ro_gui_set_icon_selected_state(pointer->w, CONTENT_BLOCK_POPUPS,
|
|
|
|
false);
|
|
|
|
ro_gui_set_icon_selected_state(pointer->w, CONTENT_NO_PLUGINS,
|
|
|
|
false);
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_set_icon_selected_state(pointer->w, CONTENT_TARGET_BLANK,
|
|
|
|
true);
|
2012-12-15 20:59:00 +04:00
|
|
|
ro_gui_set_icon_selected_state(pointer->w, CONTENT_NO_JAVASCRIPT,
|
|
|
|
false);
|
2006-04-06 21:51:25 +04:00
|
|
|
}
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_options_content_ok(wimp_w w)
|
|
|
|
{
|
2013-05-27 17:18:01 +04:00
|
|
|
nsoption_set_bool(block_advertisements,
|
2012-03-22 13:34:34 +04:00
|
|
|
ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_ADVERTISEMENTS));
|
|
|
|
|
|
|
|
nsoption_set_bool(block_popups,
|
|
|
|
ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_POPUPS));
|
|
|
|
nsoption_set_bool(no_plugins,
|
|
|
|
ro_gui_get_icon_selected_state(w, CONTENT_NO_PLUGINS));
|
|
|
|
|
|
|
|
nsoption_set_bool(target_blank,
|
|
|
|
ro_gui_get_icon_selected_state(w, CONTENT_TARGET_BLANK));
|
2006-04-06 21:51:25 +04:00
|
|
|
|
2012-12-15 20:59:00 +04:00
|
|
|
nsoption_set_bool(enable_javascript,
|
|
|
|
!ro_gui_get_icon_selected_state(w, CONTENT_NO_JAVASCRIPT));
|
|
|
|
|
2006-04-06 21:51:25 +04:00
|
|
|
ro_gui_save_options();
|
|
|
|
return true;
|
|
|
|
}
|