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

KinoCommon Class Reference

This class is the main GUI class. More...

#include <kino_common.h>

Collaboration diagram for KinoCommon:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 KinoCommon (GtkWidget *widget)
 Constructor for KinoCommon - initialises all GUI widgets.
 ~KinoCommon ()
 Destructor for the kino common object.
GtkWidget * getWidget ()
PlayListgetPlayList ()
int getCurrentScene ()
bool newFile (bool prompt=true)
 Carries out a New File request in the kino application.
void bulkLoad (int, char *[])
 Loads all files specified in the command line style arguments.
std::string importFile (const char *filename)
 Give option to import a file by transcoding to DV.
void insertFile ()
 Inserts a file at the current position.
void appendFile ()
 Appends a file after the current position.
void loadFile ()
 Opens a file.
bool savePlayListAs ()
 Save the current play list with a different name to the original loaded (or previously saved as) play list file name.
bool savePlayList ()
 Save the current play list to the file used to load the playlist originally.
void saveFrame ()
 Save the current frame as a still frame.
void publishPlayList ()
void publishFrame ()
void loadPlayList (char *)
void changePageRequest (int page)
 Sends change page request to the gui.
void setCurrentPage (int page)
 Carries out a change page - this should be triggered by changePageRequest to ensure that the GUI stays in sync with the common structure.
PagegetCurrentPage ()
 Returns the current Page object.
PagegetPage (int page)
 Returns the Page object associated to the specified notebook page.
void activateWidgets ()
 Activate or deactivate the widgets at the request of the previous page.
PageEditorgetPageEditor ()
 Returns the Page associated to the Editor page.
PageCapturegetPageCapture ()
 Returns the Page associated to the Capture page.
PageTimelinegetPageTimeline ()
 Returns the Page associated to the Timeline page.
PageBttvgetPageBttv ()
 Returns the 'BTTV' page (test code for extending hardware support).
PageExportgetPageExport ()
 Returns the Export page.
PageTrimgetPageTrim ()
 Returns the Trim page.
PageMagickgetPageMagick ()
 Returns the Magick page.
PageUndefinedgetPageUndefined ()
 Returns the Page associated to the Undefined page.
int moveToFrame ()
 Move to the current frame.
int moveToFrame (int)
 Move to the frame specified.
int moveByFrames (int)
 Move the frame relative to the number specified.
void showFrameInfo (int)
 Relay the current frame info to the GUI.
void showFrameMoreInfo (Frame &, FileHandler *)
 Display detailed information about this frame and its file.
void keyboardFeedback (const char *, const char *)
 Relay the current command and any message associated to it.
gboolean processKeyboard (GdkEventKey *event)
 Trigger the keyboard action of the current page.
gboolean processCommand (char *)
 Trigger a menu command action of the current page.
void selectScene (int)
 Trigger the select scene action of the current page.
void videoStartOfMovie ()
 Trigger the start of movie action of the current page.
void videoPreviousScene ()
 Trigger the previous scene action of the current page.
void videoStartOfScene ()
 Trigger the start of scene action of the current page.
void videoRewind ()
 Trigger the rewind action of the current page.
void videoBack (int step=-1)
 Trigger the back action of the current page.
void videoPlay ()
 Trigger the play action of the current page.
void videoForward (int step=1)
 Trigger the forward action of the current page.
void videoFastForward ()
 Trigger the fast forward action of the current page.
void videoNextScene ()
 Trigger the next scene action of the current page.
void videoEndOfScene ()
 Trigger the end of scene action of the current page.
void videoEndOfMovie ()
 Trigger the end movie action of the current page.
void videoPause ()
 Trigger the pause action of the current page.
void videoStop ()
 Trigger the stop action of the current page.
void videoShuttle (int)
 Bi-directional variable-speed playback.
void windowMoved ()
void visibilityChanged (gboolean)
void toggleComponents (component_enum, bool)
 Set the state of toggle buttons.
component_enum getComponentState ()
 Get the current component state data.
void commitComponentState (component_enum=(component_enum) 0)
 Set the component state data and commit it.
char * getFileToOpen (char *title, bool isDVFile, GtkWidget *widget)
 Handles the modal dialog for collecting a file to open.
char * getFileToSaveFormat (char *title, GtkWidget *widget, int &format)
char * getFileToOpen (char *title, bool isDVFile=true)
char * getFileToSave (char *title)
char * getFileToSaveFormat (char *title, int &format)
void setPreviewSize (float factor, bool noWarning=false)
 Resize the video preview area to a percentage of source image size.
void loadSplash (GtkDrawingArea *)
 Load the splash image into the video preview area.
void clearPreview (GtkDrawingArea *)
 Make the video preview area black.
void setWindowTitle ()
 Sets the document name in the window title.
void saveFrame (int, char *)
 Save the specified frame to the specified file.
bool loadMediaObject (char *, int)
 Loads the specified media file before the specified frame.
void packIt (const char *, const char *)
 Set the video display to be fixed size or scalable.
void setStatusBar (const char *,...)
 Helper function for the pages.
