refactored cue buttons into separate CuePlayer class

This commit is contained in:
fgerlits 2005-05-13 17:50:17 +00:00
parent 9c09b528ca
commit 17e320da97
8 changed files with 556 additions and 277 deletions

View file

@ -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<Playable>::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<Ptr<Playable>::Ref> playableColumn;
/**
* Constructor.
*/
PlayableTreeModelColumnRecord(void) throw ()
{
add(playableColumn);
}
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace Widgets
} // namespace LiveSupport
#endif // LiveSupport_Widgets_PlayableTreeModelColumnRecord_h

View file

@ -21,7 +21,7 @@
# #
# #
# Author : $Author: fgerlits $ # 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 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
# #
# @configure_input@ # @configure_input@
@ -194,7 +194,8 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/SearchWindow.o \ ${TMP_DIR}/SearchWindow.o \
${TMP_DIR}/BrowseEntry.o \ ${TMP_DIR}/BrowseEntry.o \
${TMP_DIR}/BrowseItem.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 \ G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
${TMP_DIR}/${PACKAGE_NAME}_en.res \ ${TMP_DIR}/${PACKAGE_NAME}_en.res \

View file

@ -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 <iostream>
#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<GLiveSupport>::Ref gLiveSupport,
Gtk::TreeView * treeView,
const PlayableTreeModelColumnRecord & modelColumns)
throw ()
: gLiveSupport(gLiveSupport),
treeView(treeView),
modelColumns(modelColumns)
{
Ptr<WidgetFactory>::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<Gtk::TreeView::Selection> refSelection =
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) {
Ptr<Playable>::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();
}

View file

