diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-07-16 23:26:14 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-07-16 23:26:14 +0200 |
commit | 9894c2b26607d847b84c6b3015b71192f66e32d9 (patch) | |
tree | 060bee8d570f7f1f3f1136b9e55f24712266370d | |
parent | ad265610a696852968cb35bd7586e96c7e6029c9 (diff) | |
download | alpine-usb-creator-9894c2b26607d847b84c6b3015b71192f66e32d9.tar.bz2 alpine-usb-creator-9894c2b26607d847b84c6b3015b71192f66e32d9.tar.xz |
Add simple creator thread
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | creator_thread.cpp | 25 | ||||
-rw-r--r-- | creator_thread.h | 19 | ||||
-rw-r--r-- | dialog.cpp | 14 | ||||
-rw-r--r-- | dialog.h | 1 |
5 files changed, 59 insertions, 2 deletions
@@ -5,7 +5,7 @@ WX_CFLAGS := $(shell wx-config --cflags) WX_LIBS := $(shell wx-config --libs) -OBJS_alpine-usb-creator-wxgtk := main.o dialog.o dialog_ui.o +OBJS_alpine-usb-creator-wxgtk := main.o dialog.o dialog_ui.o creator_thread.o LIBS_alpine-usb-creator-wxgtk := $(WX_LIBS) CFLAGS += $(WX_CFLAGS) diff --git a/creator_thread.cpp b/creator_thread.cpp new file mode 100644 index 0000000..2443c6b --- /dev/null +++ b/creator_thread.cpp @@ -0,0 +1,25 @@ +#include "creator_thread.h" + +CreatorThread::CreatorThread(Dialog *d) + : wxThread() +{ + m_dialog = d; +} + +void CreatorThread::OnExit() +{ +} + +wxThread::ExitCode CreatorThread::Entry() +{ + int i; + for (i = 0; i<=100; i++) { + wxMutexGuiEnter(); + m_dialog->SetProgress(i); + wxMutexGuiLeave(); + + wxMilliSleep(100); + } + return NULL; +} + diff --git a/creator_thread.h b/creator_thread.h new file mode 100644 index 0000000..82b218b --- /dev/null +++ b/creator_thread.h @@ -0,0 +1,19 @@ +#ifndef CREATOR_THREAD_H +#define CREATOR_THREAD_H + +#include <wx/thread.h> +#include "dialog.h" + +class CreatorThread : public wxThread +{ +public: + CreatorThread(Dialog *d); + virtual void *Entry(); + virtual void OnExit(); + +protected: + Dialog *m_dialog; +}; + +#endif + @@ -3,6 +3,7 @@ #include <wx/msgdlg.h> #include "dialog.h" +#include "creator_thread.h" #ifdef __WINDOWS__ #include <windows.h> @@ -45,7 +46,14 @@ void Dialog::OnRefreshDrives(wxCommandEvent &event) void Dialog::OnStartButton(wxCommandEvent &event) { - wxMessageBox(wxT("To be implemented")); + CreatorThread *thread = new CreatorThread(this); + if (thread->Create() == wxTHREAD_NO_ERROR) { + m_start_button->Disable(); + m_target->Disable(); + m_iso_picker->Disable(); + m_refresh_button->Disable(); + thread->Run(); + } } void Dialog::OnCancelButton(wxCommandEvent &event) @@ -73,3 +81,7 @@ void Dialog::OnTargetChange(wxCommandEvent &event) UpdateStartButton(); } +void Dialog::SetProgress(int value) +{ + m_gauge->SetValue(value); +} @@ -8,6 +8,7 @@ class Dialog : public DialogUI public: Dialog(wxWindow *parent); void RefreshDrives(void); + void SetProgress(int value); protected: void UpdateStartButton(void); |