void setMoreInfo (bool state)
SMIL::Time::TimeFormat getTimeFormat () const
void setTimeFormat (SMIL::Time::TimeFormat format)
SMIL::MediaClippingTimegetTime ()
void setCurrentScene (int frame)
string getLastDirectory ()
void setLastDirectory (const string &value)
void updateRecentFiles ()
bool exitKino ()
int checkFile (char *)
 Determines the format of the file.

Static Public Member Functions

static GtkWindow * getWidgetWindow (GtkWidget *widget)

Public Attributes

int g_currentFrame
gboolean hasListChanged

Protected Member Functions

void start ()
 Trigger the start action of the current page.
void clean ()
 Trigger the clean action of the current page.
void setFileEditted (char *)
void setCurrentDirectoryFromFile (char *)
void saveAVI (char *)
bool loadPlayList (char *, int)
 Loads the specified play list before the specified frame.
bool savePlayList (char *)
 Saves the playlist.
void fetchProjectMetadata (const std::string &projectKey)
 Uses libml2 to fetch the metadata from a CMS.

Private Attributes

GtkWidget * widget
GtkWidget * edit_menu
GtkWidget * view_menu
GtkNotebook * notebook
GtkEntry * command
GtkButton * video_start_movie_button
GtkButton * video_start_scene_button
GtkButton * video_rewind_button
GtkButton * video_back_button
GtkButton * video_play_button
GtkButton * video_stop_button
GtkButton * video_forward_button
GtkButton * video_fast_forward_button
GtkButton * video_end_scene_button
GtkButton * video_end_movie_button
GtkRange * video_shuttle
GtkStatusbar * statusbar
PlayList playlist
int currentPage
PageEditoreditor
PageCapturecapture
PageTimelinetimeline
PageBttvbttv
PageExportexportPage
PageTrimtrimPage
PageMagickmagickPage
PageUndefinedundefined
char tempFileName [PATH_MAX+NAME_MAX]
char playlistFileName [PATH_MAX+NAME_MAX]
gulong component_state
bool is_component_state_changing
string last_directory
bool showMoreInfo
int currentScene
SMIL::MediaClippingTime time
std::vector< GtkWidget * > recentMenuItems

Detailed Description

This class is the main GUI class.

As such it is responsible for providing the functionality for all GUI actions relating to widgets which are outside of an individual notebook page (ie: the menu, scene list, transport controls, command line, frame info and the notebook itself).

It is also responsible for holding the current play list.

NB: I would like to make this class more dynamic, especially in terms of notebook pages. Ideally, a notebook page would become a plug in, with each Page object being registered with this class (and a subsequent notebook page being added to the GUI). Glade (and libglade) could be used in such a scenario, but it would necessitate a separate glade project per page (I think... haven't really looked at how best to do this yet). The advantage would be that not only could third party plug-ins be developed, but irrelevant notebook pages could be discarded (ie: if you have no firewire capture card, then that page could be excluded).

Definition at line 108 of file kino_common.h.


Constructor & Destructor Documentation

KinoCommon::KinoCommon GtkWidget *  widget  ) 
 

Constructor for KinoCommon - initialises all GUI widgets.

Parameters:
widget top level widget for the main window

Definition at line 90 of file kino_common.cc.

References bttv, capture, component_state, currentPage, currentScene, edit_menu, editor, exportPage, g_currentFrame, Preferences::getInstance(), hasListChanged, is_component_state_changing, lookup_widget(), magickPage, notebook, setTimeFormat(), statusbar, SMIL::Time::TIME_FORMAT_FRAMES, SMIL::Time::TIME_FORMAT_NONE, timeline, trimPage, undefined, video_back_button, video_end_movie_button, video_end_scene_button, video_fast_forward_button, video_forward_button, video_play_button, video_rewind_button, video_shuttle, video_start_movie_button, video_start_scene_button, VIDEO_STOP, video_stop_button, and view_menu.

