also: made the contents of the window stored at logout and restored at 
startup
This commit is contained in:
fgerlits 2007-05-23 11:40:04 +00:00
parent c2eab3dfd7
commit 1bfa7f3207
10 changed files with 171 additions and 3 deletions

View File

@ -705,7 +705,7 @@ GLiveSupport :: loadWindowContents(ContentsStorable * window)
<< std::endl;
return;
} catch (std::invalid_argument &e) {
// no scratchpad stored for this user yet; no problem
// no preferences stored for this user yet; no problem
return;
}

View File

@ -61,6 +61,11 @@ namespace {
*/
const Glib::ustring windowName = "liveModeWindow";
/*------------------------------------------------------------------------------
* The name of the user preference for storing contents of the window.
*----------------------------------------------------------------------------*/
const Glib::ustring userPreferencesKeyName = "liveModeContents";
}
/* =============================================== local function prototypes */
@ -150,6 +155,16 @@ LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
Gtk::HBox * cueAudioButtonsBox = Gtk::manage(new Gtk::HBox);
cueAudioButtons = Gtk::manage(new CuePlayer(
gLiveSupport, treeView, modelColumns ));
Gtk::HBox * autoPlayNextBox = Gtk::manage(new Gtk::HBox);
try {
autoPlayNext = Gtk::manage(new Gtk::CheckButton(
*getResourceUstring("autoPlayNextLabel") ));
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
std::exit(1);
}
autoPlayNextBox->pack_start(*autoPlayNext, Gtk::PACK_SHRINK, 10);
topButtonBox->pack_start(*outputPlayButton, Gtk::PACK_EXPAND_PADDING, 10);
topButtonBox->pack_start(*cueAudioBox, Gtk::PACK_EXPAND_PADDING, 10);
@ -165,6 +180,7 @@ LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
bottomButtonBox->pack_start(*removeButton);
vBox.pack_start(*topButtonBox, Gtk::PACK_SHRINK, 5);
vBox.pack_start(*autoPlayNextBox, Gtk::PACK_SHRINK, 5);
vBox.pack_start(scrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5);
vBox.pack_start(*bottomButtonBox, Gtk::PACK_SHRINK, 5);
add(vBox);
@ -181,6 +197,8 @@ LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
audioClipContextMenu = constructAudioClipContextMenu();
playlistContextMenu = constructPlaylistContextMenu();
userPreferencesKey.reset(new const Glib::ustring(userPreferencesKeyName));
// show
set_name(windowName);
set_default_size(400, 500);
@ -251,6 +269,26 @@ LiveModeWindow :: addItem(Gtk::TreeModel::iterator iter,
}
/*------------------------------------------------------------------------------
* Add an item to the Live Mode window, by ID.
*----------------------------------------------------------------------------*/
void
LiveModeWindow :: addItem(Ptr<const UniqueId>::Ref id)
throw ()
{
Ptr<Playable>::Ref playable;
try {
playable = gLiveSupport->acquirePlayable(id);
} catch (XmlRpcException &e) {
std::cerr << "could not acquire playable in LiveModeWindow: "
<< e.what() << std::endl;
return;
}
addItem(playable);
}
/*------------------------------------------------------------------------------
* "Pop" the first item from the top of the Live Mode Window.
*----------------------------------------------------------------------------*/
@ -258,8 +296,11 @@ Ptr<Playable>::Ref
LiveModeWindow :: popTop(void) throw ()
{
Ptr<Playable>::Ref playable;
if (!autoPlayNext->get_active()) {
return playable; // return a 0 pointer if auto is set to off
}
Gtk::TreeModel::iterator iter = treeModel->children().begin();
if (iter) {
playable = (*iter)[modelColumns.playableColumn];
treeModel->erase(iter);
@ -706,6 +747,68 @@ LiveModeWindow :: updateStrings(void) throw ()
}
/*------------------------------------------------------------------------------
* Return the contents of the Scratchpad.
*----------------------------------------------------------------------------*/
Ptr<Glib::ustring>::Ref
LiveModeWindow :: getContents(void) throw ()
{
std::ostringstream contentsStream;
contentsStream << int(autoPlayNext->get_active()) << " ";
Gtk::TreeModel::const_iterator it;
for (it = treeModel->children().begin();
it != treeModel->children().end(); ++it) {
Gtk::TreeRow row = *it;
Ptr<Playable>::Ref playable = row[modelColumns.playableColumn];
contentsStream << playable->getId()->getId() << " ";
}
Ptr<Glib::ustring>::Ref contents(new Glib::ustring(
contentsStream.str() ));
return contents;
}
/*------------------------------------------------------------------------------
* Restore the contents of the Scratchpad.
*----------------------------------------------------------------------------*/
void
LiveModeWindow :: setContents(Ptr<const Glib::ustring>::Ref contents)
throw ()
{
std::istringstream contentsStream(*contents);
if (contentsStream.eof()) {
return;
}
int autoPlayNextValue;
contentsStream >> autoPlayNextValue;
autoPlayNext->set_active(autoPlayNextValue);
std::vector<UniqueId::IdType> contentsVector;
while (!contentsStream.eof()) {
UniqueId::IdType nextItem;
contentsStream >> nextItem;
if (contentsStream.fail()) {
contentsStream.clear();
contentsStream.ignore();
} else {
contentsVector.push_back(nextItem);
}
}
treeModel->clear();
std::vector<UniqueId::IdType>::reverse_iterator it;
for (it = contentsVector.rbegin(); it != contentsVector.rend(); ++it) {
Ptr<const UniqueId>::Ref id(new const UniqueId(*it));
addItem(id);
}
}
/*------------------------------------------------------------------------------
* Event handler called when the the window gets hidden.
*----------------------------------------------------------------------------*/

View File

@ -52,6 +52,7 @@
#include "LiveSupport/Widgets/ZebraTreeView.h"
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "GuiWindow.h"
#include "ContentsStorable.h"
#include "CuePlayer.h"
#include "GLiveSupport.h"
#include "ExportPlaylistWindow.h"
@ -78,7 +79,8 @@ using namespace LiveSupport::Widgets;
* @author $Author$
* @version $Revision$
*/
class LiveModeWindow : public GuiWindow
class LiveModeWindow : public GuiWindow,
public ContentsStorable
{
private:
/**
@ -91,6 +93,11 @@ class LiveModeWindow : public GuiWindow
*/
bool isDeleting;
/**
* The user preferences key.
*/
Ptr<const Glib::ustring>::Ref userPreferencesKey;
/**
* The Export Playlist pop-up window.
*/
@ -121,6 +128,12 @@ class LiveModeWindow : public GuiWindow
*/
Button * removeButton;
/**
* If checked, the top item in the window will start playing
* automatically after the current one finishes.
*/
Gtk::CheckButton * autoPlayNext;
/**
* Construct the right-click context menu for local audio clips.
*
@ -363,6 +376,15 @@ class LiveModeWindow : public GuiWindow
addItem(Gtk::TreeModel::iterator iter,
Ptr<Playable>::Ref playable) throw ();
/**
* Add an item to the top of the Live Mode Window, by ID.
*
* @param id the id of the item to add.
* @see setContents().
*/
void
addItem(Ptr<const UniqueId>::Ref id) throw ();
/**
* "Pop" the first item from the top of the Live Mode Window.
*
@ -409,6 +431,41 @@ class LiveModeWindow : public GuiWindow
*/
void
updateStrings(void) throw ();
/**
* Return the contents of the Live Mode window.
* This means the list of audio files, plus the state of the
* autoPlayNext checkbox.
*
* @return 0 or 1, followed by a space-separated list of the
* unique IDs, in base 10.
*/
Ptr<Glib::ustring>::Ref
getContents(void) throw ();
/**
* Restore the contents of the Scratchpad.
* The current contents are discarded, and replaced with the items
* listed in the 'contents' parameter.
*
* @param contents 0 or 1, followed by a space-separated list of the
* unique IDs, in base 10.
*/
void
setContents(Ptr<const Glib::ustring>::Ref contents) throw ();
/**
* Return the user preferences key.
* The contents of the window will be stored in the user preferences
* under this key.
*
* @return the user preference key.
*/
Ptr<const Glib::ustring>::Ref
getUserPreferencesKey(void) throw ()
{
return userPreferencesKey;
}
};
/* ================================================= external data structures */

View File

@ -467,6 +467,7 @@ MasterPanelWindow :: updateLiveModeWindow(Ptr<Playable>::Ref playable)
liveModeWindow.reset(new LiveModeWindow(gLiveSupport,
bundle,
liveModeButton));
gLiveSupport->loadWindowContents(liveModeWindow);
}
liveModeWindow->present();
@ -678,6 +679,7 @@ MasterPanelWindow :: showAnonymousUI(void) throw ()
optionsButton->hide();
if (liveModeWindow.get()) {
gLiveSupport->storeWindowContents(liveModeWindow);
if (liveModeWindow->is_visible()) {
liveModeWindow->hide();
}

View File

@ -257,6 +257,7 @@ es:table
uploadToHubMenuItem:string { "Upload to Network Hub" }
cuePlayerLabel:string { "Previsualizar" }
autoPlayNextLabel:string { "#Play the next item automatically#" }
clearListButtonLabel:string { "Clear list" }
removeButtonLabel:string { "Remove item(s)" }

View File

@ -254,6 +254,7 @@ hu:table
uploadToHubMenuItem:string { "Upload to Network Hub" }
cuePlayerLabel:string { "Belehallgatni" }
autoPlayNextLabel:string { "#Play the next item automatically#" }
clearListButtonLabel:string { "Clear list" }
removeButtonLabel:string { "Remove item(s)" }

View File

@ -256,6 +256,7 @@ nl:table
uploadToHubMenuItem:string { "Upload to Network Hub" }
cuePlayerLabel:string { "Cue" }
autoPlayNextLabel:string { "#Play the next item automatically#" }
clearListButtonLabel:string { "Clear list" }
removeButtonLabel:string { "Remove item(s)" }

View File

@ -256,6 +256,7 @@ root:table
uploadToHubMenuItem:string { "Upload to Network Hub" }
cuePlayerLabel:string { "Preview" }
autoPlayNextLabel:string { "Play the next item automatically" }
clearListButtonLabel:string { "Clear list" }
removeButtonLabel:string { "Remove item(s)" }

View File

@ -251,6 +251,7 @@ sr_CS:table
uploadToHubMenuItem:string { "Uputi na centralni server" }
cuePlayerLabel:string { "Proba" }
autoPlayNextLabel:string { "#Play the next item automatically#" }
clearListButtonLabel:string { "Očisti listu" }
removeButtonLabel:string { "Ukloni" }

View File

@ -251,6 +251,7 @@ sr_CS_CYRILLIC:table
uploadToHubMenuItem:string { "Упути на централни сервер" }
cuePlayerLabel:string { "Проба" }
autoPlayNextLabel:string { "#Play the next item automatically#" }
clearListButtonLabel:string { "Очисти листу" }
removeButtonLabel:string { "Уклони" }