mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
[project @ 2006-01-09 00:12:09 by rjw]
Begin moving message routing to new code. Implement Adjust-click close behaviour for local files. svn path=/import/netsurf/; revision=2019
This commit is contained in:
parent
97950c2033
commit
08ca6a9ae4
107
riscos/gui.c
107
riscos/gui.c
@ -240,11 +240,11 @@ static char *ro_gui_ieurl_file_parse(const char *file_name);
|
||||
static void ro_msg_terminate_filename(wimp_full_message_data_xfer *message);
|
||||
static void ro_msg_datasave(wimp_message *message);
|
||||
static void ro_msg_datasave_ack(wimp_message *message);
|
||||
static void ro_msg_dataopen(wimp_message *block);
|
||||
static void ro_msg_dataopen(wimp_message *message);
|
||||
static void ro_msg_prequit(wimp_message *message);
|
||||
static void ro_msg_save_desktop(wimp_message *message);
|
||||
static char *ro_path_to_url(const char *path);
|
||||
static void ro_gui_view_source_bounce(wimp_event_no event, wimp_message *message);
|
||||
static void ro_gui_view_source_bounce(wimp_message *message);
|
||||
|
||||
|
||||
/**
|
||||
@ -373,6 +373,20 @@ void gui_init(int argc, char** argv)
|
||||
error->errnum, error->errmess));
|
||||
die(error->errmess);
|
||||
}
|
||||
/* register our message handlers */
|
||||
ro_message_register_route(message_HELP_REQUEST,
|
||||
ro_gui_interactive_help_request);
|
||||
ro_message_register_route(message_DATA_OPEN,
|
||||
ro_msg_dataopen);
|
||||
ro_message_register_route(message_DATA_SAVE,
|
||||
ro_msg_datasave);
|
||||
ro_message_register_route(message_DATA_SAVE_ACK,
|
||||
ro_msg_datasave_ack);
|
||||
ro_message_register_route(message_PRE_QUIT,
|
||||
ro_msg_prequit);
|
||||
ro_message_register_route(message_SAVE_DESKTOP,
|
||||
ro_msg_save_desktop);
|
||||
/* end of handler registration */
|
||||
|
||||
nsfont_init();
|
||||
|
||||
@ -993,12 +1007,66 @@ void ro_gui_close_window_request(wimp_close *close)
|
||||
{
|
||||
struct gui_window *g;
|
||||
struct gui_download_window *dw;
|
||||
|
||||
/* Check for children
|
||||
*/
|
||||
ro_gui_dialog_close_persistent(close->w);
|
||||
wimp_pointer pointer;
|
||||
os_error *error;
|
||||
char *temp_name, *r;
|
||||
char *filename;
|
||||
struct content *content = NULL;
|
||||
|
||||
if ((g = ro_gui_window_lookup(close->w)) != NULL) {
|
||||
error = xwimp_get_pointer_info(&pointer);
|
||||
if (error) {
|
||||
LOG(("xwimp_get_pointer_info: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("WimpError", error->errmess);
|
||||
return;
|
||||
}
|
||||
if (g->bw)
|
||||
content = g->bw->current_content;
|
||||
if ((pointer.buttons & wimp_CLICK_ADJUST) && (content) &&
|
||||
(content->url) && (!strncmp(content->url, "file:/", 6))) {
|
||||
if (strncmp(content->url, "file:///", 8) == 0)
|
||||
temp_name = curl_unescape(content->url + 7,
|
||||
strlen(content->url) - 7);
|
||||
else
|
||||
temp_name = curl_unescape(content->url + 5,
|
||||
strlen(content->url) - 5);
|
||||
if (!temp_name) {
|
||||
warn_user("NoMemory", 0);
|
||||
return;
|
||||
}
|
||||
filename = malloc(strlen(temp_name) + 100);
|
||||
if (!filename) {
|
||||
curl_free(temp_name);
|
||||
warn_user("NoMemory", 0);
|
||||
return;
|
||||
}
|
||||
sprintf(filename, "Filer_OpenDir ");
|
||||
r = __riscosify(temp_name, 0, __RISCOSIFY_NO_SUFFIX,
|
||||
filename + 14, strlen(temp_name) + 86, 0);
|
||||
if (r == 0) {
|
||||
LOG(("__riscosify failed"));
|
||||
return;
|
||||
}
|
||||
curl_free(temp_name);
|
||||
while (r > filename) {
|
||||
if (*r == '.') {
|
||||
*r = '\0';
|
||||
break;
|
||||
}
|
||||
*r--;
|
||||
}
|
||||
error = xos_cli(filename);
|
||||
if (error) {
|
||||
LOG(("xos_cli: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user("MiscError", error->errmess);
|
||||
return;
|
||||
}
|
||||
free(filename);
|
||||
}
|
||||
if (ro_gui_shift_pressed())
|
||||
return;
|
||||
ro_gui_url_complete_close(NULL, 0);
|
||||
browser_window_destroy(g->bw);
|
||||
} else if ((dw = ro_gui_download_window_lookup(close->w)) != NULL) {
|
||||
@ -1006,6 +1074,7 @@ void ro_gui_close_window_request(wimp_close *close)
|
||||
} else {
|
||||
ro_gui_dialog_close(close->w);
|
||||
}
|
||||
ro_gui_dialog_close_persistent(close->w);
|
||||
}
|
||||
|
||||
|
||||
@ -1197,18 +1266,6 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
|
||||
return;
|
||||
|
||||
switch (message->action) {
|
||||
case message_HELP_REQUEST:
|
||||
ro_gui_interactive_help_request(message);
|
||||
break;
|
||||
|
||||
case message_DATA_SAVE:
|
||||
ro_msg_datasave(message);
|
||||
break;
|
||||
|
||||
case message_DATA_SAVE_ACK:
|
||||
ro_msg_datasave_ack(message);
|
||||
break;
|
||||
|
||||
case message_DATA_LOAD:
|
||||
ro_msg_terminate_filename((wimp_full_message_data_xfer*)message);
|
||||
|
||||
@ -1229,18 +1286,6 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case message_DATA_OPEN:
|
||||
ro_msg_dataopen(message);
|
||||
break;
|
||||
|
||||
case message_PRE_QUIT:
|
||||
ro_msg_prequit(message);
|
||||
break;
|
||||
|
||||
case message_SAVE_DESKTOP:
|
||||
ro_msg_save_desktop(message);
|
||||
break;
|
||||
|
||||
case message_MENU_WARNING:
|
||||
ro_gui_menu_warning((wimp_message_menu_warning *)
|
||||
&message->data);
|
||||
@ -2030,7 +2075,7 @@ void ro_gui_view_source(struct content *content)
|
||||
}
|
||||
|
||||
|
||||
void ro_gui_view_source_bounce(wimp_event_no event, wimp_message *message) {
|
||||
void ro_gui_view_source_bounce(wimp_message *message) {
|
||||
char *filename;
|
||||
os_error *error;
|
||||
char command[256];
|
||||
|
@ -22,14 +22,14 @@
|
||||
struct active_message {
|
||||
unsigned int message_code;
|
||||
int id;
|
||||
void (*callback)(wimp_event_no event, wimp_message *message);
|
||||
void (*callback)(wimp_message *message);
|
||||
struct active_message *next;
|
||||
struct active_message *previous;
|
||||
};
|
||||
struct active_message *current_messages = NULL;
|
||||
|
||||
static struct active_message *ro_message_add(unsigned int message_code,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message));
|
||||
void (*callback)(wimp_message *message));
|
||||
static void ro_message_free(int ref);
|
||||
|
||||
|
||||
@ -43,8 +43,7 @@ static void ro_message_free(int ref);
|
||||
* \return true on success, false otherwise
|
||||
*/
|
||||
bool ro_message_send_message(wimp_event_no event, wimp_message *message,
|
||||
wimp_t task,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message)) {
|
||||
wimp_t task, void (*callback)(wimp_message *message)) {
|
||||
os_error *error;
|
||||
|
||||
assert(message);
|
||||
@ -81,7 +80,7 @@ bool ro_message_send_message(wimp_event_no event, wimp_message *message,
|
||||
*/
|
||||
bool ro_message_register_handler(wimp_message *message,
|
||||
unsigned int message_code,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message)) {
|
||||
void (*callback)(wimp_message *message)) {
|
||||
struct active_message *add;
|
||||
|
||||
assert(message);
|
||||
@ -102,14 +101,14 @@ bool ro_message_register_handler(wimp_message *message,
|
||||
* \return true on success, false on memory exhaustion
|
||||
*/
|
||||
bool ro_message_register_route(unsigned int message_code,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message)) {
|
||||
void (*callback)(wimp_message *message)) {
|
||||
assert(callback);
|
||||
|
||||
return (ro_message_add(message_code, callback) != NULL);
|
||||
}
|
||||
|
||||
struct active_message *ro_message_add(unsigned int message_code,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message)) {
|
||||
void (*callback)(wimp_message *message)) {
|
||||
struct active_message *add;
|
||||
|
||||
assert(callback);
|
||||
@ -152,7 +151,7 @@ bool ro_message_handle_message(wimp_event_no event, wimp_message *message) {
|
||||
(message->action == test->message_code)) {
|
||||
handled = true;
|
||||
if (test->callback)
|
||||
test->callback(event, message);
|
||||
test->callback(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -165,7 +164,7 @@ bool ro_message_handle_message(wimp_event_no event, wimp_message *message) {
|
||||
for (test = current_messages; test; test = test->next) {
|
||||
if ((test->id == 0) &&
|
||||
(message->action == test->message_code)) {
|
||||
test->callback(event, message);
|
||||
test->callback(message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,12 @@
|
||||
#include "oslib/wimp.h"
|
||||
|
||||
bool ro_message_send_message(wimp_event_no event, wimp_message *message,
|
||||
wimp_t task,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message));
|
||||
wimp_t task, void (*callback)(wimp_message *message));
|
||||
bool ro_message_register_handler(wimp_message *message,
|
||||
unsigned int message_code,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message));
|
||||
void (*callback)(wimp_message *message));
|
||||
bool ro_message_register_route(unsigned int message_code,
|
||||
void (*callback)(wimp_event_no event, wimp_message *message));
|
||||
void (*callback)(wimp_message *message));
|
||||
bool ro_message_handle_message(wimp_event_no event, wimp_message *message);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user