00090                                           : last_directory( "" )
00091 {
00092     cerr << "> Kino Common being built" << endl;
00093 
00094     // Initialise class variables from GUI components
00095     this->widget = widget;
00096     this->edit_menu = lookup_widget( widget, "edit" );
00097     this->view_menu = lookup_widget( widget, "view1" );
00098     this->notebook = GTK_NOTEBOOK( lookup_widget( widget, "main_notebook" ) );
00099     this->video_start_movie_button = GTK_BUTTON( lookup_widget( widget, "video_start_movie_button" ) );
00100     this->video_start_scene_button = GTK_BUTTON( lookup_widget( widget, "video_start_scene_button" ) );
00101     this->video_rewind_button = GTK_BUTTON( lookup_widget( widget, "video_rewind_button" ) );
00102     this->video_back_button = GTK_BUTTON( lookup_widget( widget, "video_back_button" ) );
00103     this->video_play_button = GTK_BUTTON( lookup_widget( widget, "video_play_button" ) );
00104     this->video_stop_button = GTK_BUTTON( lookup_widget( widget, "video_stop_button" ) );
00105     this->video_forward_button = GTK_BUTTON( lookup_widget( widget, "video_forward_button" ) );
00106     this->video_fast_forward_button = GTK_BUTTON( lookup_widget( widget, "video_fast_forward_button" ) );
00107     this->video_end_scene_button = GTK_BUTTON( lookup_widget( widget, "video_end_scene_button" ) );
00108     this->video_end_movie_button = GTK_BUTTON( lookup_widget( widget, "video_end_movie_button" ) );
00109     this->video_shuttle = GTK_RANGE( lookup_widget( widget, "hscale_shuttle" ) );
00110     this->statusbar = GTK_STATUSBAR( lookup_widget( widget, "statusbar" ) );
00111 
00112     // Create page objects
00113     this->editor = new PageEditor( this );
00114     this->capture = new PageCapture( this );
00115     this->timeline = new PageTimeline( this );
00116     this->undefined = new PageUndefined( this );
00117     this->bttv = new PageBttv( this );
00118     this->exportPage = new PageExport( this );
00119     this->trimPage = new PageTrim( this );
00120     this->magickPage = new PageMagick( this );
00121 
00122     // Initialise other class variables
00123     strcpy( this->tempFileName, "" );
00124     this->g_currentFrame = -1;
00125     this->hasListChanged = TRUE;
00126     this->currentScene = -1;
00127     this->currentPage = -1;
00128 
00129     this->component_state = VIDEO_STOP;
00130     this->is_component_state_changing = false;
00131     
00132     SMIL::Time::TimeFormat timeFormat = static_cast< SMIL::Time::TimeFormat >( Preferences::getInstance().timeFormat );
00133     GtkWidget *timemenu = lookup_widget( widget, "optionmenu_time_format" );
00134     if  ( timeFormat == SMIL::Time::TIME_FORMAT_NONE )
00135         setTimeFormat( SMIL::Time::TIME_FORMAT_FRAMES );
00136     gtk_option_menu_set_history( GTK_OPTION_MENU( timemenu ), Preferences::getInstance().timeFormat - 1 );
00137     
00138 }

KinoCommon::~KinoCommon  ) 
 

Destructor for the kino common object.

Definition at line 143 of file kino_common.cc.

References bttv, capture, clean(), editor, exportPage, GetFileMap(), magickPage, timeline, trimPage, and undefined.

00144 {
00145     cerr << "> Kino Common being destroyed" << endl;
00146     clean();
00147     delete this->editor;
00148     delete this->capture;
00149     delete this->timeline;
00150     delete this->undefined;
00151     delete this->bttv;
00152     delete this->exportPage;
00153     delete this->trimPage;
00154     delete this->magickPage;
00155     GetFileMap() ->Clear();
00156     cerr << "> Kino Common destroyed" << endl;
00157 }


Member Function Documentation

void KinoCommon::activateWidgets  ) 
 

Activate or deactivate the widgets at the request of the previous page.

This method is always called immediately after the current pages start method and can be called at the discretion of the page if required.

Definition at line 1994 of file kino_common.cc.

References EDIT_MENU, getCurrentPage(), GetStoryboard(), lookup_widget(), SCENE_LIST, VIDEO_BACK, video_back_button, video_end_movie_button, VIDEO_END_OF_MOVIE, video_end_scene_button, VIDEO_FAST_FORWARD, video_fast_forward_button, VIDEO_FORWARD, video_forward_button, VIDEO_NEXT_SCENE, VIDEO_PLAY, video_play_button, VIDEO_REWIND, video_rewind_button, VIDEO_SHUTTLE, video_shuttle, video_start_movie_button, VIDEO_START_OF_MOVIE, VIDEO_START_OF_SCENE, video_start_scene_button, VIDEO_STOP, video_stop_button, and widget.

Referenced by PageCapture::applyAVCState(), on_preferences_dialog_ok_button_clicked(), PageExport::setCurrentMode(), PageMagick::ShowCurrentStatus(), PageCapture::start(), start(), PageCapture::startCapture(), and PageMagick::StartRender().

