2006-01-07 03:38:14 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2005 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-01-07 03:38:14 +03:00
|
|
|
*/
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
#include <stdbool.h>
|
2015-06-22 12:42:01 +03:00
|
|
|
#include <stdlib.h>
|
2014-06-06 02:01:37 +04:00
|
|
|
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2014-06-06 02:01:37 +04:00
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/menus.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "riscos/url_suggest.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
|
|
|
#include "riscos/configure.h"
|
|
|
|
#include "riscos/configure/configure.h"
|
2014-06-06 02:01:37 +04:00
|
|
|
#include "riscos/dialog.h"
|
2006-01-07 03:38:14 +03:00
|
|
|
|
|
|
|
#define HOME_URL_FIELD 3
|
|
|
|
#define HOME_URL_GRIGHT 4
|
|
|
|
#define HOME_OPEN_STARTUP 5
|
|
|
|
#define HOME_DEFAULT_BUTTON 6
|
|
|
|
#define HOME_CANCEL_BUTTON 7
|
|
|
|
#define HOME_OK_BUTTON 8
|
|
|
|
|
|
|
|
static void ro_gui_options_home_default(wimp_pointer *pointer);
|
|
|
|
static bool ro_gui_options_home_ok(wimp_w w);
|
2011-02-21 02:16:33 +03:00
|
|
|
static bool ro_gui_options_home_menu_prepare(wimp_w w, wimp_i i,
|
|
|
|
wimp_menu *menu, wimp_pointer *pointer);
|
2006-01-07 03:38:14 +03:00
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_options_home_initialise(wimp_w w)
|
|
|
|
{
|
2006-01-07 03:38:14 +03:00
|
|
|
/* set the current values */
|
|
|
|
ro_gui_set_icon_string(w, HOME_URL_FIELD,
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_charp(homepage_url) ?
|
|
|
|
nsoption_charp(homepage_url) : "", true);
|
|
|
|
|
2006-11-27 18:35:18 +03:00
|
|
|
ro_gui_set_icon_selected_state(w, HOME_OPEN_STARTUP,
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_bool(open_browser_at_startup));
|
|
|
|
|
2006-01-07 03:38:14 +03:00
|
|
|
ro_gui_set_icon_shaded_state(w,
|
2010-10-05 23:14:46 +04:00
|
|
|
HOME_URL_GRIGHT, !ro_gui_url_suggest_prepare_menu());
|
2006-01-07 03:38:14 +03:00
|
|
|
|
|
|
|
/* initialise all functions for a newly created window */
|
|
|
|
ro_gui_wimp_event_register_menu_gright(w, HOME_URL_FIELD,
|
2011-02-21 02:16:33 +03:00
|
|
|
HOME_URL_GRIGHT, ro_gui_url_suggest_menu);
|
2006-01-07 03:38:14 +03:00
|
|
|
ro_gui_wimp_event_register_checkbox(w, HOME_OPEN_STARTUP);
|
|
|
|
ro_gui_wimp_event_register_button(w, HOME_DEFAULT_BUTTON,
|
|
|
|
ro_gui_options_home_default);
|
|
|
|
ro_gui_wimp_event_register_cancel(w, HOME_CANCEL_BUTTON);
|
|
|
|
ro_gui_wimp_event_register_ok(w, HOME_OK_BUTTON,
|
|
|
|
ro_gui_options_home_ok);
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_wimp_event_register_menu_prepare(w,
|
|
|
|
ro_gui_options_home_menu_prepare);
|
2006-01-07 03:38:14 +03:00
|
|
|
ro_gui_wimp_event_set_help_prefix(w, "HelpHomeConfig");
|
|
|
|
ro_gui_wimp_event_memorise(w);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_options_home_default(wimp_pointer *pointer)
|
|
|
|
{
|
2006-01-07 03:38:14 +03:00
|
|
|
/* set the default values */
|
2008-08-05 05:32:15 +04:00
|
|
|
ro_gui_set_icon_string(pointer->w, HOME_URL_FIELD, "", true);
|
2006-01-07 03:38:14 +03:00
|
|
|
ro_gui_set_icon_selected_state(pointer->w, HOME_OPEN_STARTUP, false);
|
|
|
|
}
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_options_home_ok(wimp_w w)
|
|
|
|
{
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(homepage_url,
|
|
|
|
strdup(ro_gui_get_icon_string(w, HOME_URL_FIELD)));
|
|
|
|
|
|
|
|
nsoption_set_bool(open_browser_at_startup,
|
|
|
|
ro_gui_get_icon_selected_state(w, HOME_OPEN_STARTUP));
|
2006-01-07 03:38:14 +03:00
|
|
|
|
|
|
|
ro_gui_save_options();
|
|
|
|
return true;
|
|
|
|
}
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to prepare menus in the Configure Home dialog. At present, this
|
|
|
|
* only has to handle the URL Suggestion pop-up.
|
|
|
|
*
|
|
|
|
* \param w The window handle owning the menu.
|
|
|
|
* \param i The icon handle owning the menu.
|
|
|
|
* \param *menu The menu to be prepared.
|
|
|
|
* \param *pointer The associated mouse click event block, or NULL
|
|
|
|
* on an Adjust-click re-opening.
|
|
|
|
* \return true if the event was handled; false if not.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_options_home_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
|
|
|
|
wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
if (menu != ro_gui_url_suggest_menu || i != HOME_URL_GRIGHT)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (pointer != NULL)
|
|
|
|
ro_gui_url_suggest_prepare_menu();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|