This commit is contained in:
fgerlits 2006-11-30 12:39:32 +00:00
parent fafbf6e87b
commit 3fd1e71d51
4 changed files with 45 additions and 7 deletions

View File

@ -117,7 +117,7 @@ class Notebook : public Gtk::Alignment
virtual void virtual void
onTabClicked(void) throw () onTabClicked(void) throw ()
{ {
notebook->activatePage(index); notebook->setActivePage(index);
} }
/** /**
@ -304,13 +304,34 @@ class Notebook : public Gtk::Alignment
appendPage(Gtk::Widget & widget, appendPage(Gtk::Widget & widget,
const Glib::ustring & label) throw (); 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. * Make a specific page active.
* *
* @param pageNo the index of the page to make active. * @param pageNo the index of the page to make active.
*/ */
virtual void 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 ();
}; };

View File

@ -246,7 +246,7 @@ Notebook :: pagesAdded(void) throw ()
} }
// reset the active page to 0, and show it // 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 * Make a page active
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
Notebook :: activatePage(unsigned int pageNo) throw () Notebook :: setActivePage(unsigned int pageNo) throw ()
{ {
if (pageNo >= pageList.size()) { if (pageNo >= pageList.size()) {
return; 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);
}
}

View File

@ -967,7 +967,7 @@ OptionsWindow :: resetEditedKeyBinding(void) throw ()
void void
OptionsWindow :: run(void) throw () OptionsWindow :: run(void) throw ()
{ {
mainNotebook->activatePage(2); // "Servers" mainNotebook->setActivePage(2); // "Servers"
property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS); property_window_position().set_value(Gtk::WIN_POS_CENTER_ALWAYS);
show_all(); show_all();
Gtk::Main::run(*this); Gtk::Main::run(*this);

View File

@ -991,7 +991,7 @@ bool
SearchWindow :: uploadToHub(Ptr<Playable>::Ref playable) throw () SearchWindow :: uploadToHub(Ptr<Playable>::Ref playable) throw ()
{ {
try { try {
searchInput->activatePage(3); searchInput->setActivePage(3);
transportList->addUpload(playable); transportList->addUpload(playable);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
@ -1020,7 +1020,7 @@ SearchWindow :: onDownloadFromHub(void) throw ()
if (playable) { if (playable) {
if (!gLiveSupport->existsPlayable(playable->getId())) { if (!gLiveSupport->existsPlayable(playable->getId())) {
try { try {
searchInput->activatePage(3); searchInput->setActivePage(3);
transportList->addDownload(playable); transportList->addDownload(playable);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
@ -1093,8 +1093,13 @@ void
SearchWindow :: onSearchWhereChanged(void) throw () SearchWindow :: onSearchWhereChanged(void) throw ()
{ {
if (searchIsLocal()) { if (searchIsLocal()) {
searchInput->setPageSensitive(2, true);
searchResultsTreeView->set_model(localSearchResults); searchResultsTreeView->set_model(localSearchResults);
} else { } else {
if (searchInput->getActivePage() == 2) {
searchInput->setActivePage(0);
}
searchInput->setPageSensitive(2, false);
searchResultsTreeView->set_model(remoteSearchResults); searchResultsTreeView->set_model(remoteSearchResults);
} }