2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
2004-12-09 13:30:44 +03:00
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2003-06-30 16:44:03 +04:00
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2004-02-13 19:09:12 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2003-06-30 16:44:03 +04:00
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
2005-03-20 17:57:19 +03:00
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2004-07-19 02:21:32 +04:00
|
|
|
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
|
2002-09-11 18:24:02 +04:00
|
|
|
*/
|
|
|
|
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <assert.h>
|
2004-07-17 17:00:38 +04:00
|
|
|
#include <errno.h>
|
2005-02-08 02:00:09 +03:00
|
|
|
#include <signal.h>
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <stdbool.h>
|
2003-08-27 02:37:32 +04:00
|
|
|
#include <stddef.h>
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2004-03-22 00:32:15 +03:00
|
|
|
#include <unixlib/features.h>
|
2003-11-08 02:51:13 +03:00
|
|
|
#include <unixlib/local.h>
|
2004-04-10 01:06:10 +04:00
|
|
|
#include "oslib/font.h"
|
2004-05-12 03:40:07 +04:00
|
|
|
#include "oslib/help.h"
|
2004-01-28 21:37:56 +03:00
|
|
|
#include "oslib/hourglass.h"
|
2003-12-27 07:50:02 +03:00
|
|
|
#include "oslib/inetsuite.h"
|
2003-01-11 20:33:31 +03:00
|
|
|
#include "oslib/os.h"
|
2004-02-27 17:09:15 +03:00
|
|
|
#include "oslib/osbyte.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "oslib/osfile.h"
|
2004-03-03 03:19:47 +03:00
|
|
|
#include "oslib/osfscontrol.h"
|
2004-04-01 04:26:05 +04:00
|
|
|
#include "oslib/osspriteop.h"
|
2004-08-09 10:28:57 +04:00
|
|
|
#include "oslib/pdriver.h"
|
2003-08-25 02:39:55 +04:00
|
|
|
#include "oslib/plugin.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
#include "oslib/wimp.h"
|
2004-04-01 04:26:05 +04:00
|
|
|
#include "oslib/wimpspriteop.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "oslib/uri.h"
|
2005-02-20 16:19:19 +03:00
|
|
|
#include "rufl.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2005-04-03 03:57:48 +04:00
|
|
|
#include "netsurf/content/content.h"
|
|
|
|
#include "netsurf/content/url_store.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "netsurf/desktop/gui.h"
|
|
|
|
#include "netsurf/desktop/netsurf.h"
|
|
|
|
#include "netsurf/desktop/options.h"
|
2004-12-09 13:30:44 +03:00
|
|
|
#include "netsurf/desktop/tree.h"
|
2005-04-03 03:57:48 +04:00
|
|
|
#include "netsurf/render/box.h"
|
2003-07-18 03:01:02 +04:00
|
|
|
#include "netsurf/render/font.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "netsurf/render/html.h"
|
2005-02-08 02:00:09 +03:00
|
|
|
#include "netsurf/riscos/buffer.h"
|
2005-02-07 17:28:43 +03:00
|
|
|
#include "netsurf/riscos/global_history.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "netsurf/riscos/gui.h"
|
2004-05-12 03:40:07 +04:00
|
|
|
#include "netsurf/riscos/help.h"
|
2005-04-08 00:46:22 +04:00
|
|
|
#include "netsurf/riscos/menus.h"
|
2004-02-13 19:09:12 +03:00
|
|
|
#include "netsurf/riscos/options.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_PLUGIN
|
2003-08-25 02:39:55 +04:00
|
|
|
#include "netsurf/riscos/plugin.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-08-09 10:28:57 +04:00
|
|
|
#ifdef WITH_PRINT
|
|
|
|
#include "netsurf/riscos/print.h"
|
|
|
|
#endif
|
2004-05-02 21:38:29 +04:00
|
|
|
#include "netsurf/riscos/save_complete.h"
|
2002-10-15 14:41:12 +04:00
|
|
|
#include "netsurf/riscos/theme.h"
|
2004-12-09 13:30:44 +03:00
|
|
|
#include "netsurf/riscos/treeview.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_URI
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "netsurf/riscos/uri.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_URL
|
2004-03-02 21:02:41 +03:00
|
|
|
#include "netsurf/riscos/url_protocol.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2005-02-03 16:18:22 +03:00
|
|
|
#include "netsurf/riscos/url_complete.h"
|
2004-05-07 23:14:54 +04:00
|
|
|
#include "netsurf/riscos/wimp.h"
|
2003-01-11 20:33:31 +03:00
|
|
|
#include "netsurf/utils/log.h"
|
2003-10-01 04:26:42 +04:00
|
|
|
#include "netsurf/utils/messages.h"
|
2003-07-15 18:37:34 +04:00
|
|
|
#include "netsurf/utils/utils.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef FILETYPE_ACORN_URI
|
|
|
|
#define FILETYPE_ACORN_URI 0xf91
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_ANT_URL
|
|
|
|
#define FILETYPE_ANT_URL 0xb28
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_IEURL
|
|
|
|
#define FILETYPE_IEURL 0x1ba
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_HTML
|
|
|
|
#define FILETYPE_HTML 0xfaf
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_JNG
|
|
|
|
#define FILETYPE_JNG 0xf78
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_CSS
|
|
|
|
#define FILETYPE_CSS 0xf79
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_MNG
|
|
|
|
#define FILETYPE_MNG 0xf83
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_GIF
|
|
|
|
#define FILETYPE_GIF 0x695
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_PNG
|
|
|
|
#define FILETYPE_PNG 0xb60
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_JPEG
|
|
|
|
#define FILETYPE_JPEG 0xc85
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
int os_version = 0;
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
const char *__dynamic_da_name = "NetSurf"; /**< For UnixLib. */
|
2005-01-29 19:17:23 +03:00
|
|
|
int __dynamic_da_max_size = 128 * 1024 * 1024; /**< For UnixLib. */
|
2004-12-09 13:30:44 +03:00
|
|
|
int __feature_imagefs_is_file = 1; /**< For UnixLib. */
|
2004-07-31 16:56:25 +04:00
|
|
|
/* default filename handling */
|
|
|
|
int __riscosify_control = __RISCOSIFY_NO_SUFFIX |
|
|
|
|
__RISCOSIFY_NO_REVERSE_SUFFIX;
|
2003-06-25 03:22:00 +04:00
|
|
|
|
2005-01-23 19:09:05 +03:00
|
|
|
const char * NETSURF_DIR;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-10-18 02:13:35 +04:00
|
|
|
char *default_stylesheet_url;
|
|
|
|
char *adblock_stylesheet_url;
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/** The pointer is over a window which is tracking mouse movement. */
|
|
|
|
static bool gui_track = false;
|
|
|
|
/** Handle of window which the pointer is over. */
|
|
|
|
static wimp_w gui_track_wimp_w;
|
|
|
|
/** Browser window which the pointer is over, or 0 if none. */
|
|
|
|
static struct gui_window *gui_track_gui_window;
|
|
|
|
|
|
|
|
/** Some windows have been resized, and should be reformatted. */
|
|
|
|
bool gui_reformat_pending = false;
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
gui_drag_type gui_current_drag_type;
|
2004-04-02 04:41:10 +04:00
|
|
|
wimp_t task_handle; /**< RISC OS wimp task handle. */
|
2004-03-30 15:45:48 +04:00
|
|
|
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
|
2004-12-09 13:30:44 +03:00
|
|
|
osspriteop_area *gui_sprites; /**< Sprite area containing pointer and hotlist sprites */
|
2004-05-08 22:12:36 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/** Accepted wimp user messages. */
|
2005-04-15 09:54:44 +04:00
|
|
|
static wimp_MESSAGE_LIST(36) task_messages = { {
|
2004-12-09 13:30:44 +03:00
|
|
|
message_HELP_REQUEST,
|
2003-11-08 02:51:13 +03:00
|
|
|
message_DATA_SAVE,
|
|
|
|
message_DATA_SAVE_ACK,
|
|
|
|
message_DATA_LOAD,
|
2004-08-09 10:28:57 +04:00
|
|
|
message_DATA_LOAD_ACK,
|
2003-11-08 02:51:13 +03:00
|
|
|
message_DATA_OPEN,
|
2004-02-26 03:44:42 +03:00
|
|
|
message_MENU_WARNING,
|
2004-07-04 22:44:51 +04:00
|
|
|
message_MENUS_DELETED,
|
2004-11-03 05:29:01 +03:00
|
|
|
message_MODE_CHANGE,
|
2005-04-15 09:54:44 +04:00
|
|
|
message_CLAIM_ENTITY,
|
|
|
|
message_DATA_REQUEST,
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_URI
|
2003-11-08 02:51:13 +03:00
|
|
|
message_URI_PROCESS,
|
2004-04-02 04:41:10 +04:00
|
|
|
message_URI_RETURN_RESULT,
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_URL
|
2003-12-27 07:50:02 +03:00
|
|
|
message_INET_SUITE_OPEN_URL,
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_PLUGIN
|
2003-11-08 02:51:13 +03:00
|
|
|
message_PLUG_IN_OPENING,
|
|
|
|
message_PLUG_IN_CLOSED,
|
|
|
|
message_PLUG_IN_RESHAPE_REQUEST,
|
|
|
|
message_PLUG_IN_FOCUS,
|
|
|
|
message_PLUG_IN_URL_ACCESS,
|
|
|
|
message_PLUG_IN_STATUS,
|
|
|
|
message_PLUG_IN_BUSY,
|
|
|
|
message_PLUG_IN_STREAM_NEW,
|
|
|
|
message_PLUG_IN_STREAM_WRITE,
|
|
|
|
message_PLUG_IN_STREAM_WRITTEN,
|
|
|
|
message_PLUG_IN_STREAM_DESTROY,
|
|
|
|
message_PLUG_IN_OPEN,
|
|
|
|
message_PLUG_IN_CLOSE,
|
|
|
|
message_PLUG_IN_RESHAPE,
|
|
|
|
message_PLUG_IN_STREAM_AS_FILE,
|
|
|
|
message_PLUG_IN_NOTIFY,
|
|
|
|
message_PLUG_IN_ABORT,
|
|
|
|
message_PLUG_IN_ACTION,
|
|
|
|
/* message_PLUG_IN_INFORMED, (not provided by oslib) */
|
2004-08-09 10:28:57 +04:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_PRINT
|
|
|
|
message_PRINT_SAVE,
|
|
|
|
message_PRINT_ERROR,
|
|
|
|
message_PRINT_TYPE_ODD,
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2003-11-08 02:51:13 +03:00
|
|
|
0
|
|
|
|
} };
|
|
|
|
struct ro_gui_poll_block {
|
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block *block;
|
|
|
|
struct ro_gui_poll_block *next;
|
|
|
|
};
|
|
|
|
struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0;
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2004-02-27 17:09:15 +03:00
|
|
|
static void ro_gui_choose_language(void);
|
2004-07-29 03:07:52 +04:00
|
|
|
static void ro_gui_sprites_init(void);
|
2003-11-08 02:51:13 +03:00
|
|
|
static void ro_gui_icon_bar_create(void);
|
2005-02-22 00:10:48 +03:00
|
|
|
static void ro_gui_signal(int sig);
|
|
|
|
static void ro_gui_cleanup(void);
|
2004-01-28 21:37:56 +03:00
|
|
|
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_gui_poll_queue(wimp_event_no event, wimp_block *block);
|
2004-01-28 21:37:56 +03:00
|
|
|
static void ro_gui_null_reason_code(void);
|
|
|
|
static void ro_gui_redraw_window_request(wimp_draw *redraw);
|
|
|
|
static void ro_gui_close_window_request(wimp_close *close);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
|
|
|
|
static void ro_gui_pointer_entering_window(wimp_entering *entering);
|
2004-01-28 21:37:56 +03:00
|
|
|
static void ro_gui_mouse_click(wimp_pointer *pointer);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_gui_icon_bar_click(wimp_pointer *pointer);
|
2004-05-07 23:14:54 +04:00
|
|
|
static void ro_gui_check_resolvers(void);
|
2004-02-26 03:44:42 +03:00
|
|
|
static void ro_gui_drag_end(wimp_dragged *drag);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_gui_keypress(wimp_key *key);
|
2004-01-28 21:37:56 +03:00
|
|
|
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_msg_dataload(wimp_message *block);
|
2005-04-08 06:06:46 +04:00
|
|
|
static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title);
|
2004-07-17 17:00:38 +04:00
|
|
|
static bool ro_gui_uri_file_parse_line(FILE *fp, char *b);
|
|
|
|
static char *ro_gui_url_file_parse(const char *file_name);
|
2005-02-03 23:49:43 +03:00
|
|
|
static char *ro_gui_ieurl_file_parse(const char *file_name);
|
2005-04-05 02:14:51 +04:00
|
|
|
static void ro_msg_datasave(wimp_message *message);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_msg_datasave_ack(wimp_message *message);
|
|
|
|
static void ro_msg_dataopen(wimp_message *block);
|
2003-11-08 02:51:13 +03:00
|
|
|
static char *ro_path_to_url(const char *path);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/**
|
|
|
|
* Initialise the gui (RISC OS specific part).
|
|
|
|
*/
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
void gui_init(int argc, char** argv)
|
|
|
|
{
|
2004-02-27 17:09:15 +03:00
|
|
|
char path[40];
|
|
|
|
os_error *error;
|
2004-06-09 01:35:28 +04:00
|
|
|
int length;
|
2004-08-31 01:03:48 +04:00
|
|
|
struct theme_descriptor *descriptor = NULL;
|
2005-03-20 04:55:48 +03:00
|
|
|
char *nsdir_temp;
|
2003-08-25 02:39:55 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
xhourglass_start(1);
|
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
/* read OS version for code that adapts to conform to the OS (remember
|
|
|
|
that it's preferable to check for specific features being present) */
|
|
|
|
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
|
|
|
|
|
2005-02-08 02:00:09 +03:00
|
|
|
atexit(ro_gui_cleanup);
|
2005-02-22 00:10:48 +03:00
|
|
|
signal(SIGABRT, ro_gui_signal);
|
|
|
|
signal(SIGFPE, ro_gui_signal);
|
|
|
|
signal(SIGILL, ro_gui_signal);
|
|
|
|
signal(SIGINT, ro_gui_signal);
|
|
|
|
signal(SIGSEGV, ro_gui_signal);
|
|
|
|
signal(SIGTERM, ro_gui_signal);
|
2005-02-08 02:00:09 +03:00
|
|
|
|
2005-02-03 16:18:22 +03:00
|
|
|
/* create our choices directories */
|
2005-02-22 00:10:48 +03:00
|
|
|
#ifndef ncos
|
2005-02-03 16:18:22 +03:00
|
|
|
xosfile_create_dir("<Choices$Write>.WWW", 0);
|
|
|
|
xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
|
|
|
|
xosfile_create_dir("<Choices$Write>.WWW.NetSurf.Themes", 0);
|
|
|
|
#else
|
|
|
|
xosfile_create_dir("<User$Path>.Choices.NetSurf", 0);
|
|
|
|
xosfile_create_dir("<User$Path>.Choices.NetSurf.Choices", 0);
|
|
|
|
xosfile_create_dir("<User$Path>.Choices.NetSurf.Choices.Themes", 0);
|
|
|
|
#endif
|
|
|
|
|
2004-09-14 03:56:18 +04:00
|
|
|
#ifdef WITH_SAVE_COMPLETE
|
2004-06-09 01:35:28 +04:00
|
|
|
save_complete_init();
|
2004-09-14 03:56:18 +04:00
|
|
|
#endif
|
2004-05-02 21:38:29 +04:00
|
|
|
|
2004-12-09 13:30:44 +03:00
|
|
|
/* We don't have the universal boot sequence on NCOS */
|
2004-07-19 02:21:32 +04:00
|
|
|
#ifndef ncos
|
2004-02-27 17:09:15 +03:00
|
|
|
options_read("Choices:WWW.NetSurf.Choices");
|
2004-07-19 02:21:32 +04:00
|
|
|
#else
|
|
|
|
options_read("<User$Path>.Choices.NetSurf.Choices");
|
|
|
|
#endif
|
2005-03-21 17:48:26 +03:00
|
|
|
/* set defaults for absent strings */
|
2005-02-08 02:00:09 +03:00
|
|
|
if (!option_theme)
|
2005-03-21 17:48:26 +03:00
|
|
|
option_theme = strdup("Aletheia");
|
|
|
|
if (!option_toolbar_browser)
|
2005-03-21 18:27:31 +03:00
|
|
|
option_toolbar_browser = strdup("0123|58|9");
|
2005-03-21 17:48:26 +03:00
|
|
|
if (!option_toolbar_hotlist)
|
|
|
|
option_toolbar_hotlist = strdup("401|23");
|
|
|
|
if (!option_toolbar_history)
|
|
|
|
option_toolbar_history = strdup("01|23");
|
2005-02-08 02:00:09 +03:00
|
|
|
|
2004-02-27 17:09:15 +03:00
|
|
|
ro_gui_choose_language();
|
2005-02-20 16:19:19 +03:00
|
|
|
|
2005-02-03 16:18:22 +03:00
|
|
|
url_store_load("Choices:WWW.NetSurf.URL");
|
2004-02-27 17:09:15 +03:00
|
|
|
|
2005-03-20 04:55:48 +03:00
|
|
|
nsdir_temp = getenv("NetSurf$Dir");
|
|
|
|
if (!nsdir_temp)
|
|
|
|
die("Failed to locate NetSurf directory");
|
|
|
|
NETSURF_DIR = strdup(nsdir_temp);
|
|
|
|
|
2004-06-09 01:35:28 +04:00
|
|
|
if ((length = snprintf(path, sizeof(path),
|
|
|
|
"<NetSurf$Dir>.Resources.%s.Messages",
|
2004-06-11 02:39:56 +04:00
|
|
|
option_language)) < 0 || length >= (int)sizeof(path))
|
2004-06-09 01:35:28 +04:00
|
|
|
die("Failed to locate Messages resource.");
|
2004-02-27 17:09:15 +03:00
|
|
|
messages_load(path);
|
2004-03-08 03:03:58 +03:00
|
|
|
messages_load("<NetSurf$Dir>.Resources.LangNames");
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2004-10-18 02:13:35 +04:00
|
|
|
default_stylesheet_url = strdup("file:/<NetSurf$Dir>/Resources/CSS");
|
|
|
|
adblock_stylesheet_url = strdup("file:/<NetSurf$Dir>/Resources/AdBlock");
|
2004-07-19 02:21:32 +04:00
|
|
|
#ifndef ncos
|
2004-03-08 03:03:58 +03:00
|
|
|
error = xwimp_initialise(wimp_VERSION_RO38, "NetSurf",
|
2004-05-08 22:12:36 +04:00
|
|
|
(const wimp_message_list *) &task_messages, 0,
|
|
|
|
&task_handle);
|
2004-07-19 02:21:32 +04:00
|
|
|
#else
|
|
|
|
error = xwimp_initialise(wimp_VERSION_RO38, "NCNetSurf",
|
|
|
|
(const wimp_message_list *) &task_messages, 0,
|
|
|
|
&task_handle);
|
|
|
|
#endif
|
2004-05-08 22:12:36 +04:00
|
|
|
if (error) {
|
2005-02-22 00:10:48 +03:00
|
|
|
LOG(("xwimp_initialise: 0x%x: %s",
|
2004-03-08 03:03:58 +03:00
|
|
|
error->errnum, error->errmess));
|
2004-05-08 22:12:36 +04:00
|
|
|
die(error->errmess);
|
|
|
|
}
|
2003-09-09 23:25:28 +04:00
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
nsfont_init();
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/* Issue a *Desktop to poke AcornURI into life */
|
|
|
|
if (getenv("NetSurf$Start_URI_Handler"))
|
|
|
|
xwimp_start_task("Desktop", 0);
|
2003-09-05 18:35:36 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Open the templates
|
|
|
|
*/
|
2004-06-09 01:35:28 +04:00
|
|
|
if ((length = snprintf(path, sizeof(path),
|
|
|
|
"<NetSurf$Dir>.Resources.%s.Templates",
|
2004-06-11 02:39:56 +04:00
|
|
|
option_language)) < 0 || length >= (int)sizeof(path))
|
2004-06-09 01:35:28 +04:00
|
|
|
die("Failed to locate Templates resource.");
|
2004-02-27 17:09:15 +03:00
|
|
|
error = xwimp_open_template(path);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_template failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-03-27 03:49:29 +03:00
|
|
|
die(error->errmess);
|
2003-12-30 01:50:43 +03:00
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
ro_gui_dialog_init();
|
|
|
|
ro_gui_download_init();
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_init();
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2003-11-08 02:51:13 +03:00
|
|
|
ro_gui_401login_init();
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2003-11-15 03:26:42 +03:00
|
|
|
ro_gui_history_init();
|
2003-11-08 02:51:13 +03:00
|
|
|
wimp_close_template();
|
2004-07-29 03:07:52 +04:00
|
|
|
ro_gui_sprites_init();
|
2004-12-09 13:30:44 +03:00
|
|
|
ro_gui_tree_initialise(); /* must be done after sprite loading */
|
|
|
|
ro_gui_hotlist_initialise();
|
2005-02-07 17:28:43 +03:00
|
|
|
ro_gui_global_history_initialise();
|
2004-07-19 02:21:32 +04:00
|
|
|
|
2005-01-23 19:09:05 +03:00
|
|
|
/* Load our chosen theme
|
|
|
|
*/
|
|
|
|
ro_gui_theme_initialise();
|
|
|
|
descriptor = ro_gui_theme_find(option_theme);
|
2005-02-08 02:00:09 +03:00
|
|
|
if (!descriptor)
|
|
|
|
descriptor = ro_gui_theme_find("Aletheia");
|
2005-01-23 19:09:05 +03:00
|
|
|
ro_gui_theme_apply(descriptor);
|
|
|
|
|
2004-07-19 02:21:32 +04:00
|
|
|
#ifndef ncos
|
2003-11-08 02:51:13 +03:00
|
|
|
ro_gui_icon_bar_create();
|
2004-07-19 02:21:32 +04:00
|
|
|
#endif
|
2004-05-07 23:14:54 +04:00
|
|
|
ro_gui_check_resolvers();
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-02-27 17:09:15 +03:00
|
|
|
/**
|
|
|
|
* Determine the language to use.
|
|
|
|
*
|
|
|
|
* RISC OS has no standard way of determining which language the user prefers.
|
|
|
|
* We have to guess from the 'Country' setting.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_choose_language(void)
|
|
|
|
{
|
|
|
|
char path[40];
|
|
|
|
const char *lang;
|
|
|
|
int country;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* if option_language exists and is valid, use that */
|
|
|
|
if (option_language) {
|
|
|
|
if (2 < strlen(option_language))
|
|
|
|
option_language[2] = 0;
|
|
|
|
sprintf(path, "<NetSurf$Dir>.Resources.%s", option_language);
|
2004-03-08 03:03:58 +03:00
|
|
|
if (is_dir(path)) {
|
|
|
|
if (!option_accept_language)
|
|
|
|
option_accept_language = strdup(option_language);
|
2004-02-27 17:09:15 +03:00
|
|
|
return;
|
2004-03-08 03:03:58 +03:00
|
|
|
}
|
2004-02-27 17:09:15 +03:00
|
|
|
free(option_language);
|
|
|
|
option_language = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* choose a language from the configured country number */
|
|
|
|
error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosbyte_read failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
country = 1;
|
|
|
|
}
|
|
|
|
switch (country) {
|
2004-09-25 03:52:40 +04:00
|
|
|
case 7: /* Germany */
|
|
|
|
lang = "de";
|
|
|
|
break;
|
2004-02-27 17:09:15 +03:00
|
|
|
case 6: /* France */
|
|
|
|
case 18: /* Canada2 (French Canada?) */
|
|
|
|
lang = "fr";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lang = "en";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sprintf(path, "<NetSurf$Dir>.Resources.%s", lang);
|
|
|
|
if (is_dir(path))
|
|
|
|
option_language = strdup(lang);
|
|
|
|
else
|
|
|
|
option_language = strdup("en");
|
|
|
|
assert(option_language);
|
2004-03-08 03:03:58 +03:00
|
|
|
if (!option_accept_language)
|
|
|
|
option_accept_language = strdup(option_language);
|
2004-02-27 17:09:15 +03:00
|
|
|
}
|
|
|
|
|
2004-04-10 01:06:10 +04:00
|
|
|
|
2004-04-01 04:26:05 +04:00
|
|
|
/**
|
2004-07-29 03:07:52 +04:00
|
|
|
* Load resource sprites (pointers and misc icons).
|
2004-04-01 04:26:05 +04:00
|
|
|
*/
|
2004-04-10 01:06:10 +04:00
|
|
|
|
2004-07-29 03:07:52 +04:00
|
|
|
void ro_gui_sprites_init(void)
|
2004-04-01 04:26:05 +04:00
|
|
|
{
|
2004-06-09 01:35:28 +04:00
|
|
|
int len;
|
|
|
|
fileswitch_object_type obj_type;
|
|
|
|
os_error *e;
|
2004-04-01 04:26:05 +04:00
|
|
|
|
2004-06-30 03:13:40 +04:00
|
|
|
e = xosfile_read_stamped_no_path("<NetSurf$Dir>.Resources.Sprites",
|
2004-04-10 01:06:10 +04:00
|
|
|
&obj_type, 0, 0, &len, 0, 0);
|
|
|
|
if (e) {
|
|
|
|
LOG(("xosfile_read_stamped_no_path: 0x%x: %s",
|
|
|
|
e->errnum, e->errmess));
|
|
|
|
die(e->errmess);
|
|
|
|
}
|
|
|
|
if (obj_type != fileswitch_IS_FILE)
|
|
|
|
die("<NetSurf$Dir>.Resources.Pointers missing.");
|
|
|
|
|
2004-06-30 03:13:40 +04:00
|
|
|
gui_sprites = malloc(len + 4);
|
|
|
|
if (!gui_sprites)
|
2004-06-09 01:35:28 +04:00
|
|
|
die("NoMemory");
|
2004-04-01 04:26:05 +04:00
|
|
|
|
2004-06-30 03:13:40 +04:00
|
|
|
gui_sprites->size = len+4;
|
|
|
|
gui_sprites->sprite_count = 0;
|
|
|
|
gui_sprites->first = 16;
|
|
|
|
gui_sprites->used = 16;
|
2004-04-01 04:26:05 +04:00
|
|
|
|
2004-06-09 01:35:28 +04:00
|
|
|
e = xosspriteop_load_sprite_file(osspriteop_USER_AREA,
|
2004-06-30 03:13:40 +04:00
|
|
|
gui_sprites, "<NetSurf$Dir>.Resources.Sprites");
|
2004-06-09 01:35:28 +04:00
|
|
|
if (e) {
|
2004-04-10 01:06:10 +04:00
|
|
|
LOG(("xosspriteop_load_sprite_file: 0x%x: %s",
|
|
|
|
e->errnum, e->errmess));
|
|
|
|
die(e->errmess);
|
2004-06-09 01:35:28 +04:00
|
|
|
}
|
2004-04-01 04:26:05 +04:00
|
|
|
}
|
2004-02-27 17:09:15 +03:00
|
|
|
|
2004-04-10 01:06:10 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/**
|
|
|
|
* Create an iconbar icon.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_icon_bar_create(void)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2003-11-08 02:51:13 +03:00
|
|
|
wimp_icon_create icon = {
|
|
|
|
wimp_ICON_BAR_RIGHT,
|
|
|
|
{ { 0, 0, 68, 68 },
|
|
|
|
wimp_ICON_SPRITE | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED |
|
|
|
|
(wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT),
|
|
|
|
{ "!netsurf" } } };
|
|
|
|
wimp_create_icon(&icon);
|
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
|
2004-05-07 23:14:54 +04:00
|
|
|
/**
|
|
|
|
* Warn the user if Inet$Resolvers is not set.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_check_resolvers(void)
|
|
|
|
{
|
2004-06-10 01:04:45 +04:00
|
|
|
char *resolvers;
|
|
|
|
resolvers = getenv("Inet$Resolvers");
|
2004-06-18 21:03:22 +04:00
|
|
|
if (resolvers && resolvers[0]) {
|
2004-06-10 01:04:45 +04:00
|
|
|
LOG(("Inet$Resolvers '%s'", resolvers));
|
|
|
|
} else {
|
2004-06-18 21:03:22 +04:00
|
|
|
LOG(("Inet$Resolvers not set or empty"));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("Resolvers", 0);
|
2004-06-10 01:04:45 +04:00
|
|
|
}
|
2004-05-07 23:14:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-29 03:07:52 +04:00
|
|
|
/**
|
|
|
|
* Last-minute gui init, after all other modules have initialised.
|
|
|
|
*/
|
|
|
|
|
2004-09-27 09:21:00 +04:00
|
|
|
void gui_init2(int argc, char** argv)
|
2004-07-29 03:07:52 +04:00
|
|
|
{
|
2004-09-27 09:21:00 +04:00
|
|
|
char *url = 0;
|
|
|
|
bool open_window = option_open_browser_at_startup;
|
|
|
|
|
|
|
|
/* parse command-line arguments */
|
|
|
|
if (argc == 2) {
|
|
|
|
LOG(("parameters: '%s'", argv[1]));
|
|
|
|
/* this is needed for launching URI files */
|
|
|
|
if (strcasecmp(argv[1], "-nowin") == 0)
|
|
|
|
open_window = false;
|
|
|
|
}
|
|
|
|
else if (argc == 3) {
|
|
|
|
LOG(("parameters: '%s' '%s'", argv[1], argv[2]));
|
|
|
|
open_window = true;
|
|
|
|
|
|
|
|
/* HTML files */
|
|
|
|
if (strcasecmp(argv[1], "-html") == 0) {
|
|
|
|
url = ro_path_to_url(argv[2]);
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* URL files */
|
|
|
|
else if (strcasecmp(argv[1], "-urlf") == 0) {
|
|
|
|
url = ro_gui_url_file_parse(argv[2]);
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* ANT URL Load */
|
|
|
|
else if (strcasecmp(argv[1], "-url") == 0) {
|
|
|
|
url = strdup(argv[2]);
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Unknown => exit here. */
|
|
|
|
else {
|
|
|
|
LOG(("Unknown parameters: '%s' '%s'",
|
|
|
|
argv[1], argv[2]));
|
|
|
|
return;
|
2004-07-29 03:07:52 +04:00
|
|
|
}
|
|
|
|
}
|
2004-09-27 09:21:00 +04:00
|
|
|
/* get user's homepage (if configured) */
|
|
|
|
else if (option_homepage_url && option_homepage_url[0]) {
|
|
|
|
url = calloc(strlen(option_homepage_url) + 5, sizeof(char));
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
sprintf(url, "%s", option_homepage_url);
|
|
|
|
}
|
|
|
|
/* default homepage */
|
|
|
|
else {
|
|
|
|
url = calloc(80, sizeof(char));
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
snprintf(url, 80, "file:/<NetSurf$Dir>/Docs/intro_%s",
|
|
|
|
option_language);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_KIOSK_BROWSING
|
|
|
|
open_window = true;
|
2004-07-29 03:07:52 +04:00
|
|
|
#endif
|
2004-09-27 09:21:00 +04:00
|
|
|
|
|
|
|
if (open_window)
|
2004-10-02 01:33:20 +04:00
|
|
|
browser_window_create(url, NULL, 0);
|
2004-09-27 09:21:00 +04:00
|
|
|
|
|
|
|
free(url);
|
2004-07-29 03:07:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/**
|
|
|
|
* Close down the gui (RISC OS).
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_quit(void)
|
|
|
|
{
|
2005-02-03 16:18:22 +03:00
|
|
|
url_store_save("<Choices$Write>.WWW.NetSurf.URL");
|
2004-07-30 20:16:07 +04:00
|
|
|
ro_gui_window_quit();
|
2005-02-07 17:28:43 +03:00
|
|
|
ro_gui_global_history_save();
|
2004-12-09 13:30:44 +03:00
|
|
|
ro_gui_hotlist_save();
|
2003-11-15 03:26:42 +03:00
|
|
|
ro_gui_history_quit();
|
2005-02-20 16:19:19 +03:00
|
|
|
rufl_quit();
|
2004-06-30 03:13:40 +04:00
|
|
|
free(gui_sprites);
|
2004-07-30 20:16:07 +04:00
|
|
|
xwimp_close_down(task_handle);
|
2004-10-18 02:13:35 +04:00
|
|
|
free(default_stylesheet_url);
|
|
|
|
free(adblock_stylesheet_url);
|
2004-01-28 21:37:56 +03:00
|
|
|
xhourglass_off();
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2005-02-08 02:00:09 +03:00
|
|
|
/**
|
|
|
|
* Handles a signal
|
|
|
|
*/
|
2005-02-22 00:10:48 +03:00
|
|
|
|
|
|
|
void ro_gui_signal(int sig)
|
|
|
|
{
|
2005-04-03 03:57:48 +04:00
|
|
|
struct content *c;
|
|
|
|
if (sig == SIGFPE) {
|
|
|
|
for (c = content_list; c; c = c->next)
|
|
|
|
if (c->type == CONTENT_HTML && c->data.html.layout) {
|
|
|
|
LOG(("Dumping: '%s'", c->url));
|
|
|
|
box_dump(c->data.html.layout, 0);
|
|
|
|
}
|
|
|
|
}
|
2005-02-20 16:19:19 +03:00
|
|
|
ro_gui_cleanup();
|
2005-02-08 02:00:09 +03:00
|
|
|
raise(sig);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures the gui exits cleanly.
|
|
|
|
*/
|
2005-02-22 00:10:48 +03:00
|
|
|
|
|
|
|
void ro_gui_cleanup(void)
|
|
|
|
{
|
2005-02-08 02:00:09 +03:00
|
|
|
ro_gui_buffer_close();
|
|
|
|
xhourglass_off();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Poll the OS for events (RISC OS).
|
|
|
|
*
|
|
|
|
* \param active return as soon as possible
|
|
|
|
*/
|
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
void gui_poll(bool active)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2004-01-28 21:37:56 +03:00
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block block;
|
|
|
|
const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN;
|
|
|
|
|
|
|
|
/* Process queued events. */
|
|
|
|
while (ro_gui_poll_queued_blocks) {
|
|
|
|
struct ro_gui_poll_block *next;
|
|
|
|
ro_gui_handle_event(ro_gui_poll_queued_blocks->event,
|
|
|
|
ro_gui_poll_queued_blocks->block);
|
|
|
|
next = ro_gui_poll_queued_blocks->next;
|
|
|
|
free(ro_gui_poll_queued_blocks->block);
|
|
|
|
free(ro_gui_poll_queued_blocks);
|
|
|
|
ro_gui_poll_queued_blocks = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Poll wimp. */
|
|
|
|
xhourglass_off();
|
|
|
|
if (active) {
|
|
|
|
event = wimp_poll(mask, &block, 0);
|
2005-04-15 09:54:44 +04:00
|
|
|
} else if (sched_active || gui_track || gui_reformat_pending) {
|
|
|
|
os_t t = os_read_monotonic_time();
|
|
|
|
|
|
|
|
if (gui_track)
|
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_SELECTION:
|
|
|
|
case GUI_DRAG_SCROLL:
|
|
|
|
t += 4; /* for smoother update */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
t += 10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
t += 10;
|
|
|
|
|
|
|
|
if (sched_active && (sched_time - t) < 0)
|
2004-03-28 04:29:29 +04:00
|
|
|
t = sched_time;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2004-03-28 04:29:29 +04:00
|
|
|
event = wimp_poll_idle(mask, &block, t, 0);
|
2004-01-28 21:37:56 +03:00
|
|
|
} else {
|
|
|
|
event = wimp_poll(wimp_MASK_NULL | mask, &block, 0);
|
|
|
|
}
|
|
|
|
xhourglass_on();
|
2004-03-30 15:45:48 +04:00
|
|
|
gui_last_poll = clock();
|
2004-01-28 21:37:56 +03:00
|
|
|
ro_gui_handle_event(event, &block);
|
2004-03-21 15:46:56 +03:00
|
|
|
schedule_run();
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (gui_reformat_pending && event == wimp_NULL_REASON_CODE)
|
|
|
|
ro_gui_window_process_reformats();
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Process a Wimp_Poll event.
|
|
|
|
*
|
|
|
|
* \param event wimp event number
|
|
|
|
* \param block parameter block
|
|
|
|
*/
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
|
|
|
|
{
|
|
|
|
switch (event) {
|
|
|
|
case wimp_NULL_REASON_CODE:
|
|
|
|
ro_gui_null_reason_code();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_REDRAW_WINDOW_REQUEST:
|
|
|
|
ro_gui_redraw_window_request(&block->redraw);
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_OPEN_WINDOW_REQUEST:
|
|
|
|
ro_gui_open_window_request(&block->open);
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_CLOSE_WINDOW_REQUEST:
|
|
|
|
ro_gui_close_window_request(&block->close);
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_POINTER_LEAVING_WINDOW:
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_pointer_leaving_window(&block->leaving);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_POINTER_ENTERING_WINDOW:
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_pointer_entering_window(&block->entering);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
2003-12-21 05:27:22 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_MOUSE_CLICK:
|
|
|
|
ro_gui_mouse_click(&block->pointer);
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_USER_DRAG_BOX:
|
|
|
|
ro_gui_drag_end(&(block->dragged));
|
|
|
|
break;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_KEY_PRESSED:
|
|
|
|
ro_gui_keypress(&(block->key));
|
|
|
|
break;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_MENU_SELECTION:
|
|
|
|
ro_gui_menu_selection(&(block->selection));
|
|
|
|
break;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_SCROLL_REQUEST:
|
|
|
|
ro_gui_scroll_request(&(block->scroll));
|
|
|
|
break;
|
2003-10-06 03:30:21 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_USER_MESSAGE:
|
|
|
|
case wimp_USER_MESSAGE_RECORDED:
|
|
|
|
case wimp_USER_MESSAGE_ACKNOWLEDGE:
|
|
|
|
ro_gui_user_message(event, &(block->message));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Check for important events and yield CPU (RISC OS).
|
|
|
|
*
|
|
|
|
* Required on RISC OS for cooperative multitasking.
|
|
|
|
*/
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
void gui_multitask(void)
|
|
|
|
{
|
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block block;
|
|
|
|
|
2004-03-30 15:45:48 +04:00
|
|
|
if (clock() < gui_last_poll + 10)
|
|
|
|
return;
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
xhourglass_off();
|
|
|
|
event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN, &block, 0);
|
|
|
|
xhourglass_on();
|
2004-03-30 15:45:48 +04:00
|
|
|
gui_last_poll = clock();
|
2004-01-28 21:37:56 +03:00
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case wimp_KEY_PRESSED:
|
|
|
|
case wimp_MENU_SELECTION:
|
|
|
|
ro_gui_poll_queue(event, &block);
|
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
default:
|
|
|
|
ro_gui_handle_event(event, &block);
|
|
|
|
break;
|
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a wimp_block to the queue for later handling.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_poll_queue(wimp_event_no event, wimp_block *block)
|
|
|
|
{
|
|
|
|
struct ro_gui_poll_block *q =
|
2004-12-09 13:30:44 +03:00
|
|
|
calloc(1, sizeof(struct ro_gui_poll_block));
|
|
|
|
if (!q) {
|
|
|
|
LOG(("Insufficient memory for calloc"));
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return;
|
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
|
|
|
|
q->event = event;
|
2004-12-09 13:30:44 +03:00
|
|
|
q->block = calloc(1, sizeof(*block));
|
|
|
|
if (!q->block) {
|
|
|
|
free(q);
|
|
|
|
LOG(("Insufficient memory for calloc"));
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return;
|
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
memcpy(q->block, block, sizeof(*block));
|
|
|
|
q->next = NULL;
|
|
|
|
|
|
|
|
if (ro_gui_poll_queued_blocks == NULL) {
|
|
|
|
ro_gui_poll_queued_blocks = q;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
struct ro_gui_poll_block *current =
|
|
|
|
ro_gui_poll_queued_blocks;
|
|
|
|
while (current->next != NULL)
|
|
|
|
current = current->next;
|
|
|
|
current->next = q;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Null_Reason_Code events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_null_reason_code(void)
|
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
wimp_pointer pointer;
|
|
|
|
os_error *error;
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
ro_gui_throb();
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
if (!gui_track)
|
|
|
|
return;
|
|
|
|
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info: 0x%x: %s",
|
2005-04-15 09:54:44 +04:00
|
|
|
error->errnum, error->errmess));
|
2004-07-17 17:00:38 +04:00
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
2004-02-26 03:44:42 +03:00
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
|
|
|
|
/* pointer is allowed to wander outside the initiating window
|
|
|
|
for certain drag types */
|
|
|
|
|
|
|
|
case GUI_DRAG_SELECTION:
|
|
|
|
case GUI_DRAG_SCROLL:
|
|
|
|
assert(gui_track_gui_window);
|
|
|
|
ro_gui_window_mouse_at(gui_track_gui_window, &pointer);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (gui_track_wimp_w == history_window)
|
|
|
|
ro_gui_history_mouse_at(&pointer);
|
|
|
|
if (gui_track_wimp_w == dialog_url_complete)
|
|
|
|
ro_gui_url_complete_mouse_at(&pointer, false);
|
|
|
|
else if (gui_track_gui_window)
|
|
|
|
ro_gui_window_mouse_at(gui_track_gui_window, &pointer);
|
|
|
|
break;
|
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Redraw_Window_Request events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_redraw_window_request(wimp_draw *redraw)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
if (redraw->w == history_window)
|
2004-01-28 21:37:56 +03:00
|
|
|
ro_gui_history_redraw(redraw);
|
2005-02-03 16:18:22 +03:00
|
|
|
else if (redraw->w == dialog_url_complete)
|
|
|
|
ro_gui_url_complete_redraw(redraw);
|
2004-12-09 13:30:44 +03:00
|
|
|
else if ((hotlist_tree) && (redraw->w == (wimp_w)hotlist_tree->handle))
|
|
|
|
ro_gui_tree_redraw(redraw, hotlist_tree);
|
2005-03-20 17:57:19 +03:00
|
|
|
else if ((global_history_tree) && (redraw->w == (wimp_w)global_history_tree->handle))
|
|
|
|
ro_gui_tree_redraw(redraw, global_history_tree);
|
2005-03-19 02:52:38 +03:00
|
|
|
else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
|
|
|
|
(hotlist_tree->toolbar->toolbar_handle == redraw->w))
|
|
|
|
ro_gui_theme_redraw(hotlist_tree->toolbar, redraw);
|
2005-03-20 17:57:19 +03:00
|
|
|
else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
|
|
|
|
(hotlist_tree->toolbar->editor) &&
|
|
|
|
(hotlist_tree->toolbar->editor->toolbar_handle == redraw->w))
|
|
|
|
ro_gui_theme_redraw(hotlist_tree->toolbar->editor, redraw);
|
2005-03-19 02:52:38 +03:00
|
|
|
else if ((global_history_tree) && (global_history_tree->toolbar) &&
|
|
|
|
(global_history_tree->toolbar->toolbar_handle == redraw->w))
|
|
|
|
ro_gui_theme_redraw(global_history_tree->toolbar, redraw);
|
2005-03-20 17:57:19 +03:00
|
|
|
else if ((global_history_tree) && (global_history_tree->toolbar) &&
|
|
|
|
(global_history_tree->toolbar->editor) &&
|
|
|
|
(global_history_tree->toolbar->editor->toolbar_handle == redraw->w))
|
|
|
|
ro_gui_theme_redraw(global_history_tree->toolbar->editor, redraw);
|
2004-06-11 00:41:26 +04:00
|
|
|
else if (redraw->w == dialog_debug)
|
|
|
|
ro_gui_debugwin_redraw(redraw);
|
2004-08-14 18:30:12 +04:00
|
|
|
else if ((g = ro_gui_window_lookup(redraw->w)) != NULL)
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_window_redraw(g, redraw);
|
2005-03-20 17:57:19 +03:00
|
|
|
else if ((g = ro_gui_toolbar_lookup(redraw->w)) != NULL) {
|
|
|
|
if (g->toolbar->toolbar_handle == redraw->w)
|
|
|
|
ro_gui_theme_redraw(g->toolbar, redraw);
|
|
|
|
else if ((g->toolbar->editor) &&
|
|
|
|
(g->toolbar->editor->toolbar_handle == redraw->w))
|
|
|
|
ro_gui_theme_redraw(g->toolbar->editor, redraw);
|
|
|
|
} else {
|
2004-12-09 13:30:44 +03:00
|
|
|
ro_gui_dialog_redraw(redraw);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2003-08-25 02:39:55 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle Open_Window_Request events.
|
|
|
|
*/
|
|
|
|
|
2004-06-09 01:35:28 +04:00
|
|
|
void ro_gui_open_window_request(wimp_open *open)
|
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
|
|
|
os_error *error;
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
g = ro_gui_window_lookup(open->w);
|
2004-05-05 02:23:44 +04:00
|
|
|
if (g) {
|
2004-01-28 21:37:56 +03:00
|
|
|
ro_gui_window_open(g, open);
|
2004-12-09 13:30:44 +03:00
|
|
|
} else if ((hotlist_tree) && (open->w == (wimp_w)hotlist_tree->handle)){
|
|
|
|
ro_gui_tree_open(open, hotlist_tree);
|
2005-02-07 17:28:43 +03:00
|
|
|
} else if ((global_history_tree) && (open->w == (wimp_w)global_history_tree->handle)){
|
|
|
|
ro_gui_tree_open(open, global_history_tree);
|
2004-05-05 02:23:44 +04:00
|
|
|
} else {
|
2004-07-17 17:00:38 +04:00
|
|
|
error = xwimp_open_window(open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g = ro_gui_status_lookup(open->w);
|
2004-08-31 01:03:48 +04:00
|
|
|
if (g && g->toolbar)
|
|
|
|
ro_gui_theme_resize_toolbar_status(g->toolbar);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle Close_Window_Request events.
|
|
|
|
*/
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
void ro_gui_close_window_request(wimp_close *close)
|
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
2004-06-28 03:24:11 +04:00
|
|
|
struct gui_download_window *dw;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* Check for children
|
|
|
|
*/
|
|
|
|
ro_gui_dialog_close_persistant(close->w);
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-06-28 03:24:11 +04:00
|
|
|
if (close->w == dialog_debug)
|
2004-06-11 00:41:26 +04:00
|
|
|
ro_gui_debugwin_close();
|
2005-02-03 16:18:22 +03:00
|
|
|
else if ((g = ro_gui_window_lookup(close->w)) != NULL) {
|
|
|
|
ro_gui_url_complete_close(NULL, 0);
|
2004-07-17 17:00:38 +04:00
|
|
|
browser_window_destroy(g->bw);
|
2005-02-03 16:18:22 +03:00
|
|
|
}
|
2004-08-14 18:30:12 +04:00
|
|
|
else if ((dw = ro_gui_download_window_lookup(close->w)) != NULL)
|
2004-06-28 03:24:11 +04:00
|
|
|
ro_gui_download_window_destroy(dw);
|
|
|
|
else
|
2004-01-28 21:37:56 +03:00
|
|
|
ro_gui_dialog_close(close->w);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Handle Pointer_Leaving_Window events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
|
|
|
|
{
|
|
|
|
if (gui_track_wimp_w == history_window) {
|
2005-04-15 09:54:44 +04:00
|
|
|
os_error *error = xwimp_close_window(dialog_tooltip);
|
2004-07-17 17:00:38 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_close_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_SELECTION:
|
|
|
|
case GUI_DRAG_SCROLL:
|
|
|
|
/* ignore Pointer_Leaving_Window event that the Wimp mysteriously
|
|
|
|
issues when a Wimp_DragBox drag operations is started */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gui_track = false;
|
|
|
|
gui_window_set_pointer(GUI_POINTER_DEFAULT);
|
|
|
|
break;
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Pointer_Entering_Window events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_pointer_entering_window(wimp_entering *entering)
|
|
|
|
{
|
|
|
|
gui_track_wimp_w = entering->w;
|
|
|
|
gui_track_gui_window = ro_gui_window_lookup(entering->w);
|
2005-02-03 16:18:22 +03:00
|
|
|
gui_track = gui_track_gui_window || gui_track_wimp_w == history_window ||
|
|
|
|
gui_track_wimp_w == dialog_url_complete;
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle Mouse_Click events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_mouse_click(wimp_pointer *pointer)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
2004-06-28 03:24:11 +04:00
|
|
|
struct gui_download_window *dw;
|
2004-01-28 21:37:56 +03:00
|
|
|
|
|
|
|
if (pointer->w == wimp_ICON_BAR)
|
|
|
|
ro_gui_icon_bar_click(pointer);
|
|
|
|
else if (pointer->w == history_window)
|
|
|
|
ro_gui_history_click(pointer);
|
2005-02-03 16:18:22 +03:00
|
|
|
else if (pointer->w == dialog_url_complete)
|
2005-02-09 03:16:38 +03:00
|
|
|
ro_gui_url_complete_mouse_at(pointer, true);
|
2004-12-09 13:30:44 +03:00
|
|
|
else if ((hotlist_tree) && (pointer->w == (wimp_w)hotlist_tree->handle))
|
2004-06-30 03:13:40 +04:00
|
|
|
ro_gui_hotlist_click(pointer);
|
2005-02-07 17:28:43 +03:00
|
|
|
else if ((global_history_tree) && (pointer->w == (wimp_w)global_history_tree->handle))
|
|
|
|
ro_gui_global_history_click(pointer);
|
2004-07-17 17:00:38 +04:00
|
|
|
else if (pointer->w == dialog_saveas)
|
|
|
|
ro_gui_save_click(pointer);
|
2005-03-19 02:52:38 +03:00
|
|
|
else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
|
|
|
|
(hotlist_tree->toolbar->toolbar_handle == pointer->w))
|
|
|
|
ro_gui_tree_toolbar_click(pointer, hotlist_tree);
|
2005-03-20 17:57:19 +03:00
|
|
|
else if ((hotlist_tree) && (hotlist_tree->toolbar) &&
|
|
|
|
(hotlist_tree->toolbar->editor) &&
|
|
|
|
(hotlist_tree->toolbar->editor->toolbar_handle == pointer->w))
|
|
|
|
ro_gui_tree_toolbar_click(pointer, hotlist_tree);
|
|
|
|
else if ((global_history_tree) && (global_history_tree->toolbar) &&
|
|
|
|
(global_history_tree->toolbar->toolbar_handle == pointer->w))
|
|
|
|
ro_gui_tree_toolbar_click(pointer, global_history_tree);
|
2005-03-19 02:52:38 +03:00
|
|
|
else if ((global_history_tree) && (global_history_tree->toolbar) &&
|
2005-03-20 17:57:19 +03:00
|
|
|
(global_history_tree->toolbar->editor) &&
|
|
|
|
(global_history_tree->toolbar->editor->toolbar_handle == pointer->w))
|
2005-03-19 02:52:38 +03:00
|
|
|
ro_gui_tree_toolbar_click(pointer, global_history_tree);
|
2004-08-14 18:30:12 +04:00
|
|
|
else if ((g = ro_gui_window_lookup(pointer->w)) != NULL)
|
2004-02-25 18:12:58 +03:00
|
|
|
ro_gui_window_click(g, pointer);
|
2004-08-14 18:30:12 +04:00
|
|
|
else if ((g = ro_gui_toolbar_lookup(pointer->w)) != NULL)
|
2004-01-28 21:37:56 +03:00
|
|
|
ro_gui_toolbar_click(g, pointer);
|
2004-08-14 18:30:12 +04:00
|
|
|
else if ((g = ro_gui_status_lookup(pointer->w)) != NULL)
|
2004-05-05 02:23:44 +04:00
|
|
|
ro_gui_status_click(g, pointer);
|
2004-08-14 18:30:12 +04:00
|
|
|
else if ((dw = ro_gui_download_window_lookup(pointer->w)) != NULL)
|
2004-06-28 03:24:11 +04:00
|
|
|
ro_gui_download_window_click(dw, pointer);
|
2004-01-28 21:37:56 +03:00
|
|
|
else
|
|
|
|
ro_gui_dialog_click(pointer);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle Mouse_Click events on the iconbar icon.
|
|
|
|
*/
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
void ro_gui_icon_bar_click(wimp_pointer *pointer)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2004-07-29 03:07:52 +04:00
|
|
|
char url[80];
|
|
|
|
int key_down = 0;
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
if (pointer->buttons == wimp_CLICK_MENU) {
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_create(iconbar_menu, pointer->pos.x,
|
|
|
|
96 + iconbar_menu_height, wimp_ICON_BAR);
|
2004-07-27 00:13:45 +04:00
|
|
|
|
2004-07-29 03:07:52 +04:00
|
|
|
} else if (pointer->buttons == wimp_CLICK_SELECT) {
|
|
|
|
if (option_homepage_url && option_homepage_url[0]) {
|
2004-10-02 01:33:20 +04:00
|
|
|
browser_window_create(option_homepage_url, NULL, 0);
|
2004-07-29 03:07:52 +04:00
|
|
|
} else {
|
|
|
|
snprintf(url, sizeof url,
|
|
|
|
"file:/<NetSurf$Dir>/Docs/intro_%s",
|
|
|
|
option_language);
|
2004-10-02 01:33:20 +04:00
|
|
|
browser_window_create(url, NULL, 0);
|
2004-07-29 03:07:52 +04:00
|
|
|
}
|
2004-07-27 00:13:45 +04:00
|
|
|
|
2004-06-11 00:41:26 +04:00
|
|
|
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
|
2004-07-29 03:07:52 +04:00
|
|
|
xosbyte1(osbyte_SCAN_KEYBOARD, 0 ^ 0x80, 0, &key_down);
|
2005-04-08 00:46:22 +04:00
|
|
|
if (key_down == 0)
|
|
|
|
ro_gui_menu_handle_action(pointer->w, HOTLIST_SHOW,
|
|
|
|
false);
|
|
|
|
else
|
2004-07-14 00:08:53 +04:00
|
|
|
ro_gui_debugwin_open();
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
/**
|
|
|
|
* Handle User_Drag_Box events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_drag_end(wimp_dragged *drag)
|
|
|
|
{
|
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_SELECTION:
|
2005-04-15 09:54:44 +04:00
|
|
|
ro_gui_selection_drag_end(gui_track_gui_window, drag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_DRAG_SCROLL:
|
|
|
|
ro_gui_window_scroll_end(gui_track_gui_window, drag);
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_DRAG_DOWNLOAD_SAVE:
|
2004-06-28 03:24:11 +04:00
|
|
|
ro_gui_download_drag_end(drag);
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_DRAG_SAVE:
|
|
|
|
ro_gui_save_drag_end(drag);
|
|
|
|
break;
|
2004-05-05 02:23:44 +04:00
|
|
|
|
|
|
|
case GUI_DRAG_STATUS_RESIZE:
|
2004-07-03 21:30:28 +04:00
|
|
|
break;
|
|
|
|
|
2004-12-09 13:30:44 +03:00
|
|
|
case GUI_DRAG_TREE_SELECT:
|
|
|
|
ro_gui_tree_selection_drag_end(drag);
|
2004-07-03 21:30:28 +04:00
|
|
|
break;
|
|
|
|
|
2004-12-09 13:30:44 +03:00
|
|
|
case GUI_DRAG_TREE_MOVE:
|
|
|
|
ro_gui_tree_move_drag_end(drag);
|
2004-05-05 02:23:44 +04:00
|
|
|
break;
|
2005-03-20 22:28:50 +03:00
|
|
|
|
|
|
|
case GUI_DRAG_TOOLBAR_CONFIG:
|
|
|
|
ro_gui_theme_toolbar_editor_drag_end(drag);
|
|
|
|
break;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
assert(gui_current_drag_type == GUI_DRAG_NONE);
|
|
|
|
break;
|
2004-02-26 03:44:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
/**
|
|
|
|
* Handle Key_Pressed events.
|
|
|
|
*/
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
void ro_gui_keypress(wimp_key *key)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2003-12-11 04:23:57 +03:00
|
|
|
bool handled = false;
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
|
|
|
os_error *error;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
if ((hotlist_tree) && (key->w == (wimp_w)hotlist_tree->handle))
|
2005-04-08 00:46:22 +04:00
|
|
|
handled = ro_gui_tree_keypress(key->c, hotlist_tree);
|
2005-02-07 17:28:43 +03:00
|
|
|
else if ((global_history_tree) && (key->w == (wimp_w)global_history_tree->handle))
|
2005-04-08 00:46:22 +04:00
|
|
|
handled = ro_gui_tree_keypress(key->c, global_history_tree);
|
2005-02-07 17:28:43 +03:00
|
|
|
else if ((g = ro_gui_window_lookup(key->w)) != NULL)
|
2004-07-17 17:00:38 +04:00
|
|
|
handled = ro_gui_window_keypress(g, key->c, false);
|
2004-08-14 18:30:12 +04:00
|
|
|
else if ((g = ro_gui_toolbar_lookup(key->w)) != NULL)
|
2004-07-17 17:00:38 +04:00
|
|
|
handled = ro_gui_window_keypress(g, key->c, true);
|
2004-12-09 13:30:44 +03:00
|
|
|
else
|
2004-06-09 01:35:28 +04:00
|
|
|
handled = ro_gui_dialog_keypress(key);
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (!handled) {
|
|
|
|
error = xwimp_process_key(key->c);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_process_key: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
}
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle the three User_Message events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_user_message(wimp_event_no event, wimp_message *message)
|
|
|
|
{
|
|
|
|
switch (message->action) {
|
2004-06-09 01:35:28 +04:00
|
|
|
case message_HELP_REQUEST:
|
|
|
|
ro_gui_interactive_help_request(message);
|
|
|
|
break;
|
2004-05-13 18:39:43 +04:00
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
case message_DATA_SAVE:
|
|
|
|
ro_msg_datasave(message);
|
|
|
|
break;
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_DATA_SAVE_ACK:
|
|
|
|
ro_msg_datasave_ack(message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_DATA_LOAD:
|
2004-08-09 10:28:57 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
|
|
|
|
#ifdef WITH_PRINT
|
|
|
|
if (print_current_window)
|
|
|
|
print_dataload_bounce(message);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ro_msg_dataload(message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_DATA_LOAD_ACK:
|
|
|
|
#ifdef WITH_PRINT
|
2004-08-09 13:05:34 +04:00
|
|
|
if (print_current_window)
|
|
|
|
print_cleanup();
|
2004-08-09 10:28:57 +04:00
|
|
|
#endif
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case message_DATA_OPEN:
|
|
|
|
ro_msg_dataopen(message);
|
|
|
|
break;
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
case message_MENU_WARNING:
|
|
|
|
ro_gui_menu_warning((wimp_message_menu_warning *)
|
|
|
|
&message->data);
|
|
|
|
break;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2004-07-04 22:44:51 +04:00
|
|
|
case message_MENUS_DELETED:
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_closed();
|
2004-07-04 22:44:51 +04:00
|
|
|
break;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2004-11-03 05:29:01 +03:00
|
|
|
case message_MODE_CHANGE:
|
|
|
|
ro_gui_history_mode_change();
|
2005-02-20 16:19:19 +03:00
|
|
|
rufl_invalidate_cache();
|
2004-11-03 05:29:01 +03:00
|
|
|
break;
|
2004-02-26 03:44:42 +03:00
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
case message_CLAIM_ENTITY:
|
|
|
|
ro_gui_selection_claim_entity((wimp_full_message_claim_entity*)message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_DATA_REQUEST:
|
|
|
|
ro_gui_selection_data_request((wimp_full_message_data_request*)message);
|
|
|
|
break;
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
#ifdef WITH_URI
|
|
|
|
case message_URI_PROCESS:
|
2004-04-02 04:41:10 +04:00
|
|
|
if (event != wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
ro_uri_message_received(message);
|
|
|
|
break;
|
|
|
|
case message_URI_RETURN_RESULT:
|
2004-06-29 03:57:26 +04:00
|
|
|
ro_uri_bounce(message);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef WITH_URL
|
|
|
|
case message_INET_SUITE_OPEN_URL:
|
2004-04-02 04:41:10 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
|
|
|
|
ro_url_bounce(message);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ro_url_message_received(message);
|
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef WITH_PLUGIN
|
|
|
|
case message_PLUG_IN_OPENING:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_opening(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_CLOSED:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_closed(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_RESHAPE_REQUEST:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_reshape_request(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_FOCUS:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_URL_ACCESS:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_url_access(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STATUS:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_status(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_BUSY:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_NEW:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_stream_new(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_WRITE:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_WRITTEN:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_stream_written(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_DESTROY:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_OPEN:
|
2004-08-13 04:55:59 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
plugin_open_msg(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_CLOSE:
|
2004-08-13 04:55:59 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
plugin_close_msg(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_RESHAPE:
|
|
|
|
case message_PLUG_IN_STREAM_AS_FILE:
|
|
|
|
case message_PLUG_IN_NOTIFY:
|
|
|
|
case message_PLUG_IN_ABORT:
|
|
|
|
case message_PLUG_IN_ACTION:
|
|
|
|
break;
|
|
|
|
#endif
|
2004-08-09 10:28:57 +04:00
|
|
|
#ifdef WITH_PRINT
|
|
|
|
case message_PRINT_SAVE:
|
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
print_save_bounce(message);
|
|
|
|
break;
|
|
|
|
case message_PRINT_ERROR:
|
|
|
|
print_error(message);
|
|
|
|
break;
|
|
|
|
case message_PRINT_TYPE_ODD:
|
|
|
|
print_type_odd(message);
|
|
|
|
break;
|
|
|
|
#endif
|
2004-01-28 21:37:56 +03:00
|
|
|
|
|
|
|
case message_QUIT:
|
|
|
|
netsurf_quit = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-03 03:19:47 +03:00
|
|
|
/**
|
|
|
|
* Handle Message_DataLoad (file dragged in).
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_dataload(wimp_message *message)
|
2002-12-31 01:56:30 +03:00
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
int file_type = message->data.data_xfer.file_type;
|
2005-04-08 06:06:46 +04:00
|
|
|
int tree_file_type = file_type;
|
2004-03-05 02:15:17 +03:00
|
|
|
char *url = 0;
|
2005-04-08 06:06:46 +04:00
|
|
|
char *title = NULL;
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
2004-12-09 13:30:44 +03:00
|
|
|
struct node *node;
|
|
|
|
struct node *link;
|
2004-07-17 17:00:38 +04:00
|
|
|
os_error *error;
|
2004-12-09 13:30:44 +03:00
|
|
|
int x, y;
|
|
|
|
bool before;
|
2005-04-08 06:06:46 +04:00
|
|
|
bool tree_edit = false;
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
g = ro_gui_window_lookup(message->data.data_xfer.w);
|
2005-04-22 01:36:23 +04:00
|
|
|
if (g) {
|
|
|
|
if (ro_gui_window_dataload(g, message))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g = ro_gui_toolbar_lookup(message->data.data_xfer.w);
|
|
|
|
if (g && ro_gui_toolbar_dataload(g, message))
|
|
|
|
return;
|
|
|
|
}
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
switch (file_type) {
|
|
|
|
case FILETYPE_ACORN_URI:
|
2005-04-08 06:06:46 +04:00
|
|
|
url = ro_gui_uri_file_parse(message->data.data_xfer.file_name,
|
|
|
|
&title);
|
|
|
|
tree_file_type = 0xfaf;
|
2005-04-05 02:14:51 +04:00
|
|
|
break;
|
|
|
|
case FILETYPE_ANT_URL:
|
|
|
|
url = ro_gui_url_file_parse(message->data.data_xfer.file_name);
|
2005-04-08 06:06:46 +04:00
|
|
|
tree_file_type = 0xfaf;
|
2005-04-05 02:14:51 +04:00
|
|
|
break;
|
|
|
|
case FILETYPE_IEURL:
|
|
|
|
url = ro_gui_ieurl_file_parse(message->data.data_xfer.file_name);
|
2005-04-08 06:06:46 +04:00
|
|
|
tree_file_type = 0xfaf;
|
2005-04-05 02:14:51 +04:00
|
|
|
break;
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
case FILETYPE_HTML:
|
|
|
|
case FILETYPE_JNG:
|
|
|
|
case FILETYPE_CSS:
|
|
|
|
case FILETYPE_MNG:
|
|
|
|
case FILETYPE_GIF:
|
|
|
|
case osfile_TYPE_DRAW:
|
|
|
|
case FILETYPE_PNG:
|
|
|
|
case FILETYPE_JPEG:
|
|
|
|
case osfile_TYPE_SPRITE:
|
|
|
|
case osfile_TYPE_TEXT:
|
|
|
|
/* display the actual file */
|
|
|
|
url = ro_path_to_url(message->data.data_xfer.file_name);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2004-12-09 13:30:44 +03:00
|
|
|
|
|
|
|
if (!url)
|
2005-02-03 23:49:43 +03:00
|
|
|
/* error has already been reported by one of the
|
2004-12-09 13:30:44 +03:00
|
|
|
* functions called above */
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (g) {
|
2005-01-25 01:14:59 +03:00
|
|
|
browser_window_go(g->bw, url, 0);
|
2005-02-03 23:49:43 +03:00
|
|
|
} else if ((hotlist_tree) && ((wimp_w)hotlist_tree->handle ==
|
|
|
|
message->data.data_xfer.w)) {
|
2005-04-08 06:06:46 +04:00
|
|
|
if (!title) {
|
|
|
|
tree_edit = true;
|
|
|
|
title = url;
|
|
|
|
}
|
2005-02-03 23:49:43 +03:00
|
|
|
ro_gui_tree_get_tree_coordinates(hotlist_tree,
|
|
|
|
message->data.data_xfer.pos.x,
|
|
|
|
message->data.data_xfer.pos.y,
|
|
|
|
&x, &y);
|
|
|
|
link = tree_get_link_details(hotlist_tree, x, y, &before);
|
|
|
|
node = tree_create_URL_node(NULL,
|
2005-04-08 06:06:46 +04:00
|
|
|
title, url, tree_file_type,
|
2005-02-03 23:49:43 +03:00
|
|
|
time(NULL), -1, 0);
|
|
|
|
tree_link_node(link, node, before);
|
|
|
|
tree_handle_node_changed(hotlist_tree, node, false, true);
|
|
|
|
tree_redraw_area(hotlist_tree, node->box.x - NODE_INSTEP, 0,
|
|
|
|
NODE_INSTEP, 16384);
|
2005-04-08 06:06:46 +04:00
|
|
|
if (tree_edit)
|
|
|
|
ro_gui_tree_start_edit(hotlist_tree, &node->data, NULL);
|
|
|
|
else
|
|
|
|
free(title);
|
2004-12-09 13:30:44 +03:00
|
|
|
} else {
|
2005-02-03 23:49:43 +03:00
|
|
|
browser_window_create(url, 0, 0);
|
2004-12-09 13:30:44 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2004-03-06 01:15:33 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
free(url);
|
|
|
|
}
|
2004-03-06 01:15:33 +03:00
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Parse an Acorn URI file.
|
|
|
|
*
|
|
|
|
* \param file_name file to read
|
2005-04-08 06:06:46 +04:00
|
|
|
* \param uri_title pointer to receive title data, or NULL for no data
|
2004-07-17 17:00:38 +04:00
|
|
|
* \return URL from file, or 0 on error and error reported
|
|
|
|
*/
|
|
|
|
|
2005-04-08 06:06:46 +04:00
|
|
|
char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
|
|
|
/* See the "Acorn URI Handler Functional Specification" for the
|
|
|
|
* definition of the URI file format. */
|
|
|
|
char line[400];
|
2005-04-08 06:06:46 +04:00
|
|
|
char *url = NULL;
|
2004-07-17 17:00:38 +04:00
|
|
|
FILE *fp;
|
|
|
|
|
2005-04-10 02:31:26 +04:00
|
|
|
*uri_title = NULL;
|
2004-07-17 17:00:38 +04:00
|
|
|
fp = fopen(file_name, "rb");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("fopen(\"%s\", \"rb\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
return 0;
|
2004-06-09 01:35:28 +04:00
|
|
|
}
|
2004-03-05 20:08:28 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* "URI" */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line) || strcmp(line, "URI") != 0)
|
|
|
|
goto uri_syntax_error;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* version */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line) ||
|
|
|
|
strspn(line, "0123456789") != strlen(line))
|
|
|
|
goto uri_syntax_error;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* URI */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line))
|
|
|
|
goto uri_syntax_error;
|
|
|
|
url = strdup(line);
|
|
|
|
if (!url) {
|
|
|
|
warn_user("NoMemory", 0);
|
2005-04-10 02:31:26 +04:00
|
|
|
fclose(fp);
|
2004-07-17 17:00:38 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2005-04-08 06:06:46 +04:00
|
|
|
/* title */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line))
|
|
|
|
goto uri_syntax_error;
|
|
|
|
if (uri_title && line[0] && ((line[0] != '*') || line[1])) {
|
|
|
|
*uri_title = strdup(line);
|
|
|
|
if (!*uri_title) /* non-fatal */
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
2005-04-17 21:16:44 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
return url;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
uri_syntax_error:
|
|
|
|
fclose(fp);
|
|
|
|
warn_user("URIError", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Read a "line" from an Acorn URI file.
|
|
|
|
*
|
|
|
|
* \param fp file pointer to read from
|
|
|
|
* \param b buffer for line, size 400 bytes
|
|
|
|
* \return true on success, false on EOF
|
|
|
|
*/
|
2004-04-03 03:59:53 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
bool ro_gui_uri_file_parse_line(FILE *fp, char *b)
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
c = getc(fp);
|
|
|
|
if (c == EOF)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* skip comment lines */
|
|
|
|
while (c == '#') {
|
|
|
|
do { c = getc(fp); } while (c != EOF && 32 <= c);
|
|
|
|
if (c == EOF)
|
|
|
|
return false;
|
|
|
|
do { c = getc(fp); } while (c != EOF && c < 32);
|
|
|
|
if (c == EOF)
|
|
|
|
return false;
|
2004-03-03 03:19:47 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* read "line" */
|
|
|
|
do {
|
|
|
|
if (i == 399)
|
|
|
|
return false;
|
|
|
|
b[i++] = c;
|
|
|
|
c = getc(fp);
|
|
|
|
} while (c != EOF && 32 <= c);
|
2004-04-03 03:59:53 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* skip line ending control characters */
|
|
|
|
while (c != EOF && c < 32)
|
|
|
|
c = getc(fp);
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (c != EOF)
|
|
|
|
ungetc(c, fp);
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
b[i] = 0;
|
|
|
|
return true;
|
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Parse an ANT URL file.
|
|
|
|
*
|
|
|
|
* \param file_name file to read
|
|
|
|
* \return URL from file, or 0 on error and error reported
|
|
|
|
*/
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
char *ro_gui_url_file_parse(const char *file_name)
|
|
|
|
{
|
|
|
|
char line[400];
|
|
|
|
char *url;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
fp = fopen(file_name, "r");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("fopen(\"%s\", \"r\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (!fgets(line, sizeof line, fp)) {
|
|
|
|
if (ferror(fp)) {
|
|
|
|
LOG(("fgets: %i: %s",
|
|
|
|
errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
} else
|
|
|
|
warn_user("LoadError", messages_get("EmptyError"));
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
fclose(fp);
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (line[strlen(line) - 1] == '\n')
|
|
|
|
line[strlen(line) - 1] = '\0';
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
url = strdup(line);
|
|
|
|
if (!url) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return 0;
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
return url;
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
|
|
|
|
2003-09-11 01:44:11 +04:00
|
|
|
|
2005-02-03 23:49:43 +03:00
|
|
|
/**
|
|
|
|
* Parse an IEURL file.
|
|
|
|
*
|
|
|
|
* \param file_name file to read
|
|
|
|
* \return URL from file, or 0 on error and error reported
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *ro_gui_ieurl_file_parse(const char *file_name)
|
|
|
|
{
|
|
|
|
char line[400];
|
|
|
|
char *url = 0;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
fp = fopen(file_name, "r");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("fopen(\"%s\", \"r\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgets(line, sizeof line, fp)) {
|
|
|
|
if (strncmp(line, "URL=", 4) == 0) {
|
|
|
|
if (line[strlen(line) - 1] == '\n')
|
|
|
|
line[strlen(line) - 1] = '\0';
|
|
|
|
url = strdup(line + 4);
|
|
|
|
if (!url) {
|
|
|
|
fclose(fp);
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ferror(fp)) {
|
|
|
|
LOG(("fgets: %i: %s",
|
|
|
|
errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
if (!url)
|
|
|
|
warn_user("URIError", 0);
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
/**
|
|
|
|
* Handle Message_DataSave
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_datasave(wimp_message *message)
|
|
|
|
{
|
|
|
|
wimp_full_message_data_xfer *dataxfer = (wimp_full_message_data_xfer*)message;
|
|
|
|
|
|
|
|
switch (dataxfer->file_type) {
|
|
|
|
case FILETYPE_ACORN_URI:
|
|
|
|
case FILETYPE_ANT_URL:
|
|
|
|
case FILETYPE_IEURL:
|
|
|
|
case FILETYPE_HTML:
|
|
|
|
case FILETYPE_JNG:
|
|
|
|
case FILETYPE_CSS:
|
|
|
|
case FILETYPE_MNG:
|
|
|
|
case FILETYPE_GIF:
|
|
|
|
case osfile_TYPE_DRAW:
|
|
|
|
case FILETYPE_PNG:
|
|
|
|
case FILETYPE_JPEG:
|
|
|
|
case osfile_TYPE_SPRITE:
|
|
|
|
case osfile_TYPE_TEXT: {
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
dataxfer->your_ref = dataxfer->my_ref;
|
|
|
|
dataxfer->size = offsetof(wimp_full_message_data_xfer, file_name) + 16;
|
|
|
|
dataxfer->action = message_DATA_SAVE_ACK;
|
|
|
|
dataxfer->est_size = -1;
|
|
|
|
memcpy(dataxfer->file_name, "<Wimp$Scrap>", 13);
|
|
|
|
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
/**
|
|
|
|
* Handle Message_DataSaveAck.
|
|
|
|
*/
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
void ro_msg_datasave_ack(wimp_message *message)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-08-09 10:28:57 +04:00
|
|
|
#ifdef WITH_PRINT
|
2004-11-04 02:27:15 +03:00
|
|
|
if (print_ack(message))
|
2004-08-09 10:28:57 +04:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_DOWNLOAD_SAVE:
|
2004-06-28 03:24:11 +04:00
|
|
|
ro_gui_download_datasave_ack(message);
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
case GUI_DRAG_SAVE:
|
|
|
|
ro_gui_save_datasave_ack(message);
|
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Message_DataOpen (double-click on file in the Filer).
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_dataopen(wimp_message *message)
|
|
|
|
{
|
2004-11-30 00:47:00 +03:00
|
|
|
int file_type = message->data.data_xfer.file_type;
|
2004-03-05 02:15:17 +03:00
|
|
|
char *url = 0;
|
2004-11-30 00:47:00 +03:00
|
|
|
size_t len;
|
|
|
|
os_error *error;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-11-30 00:47:00 +03:00
|
|
|
if (file_type == 0xb28) /* ANT URL file */
|
|
|
|
url = ro_gui_url_file_parse(message->data.data_xfer.file_name);
|
|
|
|
else if (file_type == 0xfaf) /* HTML file */
|
|
|
|
url = ro_path_to_url(message->data.data_xfer.file_name);
|
2005-02-03 23:49:43 +03:00
|
|
|
else if (file_type == 0x1ba) /* IEURL file */
|
|
|
|
url = ro_gui_ieurl_file_parse(message->
|
|
|
|
data.data_xfer.file_name);
|
2004-11-30 00:47:00 +03:00
|
|
|
else if (file_type == 0x2000) { /* application */
|
|
|
|
len = strlen(message->data.data_xfer.file_name);
|
|
|
|
if (len < 9 || strcmp(".!NetSurf",
|
|
|
|
message->data.data_xfer.file_name + len - 9))
|
|
|
|
return;
|
|
|
|
if (option_homepage_url && option_homepage_url[0]) {
|
|
|
|
url = strdup(option_homepage_url);
|
|
|
|
} else {
|
|
|
|
url = malloc(80);
|
|
|
|
if (url)
|
|
|
|
snprintf(url, 80,
|
|
|
|
"file:/<NetSurf$Dir>/Docs/intro_%s",
|
|
|
|
option_language);
|
2004-06-09 01:35:28 +04:00
|
|
|
}
|
2004-11-30 00:47:00 +03:00
|
|
|
if (!url)
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else
|
|
|
|
return;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
2004-11-30 00:47:00 +03:00
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!url)
|
2005-02-03 23:49:43 +03:00
|
|
|
/* error has already been reported by one of the
|
2004-11-30 00:47:00 +03:00
|
|
|
* functions called above */
|
|
|
|
return;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
|
|
|
/* create a new window with the file */
|
2004-11-30 00:47:00 +03:00
|
|
|
browser_window_create(url, NULL, 0);
|
|
|
|
|
|
|
|
free(url);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a RISC OS pathname to a file: URL.
|
2004-03-03 03:19:47 +03:00
|
|
|
*
|
|
|
|
* \param path RISC OS pathname
|
|
|
|
* \return URL, allocated on heap, or 0 on failure
|
2003-11-08 02:51:13 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
char *ro_path_to_url(const char *path)
|
|
|
|
{
|
2004-03-03 03:19:47 +03:00
|
|
|
int spare;
|
|
|
|
char *buffer = 0;
|
|
|
|
char *url = 0;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xosfscontrol_canonicalise_path(path, 0, 0, 0, 0, &spare);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfscontrol_canonicalise_path failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("PathToURL", error->errmess);
|
2004-03-03 03:19:47 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer = malloc(1 - spare);
|
|
|
|
url = malloc(1 - spare + 10);
|
|
|
|
if (!buffer || !url) {
|
|
|
|
LOG(("malloc failed"));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("NoMemory", 0);
|
2004-03-03 03:19:47 +03:00
|
|
|
free(buffer);
|
|
|
|
free(url);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xosfscontrol_canonicalise_path(path, buffer, 0, 0, 1 - spare,
|
|
|
|
0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfscontrol_canonicalise_path failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("PathToURL", error->errmess);
|
2004-03-03 03:19:47 +03:00
|
|
|
free(buffer);
|
|
|
|
free(url);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(url, "file:");
|
|
|
|
__unixify(buffer, __RISCOSIFY_NO_REVERSE_SUFFIX, url + 5,
|
|
|
|
1 - spare + 5, 0);
|
|
|
|
free(buffer);
|
2003-11-08 02:51:13 +03:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-11 01:44:11 +04:00
|
|
|
/**
|
|
|
|
* Find screen size in OS units.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_screen_size(int *width, int *height)
|
|
|
|
{
|
|
|
|
int xeig_factor, yeig_factor, xwind_limit, ywind_limit;
|
|
|
|
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XEIG_FACTOR, &xeig_factor);
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YEIG_FACTOR, &yeig_factor);
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_XWIND_LIMIT, &xwind_limit);
|
|
|
|
os_read_mode_variable(os_CURRENT_MODE, os_MODEVAR_YWIND_LIMIT, &ywind_limit);
|
|
|
|
*width = (xwind_limit + 1) << xeig_factor;
|
|
|
|
*height = (ywind_limit + 1) << yeig_factor;
|
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-05-14 23:59:09 +04:00
|
|
|
/**
|
|
|
|
* Opens a language sensitive help page
|
|
|
|
*
|
|
|
|
* \param page the page to open
|
|
|
|
*/
|
2004-05-25 14:42:28 +04:00
|
|
|
void ro_gui_open_help_page(const char *page)
|
2003-09-26 20:52:53 +04:00
|
|
|
{
|
2004-02-27 17:09:15 +03:00
|
|
|
char url[80];
|
2004-06-09 01:35:28 +04:00
|
|
|
int length;
|
|
|
|
|
|
|
|
if ((length = snprintf(url, sizeof url,
|
2004-06-11 16:19:57 +04:00
|
|
|
"file:/<NetSurf$Dir>/Docs/%s_%s",
|
2004-06-11 02:39:56 +04:00
|
|
|
page, option_language)) >= 0 && length < (int)sizeof(url))
|
2004-10-02 01:33:20 +04:00
|
|
|
browser_window_create(url, NULL, 0);
|
2003-09-26 20:52:53 +04:00
|
|
|
}
|
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
/**
|
|
|
|
* Send the source of a content to a text editor.
|
|
|
|
*/
|
2004-02-26 03:44:42 +03:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
void ro_gui_view_source(struct content *content)
|
|
|
|
{
|
2004-10-18 02:13:35 +04:00
|
|
|
if (!content || !content->source_data) {
|
|
|
|
warn_user("MiscError", "No document source");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-11 05:19:14 +03:00
|
|
|
xosfile_save_stamped("<Wimp$Scrap>", 0xfff,
|
|
|
|
content->source_data,
|
|
|
|
content->source_data + content->source_size);
|
|
|
|
xos_cli("Filer_Run <Wimp$Scrap>");
|
|
|
|
xosfile_set_type("<Wimp$Scrap>", ro_content_filetype(content));
|
2003-12-11 04:23:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-13 18:39:43 +04:00
|
|
|
/**
|
|
|
|
* Broadcast an URL that we can't handle.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_launch_url(const char *url)
|
|
|
|
{
|
2004-09-14 03:56:18 +04:00
|
|
|
#ifdef WITH_URL
|
2004-05-13 18:39:43 +04:00
|
|
|
/* Try ant broadcast first */
|
|
|
|
ro_url_broadcast(url);
|
2004-09-14 03:56:18 +04:00
|
|
|
#endif
|
2004-05-13 18:39:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/**
|
|
|
|
* Display a warning for a serious problem (eg memory exhaustion).
|
|
|
|
*
|
|
|
|
* \param warning message key for warning message
|
2004-05-07 23:14:54 +04:00
|
|
|
* \param detail additional message, or 0
|
2004-02-25 18:12:58 +03:00
|
|
|
*/
|
2003-10-06 03:30:21 +04:00
|
|
|
|
2004-05-07 23:14:54 +04:00
|
|
|
void warn_user(const char *warning, const char *detail)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-08-27 02:58:19 +04:00
|
|
|
static char warn_buffer[300];
|
|
|
|
|
2004-05-07 23:14:54 +04:00
|
|
|
LOG(("%s %s", warning, detail));
|
|
|
|
snprintf(warn_buffer, sizeof warn_buffer, "%s %s",
|
|
|
|
messages_get(warning),
|
|
|
|
detail ? detail : "");
|
|
|
|
warn_buffer[sizeof warn_buffer - 1] = 0;
|
|
|
|
ro_gui_set_icon_string(dialog_warning, ICON_WARNING_MESSAGE,
|
|
|
|
warn_buffer);
|
|
|
|
xwimp_set_icon_state(dialog_warning, ICON_WARNING_HELP,
|
|
|
|
wimp_ICON_DELETED, wimp_ICON_DELETED);
|
|
|
|
ro_gui_dialog_open(dialog_warning);
|
|
|
|
xos_bell();
|
2003-10-06 03:30:21 +04:00
|
|
|
}
|
2004-03-27 03:49:29 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display an error and exit.
|
|
|
|
*
|
|
|
|
* Should only be used during initialisation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void die(const char *error)
|
|
|
|
{
|
2004-08-27 02:58:19 +04:00
|
|
|
os_error warn_error;
|
|
|
|
|
|
|
|
warn_error.errnum = 1; /* \todo: reasonable ? */
|
|
|
|
strncpy(warn_error.errmess, messages_get(error),
|
|
|
|
sizeof(warn_error.errmess)-1);
|
|
|
|
warn_error.errmess[sizeof(warn_error.errmess)-1] = '\0';
|
2004-05-07 23:14:54 +04:00
|
|
|
xwimp_report_error_by_category(&warn_error,
|
|
|
|
wimp_ERROR_BOX_OK_ICON |
|
|
|
|
wimp_ERROR_BOX_GIVEN_CATEGORY |
|
|
|
|
wimp_ERROR_BOX_CATEGORY_ERROR <<
|
|
|
|
wimp_ERROR_BOX_CATEGORY_SHIFT,
|
|
|
|
"NetSurf", "!netsurf",
|
|
|
|
(osspriteop_area *) 1, 0, 0);
|
2004-03-27 03:49:29 +03:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|