diff options
author | Richard Wilson <rjw@netsurf-browser.org> | 2005-03-21 16:16:45 +0000 |
---|---|---|
committer | Richard Wilson <rjw@netsurf-browser.org> | 2005-03-21 16:16:45 +0000 |
commit | 803f5179ab828aacec5776f2bcda888770fcee5d (patch) | |
tree | b5911608ac042c1c34ceaba403b1a5383b68b35e /riscos/gui.c | |
parent | 82ec83b5c3d434e2a519b05deb7c22c613ff0596 (diff) | |
download | nstheme-803f5179ab828aacec5776f2bcda888770fcee5d.tar.gz nstheme-803f5179ab828aacec5776f2bcda888770fcee5d.tar.bz2 |
[project @ 2005-03-21 16:16:44 by rjw]
Add warnings for invalid file loading. Remove redundant code.
svn path=/import/nstheme/; revision=2439
Diffstat (limited to 'riscos/gui.c')
-rw-r--r-- | riscos/gui.c | 119 |
1 files changed, 11 insertions, 108 deletions
diff --git a/riscos/gui.c b/riscos/gui.c index 84adde0..71a5008 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -72,16 +72,12 @@ struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0; static void ro_gui_choose_language(void); static void ro_gui_icon_bar_create(void); static void ro_gui_handle_event(wimp_event_no event, wimp_block *block); -static void ro_gui_poll_queue(wimp_event_no event, wimp_block *block); static void ro_gui_open_window_request(wimp_open *open); -static void ro_gui_close_window_request(wimp_close *close); static void ro_gui_mouse_click(wimp_pointer *pointer); static void ro_gui_icon_bar_click(wimp_pointer *pointer); -static void ro_gui_drag_end(wimp_dragged *drag); static void ro_gui_keypress(wimp_key *key); static void ro_gui_user_message(wimp_event_no event, wimp_message *message); static void ro_msg_dataload(wimp_message *block); -static void ro_msg_datasave_ack(wimp_message *message); /** @@ -260,7 +256,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block) break; case wimp_CLOSE_WINDOW_REQUEST: - ro_gui_close_window_request(&block->close); + ro_gui_dialog_close(block->close.w); break; case wimp_MOUSE_CLICK: @@ -268,7 +264,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block) break; case wimp_USER_DRAG_BOX: - ro_gui_drag_end(&(block->dragged)); + ro_gui_save_drag_end(&(block->dragged)); break; case wimp_KEY_PRESSED: @@ -289,75 +285,6 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block) /** - * Check for important events and yield CPU (RISC OS). - * - * Required on RISC OS for cooperative multitasking. - */ - -void gui_multitask(void) -{ - wimp_event_no event; - wimp_block block; - - if (clock() < gui_last_poll + 10) - return; - - xhourglass_off(); - event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN, &block, 0); - xhourglass_on(); - gui_last_poll = clock(); - - switch (event) { - case wimp_CLOSE_WINDOW_REQUEST: - /* \todo close the window, and destroy content - * or abort loading of content */ - break; - - case wimp_KEY_PRESSED: - case wimp_MENU_SELECTION: - ro_gui_poll_queue(event, &block); - break; - - default: - ro_gui_handle_event(event, &block); - break; - } -} - - -/** - * 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 = - calloc(1, sizeof(struct ro_gui_poll_block)); - if (!q) return; - q->event = event; - q->block = calloc(1, sizeof(*block)); - if (!q->block) { - free(q); - return; - } - 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 Open_Window_Request events. */ @@ -374,15 +301,6 @@ void ro_gui_open_window_request(wimp_open *open) { /** - * Handle Close_Window_Request events. - */ - -void ro_gui_close_window_request(wimp_close *close) { - ro_gui_dialog_close(close->w); -} - - -/** * Handle Mouse_Click events. */ void ro_gui_mouse_click(wimp_pointer *pointer) { @@ -406,22 +324,13 @@ void ro_gui_icon_bar_click(wimp_pointer *pointer) 96 + iconbar_menu_height); } else if (pointer->buttons == wimp_CLICK_SELECT) { ro_gui_dialog_prepare_main(); - ro_gui_open_window_centre(NULL, dialog_main); + ro_gui_open_window_centre(dialog_main); ro_gui_set_caret_first(dialog_main); } } /** - * Handle User_Drag_Box events. - */ - -void ro_gui_drag_end(wimp_dragged *drag) { - ro_gui_save_drag_end(drag); -} - - -/** * Handle Key_Pressed events. */ @@ -431,6 +340,7 @@ void ro_gui_keypress(wimp_key *key) { if (key->c == wimp_KEY_F1) { xos_cli("Filer_Run <NSTheme$Dir>.!Help"); + return; } if (key->w == dialog_saveas) { @@ -462,13 +372,11 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message) break; case message_DATA_SAVE_ACK: - ro_msg_datasave_ack(message); + ro_gui_save_datasave_ack(message); break; case message_DATA_LOAD: - if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) { - } - else + if (event != wimp_USER_MESSAGE_ACKNOWLEDGE) ro_msg_dataload(message); break; @@ -508,13 +416,17 @@ void ro_msg_dataload(wimp_message *message) { free(sprite_filename); sprite_filename = NULL; } + } else { + warn_user("WarnBadSpr", 0); } } else { success = ro_gui_load_theme(filename); if (success) { ro_gui_dialog_prepare_main(); - ro_gui_open_window_centre(NULL, dialog_main); + ro_gui_open_window_centre(dialog_main); ro_gui_set_caret_first(dialog_main); + } else { + warn_user("WarnInvalid", 0); } } @@ -532,15 +444,6 @@ void ro_msg_dataload(wimp_message *message) { /** - * Handle Message_DataSaveAck. - */ - -void ro_msg_datasave_ack(wimp_message *message) { - ro_gui_save_datasave_ack(message); -} - - -/** * Find screen size in OS units. */ |