01995 {
01996     component_enum pattern = ( component_enum ) ( this->getCurrentPage()->activate() ^ this->getCurrentPage()->deactivate() );
01997     gtk_widget_set_sensitive( lookup_widget( widget, "undo" ), pattern & EDIT_MENU );
01998     gtk_widget_set_sensitive( lookup_widget( widget, "redo" ), pattern & EDIT_MENU );
01999     gtk_widget_set_sensitive( lookup_widget( widget, "copy_current_scene" ), pattern & EDIT_MENU );
02000     gtk_widget_set_sensitive( lookup_widget( widget, "cut_current_scene" ), pattern & EDIT_MENU );
02001     gtk_widget_set_sensitive( lookup_widget( widget, "paste_before_current_frame" ), pattern & EDIT_MENU );
02002     gtk_widget_set_sensitive( lookup_widget( widget, "split_scene" ), pattern & EDIT_MENU );
02003     gtk_widget_set_sensitive( lookup_widget( widget, "join_scenes" ), pattern & EDIT_MENU );
02004     gtk_widget_set_sensitive( lookup_widget( widget, "button_undo" ), pattern & EDIT_MENU );
02005     gtk_widget_set_sensitive( lookup_widget( widget, "button_redo" ), pattern & EDIT_MENU );
02006     gtk_widget_set_sensitive( lookup_widget( widget, "button_cut" ), pattern & EDIT_MENU );
02007     gtk_widget_set_sensitive( lookup_widget( widget, "button_copy" ), pattern & EDIT_MENU );
02008     gtk_widget_set_sensitive( lookup_widget( widget, "button_paste" ), pattern & EDIT_MENU );
02009     gtk_widget_set_sensitive( lookup_widget( widget, "button_split" ), pattern & EDIT_MENU );
02010     gtk_widget_set_sensitive( lookup_widget( widget, "button_join" ), pattern & EDIT_MENU );
02011     GetStoryboard() ->setSensitive( pattern & SCENE_LIST );
02012     gtk_widget_set_sensitive( GTK_WIDGET( video_start_movie_button ), pattern & VIDEO_START_OF_MOVIE );
02013     gtk_widget_set_sensitive( GTK_WIDGET( video_start_scene_button ), pattern & VIDEO_START_OF_SCENE );
02014     gtk_widget_set_sensitive( GTK_WIDGET( video_rewind_button ), pattern & VIDEO_REWIND );
02015     gtk_widget_set_sensitive( GTK_WIDGET( video_back_button ), pattern & VIDEO_BACK );
02016     gtk_widget_set_sensitive( GTK_WIDGET( video_play_button ), pattern & VIDEO_PLAY );
02017     gtk_widget_set_sensitive( GTK_WIDGET( video_stop_button ), pattern & VIDEO_STOP );
02018     gtk_widget_set_sensitive( GTK_WIDGET( video_forward_button ), pattern & VIDEO_FORWARD );
02019     gtk_widget_set_sensitive( GTK_WIDGET( video_fast_forward_button ), pattern & VIDEO_FAST_FORWARD );
02020     gtk_widget_set_sensitive( GTK_WIDGET( video_end_scene_button ), pattern & VIDEO_NEXT_SCENE );
02021     gtk_widget_set_sensitive( GTK_WIDGET( video_end_movie_button ), pattern & VIDEO_END_OF_MOVIE );
02022     gtk_widget_set_sensitive( GTK_WIDGET( video_shuttle ), pattern & VIDEO_SHUTTLE );
02023 }

void KinoCommon::appendFile  ) 
 

Appends a file after the current position.

Definition at line 751 of file kino_common.cc.

References AVI, changePageRequest(), checkFile(), g_currentFrame, getFileToOpen(), getPageEditor(), getPlayList(), hasListChanged, importFile(), loadMediaObject(), loadPlayList(), modal_message(), moveToFrame(), PAGE_EDITOR, PLAYLIST, QT, RAW_DV, setWindowTitle(), and UNKNOWN_FORMAT.

Referenced by PageEditor::processCommand().

00752 {
00753     changePageRequest( PAGE_EDITOR );
00754     char * filename = this->getFileToOpen( _( "Choose a DV or SMIL file to append" ) );
00755     if ( filename && strcmp( filename, "" ) )
00756     {
00757         switch ( checkFile( filename ) )
00758         {
00759         case AVI:
00760         case RAW_DV:
00761         case QT:
00762             if ( loadMediaObject( filename, g_currentFrame + 1 ) )
00763             {
00764                 g_currentFrame++;
00765                 hasListChanged = TRUE;
00766                 getPlayList() ->SetDirty( true );
00767                 break;
00768             }
00769             // Else, ask to import
00770         case UNKNOWN_FORMAT:
00771         {
00772             const std::string& importedFile = importFile( filename );
00773             if ( loadMediaObject( const_cast<char*>( importedFile.c_str() ), g_currentFrame + 1 ) )
00774             {
00775                 g_currentFrame++;
00776                 hasListChanged = TRUE;
00777                 getPlayList() ->SetDirty( true );
00778                 break;
00779             }
00780             else
00781             {
00782                 modal_message( _( "Failed to load media file \"%s\"" ), importedFile.c_str() );
00783             }
00784             break;
00785         }
00786         case PLAYLIST:
00787             // Insert the new smil
00788             if ( loadPlayList( filename, g_currentFrame + 1 ) )
00789             {
00790                 g_currentFrame++;
00791                 hasListChanged = TRUE;
00792                 getPlayList() ->SetDirty( true );
00793                 getPageEditor() ->snapshot();
00794             }
00795             break;
00796         }
00797     }
00798 
00799     setWindowTitle();
00800     moveToFrame( );
00801 }

void KinoCommon::bulkLoad int  argc,
char *  argv[]
 

Loads all files specified in the command line style arguments.

Parameters:
argc number of arguments
argv arguments

Definition at line 1433 of file kino_common.cc.

References AVI, checkFile(), currentPage, g_currentFrame, getPageEditor(), getPlayList(), hasListChanged, importFile(), loadMediaObject(), loadPlayList(), lookup_widget(), modal_message(), PAGE_TRIM, PLAYLIST, QT, RAW_DV, setWindowTitle(), UNKNOWN_FORMAT, url_decode(), and widget.

