added simple playlist management window
This commit is contained in:
parent
0abd972d26
commit
6fd2b02e01
|
@ -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 \
|
||||
|
|
|
@ -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<GLiveSupport>::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<Gtk::TreeView::Selection> 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<Gtk::TreeView::Selection> refSelection =
|
||||
treeView.get_selection();
|
||||
|
||||
if (refSelection) {
|
||||
Gtk::TreeModel::iterator iter = refSelection->get_selected();
|
||||
if (iter) {
|
||||
Ptr<const UniqueId>::Ref id = (*iter)[modelColumns.idColumn];
|
||||
|
||||
removeItem(id);
|
||||
showContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Remove an item from the dj bag
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DjBagWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw ()
|
||||
{
|
||||
Ptr<GLiveSupport::PlayableList>::Ref djBagContents;
|
||||
GLiveSupport::PlayableList::iterator it;
|
||||
GLiveSupport::PlayableList::iterator end;
|
||||
|
||||
djBagContents = gLiveSupport->getDjBagContents();
|
||||
it = djBagContents->begin();
|
||||
end = djBagContents->end();
|
||||
while (it != end) {
|
||||
Ptr<Playable>::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<Gtk::TreeView::Selection> refSelection =
|
||||
treeView.get_selection();
|
||||
|
||||
if (refSelection) {
|
||||
Gtk::TreeModel::iterator iter = refSelection->get_selected();
|
||||
if (iter) {
|
||||
Ptr<const UniqueId>::Ref id = (*iter)[modelColumns.idColumn];
|
||||
|
||||
gLiveSupport->addToPlaylist(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,11 +80,21 @@ 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<Ptr<const UniqueId>::Ref> idColumn;
|
||||
|
||||
/**
|
||||
* The column for the type of the entry in the list
|
||||
*/
|
||||
Gtk::TreeModelColumn<Glib::ustring> typeColumn;
|
||||
|
||||
/**
|
||||
* The column for the title of the audio clip or playlist.
|
||||
*/
|
||||
|
@ -95,6 +105,8 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject
|
|||
*/
|
||||
ModelColumns(void) throw ()
|
||||
{
|
||||
add(idColumn);
|
||||
add(typeColumn);
|
||||
add(titleColumn);
|
||||
}
|
||||
};
|
||||
|
@ -140,12 +152,40 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject
|
|||
*/
|
||||
Ptr<Gtk::Button>::Ref closeButton;
|
||||
|
||||
/**
|
||||
* The right-click context menu, that comes up when right-clicking
|
||||
* an entry in the entry list.
|
||||
*/
|
||||
Ptr<Gtk::Menu>::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<const UniqueId>::Ref id) throw ();
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
|
@ -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<const Glib::ustring>::Ref title,
|
|||
throw StorageException(e.what());
|
||||
}
|
||||
|
||||
// get a unique id
|
||||
Ptr<UniqueId>::Ref uid = UniqueId::generateId();
|
||||
|
||||
// create and upload an AudioClip object
|
||||
Ptr<AudioClip>::Ref audioClip(new AudioClip(uid,
|
||||
title,
|
||||
Ptr<AudioClip>::Ref audioClip(new AudioClip(title,
|
||||
playlength,
|
||||
uri));
|
||||
storage->storeAudioClip(sessionId, audioClip);
|
||||
|
@ -329,3 +325,52 @@ GLiveSupport :: uploadFile(Ptr<const Glib::ustring>::Ref title,
|
|||
return audioClip;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Upload a file to the server.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: addToPlaylist(Ptr<const UniqueId>::Ref id) throw ()
|
||||
{
|
||||
if (!editedPlaylist.get()) {
|
||||
editedPlaylist = storage->createPlaylist(sessionId);
|
||||
}
|
||||
|
||||
// for some wierd reason, the storage functions won't accept
|
||||
// Ptr<const UniqueId>::Ref, just a non-const version
|
||||
Ptr<UniqueId>::Ref uid(new UniqueId(id->getId()));
|
||||
|
||||
// append the appropriate playable object to the end of the playlist
|
||||
if (storage->existsPlaylist(sessionId, uid)) {
|
||||
Ptr<Playlist>::Ref playlist = storage->getPlaylist(sessionId, uid);
|
||||
editedPlaylist->addPlaylist(playlist, editedPlaylist->getPlaylength());
|
||||
} else if (storage->existsAudioClip(sessionId, uid)) {
|
||||
Ptr<AudioClip>::Ref clip = storage->getAudioClip(sessionId, uid);
|
||||
editedPlaylist->addAudioClip(clip, editedPlaylist->getPlaylength());
|
||||
}
|
||||
|
||||
masterPanel->updateSimplePlaylistMgmtWindow();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Save the currently edited playlist in storage
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Playlist>::Ref
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: uploadPlaylist(Ptr<const Glib::ustring>::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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<PlayableList>::Ref djBagContents;
|
||||
|
||||
/**
|
||||
* The one and only playlist that may be edited at any one time.
|
||||
*/
|
||||
Ptr<Playlist>::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<Playlist>::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<const UniqueId>::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<Playlist>::Ref
|
||||
uploadPlaylist(Ptr<const Glib::ustring>::Ref title)
|
||||
throw (StorageException);
|
||||
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
|
@ -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<GLiveSupport>::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"));
|
||||
|
@ -95,6 +97,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
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<GLiveSupport>::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<ResourceBundle>::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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 -------------------------------------------------------+ |
|
||||
* +-------------------------------------------------------------------------+
|
||||
* </code></pre>
|
||||
*
|
||||
* @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<Gtk::Button>::Ref djBagButton;
|
||||
|
||||
/**
|
||||
* The button to invoke the Simple Playlist Management Window.
|
||||
*/
|
||||
Ptr<Gtk::Button>::Ref simplePlaylistMgmtButton;
|
||||
|
||||
/**
|
||||
* The gLiveSupport object, handling the logic of the application.
|
||||
*/
|
||||
|
@ -157,6 +164,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
*/
|
||||
Ptr<DjBagWindow>::Ref djBagWindow;
|
||||
|
||||
/**
|
||||
* The one and only simple playlist management window.
|
||||
*/
|
||||
Ptr<SimplePlaylistManagementWindow>::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 */
|
||||
|
|
|
@ -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 <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#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<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::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<const Glib::ustring>::Ref title;
|
||||
Ptr<Playlist>::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<Playlist>::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<PlaylistElement>::Ref playlistElem = it->second;
|
||||
Ptr<Playable>::Ref playable = playlistElem->getPlayable();
|
||||
Gtk::TreeModel::Row row = *(entriesModel->append());
|
||||
|
||||
row[modelColumns.idColumn] = playable->getId();
|
||||
row[modelColumns.titleColumn] = *playable->getTitle();
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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 <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 Simple Playlist Management Window. Allow to edit playlists in
|
||||
* a top-down view fashion.
|
||||
*
|
||||
* The layout of this window is roughly the following:
|
||||
* <pre><code>
|
||||
* +--- simple playlist management window --------+
|
||||
* | name: +-- name input ----+ |
|
||||
* | +-- playlist entries -------+ |
|
||||
* | | +-- entry1 -------------+ | |
|
||||
* | | +-- entry2 -------------+ | |
|
||||
* | | ... | |
|
||||
* | +---------------------------+ |
|
||||
* | +-- save button ------------+ |
|
||||
* | +-- close button -----------+ |
|
||||
* | +-- status bar -------------+ |
|
||||
* +----------------------------------------------+
|
||||
* </code></pre>
|
||||
*
|
||||
* @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<Ptr<const UniqueId>::Ref> idColumn;
|
||||
|
||||
/**
|
||||
* The column for the title of the audio clip or playlist.
|
||||
*/
|
||||
Gtk::TreeModelColumn<Glib::ustring> titleColumn;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
ModelColumns(void) throw ()
|
||||
{
|
||||
add(idColumn);
|
||||
add(titleColumn);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The GLiveSupport object, holding the state of the application.
|
||||
*/
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport;
|
||||
|
||||
/**
|
||||
* The column model.
|
||||
*/
|
||||
ModelColumns modelColumns;
|
||||
|
||||
/**
|
||||
* The layout used in the window.
|
||||
*/
|
||||
Ptr<Gtk::Table>::Ref layout;
|
||||
|
||||
/**
|
||||
* The label for the name entry.
|
||||
*/
|
||||
Ptr<Gtk::Label>::Ref nameLabel;
|
||||
|
||||
/**
|
||||
* The test input entry for the name of the playlist.
|
||||
*/
|
||||
Ptr<Gtk::Entry>::Ref nameEntry;
|
||||
|
||||
/**
|
||||
* A scrolled window, so that the entry list can be scrolled.
|
||||
*/
|
||||
Ptr<Gtk::ScrolledWindow>::Ref entriesScrolledWindow;
|
||||
|
||||
/**
|
||||
* The entry tree view, now only showing rows.
|
||||
*/
|
||||
Ptr<Gtk::TreeView>::Ref entriesView;
|
||||
|
||||
/**
|
||||
* The entry tree model, as a GTK reference.
|
||||
*/
|
||||
Glib::RefPtr<Gtk::ListStore> entriesModel;
|
||||
|
||||
/**
|
||||
* The save button.
|
||||
*/
|
||||
Ptr<Gtk::Button>::Ref saveButton;
|
||||
|
||||
/**
|
||||
* The close button.
|
||||
*/
|
||||
Ptr<Gtk::Button>::Ref closeButton;
|
||||
|
||||
/**
|
||||
* The status bar.
|
||||
*/
|
||||
Ptr<Gtk::Label>::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<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::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
|
||||
|
|
@ -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" }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue