/** * Handle OK click/keypress in the save dialog. * * \param w window handle of save dialog * \return true on success, false on failure */ bool ro_gui_save_ok(wimp_w w) { const char *name = ro_gui_get_icon_string(w, ICON_SAVE_PATH); wimp_pointer pointer; char path[256]; if (!strrchr(name, '.')) { warn_user("NoPathError", NULL); return false; } ro_gui_convert_save_path(path, sizeof path, name); gui_save_sourcew = w; saving_from_dialog = true; gui_save_send_dataload = false; gui_save_close_after = xwimp_get_pointer_info(&pointer) || !(pointer.buttons & wimp_CLICK_ADJUST); memcpy(&gui_save_message.data.data_xfer.file_name, path, 1 + strlen(path)); if (ro_gui_save_content(gui_save_content, path, !option_confirm_overwrite)) { ro_gui_save_done(); return true; } return false; }
bool ro_gui_download_keypress(wimp_key *key) { struct gui_download_window *dw; dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(key->w); switch (key->c) { case wimp_KEY_ESCAPE: ro_gui_download_window_destroy(dw, false); return true; case wimp_KEY_RETURN: { const char *name = ro_gui_get_icon_string(dw->window, ICON_DOWNLOAD_PATH); if (!strrchr(name, '.')) { warn_user("NoPathError", NULL); return true; } ro_gui_convert_save_path(dw->path, sizeof dw->path, name); dw->send_dataload = false; if (ro_gui_download_save(dw, dw->path, !option_confirm_overwrite) && !dw->ctx) { /* finished already */ schedule(200, ro_gui_download_window_destroy_wrapper, dw); } return true; } break; } /* ignore all other keypresses (F12 etc) */ return false; }
void ro_gui_download_drag_end(wimp_dragged *drag) { wimp_pointer pointer; wimp_message message; struct gui_download_window *dw = download_window_current; const char *leaf; os_error *error; if (dw->saved || dw->error) return; 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; } /* ignore drags to the download window itself */ if (pointer.w == dw->window) return; leaf = strrchr(dw->path, '.'); if (leaf) leaf++; else leaf = dw->path; ro_gui_convert_save_path(message.data.data_xfer.file_name, 212, leaf); message.your_ref = 0; message.action = message_DATA_SAVE; message.data.data_xfer.w = pointer.w; message.data.data_xfer.i = pointer.i; message.data.data_xfer.pos.x = pointer.pos.x; message.data.data_xfer.pos.y = pointer.pos.y; message.data.data_xfer.est_size = dw->total_size ? dw->total_size : dw->received; message.data.data_xfer.file_type = dw->file_type; message.size = 44 + ((strlen(message.data.data_xfer.file_name) + 4) & (~3u)); error = xwimp_send_message_to_window(wimp_USER_MESSAGE, &message, pointer.w, pointer.i, 0); if (error) { LOG(("xwimp_send_message_to_window: 0x%x: %s", error->errnum, error->errmess)); warn_user("WimpError", error->errmess); } }