Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

PageExport Class Reference

This class controls the Export notebook page. More...

#include <page_export.h>

Inheritance diagram for PageExport:

Inheritance graph
[legend]
Collaboration diagram for PageExport:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PageExport (KinoCommon *common)
 Constructor for page.
virtual ~PageExport ()
 Destructor for page.
gulong activate ()
 Define active widgets.
void start ()
 Start of page.
void clean ()
 Leaving the page.
GtkWidget * getWidget ()
 accessor method to the common widget
void changeModeRequest (int mode)
 Sends change export mode request to the gui.
void setCurrentMode (int mode)
 Carries out a change mode - this should be triggered by changeModeRequest to ensure that the GUI stays in sync with the common structure.
ExportgetCurrentPage ()
 Returns the Page object that corresponds to the current export mode.
ExportgetPage (int mode)
 Returns the Page object associated to the specified notebook page.
gboolean processKeyboard (GdkEventKey *event)
 Process a keyboard event.
gboolean processCommand (char *cmd)
 Internal method for handling a complete keyboard scene.
void selectScene (int)
 Set the export range to a particular scene.
void startExport ()
 Start export generically.
void previewExport ()
 Preview export generically.
void stopExport ()
 Stop the export generically.
void pauseExport ()
void updateProgress (gfloat val)
 update the progress bar for the export process
void resetProgress ()
void timeFormatChanged ()
std::string getHelpPage ()

Public Attributes

bool isExporting
bool isPausing
bool exportMutex

Private Attributes

KinoCommoncommon
GtkNotebook * notebook
GtkProgressBar * progressBar
int currentMode
Export1394export1394
ExportAVIexportAVI
ExportStillsexportStills
ExportAudioexportAudio
ExportMJPEGexportMJPEG
ExportPipeexportPipe

Detailed Description

This class controls the Export notebook page.

Definition at line 45 of file page_export.h.


Constructor & Destructor Documentation

PageExport::PageExport KinoCommon common  ) 
 

Constructor for page.

Parameters:
common common object to which this page belongs

Definition at line 58 of file page_export.cc.

References currentMode, export1394, EXPORT_MODE_1394, exportAudio, exportAVI, exportMJPEG, exportPipe, exportStills, KinoCommon::getWidget(), lookup_widget(), notebook, and progressBar.

00059         : currentMode( -1 ), isExporting( false ), isPausing( false ), exportMutex( false )
00060 {
00061     cerr << "> Creating Export Page" << endl;
00062     this->common = common;
00063     this->notebook = GTK_NOTEBOOK( lookup_widget( common->getWidget(), "notebook_export" ) );
00064     this->progressBar = GTK_PROGRESS_BAR( lookup_widget( common->getWidget(), "progressbar" ) );
00065     gtk_progress_bar_set_pulse_step( this->progressBar, 0.05 );
00066 
00067     // Create PageExport objects
00068     this->export1394 = new Export1394( this, common );
00069     this->exportAVI = new ExportAVI( this, common );
00070     this->exportStills = new ExportStills( this, common );
00071     this->exportAudio = new ExportAudio( this, common );
00072     this->exportMJPEG = new ExportMJPEG( this, common );
00073     this->exportPipe = new ExportPipe( this, common );
00074 
00075     // Set to the first page
00076     this->currentMode = EXPORT_MODE_1394;
00077 
00078 }

PageExport::~PageExport  )  [virtual]
 

Destructor for page.

Definition at line 83 of file page_export.cc.

00084 {
00085     cerr << "> Destroying Export Page" << endl;
00086 }


Member Function Documentation

gulong PageExport::activate  )  [virtual]
 

Define active widgets.

Reimplemented from Page.

Definition at line 109 of file page_export.cc.

References getCurrentPage().

00110 {
00111     return this->getCurrentPage() ->activate();
00112 }

void PageExport::changeModeRequest int  mode  ) 
 

Sends change export mode request to the gui.

Parameters:
mode export mode to change to

Definition at line 141 of file page_export.cc.

References notebook.

00142 {
00143     gtk_notebook_set_page( notebook, mode );
00144 }

void PageExport::clean  )  [virtual]
 

Leaving the page.

Reimplemented from Page.

Definition at line 117 of file page_export.cc.

References CAPTURE_MOVIE_APPEND, getCurrentPage(), and FileTracker::GetInstance().

Referenced by setCurrentMode().

00118 {
00119     cerr << ">> Leaving Export" << endl;
00120     this->getCurrentPage() ->clean();
00121     // Just in case the user goes straight to capture
00122     FileTracker::GetInstance().SetMode( CAPTURE_MOVIE_APPEND );
00123 }

