diff --git a/livesupport/products/gLiveSupport/etc/Makefile.in b/livesupport/products/gLiveSupport/etc/Makefile.in index 37aade717..70ddd5b50 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.18 $ +# Version : $Revision: 1.19 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $ # # @configure_input@ @@ -168,7 +168,8 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \ ${TMP_DIR}/AudioClipListWindow.o \ ${TMP_DIR}/PlaylistListWindow.o \ ${TMP_DIR}/UploadFileWindow.o \ - ${TMP_DIR}/DjBagWindow.o + ${TMP_DIR}/DjBagWindow.o \ + ${TMP_DIR}/SimplePlaylistManagementWindow.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 index 7538022da..3728afbe9 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -106,12 +106,34 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, // Add the TreeView's view columns: try { + treeView.append_column(*getResourceUstring("typeColumnLabel"), + modelColumns.typeColumn); treeView.append_column(*getResourceUstring("titleColumnLabel"), modelColumns.titleColumn); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; } + // register the signal handler for treeview entries being clicked + treeView.signal_button_press_event().connect_notify(sigc::mem_fun(*this, + &DjBagWindow::onEntryClicked)); + + + // create the right-click entry context menu + entryMenu.reset(new Gtk::Menu()); + Gtk::Menu::MenuList& menuList = entryMenu->items(); + // register the signal handlers for the popup menu + menuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("addToPlaylistMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onAddToPlaylist))); + menuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("removeMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onRemoveItem))); + entryMenu->accelerate(*this); + + // show showContents(); show_all_children(); @@ -138,6 +160,17 @@ DjBagWindow :: showContents(void) throw () playable = *it; row = *(treeModel->append()); + row[modelColumns.idColumn] = playable->getId(); + switch (playable->getType()) { + case Playable::AudioClipType: + default: + row[modelColumns.typeColumn] = "audioclip"; + break; + + case Playable::PlaylistType: + row[modelColumns.typeColumn] = "playlist"; + break; + } row[modelColumns.titleColumn] = *playable->getTitle(); it++; @@ -163,3 +196,89 @@ DjBagWindow :: onCloseButtonClicked (void) throw () } +/*------------------------------------------------------------------------------ + * Event handler for an entry being clicked in the list + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onEntryClicked (GdkEventButton * event) throw () +{ + if (event->type == GDK_BUTTON_PRESS && event->button == 3) { + // only show the context menu, if something is already selected + Glib::RefPtr refSelection = + treeView.get_selection(); + if (refSelection) { + if (refSelection->get_selected()) { + entryMenu->popup(event->button, event->time); + } + } + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Remove menu item selected from the entry conext menu + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onRemoveItem(void) throw () +{ + Glib::RefPtr refSelection = + treeView.get_selection(); + + if (refSelection) { + Gtk::TreeModel::iterator iter = refSelection->get_selected(); + if (iter) { + Ptr::Ref id = (*iter)[modelColumns.idColumn]; + + removeItem(id); + showContents(); + } + } +} + + +/*------------------------------------------------------------------------------ + * Remove an item from the dj bag + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: removeItem(Ptr::Ref id) throw () +{ + Ptr::Ref djBagContents; + GLiveSupport::PlayableList::iterator it; + GLiveSupport::PlayableList::iterator end; + + djBagContents = gLiveSupport->getDjBagContents(); + it = djBagContents->begin(); + end = djBagContents->end(); + while (it != end) { + Ptr::Ref playable = *it; + + if (*playable->getId() == *id) { + djBagContents->erase(it); + break; + } + + it++; + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Add To Playlist menu item selected from the + * entry conext menu + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onAddToPlaylist(void) throw () +{ + Glib::RefPtr refSelection = + treeView.get_selection(); + + if (refSelection) { + Gtk::TreeModel::iterator iter = refSelection->get_selected(); + if (iter) { + Ptr::Ref id = (*iter)[modelColumns.idColumn]; + + gLiveSupport->addToPlaylist(id); + } + } +} + diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.h b/livesupport/products/gLiveSupport/src/DjBagWindow.h index 26e27a0d9..9e72e2e4c 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.h +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -68,7 +68,7 @@ using namespace LiveSupport::Core; * playlists. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class DjBagWindow : public Gtk::Window, public LocalizedObject { @@ -80,21 +80,33 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject * Lists one clip per row. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class ModelColumns : public Gtk::TreeModel::ColumnRecord { public: + /** + * The column for the id of the audio clip or playlist. + */ + Gtk::TreeModelColumn::Ref> idColumn; + + /** + * The column for the type of the entry in the list + */ + Gtk::TreeModelColumn typeColumn; + /** * The column for the title of the audio clip or playlist. */ - Gtk::TreeModelColumn titleColumn; + Gtk::TreeModelColumn titleColumn; /** * Constructor. */ ModelColumns(void) throw () { + add(idColumn); + add(typeColumn); add(titleColumn); } }; @@ -140,12 +152,40 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject */ Ptr::Ref closeButton; + /** + * The right-click context menu, that comes up when right-clicking + * an entry in the entry list. + */ + Ptr::Ref entryMenu; + /** * Signal handler for the close button clicked. */ virtual void onCloseButtonClicked(void) throw (); + /** + * Signal handler for the mouse clicked on one of the entries. + * + * @param event the button event recieved + */ + virtual void + onEntryClicked(GdkEventButton * event) throw (); + + /** + * Signal handler for the "remove" menu item selected from + * the entry context menu. + */ + virtual void + onRemoveItem(void) throw (); + + /** + * Signal handler for the "add to playlist" menu item selected from + * the entry context menu. + */ + virtual void + onAddToPlaylist(void) throw (); + public: /** @@ -170,6 +210,13 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject void showContents(void) throw (); + /** + * Remove an item from the dj bag. + * + * @param id the id of the item to remove. + */ + void + removeItem(Ptr::Ref id) throw (); }; /* ================================================= external data structures */ diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index 50ade4e8c..e2bd03296 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.10 $ + Version : $Revision: 1.11 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -312,12 +312,8 @@ GLiveSupport :: uploadFile(Ptr::Ref title, throw StorageException(e.what()); } - // get a unique id - Ptr::Ref uid = UniqueId::generateId(); - // create and upload an AudioClip object - Ptr::Ref audioClip(new AudioClip(uid, - title, + Ptr::Ref audioClip(new AudioClip(title, playlength, uri)); storage->storeAudioClip(sessionId, audioClip); @@ -329,3 +325,52 @@ GLiveSupport :: uploadFile(Ptr::Ref title, return audioClip; } + +/*------------------------------------------------------------------------------ + * Upload a file to the server. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: addToPlaylist(Ptr::Ref id) throw () +{ + if (!editedPlaylist.get()) { + editedPlaylist = storage->createPlaylist(sessionId); + } + + // for some wierd reason, the storage functions won't accept + // Ptr::Ref, just a non-const version + Ptr::Ref uid(new UniqueId(id->getId())); + + // append the appropriate playable object to the end of the playlist + if (storage->existsPlaylist(sessionId, uid)) { + Ptr::Ref playlist = storage->getPlaylist(sessionId, uid); + editedPlaylist->addPlaylist(playlist, editedPlaylist->getPlaylength()); + } else if (storage->existsAudioClip(sessionId, uid)) { + Ptr::Ref clip = storage->getAudioClip(sessionId, uid); + editedPlaylist->addAudioClip(clip, editedPlaylist->getPlaylength()); + } + + masterPanel->updateSimplePlaylistMgmtWindow(); +} + + +/*------------------------------------------------------------------------------ + * Save the currently edited playlist in storage + *----------------------------------------------------------------------------*/ +Ptr::Ref +LiveSupport :: GLiveSupport :: +GLiveSupport :: uploadPlaylist(Ptr::Ref title) + throw (StorageException) +{ + editedPlaylist->setTitle(title); + + storage->savePlaylist(sessionId, editedPlaylist); + + // add the saved playlist to the DJ Bag, and update it + djBagContents->push_front(editedPlaylist); + masterPanel->updateDjBagWindow(); + + return editedPlaylist; +} + + diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 8a65bedf0..9a35bbebe 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.12 $ + Version : $Revision: 1.13 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -95,7 +95,7 @@ class MasterPanelWindow; * respective documentation. * * @author $Author: maroy $ - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -167,6 +167,11 @@ class GLiveSupport : public LocalizedConfigurable, */ Ptr::Ref djBagContents; + /** + * The one and only playlist that may be edited at any one time. + */ + Ptr::Ref editedPlaylist; + /** * Read a supportedLanguages configuration element, * and fill the supportedLanguages map with its contents. @@ -352,6 +357,40 @@ class GLiveSupport : public LocalizedConfigurable, return djBagContents; } + /** + * Return the currently edited playlist. + * + * @return the currenlty edited playlist, or a reference to 0 + * if no playlist is edited + */ + Ptr::Ref + getEditedPlaylist(void) throw () + { + return editedPlaylist; + } + + /** + * Add a playable item to the currently open playlist. + * If there is no currently open playlist, open the simple playlist + * management window with a new playlist, holding only this one + * entry. + * + * @param id the id of the playable object to add to the playlist. + */ + void + addToPlaylist(Ptr::Ref id) throw (); + + /** + * Save the currently edited playlist in storage. + * + * @param title the title of the audio clip. + * @return the audio clip that was uploaded. + * @exception StorageException on upload failures. + */ + Ptr::Ref + uploadPlaylist(Ptr::Ref title) + throw (StorageException); + }; /* ================================================= external data structures */ diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx index 057b84d2a..7142446a4 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.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -76,6 +76,8 @@ MasterPanelWindow :: MasterPanelWindow (Ptr::Ref gLiveSupport, userInfoWidget.reset(new MasterPanelUserInfoWidget(gLiveSupport, bundle)); uploadFileButton.reset(new Gtk::Button("upload file")); djBagButton.reset(new Gtk::Button("dj bag")); + simplePlaylistMgmtButton.reset( + new Gtk::Button("simple playlist management")); // set up the time label timeWidget.reset(new Gtk::Label("time")); @@ -85,16 +87,17 @@ MasterPanelWindow :: MasterPanelWindow (Ptr::Ref gLiveSupport, // set up the main window, and show everything set_border_width(10); - layout->attach(*lsLogoWidget, 0, 1, 0, 2); - layout->attach(*timeWidget, 1, 2, 0, 2); - layout->attach(*nowPlayingWidget, 2, 3, 0, 2); - layout->attach(*vuMeterWidget, 3, 4, 0, 1); - layout->attach(*nextPlayingWidget, 3, 4, 1, 2); - layout->attach(*onAirWidget , 4, 5, 0, 1); - 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); + layout->attach(*lsLogoWidget, 0, 1, 0, 2); + layout->attach(*timeWidget, 1, 2, 0, 2); + layout->attach(*nowPlayingWidget, 2, 3, 0, 2); + layout->attach(*vuMeterWidget, 3, 4, 0, 1); + layout->attach(*nextPlayingWidget, 3, 4, 1, 2); + layout->attach(*onAirWidget, 4, 5, 0, 1); + 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); + layout->attach(*simplePlaylistMgmtButton, 2, 3, 2, 3); add(*layout); @@ -106,6 +109,11 @@ MasterPanelWindow :: MasterPanelWindow (Ptr::Ref gLiveSupport, &MasterPanelWindow::onUploadFileButtonClicked)); djBagButton->signal_clicked().connect(sigc::mem_fun(*this, &MasterPanelWindow::onDjBagButtonClicked)); + djBagButton->signal_clicked().connect(sigc::mem_fun(*this, + &MasterPanelWindow::onDjBagButtonClicked)); + simplePlaylistMgmtButton->signal_clicked().connect( + sigc::mem_fun(*this, + &MasterPanelWindow::onSimplePlaylistMgmtButtonClicked)); // show what's there to see showAnonymousUI(); @@ -240,6 +248,31 @@ MasterPanelWindow :: onDjBagButtonClicked(void) throw () } +/*------------------------------------------------------------------------------ + * The event when the Simple Playlist Management button has been clicked. + *----------------------------------------------------------------------------*/ +void +MasterPanelWindow :: onSimplePlaylistMgmtButtonClicked(void) throw () +{ + if (!simplePlaylistMgmtWindow.get()) { + Ptr::Ref bundle; + try { + bundle = getBundle("simplePlaylistManagementWindow"); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + return; + } + + simplePlaylistMgmtWindow.reset( + new SimplePlaylistManagementWindow(gLiveSupport, bundle)); + } + + if (!simplePlaylistMgmtWindow->is_visible()) { + simplePlaylistMgmtWindow->show(); + } +} + + /*------------------------------------------------------------------------------ * Show only the UI components that are visible when no one is logged in *----------------------------------------------------------------------------*/ @@ -249,6 +282,7 @@ MasterPanelWindow :: showAnonymousUI(void) throw () show_all(); uploadFileButton->hide(); djBagButton->hide(); + simplePlaylistMgmtButton->hide(); } diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.h b/livesupport/products/gLiveSupport/src/MasterPanelWindow.h index 6f8060928..aafabebd5 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.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -50,6 +50,7 @@ #include "GLiveSupport.h" #include "MasterPanelUserInfoWidget.h" #include "DjBagWindow.h" +#include "SimplePlaylistManagementWindow.h" namespace LiveSupport { @@ -77,11 +78,12 @@ using namespace LiveSupport::Core; * | | | | | | | + next ----+ + user info ------------+ | * | | | | | | | | playing | | | | * | +---------+ +------+ +---------+ +----------+ +-----------------------+ | + * | +-- button bar -------------------------------------------------------+ | * +-------------------------------------------------------------------------+ * * * @author $Author: maroy $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class MasterPanelWindow : public Gtk::Window, public LocalizedObject { @@ -147,6 +149,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject */ Ptr::Ref djBagButton; + /** + * The button to invoke the Simple Playlist Management Window. + */ + Ptr::Ref simplePlaylistMgmtButton; + /** * The gLiveSupport object, handling the logic of the application. */ @@ -157,6 +164,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject */ Ptr::Ref djBagWindow; + /** + * The one and only simple playlist management window. + */ + Ptr::Ref simplePlaylistMgmtWindow; + /** * Function that updates timeLabel with the current time. * This is called by GTK at regular intervals. @@ -198,6 +210,13 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject virtual void onDjBagButtonClicked(void) throw (); + /** + * Function to catch the event of the Simple Playlist + * Management button being pressed. + */ + virtual void + onSimplePlaylistMgmtButtonClicked(void) throw (); + public: /** @@ -248,9 +267,22 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject void updateDjBagWindow(void) throw () { + // this will create, open and display the window. + onDjBagButtonClicked(); djBagWindow->showContents(); } + /** + * Update the Simple Playlist Management Window + */ + void + updateSimplePlaylistMgmtWindow(void) throw () + { + // this will create, open and display the window. + onSimplePlaylistMgmtButtonClicked(); + simplePlaylistMgmtWindow->showContents(); + } + }; /* ================================================= external data structures */ diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx new file mode 100644 index 000000000..45940caab --- /dev/null +++ b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx @@ -0,0 +1,195 @@ +/*------------------------------------------------------------------------------ + + 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/SimplePlaylistManagementWindow.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include +#include + +#include "SimplePlaylistManagementWindow.h" + + +using namespace Glib; + +using namespace LiveSupport::Core; +using namespace LiveSupport::GLiveSupport; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Constructor. + *----------------------------------------------------------------------------*/ +SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( + Ptr::Ref gLiveSupport, + Ptr::Ref bundle) + throw () + : LocalizedObject(bundle) +{ + this->gLiveSupport = gLiveSupport; + + try { + set_title(*getResourceUstring("windowTitle")); + nameLabel.reset(new Gtk::Label(*getResourceUstring("nameLabel"))); + saveButton.reset(new Gtk::Button( + *getResourceUstring("saveButtonLabel"))); + closeButton.reset(new Gtk::Button( + *getResourceUstring("closeButtonLabel"))); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + } + + nameEntry.reset(new Gtk::Entry()); + entriesScrolledWindow.reset(new Gtk::ScrolledWindow()); + entriesView.reset(new Gtk::TreeView()); + + // set up the entry scrolled window, with the entry treeview inside. + entriesScrolledWindow->add(*entriesView); + entriesScrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC); + + // Create the Tree model: + entriesModel = Gtk::ListStore::create(modelColumns); + entriesView->set_model(entriesModel); + + // Add the TreeView's view columns: + try { + entriesView->append_column(*getResourceUstring("titleColumnLabel"), + modelColumns.titleColumn); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + } + + statusBar.reset(new Gtk::Label("status bar")); + + // set up the layout + layout.reset(new Gtk::Table()); + + set_border_width(10); + layout->attach(*nameLabel, 0, 1, 0, 1); + layout->attach(*nameEntry, 1, 2, 0, 1); + layout->attach(*entriesScrolledWindow, 0, 2, 1, 2); + layout->attach(*saveButton, 1, 2, 2, 3); + layout->attach(*closeButton, 1, 2, 3, 4); + layout->attach(*statusBar, 0, 2, 4, 5); + + add(*layout); + + // Register the signal handlers + saveButton->signal_clicked().connect(sigc::mem_fun(*this, + &SimplePlaylistManagementWindow::onSaveButtonClicked)); + closeButton->signal_clicked().connect(sigc::mem_fun(*this, + &SimplePlaylistManagementWindow::onCloseButtonClicked)); + + // show all + show_all(); +} + + +/*------------------------------------------------------------------------------ + * Destructor. + *----------------------------------------------------------------------------*/ +SimplePlaylistManagementWindow :: ~SimplePlaylistManagementWindow (void) + throw () +{ +} + + +/*------------------------------------------------------------------------------ + * Event handler for the save button getting clicked. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () +{ + try { + Ptr::Ref title; + Ptr::Ref playlist; + + title.reset(new Glib::ustring(nameEntry->get_text())); + + playlist = gLiveSupport->uploadPlaylist(title); + + Glib::ustring statusText("uploaded playlist "); + statusText += *playlist->getTitle(); + statusBar->set_text(statusText); + } catch (StorageException &e) { + statusBar->set_text(e.what()); + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the close button getting clicked. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: onCloseButtonClicked (void) throw () +{ + hide(); +} + + +/*------------------------------------------------------------------------------ + * Show the contents of the currently edited playlist. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: showContents(void) throw () +{ + Ptr::Ref playlist; + Playlist::const_iterator it; + Playlist::const_iterator end; + + playlist = gLiveSupport->getEditedPlaylist(); + it = playlist->begin(); + end = playlist->end(); + entriesModel->clear(); + while (it != end) { + Ptr::Ref playlistElem = it->second; + Ptr::Ref playable = playlistElem->getPlayable(); + Gtk::TreeModel::Row row = *(entriesModel->append()); + + row[modelColumns.idColumn] = playable->getId(); + row[modelColumns.titleColumn] = *playable->getTitle(); + + it++; + } +} + + diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h new file mode 100644 index 000000000..32e6d6f40 --- /dev/null +++ b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h @@ -0,0 +1,229 @@ +/*------------------------------------------------------------------------------ + + 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/SimplePlaylistManagementWindow.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef SimplePlaylistManagementWindow_h +#define SimplePlaylistManagementWindow_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 Simple Playlist Management Window. Allow to edit playlists in + * a top-down view fashion. + * + * The layout of this window is roughly the following: + *