01434 {
01435     char temp[ PATH_MAX + NAME_MAX  ];
01436     char filename[ PATH_MAX + NAME_MAX ];
01437     
01438     for ( int i = 1; i < argc; ++i )
01439     {
01440         /* Get the real name of the file, to make sure that
01441         we store absolute paths in smil files */
01442         if ( NULL != realpath( url_decode( temp, argv[ i ] ), filename ) )
01443         {
01444 
01445             switch ( checkFile( filename ) )
01446             {
01447             case AVI:
01448             case RAW_DV:
01449             case QT:
01450                 // a little hook to make the trimmer load the clip for insert edting
01451                 if ( currentPage == PAGE_TRIM )
01452                 {
01453                     gtk_entry_set_text( GTK_ENTRY( lookup_widget( widget, "entry_trim_clip" ) ), filename );
01454                 }
01455                 else if ( loadMediaObject( filename, this->getPlayList() ->GetNumFrames() ) )
01456                 {
01457                     if ( g_currentFrame == -1 )
01458                         g_currentFrame = 0;
01459                     this->hasListChanged = TRUE;
01460                 }
01461                 else
01462                 {
01463                     cerr << "KinoCommon::bulkLoad: Failed to load " << filename << endl;
01464                 }
01465                 break;
01466             case PLAYLIST:
01467                 {
01468                     int last_count = getPlayList( ) ->GetNumFrames( );
01469                     string last_doc_name = getPlayList( ) ->GetDocName( );
01470                     if ( loadPlayList( filename, last_count ) )
01471                     {
01472                         if ( last_count == 0 && last_doc_name == "" )
01473                         {
01474                             getPlayList() ->SetDocName( filename );
01475                             getPlayList() ->SetDirty( false );
01476                         }
01477                         else
01478                         {
01479                             getPlayList() ->SetDirty( true );
01480                         }
01481                         getPageEditor() ->snapshot();
01482                         if ( g_currentFrame == -1 )
01483                             g_currentFrame = 0;
01484                         this->hasListChanged = TRUE;
01485                     }
01486                 }
01487                 break;
01488             case UNKNOWN_FORMAT:
01489                 {
01490                     const std::string& importedFile = importFile( filename );
01491                     if ( currentPage == PAGE_TRIM )
01492                     {
01493                         gtk_entry_set_text( GTK_ENTRY( lookup_widget( widget, "entry_trim_clip" ) ), importedFile.c_str() );
01494                     }
01495                     else if ( loadMediaObject( const_cast<char*>( importedFile.c_str() ), this->getPlayList() ->GetNumFrames() ) )
01496                     {
01497                         if ( g_currentFrame == -1 )
01498                             g_currentFrame = 0;
01499                         hasListChanged = TRUE;
01500                         getPlayList() ->SetDirty( true );
01501                     }
01502                     else
01503                     {
01504                         modal_message( _( "Failed to load media file \"%s\"" ), importedFile.c_str() );
01505                     }
01506                 }
01507                 break;
01508             }
01509         }
01510         else
01511         {
01512             cerr << "KinoCommon::bulkLoad: Unable to resolve " << filename << endl;
01513         }
01514     }
01515     
01516     setWindowTitle( );
01517 }

void KinoCommon::changePageRequest int  page  ) 
 

Sends change page request to the gui.

Parameters:
page page to change to

Definition at line 408 of file kino_common.cc.

References notebook.

Referenced by appendFile(), insertFile(), loadFile(), newFile(), on_iconview_timeline_item_activated(), on_iconview_timeline_selection_changed(), PageTrim::processCommand(), PageTimeline::processCommand(), PageMagick::processCommand(), PageExport::processCommand(), PageEditor::processCommand(), PageCapture::processCommand(), PageTrim::processKeyboard(), PageTimeline::processKeyboard(), PageMagick::processKeyboard(), PageExport::processKeyboard(), and PageCapture::processKeyboard().

00409 {
00410     gtk_notebook_set_page( notebook, page );
00411 }

int KinoCommon::checkFile char *  FileName  ) 
 

Determines the format of the file.

It is required that a file be at least 20 bytes for it to load.

Note that it is currently required that mediafiles have either a .dv or .avi suffix since the PlayList uses the suffixes .avi and .dv to determine what FileHandler to create. Smil files are allowed to load without suffixes. (Correct?)

Parameters:
filename file to check
Returns:
AVI, PLAYLIST, RAW_DV or UNKNOWN_FORMAT

Definition at line 1240 of file kino_common.cc.

References AVI, PLAYLIST, QT, RAW_DV, and UNKNOWN_FORMAT.

Referenced by appendFile(), bulkLoad(), generate_file_preview(), insertFile(), loadFile(), on_combo_trim_clip_entry_changed(), and on_combo_trim_clip_entry_focus_out_event().