Export * PageExport::getCurrentPage  ) 
 

Returns the Page object that corresponds to the current export mode.

Returns:
the current Page object (null if current page is invalid).

Definition at line 208 of file page_export.cc.

References getPage().

Referenced by activate(), clean(), pauseExport(), previewExport(), selectScene(), start(), startExport(), and stopExport().

00209 {
00210     Export * ret = getPage( this->currentMode );
00211     return ret;
00212 }

std::string PageExport::getHelpPage  )  [inline, virtual]
 

Reimplemented from Page.

Definition at line 96 of file page_export.h.

00097     {
00098         return "export";
00099     }

Export * PageExport::getPage int  mode  ) 
 

Returns the Page object associated to the specified notebook page.

Parameters:
mode export mode of PageExport object to return
Returns:
the PageExport object associated to the given notebook page or NULL if invalid.

Definition at line 174 of file page_export.cc.

References export1394, EXPORT_MODE_1394, EXPORT_MODE_AUDIO, EXPORT_MODE_AVI, EXPORT_MODE_MJPEG, EXPORT_MODE_PIPE, EXPORT_MODE_STILLS, exportAudio, exportAVI, exportMJPEG, exportPipe, and exportStills.

Referenced by getCurrentPage().

00175 {
00176     Export * ret = NULL;
00177 
00178     switch ( mode )
00179     {
00180     case EXPORT_MODE_1394:
00181         ret = export1394;
00182         break;
00183     case EXPORT_MODE_AVI:
00184         ret = exportAVI;
00185         break;
00186     case EXPORT_MODE_STILLS:
00187         ret = exportStills;
00188         break;
00189     case EXPORT_MODE_AUDIO:
00190         ret = exportAudio;
00191         break;
00192     case EXPORT_MODE_MJPEG:
00193         ret = exportMJPEG;
00194         break;
00195     case EXPORT_MODE_PIPE:
00196         ret = exportPipe;
00197         break;
00198     }
00199 
00200     return ret;
00201 }

GtkWidget * PageExport::getWidget  ) 
 

accessor method to the common widget

For use by the export objects.

Definition at line 130 of file page_export.cc.

References common, and KinoCommon::getWidget().

Referenced by Export::Export(), ExportAudio::ExportAudio(), ExportAVI::ExportAVI(), ExportMJPEG::ExportMJPEG(), Export::selectSection(), and Export1394::start().

00131 {
00132     return common->getWidget();
00133 }

void PageExport::pauseExport  ) 
 

Definition at line 265 of file page_export.cc.

References exportMutex, getCurrentPage(), isExporting, and isPausing.

00266 {
00267     cerr << ">>> PageExport::pauseExport()" << endl;
00268     if ( !exportMutex && isExporting )
00269     {
00270         exportMutex = true;
00271         isPausing = !isPausing;
00272         getCurrentPage() ->pauseExport();
00273         exportMutex = false;
00274     }
00275 }

void PageExport::previewExport  ) 
 

Preview export generically.

Definition at line 216 of file page_export.cc.

References exportMutex, getCurrentPage(), and isExporting.

00217 {
00218     if ( !exportMutex && !isExporting )
00219     {
00220         exportMutex = true;
00221         /* Preview is also exporting - in the lock sense */
00222         isExporting = true;
00223         /* Call with true to indicate preview */
00224         getCurrentPage() ->startExport( true );
00225         isExporting = false;
00226         exportMutex = false;
00227     }
00228 }

gboolean PageExport::processCommand char *  command  )  [virtual]
 

Internal method for handling a complete keyboard scene.

Parameters:
cmd command to be processed;

Reimplemented from Page.

Definition at line 368 of file page_export.cc.

References KinoCommon::changePageRequest(), cmd, common, count, KinoCommon::getWidget(), isExporting, KinoCommon::keyboardFeedback(), kinoDeactivate(), lastcmd, PAGE_EDITOR, PAGE_TIMELINE, PAGE_TRIM, KinoCommon::savePlayList(), and stopExport().

Referenced by processKeyboard().

