summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-07-16 23:26:14 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2012-07-16 23:26:14 +0200
commit9894c2b26607d847b84c6b3015b71192f66e32d9 (patch)
tree060bee8d570f7f1f3f1136b9e55f24712266370d
parentad265610a696852968cb35bd7586e96c7e6029c9 (diff)
downloadalpine-usb-creator-9894c2b26607d847b84c6b3015b71192f66e32d9.tar.bz2
alpine-usb-creator-9894c2b26607d847b84c6b3015b71192f66e32d9.tar.xz
Add simple creator thread
-rw-r--r--Makefile2
-rw-r--r--creator_thread.cpp25
-rw-r--r--creator_thread.h19
-rw-r--r--dialog.cpp14
-rw-r--r--dialog.h1
5 files changed, 59 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 672e497..939ac1a 100644
--- a/Makefile
+++ b/Makefile
@@ -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
+
diff --git a/dialog.cpp b/dialog.cpp
index 3e03cb8..5d84300 100644
--- a/dialog.cpp
+++ b/dialog.cpp
@@ -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);
+}
diff --git a/dialog.h b/dialog.h
index d8eb652..00e2bb6 100644
--- a/dialog.h
+++ b/dialog.h
@@ -8,6 +8,7 @@ class Dialog : public DialogUI
public:
Dialog(wxWindow *parent);
void RefreshDrives(void);
+ void SetProgress(int value);
protected:
void UpdateStartButton(void);