01241 {
01242     // Try reading a few bytes from the file ...
01243     std::ifstream file( FileName );
01244     std::vector<char> buffer( 22, '\0' );
01245     file.read( &buffer[ 0 ], buffer.size() );
01246 
01247     // If it didn't work, we're done ...
01248     if ( file.bad() )
01249     {
01250         cerr << "> Error reading file: " << FileName << endl;
01251         return UNKNOWN_FORMAT;
01252     }
01253 
01254     // If the file is shorter than our buffer, we're done ...
01255     if ( file.eof() )
01256     {
01257         cerr << "> File size < " << buffer.size() << " bytes: " << FileName << endl;
01258         return UNKNOWN_FORMAT;
01259     }
01260 
01261     // Start looking at file suffixes ...
01262     const std::string filename( FileName );
01263     const std::string suffix( filename.begin() + filename.rfind( "." ), filename.end() );
01264 
01265     if ( suffix == ".avi" )
01266     {
01267         return AVI;
01268     }
01269     else if ( suffix == ".dv" || suffix == ".dif" )
01270     {
01271         // This bit of magic brought to you from the dvgrab AVI iso handler ...
01272         const unsigned char * const p = reinterpret_cast<unsigned char*>( &buffer[ 0 ] );
01273         const int section_type = p[ 0 ] >> 5;
01274         const int dif_sequence = p[ 1 ] >> 4;
01275 
01276         if ( 0 == section_type && 0 == dif_sequence )
01277             return RAW_DV;
01278 
01279         return UNKNOWN_FORMAT;
01280     }
01281     else if ( suffix == ".mov" )
01282     {
01283         return QT;
01284     }
01285 
01286     // Check to see if it's SMIL ...
01287     const std::string smil_magic( "<?xml version=\"1.0\"?>" );
01288     if ( std::string( buffer.begin(), buffer.begin() + smil_magic.size() ) == smil_magic )
01289         return PLAYLIST;
01290 
01291     // No can do!
01292     return UNKNOWN_FORMAT;
01293 }

void KinoCommon::clean  )  [protected]
 

Trigger the clean action of the current page.

Definition at line 1747 of file kino_common.cc.

References getCurrentPage().

Referenced by newFile(), setCurrentPage(), and ~KinoCommon().

01748 {
01749     getCurrentPage() ->clean();
01750 }

void KinoCommon::clearPreview GtkDrawingArea *  drawable  ) 
 

Make the video preview area black.

Parameters:
widget the GtkDrawingArea to clear.

Definition at line 2247 of file kino_common.cc.

References widget.

Referenced by PageTrim::windowMoved(), and PageCapture::windowMoved().

02248 {
02249     GtkWidget * widget = GTK_WIDGET( drawable );
02250     if ( widget->window && GDK_IS_DRAWABLE( widget->window ) )
02251     {
02252         gdk_draw_rectangle ( widget->window, widget->style->black_gc, TRUE,
02253                              widget->allocation.x, widget->allocation.y,
02254                              widget->allocation.width, widget->allocation.height );
02255     }
02256 }

void KinoCommon::commitComponentState component_enum  pattern = component_enum ) 0  ) 
 

Set the component state data and commit it.

You can set component state at the same time too. See the toggleComponents() method.

Parameters:
pattern A set of component_enums to set true

Definition at line 2091 of file kino_common.cc.

References component_state, and is_component_state_changing.

Referenced by PageCapture::applyAVCState(), PageCapture::start(), start(), PageCapture::startCapture(), PageMagick::StartRender(), videoBack(), videoEndOfMovie(), videoEndOfScene(), videoFastForward(), videoForward(), videoNextScene(), videoPause(), PageMagick::videoPlay(), videoPlay(), videoPreviousScene(), videoRewind(), videoShuttle(), videoStartOfMovie(), videoStartOfScene(), and videoStop().

02092 {
02093     this->component_state |= pattern;
02094     this->is_component_state_changing = false;
02095 }

bool KinoCommon::exitKino  ) 
 

Definition at line 2303 of file kino_common.cc.

References newFile().

02304 {
02305     return newFile( false );
02306 }

void KinoCommon::fetchProjectMetadata const std::string &  projectKey  )  [protected]
 

Uses libml2 to fetch the metadata from a CMS.

Added for tagesschau.de. It uses config items newProjectURI to make an HTTP request and newProjectXPath to extract the project ID, and expands metaValues containing xpaths.

Parameters:
projectKey a project name or identifier to put into the newProjectURI.

Definition at line 168 of file kino_common.cc.

References Preferences::getInstance(), getPlayList(), and modal_message().

Referenced by loadFile(), loadPlayList(), and newFile().

