diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/PlayableTreeModelColumnRecord.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/PlayableTreeModelColumnRecord.h new file mode 100644 index 000000000..c8a66a811 --- /dev/null +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/PlayableTreeModelColumnRecord.h @@ -0,0 +1,92 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/PlayableTreeModelColumnRecord.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef LiveSupport_Widgets_PlayableTreeModelColumnRecord_h +#define LiveSupport_Widgets_PlayableTreeModelColumnRecord_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include "LiveSupport/Core/Playable.h" +#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" + +namespace LiveSupport { +namespace Widgets { + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * A basic column record class for tree models with colorable rows and a + * (usually invisible) column of type Ptr::Ref. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + */ +class PlayableTreeModelColumnRecord : public ZebraTreeModelColumnRecord +{ + public: + /** + * The column for the playable object shown in the row. + */ + Gtk::TreeModelColumn::Ref> playableColumn; + + /** + * Constructor. + */ + PlayableTreeModelColumnRecord(void) throw () + { + add(playableColumn); + } +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace Widgets +} // namespace LiveSupport + +#endif // LiveSupport_Widgets_PlayableTreeModelColumnRecord_h + diff --git a/livesupport/products/gLiveSupport/etc/Makefile.in b/livesupport/products/gLiveSupport/etc/Makefile.in index 18e025ebe..9e8d6adff 100644 --- a/livesupport/products/gLiveSupport/etc/Makefile.in +++ b/livesupport/products/gLiveSupport/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.34 $ +# Version : $Revision: 1.35 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $ # # @configure_input@ @@ -194,7 +194,8 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \ ${TMP_DIR}/SearchWindow.o \ ${TMP_DIR}/BrowseEntry.o \ ${TMP_DIR}/BrowseItem.o \ - ${TMP_DIR}/LiveModeWindow.o + ${TMP_DIR}/LiveModeWindow.o \ + ${TMP_DIR}/CuePlayer.o G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \ ${TMP_DIR}/${PACKAGE_NAME}_en.res \ diff --git a/livesupport/products/gLiveSupport/src/CuePlayer.cxx b/livesupport/products/gLiveSupport/src/CuePlayer.cxx new file mode 100644 index 000000000..dc5bc19c1 --- /dev/null +++ b/livesupport/products/gLiveSupport/src/CuePlayer.cxx @@ -0,0 +1,231 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/CuePlayer.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "LiveSupport/Widgets/WidgetFactory.h" + +#include "CuePlayer.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; +using namespace LiveSupport::GLiveSupport; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Constructor. + *----------------------------------------------------------------------------*/ +CuePlayer :: CuePlayer(Ptr::Ref gLiveSupport, + Gtk::TreeView * treeView, + const PlayableTreeModelColumnRecord & modelColumns) + throw () + : gLiveSupport(gLiveSupport), + treeView(treeView), + modelColumns(modelColumns) +{ + Ptr::Ref wf = WidgetFactory::getInstance(); + + playButton = Gtk::manage(wf->createButton( + WidgetFactory::smallPlayButton )); + pauseButton = Gtk::manage(wf->createButton( + WidgetFactory::smallPauseButton )); + stopButton = Gtk::manage(wf->createButton( + WidgetFactory::smallStopButton )); + + playButton->signal_clicked().connect(sigc::mem_fun(*this, + &CuePlayer::onPlayButtonClicked )); + pauseButton->signal_clicked().connect(sigc::mem_fun(*this, + &CuePlayer::onPauseButtonClicked )); + stopButton->signal_clicked().connect(sigc::mem_fun(*this, + &CuePlayer::onStopButtonClicked )); + + pack_end(*stopButton, Gtk::PACK_SHRINK, 5); + pack_end(*playButton, Gtk::PACK_SHRINK); + + audioState = waitingState; + + gLiveSupport->attachCueAudioListener(this); +} + + +/*------------------------------------------------------------------------------ + * Destructor. + *----------------------------------------------------------------------------*/ +CuePlayer :: ~CuePlayer(void) throw () +{ + try { + gLiveSupport->detachCueAudioListener(this); + } catch (std::invalid_argument &e) { + std::cerr << "Could not detach cue player audio listener." + << std::endl; + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Play menu item selected from the entry conext menu + *----------------------------------------------------------------------------*/ +void +CuePlayer :: onPlayItem(void) throw () +{ + Glib::RefPtr refSelection = + treeView->get_selection(); + + if (refSelection) { + Gtk::TreeModel::iterator iter = refSelection->get_selected(); + if (iter) { + Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; + + try { + gLiveSupport->playCueAudio(playable); + } catch (XmlRpcException &e) { + std::cerr << "GLiveSupport::playCueAudio() error:" + << std::endl << e.what() << std::endl; + } catch (std::exception &e) { + std::cerr << "GLiveSupport::playCueAudio() error:" + << std::endl << e.what() << std::endl; + } + + audioState = playingState; + remove(*playButton); + pack_end(*pauseButton, Gtk::PACK_SHRINK); + pauseButton->show(); + } + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Play button getting clicked + *----------------------------------------------------------------------------*/ +void +CuePlayer :: onPlayButtonClicked(void) throw () +{ + switch (audioState) { + case waitingState: + onPlayItem(); + break; + case pausedState: + try { + gLiveSupport->pauseCueAudio(); // ie, restart + audioState = playingState; + remove(*playButton); + pack_end(*pauseButton, Gtk::PACK_SHRINK); + pauseButton->show(); + } catch (std::logic_error &e) { + std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl + << e.what() << std::endl; + } + break; + case playingState: // should never happen + std::cerr << "Assertion failed in CuePlayer:" << std::endl + << "play button clicked when it should not be visible." + << std::endl; + break; + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Pause button getting clicked + *----------------------------------------------------------------------------*/ +void +CuePlayer :: onPauseButtonClicked(void) throw () +{ + try { + gLiveSupport->pauseCueAudio(); + audioState = pausedState; + remove(*pauseButton); + pack_end(*playButton, Gtk::PACK_SHRINK); + playButton->show(); + } catch (std::logic_error &e) { + std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl + << e.what() << std::endl; + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Stop button getting clicked + *----------------------------------------------------------------------------*/ +void +CuePlayer :: onStopButtonClicked(void) throw () +{ + if (audioState != waitingState) { + try { + gLiveSupport->stopCueAudio(); + } catch (XmlRpcException &e) { + std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl + << e.what() << std::endl; + } catch (std::logic_error &e) { + std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl + << e.what() << std::endl; + } + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the "cue audio player has stopped" event. + *----------------------------------------------------------------------------*/ +void +CuePlayer :: onStop(void) throw () +{ + switch (audioState) { + case pausedState: + remove(*playButton); + break; + case playingState: + remove(*pauseButton); + break; + case waitingState: // sometimes onStop() is called twice + return; + } + audioState = waitingState; + pack_end(*playButton, Gtk::PACK_SHRINK); + playButton->show(); +} + diff --git a/livesupport/products/gLiveSupport/src/CuePlayer.h b/livesupport/products/gLiveSupport/src/CuePlayer.h new file mode 100644 index 000000000..a25ddd59e --- /dev/null +++ b/livesupport/products/gLiveSupport/src/CuePlayer.h @@ -0,0 +1,189 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: fgerlits $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/CuePlayer.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef LiveSupport_GLiveSupport_CuePlayer_h +#define LiveSupport_GLiveSupport_CuePlayer_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + +#include "LiveSupport/Core/Ptr.h" +#include "LiveSupport/PlaylistExecutor/AudioPlayerEventListener.h" +#include "LiveSupport/Widgets/ImageButton.h" +#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" + +#include "GLiveSupport.h" + + +namespace LiveSupport { +namespace GLiveSupport { + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * A box displaying a play/pause and a stop button, which control the cue + * (preview) audio player. + * + * @author $Author: fgerlits $ + * @version $Revision: 1.1 $ + */ +class CuePlayer : public Gtk::HBox, + public PlaylistExecutor::AudioPlayerEventListener +{ + private: + + /** + * The possible states of the (cue) audio player. + */ + enum AudioState { waitingState, playingState, pausedState }; + + /** + * The current state of the player. + */ + AudioState audioState; + + /** + * The play button. + */ + ImageButton * playButton; + + /** + * The pause button. + */ + ImageButton * pauseButton; + + /** + * The stop button. + */ + ImageButton * stopButton; + + /** + * The GLiveSupport object, holding the state of the application. + */ + Ptr::Ref gLiveSupport; + + /** + * The Gtk::TreeView of the parent. + */ + Gtk::TreeView * treeView; + + /** + * The Gtk::TreeModelColumnRecord of the parent. + */ + const PlayableTreeModelColumnRecord & + modelColumns; + + /** + * Default constructor. + */ + CuePlayer(void) throw (); + + /** + * Event handler for the Play button being clicked. + */ + void + onPlayButtonClicked(void) throw (); + + /** + * Event handler for the Pause button being clicked. + */ + void + onPauseButtonClicked(void) throw (); + + /** + * Event handler for the Stop button being clicked. + */ + void + onStopButtonClicked(void) throw (); + + + public: + + /** + * Constructor with parent parameters. + * + * @param gLiveSupport the GLiveSupport, application object. + * @param treeView the TreeView object showing the selection. + * @param modelColumns the object holding the types of the columns. + */ + CuePlayer(Ptr::Ref gLiveSupport, + Gtk::TreeView * treeView, + const PlayableTreeModelColumnRecord & modelColumns) + throw (); + + /** + * A virtual destructor. + */ + virtual + ~CuePlayer(void) throw (); + + /** + * Signal handler for the "play item" menu item selected + * from the entry context menu. + */ + void + onPlayItem(void) throw (); + + /** + * Event handler for the "cue audio player has stopped" event. + */ + virtual void + onStop(void) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace GLiveSupport +} // namespace LiveSupport + +#endif // LiveSupport_GLiveSupport_CuePlayer_h + diff --git a/livesupport/products/gLiveSupport/src/LiveModeWindow.h b/livesupport/products/gLiveSupport/src/LiveModeWindow.h index 7d27d1cca..629a281e2 100644 --- a/livesupport/products/gLiveSupport/src/LiveModeWindow.h +++ b/livesupport/products/gLiveSupport/src/LiveModeWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -51,7 +51,7 @@ #include "LiveSupport/Widgets/WhiteWindow.h" #include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/ZebraTreeView.h" -#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" +#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" #include "GLiveSupport.h" namespace LiveSupport { @@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets; * playlists. * * @author $Author: fgerlits $ - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ class LiveModeWindow : public WhiteWindow, public LocalizedObject { @@ -86,16 +86,11 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ - class ModelColumns : public ZebraTreeModelColumnRecord + class ModelColumns : public PlayableTreeModelColumnRecord { public: - /** - * The column for the playable object shown in the row. - */ - Gtk::TreeModelColumn::Ref> playableColumn; - /** * The column for the big row number display. */ @@ -104,8 +99,8 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject /** * The column for the play button. */ - Gtk::TreeModelColumn > - playButtonColumn; +// Gtk::TreeModelColumn > +// playButtonColumn; /** * The column for the title, creator, etc. @@ -117,9 +112,8 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject */ ModelColumns(void) throw () { - add(playableColumn); add(numberColumn); - add(playButtonColumn); +// add(playButtonColumn); add(infoColumn); } }; diff --git a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx index b28fedc31..cc519b0eb 100644 --- a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx +++ b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.16 $ + Version : $Revision: 1.17 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -68,18 +68,11 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, : WhiteWindow(WidgetFactory::scratchpadWindowTitleImage, Colors::White, WidgetFactory::getInstance()->getWhiteWindowCorners()), - LocalizedObject(bundle) + LocalizedObject(bundle), + gLiveSupport(gLiveSupport) { - this->gLiveSupport = gLiveSupport; - Ptr::Ref widgetFactory = WidgetFactory::getInstance(); - playButton = Gtk::manage(widgetFactory->createButton( - WidgetFactory::smallPlayButton)); - pauseButton = Gtk::manage(widgetFactory->createButton( - WidgetFactory::smallPauseButton)); - stopButton = Gtk::manage(widgetFactory->createButton( - WidgetFactory::smallStopButton)); try { clearListButton = Gtk::manage(widgetFactory->createButton( *getResourceUstring("clearListButtonLabel"))); @@ -90,18 +83,6 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, std::exit(1); } - playButton->set_name("playButton"); - playButton->signal_clicked().connect(sigc::mem_fun(*this, - &ScratchpadWindow::onPlayButtonClicked)); - - pauseButton->set_name("pauseButton"); - pauseButton->signal_clicked().connect(sigc::mem_fun(*this, - &ScratchpadWindow::onPauseButtonClicked)); - - stopButton->set_name("stopButton"); - stopButton->signal_clicked().connect(sigc::mem_fun(*this, - &ScratchpadWindow::onStopButtonClicked)); - clearListButton->set_name("clearListButton"); clearListButton->signal_clicked().connect(sigc::mem_fun(*this, &ScratchpadWindow::onClearListButtonClicked)); @@ -141,12 +122,10 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, vBox.pack_start(scrolledWindow); vBox.pack_start(bottomButtonBox, Gtk::PACK_SHRINK); - topButtonBox.pack_start(audioButtonBox, Gtk::PACK_EXPAND_PADDING); + audioButtonBox = Gtk::manage(new CuePlayer( + gLiveSupport, treeView, modelColumns )); + topButtonBox.pack_start(*audioButtonBox, Gtk::PACK_EXPAND_PADDING); - audioButtonBox.set_border_width(5); - audioButtonBox.pack_end(*stopButton, Gtk::PACK_SHRINK, 5); - audioButtonBox.pack_end(*playButton, Gtk::PACK_SHRINK); - bottomButtonBox.set_border_width(5); bottomButtonBox.set_layout(Gtk::BUTTONBOX_END); bottomButtonBox.pack_start(*clearListButton, Gtk::PACK_SHRINK); @@ -179,8 +158,8 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, &ScratchpadWindow::onDeleteItem))); audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("playMenuItem"), - sigc::mem_fun(*this, - &ScratchpadWindow::onPlayItem))); + sigc::mem_fun(*audioButtonBox, + &CuePlayer::onPlayItem))); audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this, @@ -224,8 +203,8 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, &ScratchpadWindow::onDeleteItem))); playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("playMenuItem"), - sigc::mem_fun(*this, - &ScratchpadWindow::onPlayItem))); + sigc::mem_fun(*audioButtonBox, + &CuePlayer::onPlayItem))); playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( *getResourceUstring("addToLiveModeMenuItem"), sigc::mem_fun(*this, @@ -243,9 +222,6 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, set_modal(false); property_window_position().set_value(Gtk::WIN_POS_NONE); - gLiveSupport->attachCueAudioListener(this); - audioState = waitingState; - showContents(); show_all_children(); } @@ -295,20 +271,6 @@ ScratchpadWindow :: showContents(void) throw () } -/*------------------------------------------------------------------------------ - * Destructor. - *----------------------------------------------------------------------------*/ -ScratchpadWindow :: ~ScratchpadWindow (void) throw () -{ - try { - gLiveSupport->detachCueAudioListener(this); - } catch (std::invalid_argument &e) { - std::cerr << "Could not detach cue player audio listener in Scratchpad." - << std::endl; - } -} - - /*------------------------------------------------------------------------------ * Event handler for the clear list button getting clicked. *----------------------------------------------------------------------------*/ @@ -614,39 +576,6 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw () } -/*------------------------------------------------------------------------------ - * Event handler for the Play menu item selected from the entry conext menu - *----------------------------------------------------------------------------*/ -void -ScratchpadWindow :: onPlayItem(void) throw () -{ - Glib::RefPtr refSelection = - treeView->get_selection(); - - if (refSelection) { - Gtk::TreeModel::iterator iter = refSelection->get_selected(); - if (iter) { - Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; - - try { - gLiveSupport->playCueAudio(playable); - } catch (XmlRpcException &e) { - std::cerr << "GLiveSupport::playCueAudio() error:" - << std::endl << e.what() << std::endl; - } catch (std::exception &e) { - std::cerr << "GLiveSupport::playCueAudio() error:" - << std::endl << e.what() << std::endl; - } - - audioState = playingState; - audioButtonBox.remove(*playButton); - audioButtonBox.pack_end(*pauseButton, Gtk::PACK_SHRINK); - pauseButton->show(); - } - } -} - - /*------------------------------------------------------------------------------ * Event handler for the Add To Live Mode menu item selected from the * entry conext menu @@ -667,95 +596,3 @@ ScratchpadWindow :: onAddToLiveMode(void) throw () } } - -/*------------------------------------------------------------------------------ - * Event handler for the Play button getting clicked - *----------------------------------------------------------------------------*/ -void -ScratchpadWindow :: onPlayButtonClicked(void) throw () -{ - switch (audioState) { - case waitingState: - onPlayItem(); - break; - case pausedState: - try { - gLiveSupport->pauseCueAudio(); // ie, restart - audioState = playingState; - audioButtonBox.remove(*playButton); - audioButtonBox.pack_end(*pauseButton, Gtk::PACK_SHRINK); - pauseButton->show(); - } catch (std::logic_error &e) { - std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl - << e.what() << std::endl; - } - break; - case playingState: // should never happen - std::cerr << "Assertion failed in ScratchPadWindow:" << std::endl - << "play button clicked when it should not be visible." - << std::endl; - break; - } -} - - -/*------------------------------------------------------------------------------ - * Event handler for the Pause button getting clicked - *----------------------------------------------------------------------------*/ -void -ScratchpadWindow :: onPauseButtonClicked(void) throw () -{ - try { - gLiveSupport->pauseCueAudio(); - audioState = pausedState; - audioButtonBox.remove(*pauseButton); - audioButtonBox.pack_end(*playButton, Gtk::PACK_SHRINK); - playButton->show(); - } catch (std::logic_error &e) { - std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl - << e.what() << std::endl; - } -} - - -/*------------------------------------------------------------------------------ - * Event handler for the Stop button getting clicked - *----------------------------------------------------------------------------*/ -void -ScratchpadWindow :: onStopButtonClicked(void) throw () -{ - if (audioState != waitingState) { - try { - gLiveSupport->stopCueAudio(); - } catch (XmlRpcException &e) { - std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl - << e.what() << std::endl; - } catch (std::logic_error &e) { - std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl - << e.what() << std::endl; - } - } -} - - -/*------------------------------------------------------------------------------ - * Event handler for the "cue audio player has stopped" event. - *----------------------------------------------------------------------------*/ -void -ScratchpadWindow :: onStop(void) throw () -{ - switch (audioState) { - case pausedState: - audioButtonBox.remove(*playButton); - break; - case playingState: - audioButtonBox.remove(*pauseButton); - break; - case waitingState: // sometimes onStop() is called twice - return; - } - audioState = waitingState; - audioButtonBox.pack_end(*playButton, Gtk::PACK_SHRINK); - playButton->show(); -} - diff --git a/livesupport/products/gLiveSupport/src/ScratchpadWindow.h b/livesupport/products/gLiveSupport/src/ScratchpadWindow.h index 3eaaa9fe2..c4310231d 100644 --- a/livesupport/products/gLiveSupport/src/ScratchpadWindow.h +++ b/livesupport/products/gLiveSupport/src/ScratchpadWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -50,7 +50,8 @@ #include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Widgets/WhiteWindow.h" #include "LiveSupport/Widgets/Button.h" -#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" +#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" +#include "CuePlayer.h" #include "GLiveSupport.h" namespace LiveSupport { @@ -72,11 +73,10 @@ using namespace LiveSupport::Widgets; * playlists. * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class ScratchpadWindow : public WhiteWindow, - public LocalizedObject, - public AudioPlayerEventListener + public LocalizedObject { private: @@ -87,16 +87,11 @@ class ScratchpadWindow : public WhiteWindow, * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ - class ModelColumns : public ZebraTreeModelColumnRecord + class ModelColumns : public PlayableTreeModelColumnRecord { public: - /** - * The column for the playable object shown in the row. - */ - Gtk::TreeModelColumn::Ref> playableColumn; - /** * The column for the type of the entry in the list */ @@ -112,7 +107,6 @@ class ScratchpadWindow : public WhiteWindow, */ ModelColumns(void) throw () { - add(playableColumn); add(typeColumn); add(titleColumn); } @@ -142,7 +136,7 @@ class ScratchpadWindow : public WhiteWindow, /** * The tree view, now only showing rows. */ - ZebraTreeView * treeView; + ZebraTreeView * treeView; /** * The tree model, as a GTK reference. @@ -154,35 +148,10 @@ class ScratchpadWindow : public WhiteWindow, */ Gtk::HBox topButtonBox; - /** - * The possible states of the (cue) audio player. - */ - enum AudioState { waitingState, playingState, pausedState }; - - /** - * The current state of the player. - */ - AudioState audioState; - /** * The box containing the audio buttons. */ - Gtk::HBox audioButtonBox; - - /** - * The play button. - */ - ImageButton * playButton; - - /** - * The pause button. - */ - ImageButton * pauseButton; - - /** - * The stop button. - */ - ImageButton * stopButton; + CuePlayer * audioButtonBox; /** * The box containing the close button. @@ -192,42 +161,24 @@ class ScratchpadWindow : public WhiteWindow, /** * The "clear list" button. */ - Button * clearListButton; + Button * clearListButton; /** * The "delete selected item" button. */ - Button * removeButton; + Button * removeButton; /** * The right-click context menu for audio clips, * that comes up when right-clicking an entry in the entry list. */ - Gtk::Menu * audioClipMenu; + Gtk::Menu * audioClipMenu; /** * The right-click context menu for playlists, * that comes up when right-clicking an entry in the entry list. */ - Gtk::Menu * playlistMenu; - - /** - * Signal handler for the play button clicked. - */ - virtual void - onPlayButtonClicked(void) throw (); - - /** - * Signal handler for the pause button clicked. - */ - virtual void - onPauseButtonClicked(void) throw (); - - /** - * Signal handler for the stop button clicked. - */ - virtual void - onStopButtonClicked(void) throw (); + Gtk::Menu * playlistMenu; /** * Signal handler for the clear list button clicked. @@ -285,13 +236,6 @@ class ScratchpadWindow : public WhiteWindow, virtual void onSchedulePlaylist(void) throw (); - /** - * Signal handler for the "play item" menu item selected - * from the entry context menu. - */ - virtual void - onPlayItem(void) throw (); - /** * Signal handler for the "add to live mode" menu item selected from * the entry context menu. @@ -324,7 +268,9 @@ class ScratchpadWindow : public WhiteWindow, * Virtual destructor. */ virtual - ~ScratchpadWindow(void) throw (); + ~ScratchpadWindow(void) throw () + { + } /** * Update the window contents, with the contents of the Scratchpad. @@ -339,12 +285,6 @@ class ScratchpadWindow : public WhiteWindow, */ void removeItem(Ptr::Ref id) throw (); - - /** - * Event handler for the "cue audio player has stopped" event. - */ - virtual void - onStop(void) throw (); }; /* ================================================= external data structures */ diff --git a/livesupport/products/gLiveSupport/src/SearchWindow.h b/livesupport/products/gLiveSupport/src/SearchWindow.h index ff8913ddb..77276d7df 100644 --- a/livesupport/products/gLiveSupport/src/SearchWindow.h +++ b/livesupport/products/gLiveSupport/src/SearchWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.11 $ + Version : $Revision: 1.12 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -49,7 +49,7 @@ #include "LiveSupport/Core/LocalizedObject.h" #include "LiveSupport/Widgets/WhiteWindow.h" #include "LiveSupport/Widgets/Button.h" -#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" +#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h" #include "LiveSupport/Widgets/AdvancedSearchEntry.h" #include "GLiveSupport.h" #include "BrowseEntry.h" @@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets; * The Search/Browse window. * * @author $Author: fgerlits $ - * @version $Revision: 1.11 $ + * @version $Revision: 1.12 $ */ class SearchWindow : public WhiteWindow, public LocalizedObject { @@ -96,7 +96,8 @@ class SearchWindow : public WhiteWindow, public LocalizedObject /** * Construct the simple search view. - * If you enter a string in theGtk::VBox simple search view and press Enter + * If you enter a string in theGtk::VBox simple search view and + * press Enter * (or the Search button), the local storage will be searched for * items (both audio clips and playlists) where either the title * (dc:title), the creator (dc:creator) or the album (dc:source) @@ -180,9 +181,9 @@ class SearchWindow : public WhiteWindow, public LocalizedObject * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.11 $ + * @version $Revision: 1.12 $ */ - class ModelColumns : public ZebraTreeModelColumnRecord + class ModelColumns : public PlayableTreeModelColumnRecord { public: /** @@ -190,11 +191,6 @@ class SearchWindow : public WhiteWindow, public LocalizedObject */ Gtk::TreeModelColumn typeColumn; - /** - * The column for the playable object shown in the row. - */ - Gtk::TreeModelColumn::Ref> playableColumn; - /** * The column for the title of the audio clip or playlist. */ @@ -216,7 +212,6 @@ class SearchWindow : public WhiteWindow, public LocalizedObject ModelColumns(void) throw () { add(typeColumn); - add(playableColumn); add(titleColumn); add(creatorColumn); add(lengthColumn);