@ -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 <gtkmm.h>
#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<GLiveSupport>::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<GLiveSupport>::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

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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/WhiteWindow.h"
#include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ZebraTreeView.h" #include "LiveSupport/Widgets/ZebraTreeView.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets;
* playlists. * playlists.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.8 $ * @version $Revision: 1.9 $
*/ */
class LiveModeWindow : public WhiteWindow, public LocalizedObject class LiveModeWindow : public WhiteWindow, public LocalizedObject
{ {
@ -86,16 +86,11 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
* Lists one clip per row. * Lists one clip per row.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.8 $ * @version $Revision: 1.9 $
*/ */
class ModelColumns : public ZebraTreeModelColumnRecord class ModelColumns : public PlayableTreeModelColumnRecord
{ {
public: public:
/**
* The column for the playable object shown in the row.
*/
Gtk::TreeModelColumn<Ptr<Playable>::Ref> playableColumn;
/** /**
* The column for the big row number display. * The column for the big row number display.
*/ */
@ -104,8 +99,8 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
/** /**
* The column for the play button. * The column for the play button.
*/ */
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > // Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> >
playButtonColumn; // playButtonColumn;
/** /**
* The column for the title, creator, etc. * The column for the title, creator, etc.
@ -117,9 +112,8 @@ class LiveModeWindow : public WhiteWindow, public LocalizedObject
*/ */
ModelColumns(void) throw () ModelColumns(void) throw ()
{ {
add(playableColumn);
add(numberColumn); add(numberColumn);
add(playButtonColumn); // add(playButtonColumn);
add(infoColumn); add(infoColumn);
} }
}; };

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -68,18 +68,11 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
: WhiteWindow(WidgetFactory::scratchpadWindowTitleImage, : WhiteWindow(WidgetFactory::scratchpadWindowTitleImage,
Colors::White, Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners()), WidgetFactory::getInstance()->getWhiteWindowCorners()),
LocalizedObject(bundle) LocalizedObject(bundle),
gLiveSupport(gLiveSupport)
{ {
this->gLiveSupport = gLiveSupport;
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance(); Ptr<WidgetFactory>::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 { try {
clearListButton = Gtk::manage(widgetFactory->createButton( clearListButton = Gtk::manage(widgetFactory->createButton(
*getResourceUstring("clearListButtonLabel"))); *getResourceUstring("clearListButtonLabel")));
@ -90,18 +83,6 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
std::exit(1); 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->set_name("clearListButton");
clearListButton->signal_clicked().connect(sigc::mem_fun(*this, clearListButton->signal_clicked().connect(sigc::mem_fun(*this,
&ScratchpadWindow::onClearListButtonClicked)); &ScratchpadWindow::onClearListButtonClicked));
@ -141,12 +122,10 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
vBox.pack_start(scrolledWindow); vBox.pack_start(scrolledWindow);
vBox.pack_start(bottomButtonBox, Gtk::PACK_SHRINK); 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_border_width(5);
bottomButtonBox.set_layout(Gtk::BUTTONBOX_END); bottomButtonBox.set_layout(Gtk::BUTTONBOX_END);
bottomButtonBox.pack_start(*clearListButton, Gtk::PACK_SHRINK); bottomButtonBox.pack_start(*clearListButton, Gtk::PACK_SHRINK);
@ -179,8 +158,8 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
&ScratchpadWindow::onDeleteItem))); &ScratchpadWindow::onDeleteItem)));
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("playMenuItem"), *getResourceUstring("playMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*audioButtonBox,
&ScratchpadWindow::onPlayItem))); &CuePlayer::onPlayItem)));
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToLiveModeMenuItem"), *getResourceUstring("addToLiveModeMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
@ -224,8 +203,8 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
&ScratchpadWindow::onDeleteItem))); &ScratchpadWindow::onDeleteItem)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("playMenuItem"), *getResourceUstring("playMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*audioButtonBox,
&ScratchpadWindow::onPlayItem))); &CuePlayer::onPlayItem)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToLiveModeMenuItem"), *getResourceUstring("addToLiveModeMenuItem"),
sigc::mem_fun(*this, sigc::mem_fun(*this,
@ -243,9 +222,6 @@ ScratchpadWindow :: ScratchpadWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
set_modal(false); set_modal(false);
property_window_position().set_value(Gtk::WIN_POS_NONE); property_window_position().set_value(Gtk::WIN_POS_NONE);
gLiveSupport->attachCueAudioListener(this);
audioState = waitingState;
showContents(); showContents();
show_all_children(); 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. * 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<Gtk::TreeView::Selection> refSelection =
treeView->get_selection();
if (refSelection) {
Gtk::TreeModel::iterator iter = refSelection->get_selected();
if (iter) {
Ptr<Playable>::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 * Event handler for the Add To Live Mode menu item selected from the
* entry conext menu * 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();
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/WhiteWindow.h" #include "LiveSupport/Widgets/WhiteWindow.h"
#include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "CuePlayer.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
namespace LiveSupport { namespace LiveSupport {
@ -72,11 +73,10 @@ using namespace LiveSupport::Widgets;
* playlists. * playlists.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class ScratchpadWindow : public WhiteWindow, class ScratchpadWindow : public WhiteWindow,
public LocalizedObject, public LocalizedObject
public AudioPlayerEventListener
{ {
private: private:
@ -87,16 +87,11 @@ class ScratchpadWindow : public WhiteWindow,
* Lists one clip per row. * Lists one clip per row.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
class ModelColumns : public ZebraTreeModelColumnRecord class ModelColumns : public PlayableTreeModelColumnRecord
{ {
public: public:
/**
* The column for the playable object shown in the row.
*/
Gtk::TreeModelColumn<Ptr<Playable>::Ref> playableColumn;
/** /**
* The column for the type of the entry in the list * The column for the type of the entry in the list
*/ */
@ -112,7 +107,6 @@ class ScratchpadWindow : public WhiteWindow,
*/ */
ModelColumns(void) throw () ModelColumns(void) throw ()
{ {
add(playableColumn);
add(typeColumn); add(typeColumn);
add(titleColumn); add(titleColumn);
} }
@ -142,7 +136,7 @@ class ScratchpadWindow : public WhiteWindow,
/** /**
* The tree view, now only showing rows. * The tree view, now only showing rows.
*/ */
ZebraTreeView * treeView; ZebraTreeView * treeView;
/** /**
* The tree model, as a GTK reference. * The tree model, as a GTK reference.
@ -154,35 +148,10 @@ class ScratchpadWindow : public WhiteWindow,
*/ */
Gtk::HBox topButtonBox; 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. * The box containing the audio buttons.
*/ */
Gtk::HBox audioButtonBox; CuePlayer * audioButtonBox;
/**
* The play button.
*/
ImageButton * playButton;
/**
* The pause button.
*/
ImageButton * pauseButton;
/**
* The stop button.
*/
ImageButton * stopButton;
/** /**
* The box containing the close button. * The box containing the close button.
@ -192,42 +161,24 @@ class ScratchpadWindow : public WhiteWindow,
/** /**
* The "clear list" button. * The "clear list" button.
*/ */
Button * clearListButton; Button * clearListButton;
/** /**
* The "delete selected item" button. * The "delete selected item" button.
*/ */
Button * removeButton; Button * removeButton;
/** /**
* The right-click context menu for audio clips, * The right-click context menu for audio clips,
* that comes up when right-clicking an entry in the entry list. * 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, * The right-click context menu for playlists,
* that comes up when right-clicking an entry in the entry list. * that comes up when right-clicking an entry in the entry list.
*/ */
Gtk::Menu * playlistMenu; 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 ();
/** /**
* Signal handler for the clear list button clicked. * Signal handler for the clear list button clicked.
@ -285,13 +236,6 @@ class ScratchpadWindow : public WhiteWindow,
virtual void virtual void
onSchedulePlaylist(void) throw (); 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 * Signal handler for the "add to live mode" menu item selected from
* the entry context menu. * the entry context menu.
@ -324,7 +268,9 @@ class ScratchpadWindow : public WhiteWindow,
* Virtual destructor. * Virtual destructor.
*/ */
virtual virtual
~ScratchpadWindow(void) throw (); ~ScratchpadWindow(void) throw ()
{
}
/** /**
* Update the window contents, with the contents of the Scratchpad. * Update the window contents, with the contents of the Scratchpad.
@ -339,12 +285,6 @@ class ScratchpadWindow : public WhiteWindow,
*/ */
void void
removeItem(Ptr<const UniqueId>::Ref id) throw (); removeItem(Ptr<const UniqueId>::Ref id) throw ();
/**
* Event handler for the "cue audio player has stopped" event.
*/
virtual void
onStop(void) throw ();
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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/Core/LocalizedObject.h"
#include "LiveSupport/Widgets/WhiteWindow.h" #include "LiveSupport/Widgets/WhiteWindow.h"
#include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h" #include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/AdvancedSearchEntry.h" #include "LiveSupport/Widgets/AdvancedSearchEntry.h"
#include "GLiveSupport.h" #include "GLiveSupport.h"
#include "BrowseEntry.h" #include "BrowseEntry.h"
@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets;
* The Search/Browse window. * The Search/Browse window.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.11 $ * @version $Revision: 1.12 $
*/ */
class SearchWindow : public WhiteWindow, public LocalizedObject class SearchWindow : public WhiteWindow, public LocalizedObject
{ {
@ -96,7 +96,8 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
/** /**
* Construct the simple search view. * 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 * (or the Search button), the local storage will be searched for
* items (both audio clips and playlists) where either the title * items (both audio clips and playlists) where either the title
* (dc:title), the creator (dc:creator) or the album (dc:source) * (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. * Lists one clip per row.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.11 $ * @version $Revision: 1.12 $
*/ */
class ModelColumns : public ZebraTreeModelColumnRecord class ModelColumns : public PlayableTreeModelColumnRecord
{ {
public: public:
/** /**
@ -190,11 +191,6 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
*/ */
Gtk::TreeModelColumn<Glib::ustring> typeColumn; Gtk::TreeModelColumn<Glib::ustring> typeColumn;
/**
* The column for the playable object shown in the row.
*/
Gtk::TreeModelColumn<Ptr<Playable>::Ref> playableColumn;
/** /**
* The column for the title of the audio clip or playlist. * The column for the title of the audio clip or playlist.
*/ */
@ -216,7 +212,6 @@ class SearchWindow : public WhiteWindow, public LocalizedObject
ModelColumns(void) throw () ModelColumns(void) throw ()
{ {
add(typeColumn); add(typeColumn);
add(playableColumn);
add(titleColumn); add(titleColumn);
add(creatorColumn); add(creatorColumn);
add(lengthColumn); add(lengthColumn);