00169 {
00170     if ( projectKey == "" )
00171         return;
00172 
00173     // Fetch the project metadata from CMS
00174     char uri[1024];
00175     uri[1023] = '\0';
00176     snprintf( uri, 1023, Preferences::getInstance().newProjectURI, projectKey.c_str() );
00177     cerr << "Composed Project URI " << uri << endl;
00178     xmlNanoHTTPInit();
00179     void *httpContext = xmlNanoHTTPOpen( uri, NULL );
00180     int code = 0;
00181     if ( httpContext && ( code = xmlNanoHTTPReturnCode( httpContext ) ) == 200 )
00182     {
00183         char *buffer = (char*) calloc( 1, 1000 );
00184         int size = 0;
00185         int nread;
00186         while ( ( nread = xmlNanoHTTPRead( httpContext, buffer + size, 999 ) ) > 0 )
00187         {
00188             size += nread;
00189             if ( nread == 999 )
00190             {
00191                 buffer = ( char* )realloc( buffer, size + 999 );
00192                 buffer[ size + 1 ] = '\0';
00193             }
00194         }
00195 
00196         // Parse the response
00197         xmlDocPtr doc = xmlParseMemory( buffer, size );
00198         xmlXPathInit();
00199         xmlXPathContextPtr xpathContext = xmlXPathNewContext( doc );
00200         if ( xpathContext )
00201         {
00202             xmlXPathObjectPtr xpathResult;
00203 
00204             // Extract the project ID
00205             if ( strcmp( Preferences::getInstance().newProjectXPath, "" ) )
00206             {
00207                 xpathResult = xmlXPathEval( (xmlChar*) Preferences::getInstance().newProjectXPath, xpathContext );
00208                 if ( xpathResult )
00209                 {
00210                     if ( xpathResult->type == XPATH_NODESET && !xmlXPathNodeSetIsEmpty( xpathResult->nodesetval ) )
00211                     {
00212                         getPlayList()->SetDocId( (char*) xmlXPathCastToString( xpathResult ) );
00213                         cerr << "newProject ID = " << xmlXPathCastToString( xpathResult ) << endl;
00214                         if ( strcmp( reinterpret_cast< char* >( xmlXPathCastToString( xpathResult ) ), "" ) == 0 )
00215                             modal_message( _("The server returned an empty response.\n\nPlease choose File/New to query the server again.") );
00216                     }
00217                     else
00218                         modal_message( _("Failed to parse project metadata:\nthe result of newProjectXPath is empty") );
00219                     xmlXPathFreeObject( xpathResult );
00220                 }
00221                 else
00222                     modal_message( _("Failed to parse project metadata:\nbad newProjectXPath expression") );
00223             }
00224 
00225             // Expand metaValues
00226             map< string, vector< std::pair< std::string, std::string > > >& metaValuesMap = Preferences::getInstance().metaValues;
00227             map< string, vector< std::pair< std::string, std::string > > >::iterator metaValuesMapIter;
00228             for ( metaValuesMapIter = metaValuesMap.begin(); metaValuesMapIter != metaValuesMap.end(); ++metaValuesMapIter )
00229             {
00230                 if ( metaValuesMapIter->second.size() > 0 )
00231                 {
00232                     const string labelPath = metaValuesMapIter->second[0].first;
00233                     const string valuePath = metaValuesMapIter->second[0].second;
00234 
00235                     // Expand the label
00236                     if ( labelPath.length() > 5 && labelPath.substr( 0, 6 ) == "xpath:" )
00237                     {
00238                         // remove the xpath from the values
00239                         metaValuesMapIter->second.erase( metaValuesMapIter->second.begin() );
00240 
00241                         xpathResult = xmlXPathEval( (xmlChar*) labelPath.substr( 6 ).c_str(), xpathContext );
00242                         if ( xpathResult )
00243                         {
00244                             if ( xpathResult->type == XPATH_NODESET )
00245                             {
00246                                 for ( int i = 0; i < xmlXPathNodeSetGetLength( xpathResult->nodesetval ); i++ )
00247                                 {
00248                                     string label( (char *) xmlXPathCastNodeToString( xmlXPathNodeSetItem( xpathResult->nodesetval, i ) ) );
00249                                     metaValuesMapIter->second.push_back( make_pair( label, label ) );
00250                                 }
00251                             }
00252                             xmlXPathFreeObject( xpathResult );
00253                         }
00254                         else
00255                             modal_message( _("Failed to parse project metadata:\nbad metaValues XPath expression") );
00256                     }
00257 
00258                     // Expand the value
00259                     if ( valuePath.length() > 5 && valuePath.substr( 0, 6 ) == "xpath:" )
00260                     {
00261                         xpathResult = xmlXPathEval( (xmlChar*) valuePath.substr( 6 ).c_str(), xpathContext );
00262                         if ( xpathResult )
00263                         {
00264                             if ( xpathResult->type == XPATH_NODESET )
00265                             {
00266                                 for ( int i = 0; i < xmlXPathNodeSetGetLength( xpathResult->nodesetval ); i++ )
00267                                     metaValuesMapIter->second[ i ].second =
00268                                         (char *) xmlXPathCastNodeToString( xmlXPathNodeSetItem( xpathResult->nodesetval, i ) );
00269                             }
00270                             xmlXPathFreeObject( xpathResult );
00271                         }
00272                         else
00273                             modal_message( _("Failed to parse project metadata:\nbad metaValues XPath expression") );
00274                     }
00275                 }
00276             }
00277 
00278             xmlXPathFreeContext( xpathContext );
00279         }
00280 
00281         free( buffer );
00282     }
00283     else if ( httpContext )
00284     {
00285         modal_message( "Server responded with error %d", code );
00286     }
00287     if ( httpContext )
00288         xmlNanoHTTPClose( httpContext );
00289 
00290     xmlNanoHTTPCleanup();
00291 }

component_enum KinoCommon::getComponentState  ) 
 

Get the current component state data.

Definition at line 2079 of file kino_common.cc.

References component_state.