00369 {
00370     int count = 1;
00371     char real[ 256 ] = "";
00372 
00373     strcpy( cmd, command );
00374 
00375     switch ( sscanf( cmd, "%d%s", &count, real ) )
00376     {
00377     case 1:
00378         // Numeric value only - return immediately if the cmd is not "0"
00379         if ( strcmp( cmd, "0" ) )
00380         {
00381             common->keyboardFeedback( cmd, "" );
00382             return FALSE;
00383         }
00384         break;
00385     case 0:
00386         sscanf( cmd, "%s", real );
00387         count = 1;
00388         break;
00389     }
00390 
00391     strcpy( lastcmd, cmd );
00392 
00393     /* write PlayList */
00394 
00395     if ( strcmp( cmd, ":w" ) == 0 )
00396     {
00397         common->keyboardFeedback( cmd, _( "Write playlist" ) );
00398         common->savePlayList( );
00399         cmd[ 0 ] = 0;
00400     }
00401 
00402     else if ( strcmp( cmd, "Enter" ) == 0 )
00403     {
00404         common->keyboardFeedback( cmd, _( "Start Export" ) );
00405         GdkEvent ev;
00406         ev.key.type = GDK_KEY_PRESS;
00407         ev.key.window = common->getWidget()->window;
00408         ev.key.send_event = TRUE;
00409         ev.key.state = 0;
00410         ev.key.length = 0;
00411         ev.key.string = "";
00412         ev.key.keyval = GDK_Return;
00413         ev.key.group = 0;
00414         gdk_event_put( &ev );
00415         cmd[ 0 ] = 0;
00416     }
00417 
00418     else if ( strcmp( cmd, "Esc" ) == 0 && isExporting )
00419     {
00420         common->keyboardFeedback( cmd, _( "Stop Export" ) );
00421         stopExport();
00422         cmd[ 0 ] = 0;
00423     }
00424 
00425     else if ( strcmp( cmd, "F2" ) == 0 )
00426     {
00427         common->keyboardFeedback( cmd, _( "Edit" ) );
00428         common->changePageRequest( PAGE_EDITOR );
00429         cmd[ 0 ] = 0;
00430     }
00431 
00432     else if ( strcmp( cmd, "A" ) == 0 )
00433     {
00434         common->keyboardFeedback( cmd, _( "Capture, append to movie" ) );
00435         common->changePageRequest( PAGE_EDITOR );
00436         cmd[ 0 ] = 0;
00437     }
00438 
00439     else if ( strcmp( cmd, "v" ) == 0 )
00440     {
00441         common->keyboardFeedback( cmd, _( "Timeline" ) );
00442         common->changePageRequest( PAGE_TIMELINE );
00443         cmd[ 0 ] = 0;
00444     }
00445 
00446     else if ( strcmp( cmd, "t" ) == 0 )
00447     {
00448         common->keyboardFeedback( cmd, _( "Trim" ) );
00449         common->changePageRequest( PAGE_TRIM );
00450         cmd[ 0 ] = 0;
00451     }
00452 
00453     else if ( strcmp( cmd, "C" ) == 0 )
00454     {
00455         common->keyboardFeedback( cmd, _( "FX" ) );
00456         common->changePageRequest( PAGE_TIMELINE );
00457         cmd[ 0 ] = 0;
00458     }
00459 
00460     /* quit */
00461 
00462     else if ( strcmp( cmd, ":q" ) == 0 )
00463     {
00464         common->keyboardFeedback( cmd, _( "quit" ) );
00465         kinoDeactivate();
00466         cmd[ 0 ] = 0;
00467     }
00468 
00469     else
00470     {
00471         // Check for invalid commands
00472         if ( strlen( real ) > 3 )
00473             cmd[ 0 ] = 0;
00474         else if ( strchr( "dgy ", real[ strlen( real ) - 1 ] ) == NULL )
00475             cmd[ 0 ] = 0;
00476 
00477         common->keyboardFeedback( cmd, "" );
00478     }
00479 
00480     return FALSE;
00481 }

gboolean PageExport::processKeyboard GdkEventKey *  event  )  [virtual]
 

Process a keyboard event.

Parameters:
event keyboard event

Reimplemented from Page.

Definition at line 293 of file page_export.cc.

References KinoCommon::changePageRequest(), cmd, common, navigate_control::escaped, g_nav_ctl, KinoCommon::keyboardFeedback(), lastcmd, notebook, PAGE_EDITOR, processCommand(), startExport(), and stopExport().

