diff --git a/checkin_notes b/checkin_notes index a9c6961f6d..5d4c0d3c9a 100755 --- a/checkin_notes +++ b/checkin_notes @@ -27553,3 +27553,16 @@ David 21 April 2005 ViewWork.cpp, h lib/ gui_rpc_client.h + +Rom 21 April 2005 + - More code cleanup + - Enable the various project defined website under new GUI scheme + + clientgui/ + BOINCBaseView.cpp, .h + Events.h + ViewMessages.cpp + ViewProjects.cpp, .h + ViewResources.cpp + ViewStatistics.cpp + ViewTransfers.cpp diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index c4ae90b29f..40e32c2b55 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -44,8 +44,6 @@ CBOINCBaseView::CBOINCBaseView(wxNotebook* pNotebook) : m_bProcessingTaskRenderEvent = false; m_bProcessingListRenderEvent = false; - m_bItemSelected = false; - // // Setup View // @@ -66,8 +64,6 @@ CBOINCBaseView::CBOINCBaseView( m_bProcessingTaskRenderEvent = false; m_bProcessingListRenderEvent = false; - m_bItemSelected = false; - // // Setup View // diff --git a/clientgui/BOINCBaseView.h b/clientgui/BOINCBaseView.h index 9d325c0634..00258dd851 100644 --- a/clientgui/BOINCBaseView.h +++ b/clientgui/BOINCBaseView.h @@ -132,8 +132,6 @@ protected: bool m_bProcessingTaskRenderEvent; bool m_bProcessingListRenderEvent; - bool m_bItemSelected; - CBOINCTaskCtrl* m_pTaskPane; CBOINCListCtrl* m_pListPane; }; diff --git a/clientgui/Events.h b/clientgui/Events.h index 5f0d93c932..234cea58e0 100644 --- a/clientgui/Events.h +++ b/clientgui/Events.h @@ -69,10 +69,8 @@ #define ID_TASK_PROJECT_RESET 9005 #define ID_TASK_PROJECT_DETACH 9006 #define ID_TASK_PROJECT_ATTACH 9007 -#define ID_TASK_PROJECT_WEB_BOINC 9098 -#define ID_TASK_PROJECT_WEB_PROJECT 9099 #define ID_TASK_PROJECT_WEB_PROJDEF_MIN 9100 -#define ID_TASK_PROJECT_WEB_PROJDEF_MAX 9199 +#define ID_TASK_PROJECT_WEB_PROJDEF_MAX 9106 #define ID_TASK_WORK_SUSPEND 9200 #define ID_TASK_WORK_RESUME 9201 #define ID_TASK_WORK_SHOWGRAPHICS 9202 diff --git a/clientgui/ViewMessages.cpp b/clientgui/ViewMessages.cpp index b699bdecc4..f718e5dbb0 100644 --- a/clientgui/ViewMessages.cpp +++ b/clientgui/ViewMessages.cpp @@ -103,6 +103,8 @@ CViewMessages::CViewMessages(wxNotebook* pNotebook) : m_pMessageInfoAttr = new wxListItemAttr(*wxBLACK, *wxWHITE, wxNullFont); m_pMessageErrorAttr = new wxListItemAttr(*wxRED, *wxWHITE, wxNullFont); + + UpdateSelection(); } diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index 017f69384e..193d83418d 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -81,6 +81,7 @@ BEGIN_EVENT_TABLE (CViewProjects, CBOINCBaseView) EVT_BUTTON(ID_TASK_PROJECT_RESET, CViewProjects::OnProjectReset) EVT_BUTTON(ID_TASK_PROJECT_DETACH, CViewProjects::OnProjectDetach) EVT_BUTTON(ID_TASK_PROJECT_ATTACH, CViewProjects::OnProjectAttach) + EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_TASK_PROJECT_WEB_PROJDEF_MIN, ID_TASK_PROJECT_WEB_PROJDEF_MAX, CViewProjects::OnProjectWebsiteClicked) EVT_LIST_ITEM_SELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListSelected) EVT_LIST_ITEM_DESELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListDeselected) END_EVENT_TABLE () @@ -92,6 +93,7 @@ CViewProjects::CViewProjects() {} CViewProjects::CViewProjects(wxNotebook* pNotebook) : CBOINCBaseView(pNotebook, ID_TASK_PROJECTSVIEW, DEFAULT_TASK_FLAGS, ID_LIST_PROJECTSVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) { + wxInt32 iCurrentEventID = 0; CTaskItemGroup* pGroup = NULL; CTaskItem* pItem = NULL; @@ -164,20 +166,14 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) : pGroup = new CTaskItemGroup( _("Web sites") ); m_TaskGroups.push_back( pGroup ); - pItem = new CTaskItem( - _("BOINC"), - _("Open the BOINC home page in a web browser."), - ID_TASK_PROJECT_WEB_BOINC - ); - pGroup->m_Tasks.push_back( pItem ); - - pItem = new CTaskItem( - _("Project"), - _("Open this project's home page in a web browser."), - ID_TASK_PROJECT_WEB_PROJECT - ); - pGroup->m_Tasks.push_back( pItem ); - + for (iCurrentEventID = ID_TASK_PROJECT_WEB_PROJDEF_MIN; iCurrentEventID <= ID_TASK_PROJECT_WEB_PROJDEF_MAX; iCurrentEventID++) { + pItem = new CTaskItem( + wxT(""), + wxT(""), + iCurrentEventID + ); + pGroup->m_Tasks.push_back( pItem ); + } // Create Task Pane Items m_pTaskPane->UpdateControls(); @@ -428,6 +424,32 @@ void CViewProjects::OnProjectAttach( wxCommandEvent& event ) { } +void CViewProjects::OnProjectWebsiteClicked( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectWebsiteClicked - Function Begin")); + + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + wxASSERT(NULL != m_pTaskPane); + wxASSERT(NULL != m_pListPane); + + pFrame->UpdateStatusText(_("Launching browser...")); + + int website_task_index = event.GetId() - ID_TASK_PROJECT_WEB_PROJDEF_MIN; + pFrame->ExecuteBrowserLink( + m_TaskGroups[1]->m_Tasks[website_task_index]->m_strWebSiteLink + ); + + pFrame->UpdateStatusText(wxT("")); + + UpdateSelection(); + pFrame->ProcessRefreshView(); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectWebsiteClicked - Function End")); +} + + wxInt32 CViewProjects::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -438,28 +460,6 @@ wxInt32 CViewProjects::GetDocCount() { } -void CViewProjects::OnListSelected(wxListEvent& event) { - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnListSelected - Function Begin")); - - - - UpdateSelection(); - event.Skip(); - - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnListSelected - Function End")); -} - - -void CViewProjects::OnListDeselected(wxListEvent& event) { - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnListDeselected - Function Begin")); - - UpdateSelection(); - event.Skip(); - - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnListDeselected - Function End")); -} - - wxString CViewProjects::OnListGetItemText(long item, long column) const { CProject* project = m_ProjectCache.at(item); wxString strBuffer = wxEmptyString; @@ -588,8 +588,17 @@ wxInt32 CViewProjects::UpdateCache(long item, long column, wxString& strNewData) void CViewProjects::UpdateSelection() { + unsigned int j; + CTaskItemGroup* pGroup = NULL; + CTaskItem* pItem = NULL; + PROJECT* project = NULL; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + // Update the tasks static box buttons - CTaskItemGroup* pGroup = m_TaskGroups[0]; + pGroup = m_TaskGroups[0]; if (m_pListPane->GetSelectedItemCount() == 0) { pGroup->button(BTN_UPDATE)->Disable(); pGroup->button(BTN_SUSPEND)->Disable(); @@ -598,29 +607,62 @@ void CViewProjects::UpdateSelection() { pGroup->button(BTN_DETACH)->Disable(); pGroup->button(BTN_ATTACH)->Enable(); } else { - CMainDocument* pDoc = wxGetApp().GetDocument(); - PROJECT* project = pDoc->project(m_pListPane->GetFirstSelected()); + project = pDoc->project(m_pListPane->GetFirstSelected()); pGroup->button(BTN_UPDATE)->Enable(); pGroup->button(BTN_SUSPEND)->Enable(); if (project->suspended_via_gui) { - pGroup->button(BTN_SUSPEND)->SetLabel(wxString("Resume")); - pGroup->button(BTN_SUSPEND)->SetToolTip(wxString("Resume work for this project")); + pGroup->button(BTN_SUSPEND)->SetLabel(_("Resume")); + pGroup->button(BTN_SUSPEND)->SetToolTip(_("Resume work for this project")); } else { - pGroup->button(BTN_SUSPEND)->SetLabel(wxString("Suspend")); - pGroup->button(BTN_SUSPEND)->SetToolTip(wxString("Suspend work for this project")); + pGroup->button(BTN_SUSPEND)->SetLabel(_("Suspend")); + pGroup->button(BTN_SUSPEND)->SetToolTip(_("Suspend work for this project")); } pGroup->button(BTN_NOWORK)->Enable(); if (project->dont_request_more_work) { - pGroup->button(BTN_NOWORK)->SetLabel(wxString("Allow new work")); - pGroup->button(BTN_NOWORK)->SetToolTip(wxString("Allow fetching new work for this project")); + pGroup->button(BTN_NOWORK)->SetLabel(_("Allow new work")); + pGroup->button(BTN_NOWORK)->SetToolTip(_("Allow fetching new work for this project")); } else { - pGroup->button(BTN_NOWORK)->SetLabel(wxString("No new work")); - pGroup->button(BTN_NOWORK)->SetToolTip(wxString("Don't fetch new work for this project")); + pGroup->button(BTN_NOWORK)->SetLabel(_("No new work")); + pGroup->button(BTN_NOWORK)->SetToolTip(_("Don't fetch new work for this project")); } pGroup->button(BTN_RESET)->Enable(); pGroup->button(BTN_DETACH)->Enable(); pGroup->button(BTN_ATTACH)->Enable(); } + + // Update the websites list + pGroup = m_TaskGroups[1]; + pGroup->m_pStaticBox->Hide(); + for (j=0; j < pGroup->m_Tasks.size(); j++) { + pItem = pGroup->m_Tasks[j]; + pItem->m_pButton->Hide(); + } + if (m_pListPane->GetSelectedItemCount()) { + project = pDoc->project(m_pListPane->GetFirstSelected()); + + pGroup->m_pStaticBox->Show(); + + // Default project url + pItem = pGroup->m_Tasks[0]; + pItem->m_pButton->SetLabel(project->project_name.c_str()); + pItem->m_pButton->SetToolTip(wxT("")); + pItem->m_pButton->Show(); + pItem->m_strWebSiteLink = project->master_url.c_str(); + + + // Project defined urls + unsigned int number_of_gui_urls = project->gui_urls.size(); + unsigned int max_number_of_buttons = ID_TASK_PROJECT_WEB_PROJDEF_MAX-ID_TASK_PROJECT_WEB_PROJDEF_MIN; + int gui_url_index = 0; + for (j=1;j<=number_of_gui_urls && j<=max_number_of_buttons;j++) { + gui_url_index = j - 1; + pItem = pGroup->m_Tasks[j]; + pItem->m_pButton->SetLabel(project->gui_urls[gui_url_index].name.c_str()); + pItem->m_pButton->SetToolTip(project->gui_urls[gui_url_index].description.c_str()); + pItem->m_pButton->Show(); + pItem->m_strWebSiteLink = project->gui_urls[gui_url_index].url.c_str(); + } + } } diff --git a/clientgui/ViewProjects.h b/clientgui/ViewProjects.h index 3d200aca41..61c17f639a 100644 --- a/clientgui/ViewProjects.h +++ b/clientgui/ViewProjects.h @@ -64,13 +64,13 @@ public: void OnProjectDetach( wxCommandEvent& event ); void OnProjectAttach( wxCommandEvent& event ); + void OnProjectWebsiteClicked( wxCommandEvent& event ); + protected: std::vector m_ProjectCache; virtual wxInt32 GetDocCount(); - virtual void OnListSelected( wxListEvent& event ); - virtual void OnListDeselected( wxListEvent& event ); virtual wxString OnListGetItemText( long item, long column ) const; virtual wxString OnDocGetItemText( long item, long column ) const; diff --git a/clientgui/ViewResources.cpp b/clientgui/ViewResources.cpp index 6d5ab10b10..409ed6393d 100644 --- a/clientgui/ViewResources.cpp +++ b/clientgui/ViewResources.cpp @@ -79,6 +79,8 @@ CViewResources::CViewResources(wxNotebook* pNotebook) : // Create List Pane Items m_pListPane->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, -1); m_pListPane->InsertColumn(COLUMN_DISKSPACE, _("Disk Space"), wxLIST_FORMAT_LEFT, -1); + + UpdateSelection(); } diff --git a/clientgui/ViewStatistics.cpp b/clientgui/ViewStatistics.cpp index a565aa9a13..0f13b0d2fb 100644 --- a/clientgui/ViewStatistics.cpp +++ b/clientgui/ViewStatistics.cpp @@ -334,6 +334,8 @@ CViewStatistics::CViewStatistics(wxNotebook* pNotebook) : // Create Task Pane Items m_pTaskPane->UpdateControls(); + + UpdateSelection(); } CViewStatistics::~CViewStatistics() { diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index 44778697c6..89fce5c3ab 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -121,6 +121,8 @@ CViewTransfers::CViewTransfers(wxNotebook* pNotebook) : m_pListPane->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 80); m_pListPane->InsertColumn(COLUMN_SPEED, _("Speed"), wxLIST_FORMAT_LEFT, 80); m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, 150); + + UpdateSelection(); }