diff --git a/livesupport/products/gLiveSupport/etc/Makefile.in b/livesupport/products/gLiveSupport/etc/Makefile.in index 5553b2eb6..37aade717 100644 --- a/livesupport/products/gLiveSupport/etc/Makefile.in +++ b/livesupport/products/gLiveSupport/etc/Makefile.in @@ -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 \ diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx new file mode 100644 index 000000000..7538022da --- /dev/null +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx @@ -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 +#include + +#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::Ref gLiveSupport, + Ptr::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::Ref djBagContents; + GLiveSupport::PlayableList::iterator it; + GLiveSupport::PlayableList::iterator end; + Ptr::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(); +} + + diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.h b/livesupport/products/gLiveSupport/src/DjBagWindow.h new file mode 100644 index 000000000..26e27a0d9 --- /dev/null +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.h @@ -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 + +#include + +#include + +#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 titleColumn; + + /** + * Constructor. + */ + ModelColumns(void) throw () + { + add(titleColumn); + } + }; + + + /** + * The GLiveSupport object, holding the state of the application. + */ + Ptr::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 treeModel; + + /** + * The box containing the close button. + */ + Gtk::HButtonBox buttonBox; + + /** + * The close button. + */ + Ptr::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::Ref gLiveSupport, + Ptr::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 + diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index 5730ce4bb..50ade4e8c 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -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::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; } diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 569eea3bd..8a65bedf0 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -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 +#include #include #include #include @@ -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::Ref> LanguageMap; + /** + * The type of the list for storing the DjBag contents. + * This is a list holding Ptr::Ref references. + */ + typedef std::list::Ref> PlayableList; + private: /** @@ -143,17 +150,22 @@ class GLiveSupport : public LocalizedConfigurable, /** * The session id for the user. */ - Ptr::Ref sessionId; + Ptr::Ref sessionId; /** * The map of supported languages. */ - Ptr::Ref supportedLanguages; + Ptr::Ref supportedLanguages; /** * The master panel window. */ - Ptr::Ref masterPanel; + Ptr::Ref masterPanel; + + /** + * The contents of a DJ Bag, stored as a list. + */ + Ptr::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::Ref fileName) throw (StorageException); + /** + * Return the DJ Bag contents. + * + * @return the list holding the DJ Bag contents. + */ + Ptr::Ref + getDjBagContents(void) throw () + { + return djBagContents; + } + }; /* ================================================= external data structures */ diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx index d67f75be1..057b84d2a 100644 --- a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx +++ b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx @@ -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::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::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::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::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(); } diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.h b/livesupport/products/gLiveSupport/src/MasterPanelWindow.h index ebf971cf5..6f8060928 100644 --- a/livesupport/products/gLiveSupport/src/MasterPanelWindow.h +++ b/livesupport/products/gLiveSupport/src/MasterPanelWindow.h @@ -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; * * * @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::Ref uploadFileButton; + /** + * The button to invoke the DJ Bag window. + */ + Ptr::Ref djBagButton; + /** * The gLiveSupport object, handling the logic of the application. */ Ptr::Ref gLiveSupport; + /** + * The one and only DJ Bag window. + */ + Ptr::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 */ diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index ee7fb6a14..94d277214 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -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" }