added DJ Bag window

This commit is contained in:
maroy 2005-01-04 10:50:12 +00:00
parent b2d6de1344
commit 39acf9f58f
8 changed files with 456 additions and 11 deletions

View file

@ -21,7 +21,7 @@
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.17 $
# Version : $Revision: 1.18 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
#
# @configure_input@
@ -167,7 +167,8 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/LoginWindow.o \
${TMP_DIR}/AudioClipListWindow.o \
${TMP_DIR}/PlaylistListWindow.o \
${TMP_DIR}/UploadFileWindow.o
${TMP_DIR}/UploadFileWindow.o \
${TMP_DIR}/DjBagWindow.o
G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
${TMP_DIR}/${PACKAGE_NAME}_en.res \

View file

@ -0,0 +1,165 @@
/*------------------------------------------------------------------------------
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/DjBagWindow.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <iostream>
#include <stdexcept>
#include "DjBagWindow.h"
using namespace Glib;
using namespace LiveSupport::Core;
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
DjBagWindow :: DjBagWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle)
throw ()
: LocalizedObject(bundle)
{
this->gLiveSupport = gLiveSupport;
try {
set_title(*getResourceUstring("windowTitle"));
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,
&DjBagWindow::onCloseButtonClicked));
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("titleColumnLabel"),
modelColumns.titleColumn);
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
}
showContents();
show_all_children();
}
/*------------------------------------------------------------------------------
* Show all audio clips
*----------------------------------------------------------------------------*/
void
DjBagWindow :: showContents(void) throw ()
{
Ptr<GLiveSupport::PlayableList>::Ref djBagContents;
GLiveSupport::PlayableList::iterator it;
GLiveSupport::PlayableList::iterator end;
Ptr<Playable>::Ref playable;
Gtk::TreeModel::Row row;
djBagContents = gLiveSupport->getDjBagContents();
it = djBagContents->begin();
end = djBagContents->end();
treeModel->clear();
while (it != end) {
playable = *it;
row = *(treeModel->append());
row[modelColumns.titleColumn] = *playable->getTitle();
it++;
}
}
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
DjBagWindow :: ~DjBagWindow (void) throw ()
{
}
/*------------------------------------------------------------------------------
* Event handler for the close button getting clicked.
*----------------------------------------------------------------------------*/
void
DjBagWindow :: onCloseButtonClicked (void) throw ()
{
hide();
}

View file

