summaryrefslogtreecommitdiffstats
path: root/HBApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'HBApp.cpp')
-rw-r--r--HBApp.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/HBApp.cpp b/HBApp.cpp
new file mode 100644
index 000000000..142b16cb8
--- /dev/null
+++ b/HBApp.cpp
@@ -0,0 +1,68 @@
+/* $Id: HBApp.cpp,v 1.6 2003/08/24 20:25:49 titer Exp $ */
+
+#include "HBCommon.h"
+#include "HBApp.h"
+#include "HBWindow.h"
+#include "HBManager.h"
+
+/* Constructor */
+HBApp::HBApp()
+ : BApplication( "application/x-vnd.titer-handbrake" )
+{
+ /* Initializations */
+ fWindow = new HBWindow();
+ fManager = new HBManager( fWindow );
+
+ /* Tell the interface we now have a manager */
+ BMessage * message = new BMessage( MANAGER_CREATED );
+ message->AddPointer( "manager", fManager );
+ fWindow->PostMessage( message );
+ delete message;
+
+ /* Show the main window */
+ fWindow->Show();
+
+ /* Check the available DVDs */
+ Status( "Checking DVD volumes...", 0.0, ENABLE_DETECTING );
+ fManager->PostMessage( DETECT_VOLUMES );
+}
+
+void HBApp::MessageReceived( BMessage * message )
+{
+ switch( message->what )
+ {
+ case PRINT_MESSAGE:
+ {
+ /* See Log() in HBCommon.cpp */
+ char * string;
+ message->FindPointer( "string", (void**) &string );
+ fprintf( stderr, string );
+ free( string );
+ break;
+ }
+
+ case CHANGE_STATUS:
+ {
+ fWindow->PostMessage( message );
+ break;
+ }
+
+ default:
+ {
+ BApplication::MessageReceived( message );
+ }
+ }
+}
+
+bool HBApp::QuitRequested()
+{
+ if( fManager->Cancel() )
+ {
+ /* We have log messages waiting, quit only after having
+ displayed them */
+ PostMessage( B_QUIT_REQUESTED );
+ return false;
+ }
+
+ return true;
+}