From 3fd1e71d514a65339529b7caa4d2e0e617ffae1b Mon Sep 17 00:00:00 2001 From: fgerlits Date: Thu, 30 Nov 2006 12:39:32 +0000 Subject: [PATCH] fixed #2044 --- .../include/LiveSupport/Widgets/Notebook.h | 25 +++++++++++++++++-- .../src/modules/widgets/src/Notebook.cxx | 16 ++++++++++-- .../gLiveSupport/src/OptionsWindow.cxx | 2 +- .../gLiveSupport/src/SearchWindow.cxx | 9 +++++-- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/campcaster/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h b/campcaster/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h index c97d2e722..475271b4f 100644 --- a/campcaster/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h +++ b/campcaster/src/modules/widgets/include/LiveSupport/Widgets/Notebook.h @@ -117,7 +117,7 @@ class Notebook : public Gtk::Alignment virtual void onTabClicked(void) throw () { - notebook->activatePage(index); + notebook->setActivePage(index); } /** @@ -304,13 +304,34 @@ class Notebook : public Gtk::Alignment appendPage(Gtk::Widget & widget, const Glib::ustring & label) throw (); + /** + * Get the number of the active page. + * + * @return the index of the active page. + */ + virtual unsigned int + getActivePage(void) throw () + { + return activePage; + } + /** * Make a specific page active. * * @param pageNo the index of the page to make active. */ virtual void - activatePage(unsigned int pageNo) throw (); + setActivePage(unsigned int pageNo) throw (); + + /** + * Enable or disable a page in the notebook. + * + * @param pageNo the index of the page to enable or disable. + * @param sensitive true (default) to enable, false to disable. + */ + virtual void + setPageSensitive(unsigned int pageNo, + bool sensitive) throw (); }; diff --git a/campcaster/src/modules/widgets/src/Notebook.cxx b/campcaster/src/modules/widgets/src/Notebook.cxx index c24dbf5f4..5e720b195 100644 --- a/campcaster/src/modules/widgets/src/Notebook.cxx +++ b/campcaster/src/modules/widgets/src/Notebook.cxx @@ -246,7 +246,7 @@ Notebook :: pagesAdded(void) throw () } // reset the active page to 0, and show it - activatePage(0); + setActivePage(0); } @@ -254,7 +254,7 @@ Notebook :: pagesAdded(void) throw () * Make a page active *----------------------------------------------------------------------------*/ void -Notebook :: activatePage(unsigned int pageNo) throw () +Notebook :: setActivePage(unsigned int pageNo) throw () { if (pageNo >= pageList.size()) { return; @@ -270,3 +270,15 @@ Notebook :: activatePage(unsigned int pageNo) throw () } +/*------------------------------------------------------------------------------ + * Enable or disable a page in the notebook. + *----------------------------------------------------------------------------*/ +void +Notebook :: setPageSensitive(unsigned int pageNo, + bool sensitive) throw () +{ + if (pageNo < pageList.size()) { + pageList[pageNo]->button->setDisabled(!sensitive); + } +} + diff --git a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx index b260f5f0d..d39ebe378 100644 --- a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx @@ -967,7 +967,7 @@ OptionsWindow :: resetEditedKeyBinding(void) throw () void OptionsWindow :: run(void) throw () { - mainNotebook->activatePage(2); // "Servers" + mainNotebook->setActivePage(2); // "Servers" property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS); show_all(); Gtk::Main::run(*this); diff --git a/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx b/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx index 6b77397cc..622b19b13 100644 --- a/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/SearchWindow.cxx @@ -991,7 +991,7 @@ bool SearchWindow :: uploadToHub(Ptr::Ref playable) throw () { try { - searchInput->activatePage(3); + searchInput->setActivePage(3); transportList->addUpload(playable); } catch (XmlRpcException &e) { @@ -1020,7 +1020,7 @@ SearchWindow :: onDownloadFromHub(void) throw () if (playable) { if (!gLiveSupport->existsPlayable(playable->getId())) { try { - searchInput->activatePage(3); + searchInput->setActivePage(3); transportList->addDownload(playable); } catch (XmlRpcException &e) { @@ -1093,8 +1093,13 @@ void SearchWindow :: onSearchWhereChanged(void) throw () { if (searchIsLocal()) { + searchInput->setPageSensitive(2, true); searchResultsTreeView->set_model(localSearchResults); } else { + if (searchInput->getActivePage() == 2) { + searchInput->setActivePage(0); + } + searchInput->setPageSensitive(2, false); searchResultsTreeView->set_model(remoteSearchResults); }