added AudioClipWindow

This commit is contained in:
maroy 2004-12-02 17:42:39 +00:00
parent 0fa7cd107d
commit 8f25fba4b3
10 changed files with 500 additions and 31 deletions

View File

@ -21,7 +21,7 @@
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.7 $
# Version : $Revision: 1.8 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
#
# @configure_input@
@ -142,7 +142,8 @@ LDFLAGS = @LDFLAGS@ -pthread \
G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/UiTestMainWindow.o \
${TMP_DIR}/GtkLocalizedObject.o \
${TMP_DIR}/LoginWindow.o
${TMP_DIR}/LoginWindow.o \
${TMP_DIR}/AudioClipWindow.o
G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
${TMP_DIR}/${PACKAGE_NAME}_en.res \

View File

@ -70,12 +70,38 @@
</authenticationClientFactory>
<storageClientFactory>
<webStorage tempFiles="file:///tmp/tempPlaylist" >
<location server="localhost"
port="80"
path="/livesupportStorageServer/xmlrpc/xrLocStor.php"
/>
</webStorage>
<testStorage tempFiles="file:///tmp/tempPlaylist">
<playlist id="1" playlength="00:00:34.000" >
<playlistElement id="101" relativeOffset="0" >
<audioClip id="10001" playlength="00:00:11.000"
uri="file:var/test1.mp3" />
</playlistElement>
<playlistElement id="102" relativeOffset="00:00:11.000000" >
<audioClip id="10002" playlength="00:00:12.000000"
uri="file:var/test2.mp3" />
<fadeInfo id="9901" fadeIn="00:00:02.000000"
fadeOut="00:00:01.500000" />
</playlistElement>
<playlistElement id="103" relativeOffset="00:00:23.000000" >
<playlist id="2" playlength="00:00:11.000000" >
<playlistElement id="111" relativeOffset="0" >
<audioClip id="10003" playlength="00:00:11.000"
uri="file:var/test3.mp3" />
</playlistElement>
</playlist>
</playlistElement>
</playlist>
<playlist id="2" playlength="00:00:11.000000" >
<playlistElement id="111" relativeOffset="0" >
<audioClip id="10003" playlength="00:00:11.000"
uri="file:var/test3.mp3" />
</playlistElement>
</playlist>
<audioClip id="10001" playlength="01:00:00.000"
uri="file:var/test1.mp3" />
<audioClip id="10002" playlength="00:30:00.000"
uri="file:var/test2.mp3" />
</testStorage>
</storageClientFactory>
<schedulerClientFactory>

View File

