From 65b62b0debbd34ebab1a0140ecdc497dd8c39dcc Mon Sep 17 00:00:00 2001 From: fgerlits Date: Tue, 3 May 2005 14:15:08 +0000 Subject: [PATCH] cleaned up Master Panel window open/close toggle buttons (they used to close windows sometimes when they weren't supposed to) --- .../gLiveSupport/src/MasterPanelWindow.cxx | 56 ++++------ .../gLiveSupport/src/MasterPanelWindow.h | 104 ++++++++++-------- .../src/SimplePlaylistManagementWindow.cxx | 42 ++++--- 3 files changed, 103 insertions(+), 99 deletions(-) diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx index 4cbec0c6c..1b8e4c9d3 100644 --- a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx +++ b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -84,7 +84,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr::Ref gLiveSupport, nowPlayingWidget = Gtk::manage(new Gtk::Label("now playing")); nowPlayingBin = Gtk::manage(widgetFactory->createDarkBlueBin()); nowPlayingBin->add(*nowPlayingWidget); - timeBin->set_size_request(-1, 104); + nowPlayingBin->set_size_request(-1, 104); // set up the VU meter widget 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. *----------------------------------------------------------------------------*/ void -MasterPanelWindow :: onLiveModeButtonClicked(void) throw () +MasterPanelWindow :: updateLiveModeWindow(void) throw () { if (!liveModeWindow.get()) { Ptr::Ref bundle; @@ -343,16 +343,12 @@ MasterPanelWindow :: onLiveModeButtonClicked(void) throw () } liveModeWindow.reset(new LiveModeWindow(gLiveSupport, bundle)); - liveModeWindow->show(); - liveModeWindow->showContents(); - return; } - + + liveModeWindow->showContents(); + if (!liveModeWindow->is_visible()) { liveModeWindow->show(); - liveModeWindow->showContents(); - } else { - liveModeWindow->hide(); } } @@ -361,7 +357,7 @@ MasterPanelWindow :: onLiveModeButtonClicked(void) throw () * The event when the upload file button has been clicked. *----------------------------------------------------------------------------*/ void -MasterPanelWindow :: onUploadFileButtonClicked(void) throw () +MasterPanelWindow :: onUploadFileButtonClicked(void) throw () { if (!uploadFileWindow.get()) { Ptr::Ref bundle; @@ -389,7 +385,7 @@ MasterPanelWindow :: onUploadFileButtonClicked(void) throw () * The event when the Scratchpad button has been clicked. *----------------------------------------------------------------------------*/ void -MasterPanelWindow :: onScratchpadButtonClicked(void) throw () +MasterPanelWindow :: updateScratchpadWindow(void) throw () { if (!scratchpadWindow.get()) { Ptr::Ref bundle; @@ -401,16 +397,12 @@ MasterPanelWindow :: onScratchpadButtonClicked(void) throw () } scratchpadWindow.reset(new ScratchpadWindow(gLiveSupport, bundle)); - scratchpadWindow->show(); - scratchpadWindow->showContents(); - return; } + scratchpadWindow->showContents(); + if (!scratchpadWindow->is_visible()) { 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. *----------------------------------------------------------------------------*/ void -MasterPanelWindow :: onSimplePlaylistMgmtButtonClicked(void) throw () +MasterPanelWindow :: updateSimplePlaylistMgmtWindow(void) throw () { if (!simplePlaylistMgmtWindow.get()) { Ptr::Ref bundle; @@ -432,14 +424,12 @@ MasterPanelWindow :: onSimplePlaylistMgmtButtonClicked(void) throw () simplePlaylistMgmtWindow.reset( new SimplePlaylistManagementWindow(gLiveSupport, bundle)); - simplePlaylistMgmtWindow->show(); - return; } + simplePlaylistMgmtWindow->showContents(); + if (!simplePlaylistMgmtWindow->is_visible()) { simplePlaylistMgmtWindow->show(); - } else { - simplePlaylistMgmtWindow->hide(); } } @@ -448,7 +438,9 @@ MasterPanelWindow :: onSimplePlaylistMgmtButtonClicked(void) throw () * The event when the Scheduler button has been clicked. *----------------------------------------------------------------------------*/ void -MasterPanelWindow :: onSchedulerButtonClicked(void) throw () +MasterPanelWindow :: updateSchedulerWindow( + Ptr::Ref time) + throw () { if (!schedulerWindow.get()) { Ptr::Ref bundle; @@ -460,14 +452,16 @@ MasterPanelWindow :: onSchedulerButtonClicked(void) throw () } schedulerWindow.reset(new SchedulerWindow(gLiveSupport, bundle)); - schedulerWindow->show(); - return; } + + if (time.get()) { + schedulerWindow->setTime(time); + } + + schedulerWindow->showContents(); if (!schedulerWindow->is_visible()) { schedulerWindow->show(); - } else { - schedulerWindow->hide(); } } @@ -476,7 +470,7 @@ MasterPanelWindow :: onSchedulerButtonClicked(void) throw () * The event when the Search button has been clicked. *----------------------------------------------------------------------------*/ void -MasterPanelWindow :: onSearchButtonClicked(void) throw () +MasterPanelWindow :: updateSearchWindow(void) throw () { if (!searchWindow.get()) { Ptr::Ref bundle; @@ -488,14 +482,10 @@ MasterPanelWindow :: onSearchButtonClicked(void) throw () } searchWindow.reset(new SearchWindow(gLiveSupport, bundle)); - searchWindow->show(); - return; } if (!searchWindow->is_visible()) { searchWindow->show(); - } else { - searchWindow->hide(); } } diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.h b/livesupport/products/gLiveSupport/src/MasterPanelWindow.h index 6424ad12b..20e200a34 100644 --- a/livesupport/products/gLiveSupport/src/MasterPanelWindow.h +++ b/livesupport/products/gLiveSupport/src/MasterPanelWindow.h @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -91,7 +91,7 @@ using namespace LiveSupport::Widgets; * * * @author $Author: fgerlits $ - * @version $Revision: 1.14 $ + * @version $Revision: 1.15 $ */ class MasterPanelWindow : public Gtk::Window, public LocalizedObject { @@ -286,35 +286,76 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject * pressed. */ 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 * pressed. */ 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 * Management button being pressed. */ 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 * button being pressed. */ 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 * button being pressed. */ virtual void - onSearchButtonClicked(void) throw (); + onSearchButtonClicked(void) throw () + { + if (!searchWindow || + searchWindow && !searchWindow->is_visible()) { + updateSearchWindow(); + } else { + searchWindow->hide(); + } + } public: @@ -364,68 +405,35 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject * Update the Live Mode window. */ void - updateLiveModeWindow(void) throw () - { - // this will create, open and display the window. - onLiveModeButtonClicked(); - } + updateLiveModeWindow(void) throw (); /** * Update the Scratchpad window. */ void - updateScratchpadWindow(void) throw () - { - // this will create, open and display the window. - onScratchpadButtonClicked(); - } + updateScratchpadWindow(void) throw (); /** * Update the Simple Playlist Management Window */ void - updateSimplePlaylistMgmtWindow(void) throw () - { - // this will create, open and display the window. - onSimplePlaylistMgmtButtonClicked(); - simplePlaylistMgmtWindow->showContents(); - } + updateSimplePlaylistMgmtWindow(void) throw (); /** - * Update the Scheduler Window - */ - void - updateSchedulerWindow(void) throw () - { - // this will create, open and display the window. - onSchedulerButtonClicked(); - schedulerWindow->showContents(); - } - - /** - * Update the Scheduler Window to display a new time. + * Update the Scheduler Window, optionally to display a new time. * * @param time the time to display in the scheduler window. */ void - updateSchedulerWindow(Ptr::Ref time) - throw () - { - // this will create, open and display the window. - onSchedulerButtonClicked(); - schedulerWindow->setTime(time); - schedulerWindow->showContents(); - } + updateSchedulerWindow(Ptr::Ref time = + Ptr::Ref()) + throw (); /** * Update the Search Window */ void - updateSearchWindow(void) throw () - { - // this will create, open and display the window. - onSearchButtonClicked(); - } + updateSearchWindow(void) throw (); }; /* ================================================= external data structures */ diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx index 18e9d0857..33926142d 100644 --- a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx @@ -22,7 +22,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -154,6 +154,10 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () title.reset(new Glib::ustring(nameEntry->get_text())); playlist = gLiveSupport->getEditedPlaylist(); + if (!playlist) { + return; + } + playlist->setTitle(title); playlist = gLiveSupport->savePlaylist(); @@ -197,23 +201,25 @@ SimplePlaylistManagementWindow :: showContents(void) throw () 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.startColumn] = - to_simple_string(*playlistElem->getRelativeOffset()); - row[modelColumns.titleColumn] = *playable->getTitle(); - row[modelColumns.lengthColumn] = - to_simple_string(*playable->getPlaylength()); - - it++; + + if (playlist) { + 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.startColumn] = + to_simple_string(*playlistElem->getRelativeOffset()); + row[modelColumns.titleColumn] = *playable->getTitle(); + row[modelColumns.lengthColumn] = + to_simple_string(*playable->getPlaylength()); + + it++; + } } } -