@ -0,0 +1,185 @@
/*------------------------------------------------------------------------------
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/DjBagWindow.h,v $
------------------------------------------------------------------------------*/
#ifndef DjBagWindow_h
#define DjBagWindow_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 "LiveSupport/Core/LocalizedObject.h"
#include "GLiveSupport.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* The DJ Bag window, showing recent and relevant audio clips and
* playlists.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class DjBagWindow : public Gtk::Window, public LocalizedObject
{
protected:
/**
* The columns model needed by Gtk::TreeView.
* Lists one clip per row.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
*/
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
/**
* The column for the title of the audio clip or playlist.
*/
Gtk::TreeModelColumn<Glib::ustring> titleColumn;
/**
* Constructor.
*/
ModelColumns(void) throw ()
{
add(titleColumn);
}
};
/**
* 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 ();
public:
/**
* Constructor.
*
* @param gLiveSupport the GLiveSupport, application object.
* @param bundle the resource bundle holding the localized
* resources for this window
*/
DjBagWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle) throw ();
/**
* Virtual destructor.
*/
virtual
~DjBagWindow(void) throw ();
/**
* Update the window contents, with the contents of the dj bag.
*/
void
showContents(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace GLiveSupport
} // namespace LiveSupport
#endif // DjBagWindow_h

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.9 $
Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
------------------------------------------------------------------------------*/
@ -322,6 +322,10 @@ GLiveSupport :: uploadFile(Ptr<const Glib::ustring>::Ref title,
uri));
storage->storeAudioClip(sessionId, audioClip);
// add the uploaded file to the DJ Bag, and update it
djBagContents->push_front(audioClip);
masterPanel->updateDjBagWindow();
return audioClip;
}

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.11 $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
------------------------------------------------------------------------------*/
@ -41,6 +41,7 @@
#endif
#include <string>
#include <list>
#include <map>
#include <boost/enable_shared_from_this.hpp>
#include <unicode/resbund.h>
@ -94,7 +95,7 @@ class MasterPanelWindow;
* respective documentation.
*
* @author $Author: maroy $
* @version $Revision: 1.11 $
* @version $Revision: 1.12 $
* @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory
* @see StorageClientFactory
@ -113,6 +114,12 @@ class GLiveSupport : public LocalizedConfigurable,
typedef std::map<const std::string,
Ptr<const UnicodeString>::Ref> LanguageMap;
/**
* The type of the list for storing the DjBag contents.
* This is a list holding Ptr<Playable>::Ref references.
*/
typedef std::list<Ptr<Playable>::Ref> PlayableList;
private:
/**
@ -143,17 +150,22 @@ class GLiveSupport : public LocalizedConfigurable,
/**
* The session id for the user.
*/
Ptr<SessionId>::Ref sessionId;
Ptr<SessionId>::Ref sessionId;
/**
* The map of supported languages.
*/
Ptr<LanguageMap>::Ref supportedLanguages;
Ptr<LanguageMap>::Ref supportedLanguages;
/**
* The master panel window.
*/
Ptr<MasterPanelWindow>::Ref masterPanel;
Ptr<MasterPanelWindow>::Ref masterPanel;
/**
* The contents of a DJ Bag, stored as a list.
*/
Ptr<PlayableList>::Ref djBagContents;
/**
* Read a supportedLanguages configuration element,
@ -174,6 +186,7 @@ class GLiveSupport : public LocalizedConfigurable,
*/
GLiveSupport(void) throw ()
{
djBagContents.reset(new PlayableList());
}
/**
@ -328,6 +341,17 @@ class GLiveSupport : public LocalizedConfigurable,
Ptr<const std::string>::Ref fileName)
throw (StorageException);
/**
* Return the DJ Bag contents.
*
* @return the list holding the DJ Bag contents.
*/
Ptr<PlayableList>::Ref
getDjBagContents(void) throw ()
{
return djBagContents;
}
};
/* ================================================= external data structures */

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/MasterPanelWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -40,6 +40,7 @@
#include "LiveSupport/Core/TimeConversion.h"
#include "UploadFileWindow.h"
#include "DjBagWindow.h"
#include "MasterPanelWindow.h"
@ -74,6 +75,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
radioLogoWidget.reset(new Gtk::Label("radio logo"));
userInfoWidget.reset(new MasterPanelUserInfoWidget(gLiveSupport, bundle));
uploadFileButton.reset(new Gtk::Button("upload file"));
djBagButton.reset(new Gtk::Button("dj bag"));
// set up the time label
timeWidget.reset(new Gtk::Label("time"));
@ -92,6 +94,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
layout->attach(*radioLogoWidget , 5, 6, 0, 1);
layout->attach(*userInfoWidget , 4, 6, 1, 2);
layout->attach(*uploadFileButton, 0, 1, 2, 3);
layout->attach(*djBagButton, 1, 2, 2, 3);
add(*layout);
@ -101,6 +104,8 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
// bind events
uploadFileButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onUploadFileButtonClicked));
djBagButton->signal_clicked().connect(sigc::mem_fun(*this,
&MasterPanelWindow::onDjBagButtonClicked));
// show what's there to see
showAnonymousUI();
@ -211,6 +216,30 @@ MasterPanelWindow :: onUploadFileButtonClicked(void) throw ()
}
/*------------------------------------------------------------------------------
* The event when the DJ Bag button has been clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: onDjBagButtonClicked(void) throw ()
{
if (!djBagWindow.get()) {
Ptr<ResourceBundle>::Ref bundle;
try {
bundle = getBundle("djBagWindow");
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
return;
}
djBagWindow.reset(new DjBagWindow(gLiveSupport, bundle));
}
if (!djBagWindow->is_visible()) {
djBagWindow->show();
}
}
/*------------------------------------------------------------------------------
* Show only the UI components that are visible when no one is logged in
*----------------------------------------------------------------------------*/
@ -219,6 +248,7 @@ MasterPanelWindow :: showAnonymousUI(void) throw ()
{
show_all();
uploadFileButton->hide();
djBagButton->hide();
}

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/MasterPanelWindow.h,v $
------------------------------------------------------------------------------*/
@ -49,6 +49,8 @@
#include "GLiveSupport.h"
#include "MasterPanelUserInfoWidget.h"
#include "DjBagWindow.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -79,7 +81,7 @@ using namespace LiveSupport::Core;
* </code></pre>
*
* @author $Author: maroy $
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
class MasterPanelWindow : public Gtk::Window, public LocalizedObject
{
@ -140,11 +142,21 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
*/
Ptr<Gtk::Button>::Ref uploadFileButton;
/**
* The button to invoke the DJ Bag window.
*/
Ptr<Gtk::Button>::Ref djBagButton;
/**
* The gLiveSupport object, handling the logic of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The one and only DJ Bag window.
*/
Ptr<DjBagWindow>::Ref djBagWindow;
/**
* Function that updates timeLabel with the current time.
* This is called by GTK at regular intervals.
@ -179,6 +191,13 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
virtual void
onUploadFileButtonClicked(void) throw ();
/**
* Function to catch the event of the DJ Bag button being
* pressed.
*/
virtual void
onDjBagButtonClicked(void) throw ();
public:
/**
@ -223,6 +242,15 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
void
showLoggedInUI(void) throw ();
/**
* Update the DJ Bag window.
*/
void
updateDjBagWindow(void) throw ()
{
djBagWindow->showContents();
}
};
/* ================================================= external data structures */

View file

@ -27,6 +27,14 @@ root:table
closeButtonLabel:string { "close" }
}
djBagWindow:table
{
windowTitle:string { "LiveSupport Dj Bag" }
titleColumnLabel:string { "title" }
closeButtonLabel:string { "close" }
}
playlistListWindow:table
{
windowTitle:string { "LiveSupport Playlist Window" }