Referenced by PageCapture::applyAVCState(), PageTrim::processKeyboard(), PageCapture::processKeyboard(), start(), PageMagick::StartRender(), PageTrim::videoBack(), PageMagick::videoBack(), PageEditor::videoBack(), PageTrim::videoEndOfMovie(), PageMagick::videoEndOfMovie(), PageEditor::videoEndOfMovie(), PageTrim::videoFastForward(), PageEditor::videoFastForward(), PageTrim::videoForward(), PageMagick::videoForward(), PageEditor::videoForward(), PageMagick::videoNextScene(), PageTrim::videoPause(), PageTrim::videoPlay(), PageMagick::videoPlay(), PageEditor::videoPlay(), PageMagick::videoPreviousScene(), PageTrim::videoRewind(), PageEditor::videoRewind(), videoShuttle(), PageMagick::videoStartOfMovie(), PageTrim::videoStop(), PageMagick::videoStop(), and PageEditor::videoStop().

02080 {
02081     return ( component_enum ) this->component_state;
02082 }

Page * KinoCommon::getCurrentPage  ) 
 

Returns the current Page object.

Returns:
the current Page object (will be PageUndefined if current page is invalid).

Definition at line 475 of file kino_common.cc.

References getPage(), and getPageUndefined().

Referenced by activateWidgets(), clean(), loadFile(), loadPlayList(), moveToFrame(), on_preferences_dialog_ok_button_clicked(), processCommand(), processKeyboard(), selectScene(), setTimeFormat(), showFrameInfo(), start(), videoBack(), videoEndOfMovie(), videoEndOfScene(), videoFastForward(), videoForward(), videoNextScene(), videoPause(), videoPlay(), videoPreviousScene(), videoRewind(), videoShuttle(), videoStartOfMovie(), videoStartOfScene(), videoStop(), visibilityChanged(), and windowMoved().

00476 {
00477     Page * ret = getPage( this->currentPage );
00478     if ( ret == NULL )
00479         ret = getPageUndefined();
00480     return ret;
00481 }

int KinoCommon::getCurrentScene  )  [inline]
 

Definition at line 179 of file kino_common.h.

References currentScene.

Referenced by on_tool_change(), showScenesThread(), and Storyboard::Storyboard().

00180     {
00181         return this->currentScene;
00182     }

char* KinoCommon::getFileToOpen char *  title,
bool  isDVFile = true
[inline]
 

Definition at line 258 of file kino_common.h.

References getFileToOpen(), and getWidget().

00259     {
00260         return getFileToOpen( title, isDVFile, getWidget() );
00261     }

char * KinoCommon::getFileToOpen char *  title,
bool  isDVFile,
GtkWidget *  widget
 

Handles the modal dialog for collecting a file to open.

The file is not opened, but returned by this method.

Parameters:
title title of the window
Returns:
a string inidicating the selected file (an empty string denotes no selection)

Definition at line 1079 of file kino_common.cc.

References directory_utils::get_directory_from_file(), getPlayList(), getWidgetWindow(), last_directory, tempFileName, and update_preview_cb().

Referenced by appendFile(), getFileToOpen(), insertFile(), loadFile(), ImageCreateFromFile::on_button_file_clicked(), AudioMix::on_button_mix_file_clicked(), AudioDub::on_button_sub_file_clicked(), and on_button_trim_open_clicked().

01080 {
01081     GtkWidget *dialog;
01082     GtkDrawingArea *preview;
01083     GtkFileFilter *filter;
01084 
01085     dialog = gtk_file_chooser_dialog_new( title,
01086                 getWidgetWindow(widget),
01087                 GTK_FILE_CHOOSER_ACTION_OPEN,
01088                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
01089                 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
01090                 static_cast<gchar*>( NULL ) );
01091     gtk_dialog_set_alternative_button_order( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1 );
01092 //  gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER(dialog), TRUE );
01093 
01094     if ( isDVFile )
01095     {
01096         preview = ( GtkDrawingArea* )gtk_drawing_area_new();
01097         gtk_widget_set_size_request( GTK_WIDGET(preview), 160, 120 );
01098         gtk_file_chooser_set_preview_widget( GTK_FILE_CHOOSER(dialog),
01099                     GTK_WIDGET(preview) );
01100         g_signal_connect( dialog, "update-preview",
01101                     G_CALLBACK(update_preview_cb), preview );
01102     
01103         filter = gtk_file_filter_new();
01104         gtk_file_filter_set_name( filter, "All Files" );
01105         gtk_file_filter_add_pattern( filter, "*" );
01106         gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter );
01107     
01108         filter = gtk_file_filter_new();
01109         gtk_file_filter_set_name( filter, "SMIL Files (*.smil, *.kino)" );
01110         gtk_file_filter_add_pattern( filter, "*.smil" );
01111         gtk_file_filter_add_pattern( filter, "*.kino" );
01112         gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter );
01113     
01114         filter = gtk_file_filter_new();
01115         gtk_file_filter_set_name( filter, "Raw DV Files (*.dv, *.dif)" );
01116         gtk_file_filter_add_pattern( filter, "*.dv" );
01117         gtk_file_filter_add_pattern( filter, "*.dif" );
01118         gtk_file_choose