cleaned up Master Panel window open/close toggle buttons

(they used to close windows sometimes when they weren't supposed to)
This commit is contained in:
fgerlits 2005-05-03 14:15:08 +00:00
parent af576dcdb1
commit 65b62b0deb
3 changed files with 103 additions and 99 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.25 $ Version : $Revision: 1.26 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -84,7 +84,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
nowPlayingWidget = Gtk::manage(new Gtk::Label("now playing")); nowPlayingWidget = Gtk::manage(new Gtk::Label("now playing"));
nowPlayingBin = Gtk::manage(widgetFactory->createDarkBlueBin()); nowPlayingBin = Gtk::manage(widgetFactory->createDarkBlueBin());
nowPlayingBin->add(*nowPlayingWidget); nowPlayingBin->add(*nowPlayingWidget);
timeBin->set_size_request(-1, 104); nowPlayingBin->set_size_request(-1, 104);
// set up the VU meter widget // set up the VU meter widget
vuMeterWidget = Gtk::manage(new Gtk::Label("VU meter")); vuMeterWidget = Gtk::manage(new Gtk::Label("VU meter"));
@ -331,7 +331,7 @@ MasterPanelWindow :: onUpdateTime(int dummy) throw ()
* The event when the Live Mode button has been clicked. * The event when the Live Mode button has been clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: onLiveModeButtonClicked(void) throw () MasterPanelWindow :: updateLiveModeWindow(void) throw ()
{ {
if (!liveModeWindow.get()) { if (!liveModeWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle;
@ -343,16 +343,12 @@ MasterPanelWindow :: onLiveModeButtonClicked(void) throw ()
} }
liveModeWindow.reset(new LiveModeWindow(gLiveSupport, bundle)); liveModeWindow.reset(new LiveModeWindow(gLiveSupport, bundle));
liveModeWindow->show();
liveModeWindow->showContents();
return;
} }
liveModeWindow->showContents();
if (!liveModeWindow->is_visible()) { if (!liveModeWindow->is_visible()) {
liveModeWindow->show(); liveModeWindow->show();
liveModeWindow->showContents();
} else {
liveModeWindow->hide();
} }
} }
@ -389,7 +385,7 @@ MasterPanelWindow :: onUploadFileButtonClicked(void) throw ()
* The event when the Scratchpad button has been clicked. * The event when the Scratchpad button has been clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: onScratchpadButtonClicked(void) throw () MasterPanelWindow :: updateScratchpadWindow(void) throw ()
{ {
if (!scratchpadWindow.get()) { if (!scratchpadWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle;
@ -401,16 +397,12 @@ MasterPanelWindow :: onScratchpadButtonClicked(void) throw ()
} }
scratchpadWindow.reset(new ScratchpadWindow(gLiveSupport, bundle)); scratchpadWindow.reset(new ScratchpadWindow(gLiveSupport, bundle));
scratchpadWindow->show();
scratchpadWindow->showContents();
return;
} }
scratchpadWindow->showContents();
if (!scratchpadWindow->is_visible()) { if (!scratchpadWindow->is_visible()) {
scratchpadWindow->show(); scratchpadWindow->show();
scratchpadWindow->showContents();
} else {
scratchpadWindow->hide();
} }
} }
@ -419,7 +411,7 @@ MasterPanelWindow :: onScratchpadButtonClicked(void) throw ()
* The event when the Simple Playlist Management button has been clicked. * The event when the Simple Playlist Management button has been clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: onSimplePlaylistMgmtButtonClicked(void) throw () MasterPanelWindow :: updateSimplePlaylistMgmtWindow(void) throw ()
{ {
if (!simplePlaylistMgmtWindow.get()) { if (!simplePlaylistMgmtWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle;
@ -432,14 +424,12 @@ MasterPanelWindow :: onSimplePlaylistMgmtButtonClicked(void) throw ()
simplePlaylistMgmtWindow.reset( simplePlaylistMgmtWindow.reset(
new SimplePlaylistManagementWindow(gLiveSupport, bundle)); new SimplePlaylistManagementWindow(gLiveSupport, bundle));
simplePlaylistMgmtWindow->show();
return;
} }
simplePlaylistMgmtWindow->showContents();
if (!simplePlaylistMgmtWindow->is_visible()) { if (!simplePlaylistMgmtWindow->is_visible()) {
simplePlaylistMgmtWindow->show(); simplePlaylistMgmtWindow->show();
} else {
simplePlaylistMgmtWindow->hide();
} }
} }
@ -448,7 +438,9 @@ MasterPanelWindow :: onSimplePlaylistMgmtButtonClicked(void) throw ()
* The event when the Scheduler button has been clicked. * The event when the Scheduler button has been clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: onSchedulerButtonClicked(void) throw () MasterPanelWindow :: updateSchedulerWindow(
Ptr<boost::posix_time::ptime>::Ref time)
throw ()
{ {
if (!schedulerWindow.get()) { if (!schedulerWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle;
@ -460,14 +452,16 @@ MasterPanelWindow :: onSchedulerButtonClicked(void) throw ()
} }
schedulerWindow.reset(new SchedulerWindow(gLiveSupport, bundle)); schedulerWindow.reset(new SchedulerWindow(gLiveSupport, bundle));
schedulerWindow->show();
return;
} }
if (time.get()) {
schedulerWindow->setTime(time);
}
schedulerWindow->showContents();
if (!schedulerWindow->is_visible()) { if (!schedulerWindow->is_visible()) {
schedulerWindow->show(); schedulerWindow->show();
} else {
schedulerWindow->hide();
} }
} }
@ -476,7 +470,7 @@ MasterPanelWindow :: onSchedulerButtonClicked(void) throw ()
* The event when the Search button has been clicked. * The event when the Search button has been clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: onSearchButtonClicked(void) throw () MasterPanelWindow :: updateSearchWindow(void) throw ()
{ {
if (!searchWindow.get()) { if (!searchWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle;
@ -488,14 +482,10 @@ MasterPanelWindow :: onSearchButtonClicked(void) throw ()
} }
searchWindow.reset(new SearchWindow(gLiveSupport, bundle)); searchWindow.reset(new SearchWindow(gLiveSupport, bundle));
searchWindow->show();
return;
} }
if (!searchWindow->is_visible()) { if (!searchWindow->is_visible()) {
searchWindow->show(); searchWindow->show();
} else {
searchWindow->hide();
} }
} }

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.14 $ Version : $Revision: 1.15 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -91,7 +91,7 @@ using namespace LiveSupport::Widgets;
* </code></pre> * </code></pre>
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.14 $ * @version $Revision: 1.15 $
*/ */
class MasterPanelWindow : public Gtk::Window, public LocalizedObject class MasterPanelWindow : public Gtk::Window, public LocalizedObject
{ {
@ -286,35 +286,76 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
* pressed. * pressed.
*/ */
virtual void virtual void
onLiveModeButtonClicked(void) throw (); onLiveModeButtonClicked(void) throw ()
{
if (!liveModeWindow ||
liveModeWindow && !liveModeWindow->is_visible()) {
updateLiveModeWindow();
} else {
liveModeWindow->hide();
}
}
/** /**
* Function to catch the event of the Scratchpad button being * Function to catch the event of the Scratchpad button being
* pressed. * pressed.
*/ */
virtual void virtual void
onScratchpadButtonClicked(void) throw (); onScratchpadButtonClicked(void) throw ()
{
if (!scratchpadWindow ||
scratchpadWindow && !scratchpadWindow->is_visible()) {
updateScratchpadWindow();
} else {
scratchpadWindow->hide();
}
}
/** /**
* Function to catch the event of the Simple Playlist * Function to catch the event of the Simple Playlist
* Management button being pressed. * Management button being pressed.
*/ */
virtual void virtual void
onSimplePlaylistMgmtButtonClicked(void) throw (); onSimplePlaylistMgmtButtonClicked(void) throw ()
{
if (!simplePlaylistMgmtWindow ||
simplePlaylistMgmtWindow &&
!simplePlaylistMgmtWindow->is_visible()) {
updateSimplePlaylistMgmtWindow();
} else {
simplePlaylistMgmtWindow->hide();
}
}
/** /**
* Function to catch the event of the Scheduler button * Function to catch the event of the Scheduler button
* button being pressed. * button being pressed.
*/ */
virtual void virtual void
onSchedulerButtonClicked(void) throw (); onSchedulerButtonClicked(void) throw ()
{
if (!schedulerWindow ||
schedulerWindow && !schedulerWindow->is_visible()) {
updateSchedulerWindow();
} else {
schedulerWindow->hide();
}
}
/** /**
* Function to catch the event of the Search button * Function to catch the event of the Search button
* button being pressed. * button being pressed.
*/ */
virtual void virtual void
onSearchButtonClicked(void) throw (); onSearchButtonClicked(void) throw ()
{
if (!searchWindow ||
searchWindow && !searchWindow->is_visible()) {
updateSearchWindow();
} else {
searchWindow->hide();
}
}
public: public:
@ -364,68 +405,35 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
* Update the Live Mode window. * Update the Live Mode window.
*/ */
void void
updateLiveModeWindow(void) throw () updateLiveModeWindow(void) throw ();
{
// this will create, open and display the window.
onLiveModeButtonClicked();
}
/** /**
* Update the Scratchpad window. * Update the Scratchpad window.
*/ */
void void
updateScratchpadWindow(void) throw () updateScratchpadWindow(void) throw ();
{
// this will create, open and display the window.
onScratchpadButtonClicked();
}
/** /**
* Update the Simple Playlist Management Window * Update the Simple Playlist Management Window
*/ */
void void
updateSimplePlaylistMgmtWindow(void) throw () updateSimplePlaylistMgmtWindow(void) throw ();
{
// this will create, open and display the window.
onSimplePlaylistMgmtButtonClicked();
simplePlaylistMgmtWindow->showContents();
}
/** /**
* Update the Scheduler Window * Update the Scheduler Window, optionally to display a new time.
*/
void
updateSchedulerWindow(void) throw ()
{
// this will create, open and display the window.
onSchedulerButtonClicked();
schedulerWindow->showContents();
}
/**
* Update the Scheduler Window to display a new time.
* *
* @param time the time to display in the scheduler window. * @param time the time to display in the scheduler window.
*/ */
void void
updateSchedulerWindow(Ptr<boost::posix_time::ptime>::Ref time) updateSchedulerWindow(Ptr<boost::posix_time::ptime>::Ref time =
throw () Ptr<boost::posix_time::ptime>::Ref())
{ throw ();
// this will create, open and display the window.
onSchedulerButtonClicked();
schedulerWindow->setTime(time);
schedulerWindow->showContents();
}
/** /**
* Update the Search Window * Update the Search Window
*/ */
void void
updateSearchWindow(void) throw () updateSearchWindow(void) throw ();
{
// this will create, open and display the window.
onSearchButtonClicked();
}
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.9 $ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -154,6 +154,10 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw ()
title.reset(new Glib::ustring(nameEntry->get_text())); title.reset(new Glib::ustring(nameEntry->get_text()));
playlist = gLiveSupport->getEditedPlaylist(); playlist = gLiveSupport->getEditedPlaylist();
if (!playlist) {
return;
}
playlist->setTitle(title); playlist->setTitle(title);
playlist = gLiveSupport->savePlaylist(); playlist = gLiveSupport->savePlaylist();
@ -197,6 +201,8 @@ SimplePlaylistManagementWindow :: showContents(void) throw ()
Playlist::const_iterator end; Playlist::const_iterator end;
playlist = gLiveSupport->getEditedPlaylist(); playlist = gLiveSupport->getEditedPlaylist();
if (playlist) {
it = playlist->begin(); it = playlist->begin();
end = playlist->end(); end = playlist->end();
entriesModel->clear(); entriesModel->clear();
@ -215,5 +221,5 @@ SimplePlaylistManagementWindow :: showContents(void) throw ()
it++; it++;
} }
} }
}