00294 {
00295     gboolean ret = FALSE;
00296 
00297 #if 0
00298     printf( "send_event: %2.2x\n", event->send_event );
00299     printf( "time  : %8.8x\n", event->time );
00300     printf( "state : %8.8x\n", event->state );
00301     printf( "keyval: %8.8x\n", event->keyval );
00302     printf( "length: %8.8x\n", event->length );
00303     printf( "group : %8.8x\n", event->group );
00304     printf( "string: %s\n", event->string );
00305     printf( "(hex) : %2.2x\n", event->string[ 0 ] );
00306     printf( "cmd   : %s\n", cmd );
00307     printf( "(hex) : %8.8x\n", cmd[ 0 ] );
00308 #endif
00309 
00310     // Only process while not escape mode
00311     if ( g_nav_ctl.escaped == FALSE )
00312     {
00313         if ( strcmp( lastcmd, "alt" ) == 0 )
00314         {
00315             strcpy( lastcmd, "" );
00316             return ret;
00317         }
00318 
00319         switch ( event->keyval )
00320         {
00321             // Translate special keys to equivalent command
00322         case GDK_Return:
00323             common->keyboardFeedback( cmd, _( "Start Export" ) );
00324             startExport();
00325             return TRUE;
00326         case GDK_Escape:
00327             if ( this->isExporting )
00328             {
00329                 common->keyboardFeedback( cmd, _( "Stop Export" ) );
00330                 stopExport( );
00331             }
00332             else
00333             {
00334                 common->changePageRequest( PAGE_EDITOR );
00335             }
00336             cmd[ 0 ] = 0;
00337             return TRUE;
00338         case GDK_Alt_L:
00339         case GDK_Alt_R:
00340             strcpy( lastcmd, "alt" );
00341             return FALSE;
00342         default:
00343             strcat( cmd, event->string );
00344             break;
00345         }
00346 
00347         if ( !strcmp( cmd, "." ) )
00348             strcpy( cmd, lastcmd );
00349 
00350         ret = processCommand( cmd );
00351 
00352     }
00353     else if ( event->keyval == GDK_Return || event->keyval == GDK_Escape )
00354     {
00355         g_nav_ctl.escaped = FALSE;
00356         gtk_widget_grab_focus( GTK_WIDGET( notebook ) );
00357     }
00358 
00359     return ret;
00360 }

void PageExport::resetProgress  ) 
 

Definition at line 515 of file page_export.cc.

References progressBar.

Referenced by ExportAVI::doExport(), start(), and Export::startExport().

00516 {
00517     gtk_progress_bar_update( progressBar, 0.0 );
00518 }

void PageExport::selectScene int  scene  )  [virtual]
 

Set the export range to a particular scene.

Parameters:
scene the numerical index referring to a scene in the playlist

Reimplemented from Page.

Definition at line 282 of file page_export.cc.

References getCurrentPage().

00283 {
00284     getCurrentPage() ->selectScene( scene );
00285 }

void PageExport::setCurrentMode int  mode  ) 
 

Carries out a change mode - this should be triggered by changeModeRequest to ensure that the GUI stays in sync with the common structure.

Parameters:
mode export mode to change to

Definition at line 151 of file page_export.cc.

References KinoCommon::activateWidgets(), clean(), common, currentMode, and start().

00152 {
00153     if ( currentMode != mode )
00154     {
00155         if ( currentMode != -1 )
00156             this->clean();
00157         currentMode = mode;
00158         this->start();
00159         
00160         // Enable or disable the widgets - it calls our activate() and
00161         // deactivate() and can control the storyboard whereas 
00162         // Export::activate() can not!
00163         common->activateWidgets();
00164     }
00165 }

void PageExport::start  )  [virtual]
 

Start of page.

Reimplemented from Page.

Definition at line 91 of file page_export.cc.

References CAPTURE_IGNORE, common, getCurrentPage(), FileTracker::GetInstance(), KinoCommon::getWidget(), isExporting, lookup_widget(), and resetProgress().

Referenced by setCurrentMode().

00092 {
00093     cerr << ">> Starting Export" << endl;
00094     gtk_notebook_set_page( GTK_NOTEBOOK( lookup_widget( common->getWidget(), "notebook_keyhelp" ) ), 3 );
00095     this->getCurrentPage() ->start();
00096     if ( !isExporting )
00097     {
00098         resetProgress();
00099     }
00100 
00101     // Because the file tracker tracks all created files, make sure we ignore exports
00102     FileTracker::GetInstance().SetMode( CAPTURE_IGNORE );
00103     gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( lookup_widget( common->getWidget(), "menuitem_export" ) ), TRUE );
00104 }

void PageExport::startExport  ) 
 

Start export generically.

Definition at line 232 of file page_export.cc.

References exportMutex, getCurrentPage(), and isExporting.

Referenced by processKeyboard().

00233 {
00234     if ( !exportMutex && !isExporting )
00235     {
00236         exportMutex = true;
00237         isExporting = true;
00238 
00239         getCurrentPage() ->startExport();
00240 
00241         exportMutex = false;
00242     }
00243 }

void PageExport::stopExport  ) 
 

Stop the export generically.

Definition at line 248 of file page_export.cc.

References exportMutex, getCurrentPage(), isExporting, and isPausing.

Referenced by processCommand(), and processKeyboard().