+ *  +--- simple playlist management window --------+
+ *  | name:    +-- name input ----+                |
+ *  | +-- playlist entries -------+                |
+ *  | | +-- entry1 -------------+ |                |
+ *  | | +-- entry2 -------------+ |                |
+ *  | |  ...                      |                |
+ *  | +---------------------------+                |
+ *  | +-- save button ------------+                |
+ *  | +-- close button -----------+                |
+ *  | +-- status bar -------------+                |
+ *  +----------------------------------------------+
+ *  
+ * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + */ +class SimplePlaylistManagementWindow : public Gtk::Window, + public LocalizedObject +{ + + protected: + + /** + * The columns model needed by Gtk::TreeView. + * Lists one playlist entry 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 or playlist. + */ + Gtk::TreeModelColumn::Ref> idColumn; + + /** + * The column for the title of the audio clip or playlist. + */ + Gtk::TreeModelColumn titleColumn; + + /** + * Constructor. + */ + ModelColumns(void) throw () + { + add(idColumn); + add(titleColumn); + } + }; + + + /** + * The GLiveSupport object, holding the state of the application. + */ + Ptr::Ref gLiveSupport; + + /** + * The column model. + */ + ModelColumns modelColumns; + + /** + * The layout used in the window. + */ + Ptr::Ref layout; + + /** + * The label for the name entry. + */ + Ptr::Ref nameLabel; + + /** + * The test input entry for the name of the playlist. + */ + Ptr::Ref nameEntry; + + /** + * A scrolled window, so that the entry list can be scrolled. + */ + Ptr::Ref entriesScrolledWindow; + + /** + * The entry tree view, now only showing rows. + */ + Ptr::Ref entriesView; + + /** + * The entry tree model, as a GTK reference. + */ + Glib::RefPtr entriesModel; + + /** + * The save button. + */ + Ptr::Ref saveButton; + + /** + * The close button. + */ + Ptr::Ref closeButton; + + /** + * The status bar. + */ + Ptr::Ref statusBar; + + /** + * Signal handler for the save button clicked. + */ + virtual void + onSaveButtonClicked(void) throw (); + + /** + * 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 + */ + SimplePlaylistManagementWindow(Ptr::Ref gLiveSupport, + Ptr::Ref bundle) + throw (); + + /** + * Virtual destructor. + */ + virtual + ~SimplePlaylistManagementWindow(void) throw (); + + /** + * Show / update the contents of the playlist management window. + */ + virtual void + showContents(void) throw (); + +}; + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace GLiveSupport +} // namespace LiveSupport + +#endif // SimplePlaylistManagementWindow_h + diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index 94d277214..c8396422d 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -31,8 +31,12 @@ root:table { windowTitle:string { "LiveSupport Dj Bag" } + typeColumnLabel:string { "type" } titleColumnLabel:string { "title" } closeButtonLabel:string { "close" } + + removeMenuItem:string { "_Remove" } + addToPlaylistMenuItem:string { "_Add To Playlist" } } playlistListWindow:table @@ -49,5 +53,16 @@ root:table closeButtonLabel:string { "close" } } + + simplePlaylistManagementWindow:table + { + windowTitle:string { "LiveSupport Dj Bag" } + + titleColumnLabel:string { "title" } + nameLabel:string { "name" } + saveButtonLabel:string { "save" } + closeButtonLabel:string { "close" } + } + }