feat(modulo): return result from Wizard

This commit is contained in:
Federico Terzi 2021-06-27 20:18:49 +02:00
parent ce3a1c456c
commit 7e09fe769b
3 changed files with 12 additions and 6 deletions

View File

@ -170,7 +170,7 @@ extern "C" {
pub(crate) fn update_items(app: *const c_void, items: *const SearchItem, itemCount: c_int); pub(crate) fn update_items(app: *const c_void, items: *const SearchItem, itemCount: c_int);
// WIZARD // WIZARD
pub(crate) fn interop_show_wizard(metadata: *const WizardMetadata); pub(crate) fn interop_show_wizard(metadata: *const WizardMetadata) -> c_int;
// WELCOME // WELCOME
pub(crate) fn interop_show_welcome(metadata: *const WelcomeMetadata); pub(crate) fn interop_show_welcome(metadata: *const WelcomeMetadata);

View File

@ -27,7 +27,7 @@ lazy_static! {
static ref HANDLERS: Mutex<Option<WizardHandlers>> = Mutex::new(None); static ref HANDLERS: Mutex<Option<WizardHandlers>> = Mutex::new(None);
} }
pub fn show(options: WizardOptions) { pub fn show(options: WizardOptions) -> bool {
let c_version = CString::new(options.version).expect("unable to convert version to CString"); let c_version = CString::new(options.version).expect("unable to convert version to CString");
let (_c_window_icon_path, c_window_icon_path_ptr) = let (_c_window_icon_path, c_window_icon_path_ptr) =
@ -179,7 +179,9 @@ pub fn show(options: WizardOptions) {
on_completed, on_completed,
}; };
unsafe { let successful = unsafe {
super::interop::interop_show_wizard(&wizard_metadata); super::interop::interop_show_wizard(&wizard_metadata)
} };
if successful == 1 { true } else { false }
} }

View File

@ -36,6 +36,7 @@ const int ACCESSIBILITY_PAGE_INDEX = ADD_PATH_PAGE_INDEX + 1;
const int MAX_PAGE_INDEX = ACCESSIBILITY_PAGE_INDEX + 1; // Update if a new page is added at the end const int MAX_PAGE_INDEX = ACCESSIBILITY_PAGE_INDEX + 1; // Update if a new page is added at the end
WizardMetadata *metadata = nullptr; WizardMetadata *metadata = nullptr;
int completed_successfully = 0;
// App Code // App Code
@ -159,6 +160,7 @@ void DerivedFrame::navigate_to_next_page_or_close()
{ {
if (metadata->on_completed) { if (metadata->on_completed) {
metadata->on_completed(); metadata->on_completed();
completed_successfully = 1;
} }
Close(true); Close(true);
@ -319,7 +321,7 @@ bool WizardApp::OnInit()
return true; return true;
} }
extern "C" void interop_show_wizard(WizardMetadata *_metadata) extern "C" int interop_show_wizard(WizardMetadata *_metadata)
{ {
// Setup high DPI support on Windows // Setup high DPI support on Windows
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -331,4 +333,6 @@ extern "C" void interop_show_wizard(WizardMetadata *_metadata)
wxApp::SetInstance(new WizardApp()); wxApp::SetInstance(new WizardApp());
int argc = 0; int argc = 0;
wxEntry(argc, (char **)nullptr); wxEntry(argc, (char **)nullptr);
return completed_successfully;
} }