@ -0,0 +1,183 @@
/*------------------------------------------------------------------------------
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: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/AudioClipWindow.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <iostream>
#include <stdexcept>
#include "AudioClipWindow.h"
using namespace Glib;
using namespace LiveSupport::Core;
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
AudioClipWindow :: AudioClipWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ()
: GtkLocalizedObject(bundle)
{
this->gLiveSupport = gLiveSupport;
try {
closeButton.reset(new Gtk::Button(
*getResourceUstring("closeButtonLabel")));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
// set up the close button
closeButton->set_name("closeButton");
closeButton->set_flags(Gtk::CAN_FOCUS|Gtk::CAN_DEFAULT|Gtk::HAS_DEFAULT);
closeButton->set_relief(Gtk::RELIEF_NORMAL);
// Register the signal handler for the button getting clicked.
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
&AudioClipWindow::onCloseButtonClicked));
set_title("LiveSupport Audio Clip Window");
set_border_width(5);
set_default_size(400, 200);
add(vBox);
// Add the TreeView, inside a ScrolledWindow, with the button underneath:
scrolledWindow.add(treeView);
// Only show the scrollbars when they are necessary:
scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
vBox.pack_start(scrolledWindow);
vBox.pack_start(buttonBox, Gtk::PACK_SHRINK);
buttonBox.pack_start(*closeButton, Gtk::PACK_SHRINK);
buttonBox.set_border_width(5);
buttonBox.set_layout(Gtk::BUTTONBOX_END);
// Create the Tree model:
treeModel = Gtk::ListStore::create(modelColumns);
treeView.set_model(treeModel);
// Add the TreeView's view columns:
try {
treeView.append_column(*getResourceUstring("idColumnLabel"),
modelColumns.idColumn);
treeView.append_column(*getResourceUstring("lengthColumnLabel"),
modelColumns.lengthColumn);
treeView.append_column(*getResourceUstring("uriColumnLabel"),
modelColumns.uriColumn);
treeView.append_column(*getResourceUstring("tokenColumnLabel"),
modelColumns.tokenColumn);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
showAllAudioClips();
show_all_children();
}
/*------------------------------------------------------------------------------
* Show all audio clips
*----------------------------------------------------------------------------*/
void
AudioClipWindow :: showAllAudioClips(void) throw ()
{
// list all audio clips
Ptr<SessionId>::Ref sessionId;
Ptr<StorageClientInterface>::Ref storage;
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClips;
std::vector<Ptr<AudioClip>::Ref>::iterator it;
std::vector<Ptr<AudioClip>::Ref>::iterator end;
Ptr<AudioClip>::Ref clip;
Gtk::TreeModel::Row row;
std::string lengthStr;
sessionId = gLiveSupport->getSessionId();
storage = gLiveSupport->getStorage();
audioClips = storage->getAllAudioClips(sessionId);
it = audioClips->begin();
end = audioClips->end();
while (it < end) {
clip = *it;
row = *(treeModel->append());
lengthStr = boost::posix_time::to_simple_string(*clip->getPlaylength());
row[modelColumns.idColumn] = clip->getId()->getId();
row[modelColumns.lengthColumn] = lengthStr;
row[modelColumns.uriColumn] = clip->getUri().get() ? *clip->getUri()
: "";
row[modelColumns.tokenColumn] = clip->getToken().get()
? *clip->getUri()
: "";
it++;
}
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
AudioClipWindow :: ~AudioClipWindow (void) throw ()
{
}
/*------------------------------------------------------------------------------
* Event handler for the close button getting clicked.
*----------------------------------------------------------------------------*/
void
AudioClipWindow :: onCloseButtonClicked (void) throw ()
{
hide();
}

View File

@ -0,0 +1,201 @@
/*------------------------------------------------------------------------------
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: maroy $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/AudioClipWindow.h,v $
------------------------------------------------------------------------------*/
#ifndef AudioClipWindow_h
#define AudioClipWindow_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <string>
#include <unicode/resbund.h>
#include <gtkmm.h>
#include "LiveSupport/Core/Ptr.h"
#include "GtkLocalizedObject.h"
#include "GLiveSupport.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* A window, showing and handling audio clips.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class AudioClipWindow : public Gtk::Window, public GtkLocalizedObject
{
protected:
/**
* The model columns, for the audio clip window.
* Lists one clip per row.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
/**
* The column for the id of the audio clip.
*/
Gtk::TreeModelColumn<unsigned int> idColumn;
/**
* The column for the length of the audio clip.
*/
Gtk::TreeModelColumn<Glib::ustring> lengthColumn;
/**
* The column for the URI of the audio clip.
*/
Gtk::TreeModelColumn<Glib::ustring> uriColumn;
/**
* The column for the token of the audio clip.
*/
Gtk::TreeModelColumn<Glib::ustring> tokenColumn;
/**
* Constructor.
*/
ModelColumns(void) throw ()
{
add(idColumn);
add(lengthColumn);
add(uriColumn);
add(tokenColumn);
}
};
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The column model.
*/
ModelColumns modelColumns;
/**
* The main container in the window.
*/
Gtk::VBox vBox;
/**
* A scrolled window, so that the list can be scrolled.
*/
Gtk::ScrolledWindow scrolledWindow;
/**
* The tree view, now only showing rows.
*/
Gtk::TreeView treeView;
/**
* The tree model, as a GTK reference.
*/
Glib::RefPtr<Gtk::ListStore> treeModel;
/**
* The box containing the close button.
*/
Gtk::HButtonBox buttonBox;
/**
* The close button.
*/
Ptr<Gtk::Button>::Ref closeButton;
/**
* Signal handler for the close button clicked.
*/
virtual void
onCloseButtonClicked(void) throw ();
/**
* Update the window contents, with all the video clips.
*/
void
showAllAudioClips(void) throw ();
public:
/**
* Constructor.
*
* @param gLiveSupport the GLiveSupport, application object.
* @param bundle the resource bundle holding the localized
* resources for this window
*/
AudioClipWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) throw ();
/**
* Virtual destructor.
*/
virtual
~AudioClipWindow(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace GLiveSupport
} // namespace LiveSupport
#endif // AudioClipWindow_h

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
------------------------------------------------------------------------------*/
@ -85,7 +85,7 @@ using namespace LiveSupport::SchedulerClient;
* respective documentation.
*
* @author $Author: maroy $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
* @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory
* @see StorageClientFactory
@ -216,6 +216,17 @@ class GLiveSupport : public Configurable,
*/
void
logout(void) throw ();
/**
* Accessor function to the storage client held by this object.
*
* @return the storage client held by this object.
*/
Ptr<StorageClientInterface>::Ref
getStorage(void) throw ()
{
return storage;
}
};
/* ================================================= external data structures */

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LoginWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -152,13 +152,7 @@ LoginWindow :: LoginWindow (Ptr<ResourceBundle>::Ref bundle)
// add the table to the window, and show everything
add(*table);
loginLabel->show();
passwordLabel->show();
loginEntry->show();
passwordEntry->show();
okButton->show();
table->show();
show();
show_all();
}
@ -171,7 +165,7 @@ LoginWindow :: ~LoginWindow (void) throw ()
/*------------------------------------------------------------------------------
* Event handler for the button getting clicked.
* Event handler for the OK button getting clicked.
*----------------------------------------------------------------------------*/
void
LoginWindow :: onOkButtonClicked (void) throw ()

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -40,6 +40,7 @@
#include "LiveSupport/Core/TimeConversion.h"
#include "LoginWindow.h"
#include "AudioClipWindow.h"
#include "UiTestMainWindow.h"
@ -82,6 +83,11 @@ UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
logoutButton->signal_clicked().connect(sigc::mem_fun(*this,
&UiTestMainWindow::onLogoutButtonClicked));
// set up the audio clip button
audioClipButton.reset(new Gtk::Button("audioClips"));
audioClipButton->signal_clicked().connect(sigc::mem_fun(*this,
&UiTestMainWindow::onAudioClipButtonClicked));
// set up the quit button
quitButton.reset(new Gtk::Button("quit"));
quitButton->signal_clicked().connect(sigc::mem_fun(*this,
@ -95,18 +101,13 @@ UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
layout->add(*statusLabel);
layout->add(*timeLabel);
layout->add(*loginButton);
layout->add(*audioClipButton);
layout->add(*logoutButton);
layout->add(*quitButton);
add(*layout);
// show everything
statusLabel->show();
timeLabel->show();
loginButton->show();
logoutButton->show();
quitButton->show();
layout->show();
show();
show_all();
// set the timer, that will update timeLabel
setTimer();
@ -150,7 +151,7 @@ UiTestMainWindow :: resetTimer(void) throw ()
/*------------------------------------------------------------------------------
* Event handler for the logout getting clicked.
* Event handler for the logout button getting clicked.
*----------------------------------------------------------------------------*/
void
UiTestMainWindow :: onLogoutButtonClicked (void) throw ()
@ -161,7 +162,7 @@ UiTestMainWindow :: onLogoutButtonClicked (void) throw ()
/*------------------------------------------------------------------------------
* Event handler for the quit getting clicked.
* Event handler for the quit button getting clicked.
*----------------------------------------------------------------------------*/
void
UiTestMainWindow :: onQuitButtonClicked (void) throw ()
@ -226,3 +227,24 @@ UiTestMainWindow :: onUpdateTime(int dummy) throw ()
}
/*------------------------------------------------------------------------------
* Event handler for the audio clip button getting clicked.
*----------------------------------------------------------------------------*/
void
UiTestMainWindow :: onAudioClipButtonClicked (void) throw ()
{
Ptr<ResourceBundle>::Ref bundle;
try {
bundle = getBundle("audioClipWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
Ptr<AudioClipWindow>::Ref audioClipWindow(
new AudioClipWindow(gLiveSupport, bundle));
Gtk::Main::run(*audioClipWindow);
}

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.h,v $
------------------------------------------------------------------------------*/
@ -66,7 +66,7 @@ using namespace LiveSupport::Core;
* A window, enabling interactive testing of UI components.
*
* @author $Author: maroy $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
{
@ -107,6 +107,11 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
*/
Ptr<Gtk::Button>::Ref logoutButton;
/**
* The button to that brings up the audio clip window.
*/
Ptr<Gtk::Button>::Ref audioClipButton;
/**
* The gLiveSupport object, handling the logic of the application.
*/
@ -130,6 +135,12 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
virtual void
onLogoutButtonClicked(void) throw ();
/**
* Signal handler for the audio clip button clicked.
*/
virtual void
onAudioClipButtonClicked(void) throw ();
/**
* Function that updates timeLabel with the current time.
* This is called by GTK at regular intervals.

View File

@ -9,5 +9,15 @@ hu:table
passwordLabel:string { "jelszó:" }
okButtonLabel:string { "Belépés" }
}
audioClipWindow:table
{
idColumnLabel:string { "azonositó" }
lengthColumnLabel:string { "hossz" }
uriColumnLabel:string { "URI" }
tokenColumnLabel:string { "token" }
closeButtonLabel:string { "Bezár" }
}
}

View File

@ -9,5 +9,15 @@ root:table
passwordLabel:string { "password:" }
okButtonLabel:string { "OK" }
}
audioClipWindow:table
{
idColumnLabel:string { "id" }
lengthColumnLabel:string { "length" }
uriColumnLabel:string { "URI" }
tokenColumnLabel:string { "token" }
closeButtonLabel:string { "close" }
}
}