00249 {
00250     if ( !exportMutex && isExporting )
00251     {
00252         exportMutex = true;
00253 
00254         getCurrentPage() ->stopExport();
00255 
00256         isExporting = false;
00257         /* The buttons are fixed from Export */
00258         isPausing = false;
00259         exportMutex = false;
00260     }
00261 }

void PageExport::timeFormatChanged  )  [virtual]
 

Reimplemented from Page.

Definition at line 520 of file page_export.cc.

References common, KinoCommon::getWidget(), lookup_widget(), on_spinbutton_export_range_end_value_changed(), and on_spinbutton_export_range_start_value_changed().

00521 {
00522     on_spinbutton_export_range_start_value_changed( GTK_SPIN_BUTTON( lookup_widget( common->getWidget(), "spinbutton_export_range_start" ) ), NULL );
00523     on_spinbutton_export_range_end_value_changed( GTK_SPIN_BUTTON( lookup_widget( common->getWidget(), "spinbutton_export_range_end" ) ), NULL );
00524 }

void PageExport::updateProgress gfloat  val  ) 
 

update the progress bar for the export process

Definition at line 486 of file page_export.cc.

References progressBar.

Referenced by Export::calculateAdjustedRate(), Export::innerLoopUpdate(), and Export::startExport().

00487 {
00488     struct timeval tv;
00489     long long now;
00490     static long long lastUpdateTime = 0;
00491 
00492     gettimeofday( &tv, 0 );
00493     now = 1000000 * ( long long ) tv.tv_sec + ( long long ) tv.tv_usec;
00494 
00495     /* update every 0.3 second */
00496 
00497     if ( val > 1.0 )
00498         val = 1.0;
00499 
00500     if ( now > lastUpdateTime + 300000 || val == 1.0 )
00501     {
00502         if ( val < 0.0 )
00503             gtk_progress_bar_pulse( progressBar );
00504         else
00505             gtk_progress_bar_set_fraction( progressBar, val );
00506         lastUpdateTime = now;
00507     }
00508 
00509     while ( gtk_events_pending() )
00510     {
00511         gtk_main_iteration();
00512     }
00513 }


Member Data Documentation

KinoCommon* PageExport::common [private]
 

Definition at line 48 of file page_export.h.

Referenced by getWidget(), processCommand(), processKeyboard(), setCurrentMode(), start(), and timeFormatChanged().

int PageExport::currentMode [private]
 

Definition at line 51 of file page_export.h.

Referenced by PageExport(), and setCurrentMode().

Export1394* PageExport::export1394 [private]
 

Definition at line 52 of file page_export.h.

Referenced by getPage(), and PageExport().

ExportAudio* PageExport::exportAudio [private]
 

Definition at line 55 of file page_export.h.

Referenced by getPage(), and PageExport().

ExportAVI* PageExport::exportAVI [private]
 

Definition at line 53 of file page_export.h.

Referenced by getPage(), and PageExport().

ExportMJPEG* PageExport::exportMJPEG [private]
 

Definition at line 56 of file page_export.h.

Referenced by getPage(), and PageExport().

bool PageExport::exportMutex
 

Definition at line 67 of file page_export.h.

Referenced by Export::activate(), pauseExport(), previewExport(), startExport(), Export::startExport(), and stopExport().

ExportPipe* PageExport::exportPipe [private]
 

Definition at line 57 of file page_export.h.

Referenced by getPage(), and PageExport().

ExportStills* PageExport::exportStills [private]
 

Definition at line 54 of file page_export.h.

Referenced by getPage(), and PageExport().

bool PageExport::isExporting
 

Definition at line 62 of file page_export.h.

Referenced by Export::activate(), Export::calculateAdjustedRate(), ExportStills::doExport(), ExportPipe::doExport(), ExportMJPEG::doExport(), ExportAVI::doExport(), ExportAudio::doExport(), Export1394::doExport(), pauseExport(), previewExport(), processCommand(), Export::selectScene(), start(), startExport(), Export::startExport(), and stopExport().

bool PageExport::isPausing
 

Definition at line 64 of file page_export.h.

Referenced by Export::calculateAdjustedRate(), Export::doPause(), Export::innerLoopUpdate(), pauseExport(), and stopExport().

GtkNotebook* PageExport::notebook [private]
 

Definition at line 49 of file page_export.h.

Referenced by changeModeRequest(), PageExport(), and processKeyboard().

GtkProgressBar* PageExport::progressBar [private]
 

Definition at line 50 of file page_export.h.

Referenced by PageExport(), resetProgress(), and updateProgress().


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 22:13:14 2007 for Kino by  doxygen 1.4.2