Skip to content

Commit

Permalink
Fixed: don't allow to show/hide detached panes
Browse files Browse the repository at this point in the history
Fixed: don't show the workspace tab if it is detached or hidden after a workspace load
  • Loading branch information
eranif committed Oct 11, 2015
1 parent e7ee938 commit b4e1e84
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 83 deletions.
66 changes: 5 additions & 61 deletions LiteEditor/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,6 @@ EVT_UPDATE_UI(XRCID("show_nav_toolbar"), clMainFrame::OnShowNavBarUI)
EVT_UPDATE_UI(viewAsSubMenuID, clMainFrame::OnFileExistUpdateUI)
EVT_UPDATE_UI_RANGE(viewAsMenuItemID, viewAsMenuItemMaxID, clMainFrame::DispatchUpdateUIEvent)

EVT_MENU(XRCID("show_workspace_tab"), clMainFrame::OnViewShowWorkspaceTab)
EVT_MENU(XRCID("show_explorer_tab"), clMainFrame::OnViewShowExplorerTab)
EVT_MENU(XRCID("show_tabs_tab"), clMainFrame::OnViewShowTabs)
EVT_MENU(XRCID("show_tabgroups_tab"), clMainFrame::OnViewShowTabgroups)

EVT_UPDATE_UI(XRCID("show_workspace_tab"), clMainFrame::OnViewShowWorkspaceTabUI)
EVT_UPDATE_UI(XRCID("show_explorer_tab"), clMainFrame::OnViewShowExplorerTabUI)
EVT_UPDATE_UI(XRCID("show_tabs_tab"), clMainFrame::OnViewShowTabsUI)
EVT_UPDATE_UI(XRCID("show_tabgroups_tab"), clMainFrame::OnViewShowTabgroupsUI)

//-------------------------------------------------------
// Search menu
//-------------------------------------------------------
Expand Down Expand Up @@ -5607,55 +5597,8 @@ void clMainFrame::OnGrepWordUI(wxUpdateUIEvent& e)
}

void clMainFrame::OnPchCacheEnded(wxCommandEvent& e) { e.Skip(); }

void clMainFrame::OnPchCacheStarted(wxCommandEvent& e) { e.Skip(); }

////////////////// View -> Workspace View -> /////////////////////////////////////

void clMainFrame::OnViewShowExplorerTab(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Explorer_Tab);
GetWorkspacePane()->UpdateTabs();
}

void clMainFrame::OnViewShowExplorerTabUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Explorer_Tab));
}

void clMainFrame::OnViewShowTabgroups(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Tabgroups_Tab);
GetWorkspacePane()->UpdateTabs();
}

void clMainFrame::OnViewShowTabgroupsUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Tabgroups_Tab));
}

void clMainFrame::OnViewShowTabs(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Tabs_Tab);
GetWorkspacePane()->UpdateTabs();
}

void clMainFrame::OnViewShowTabsUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Tabs_Tab));
}

void clMainFrame::OnViewShowWorkspaceTab(wxCommandEvent& e)
{
DoEnableWorkspaceViewFlag(e.IsChecked(), View_Show_Workspace_Tab);
GetWorkspacePane()->UpdateTabs();
}

void clMainFrame::OnViewShowWorkspaceTabUI(wxUpdateUIEvent& event)
{
event.Check(GetWorkspacePane()->IsTabVisible(View_Show_Workspace_Tab));
}

///////////////////// Helper methods /////////////////////////////

void clMainFrame::DoEnableWorkspaceViewFlag(bool enable, int flag)
Expand Down Expand Up @@ -6195,10 +6138,11 @@ void clMainFrame::OnMarkEditorReadonlyUI(wxUpdateUIEvent& e)
void clMainFrame::OnWorkspaceLoaded(wxCommandEvent& e)
{
e.Skip();

// Ensure that the workspace view is visible
DoEnableWorkspaceViewFlag(true, View_Show_Workspace_Tab);
GetWorkspacePane()->UpdateTabs();
// If the workspace tab is visible, make it active
int where = GetWorkspacePane()->GetNotebook()->GetPageIndex(_("Workspace"));
if(where != wxNOT_FOUND) {
GetWorkspacePane()->GetNotebook()->SetSelection(where);
}
}

void clMainFrame::OnFileOpenFolder(wxCommandEvent& event)
Expand Down
10 changes: 0 additions & 10 deletions LiteEditor/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,6 @@ class clMainFrame : public wxFrame
void OnPageSetup(wxCommandEvent& event);
void OnRecentWorkspaceUI(wxUpdateUIEvent& e);

// View -> Workspace View -> ...
void OnViewShowWorkspaceTab(wxCommandEvent& e);
void OnViewShowWorkspaceTabUI(wxUpdateUIEvent& event);
void OnViewShowExplorerTab(wxCommandEvent& e);
void OnViewShowExplorerTabUI(wxUpdateUIEvent& event);
void OnViewShowTabs(wxCommandEvent& e);
void OnViewShowTabsUI(wxUpdateUIEvent& event);
void OnViewShowTabgroups(wxCommandEvent& e);
void OnViewShowTabgroupsUI(wxUpdateUIEvent& event);

void OnViewOptions(wxCommandEvent& event);
void OnToggleMainTBars(wxCommandEvent& event);
void OnTogglePluginTBars(wxCommandEvent& event);
Expand Down
11 changes: 0 additions & 11 deletions LiteEditor/workspace_pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ void WorkspacePane::CreateGUIControls()
if(m_book->GetPageCount() > 0) {
m_book->SetSelection((size_t)0);
}
UpdateTabs();
m_mgr->Update();
}

Expand All @@ -206,16 +205,6 @@ void WorkspacePane::UpdateProgress(int val)
m_parsingProgress->Update();
}

void WorkspacePane::UpdateTabs()
{
long flags = EditorConfigST::Get()->GetInteger(wxT("view_workspace_view"), View_Show_Default);

DoShowTab(flags & View_Show_Workspace_Tab, _("Workspace"));
DoShowTab(flags & View_Show_Explorer_Tab, _("Explorer"));
DoShowTab(flags & View_Show_Tabs_Tab, _("Tabs"));
DoShowTab(flags & View_Show_Tabgroups_Tab, _("Tabgroups"));
}

typedef struct {
wxString text;
wxWindow* win;
Expand Down
1 change: 0 additions & 1 deletion LiteEditor/workspace_pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class WorkspacePane : public wxPanel

void UpdateProgress(int val);
void ClearProgress();
void UpdateTabs();
void ApplySavedTabOrder() const;
void SaveWorkspaceViewTabOrder() const;
bool IsTabVisible(int flag);
Expand Down
8 changes: 8 additions & 0 deletions Plugin/clDockingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <map>
#include "codelite_events.h"
#include "event_notifier.h"
#include "detachedpanesinfo.h"
#include "editor_config.h"

#define WORKSPACE_VIEW "Workspace View"
#define OUTPUT_VIEW "Output View"
Expand Down Expand Up @@ -67,6 +69,9 @@ void clDockingManager::ShowOutputViewOpenTabMenu()

wxString clDockingManager::ShowMenu(wxWindow* win, const wxArrayString& tabs, Notebook* book, bool& checked)
{
DetachedPanesInfo dpi;
EditorConfigST::Get()->ReadObject("DetachedPanesList", &dpi);

std::map<int, wxString> tabsIds;
wxMenu menu;
for(size_t i = 0; i < tabs.size(); ++i) {
Expand All @@ -76,6 +81,9 @@ wxString clDockingManager::ShowMenu(wxWindow* win, const wxArrayString& tabs, No
wxMenuItem* item = new wxMenuItem(&menu, tabId, label, "", wxITEM_CHECK);
menu.Append(item);
item->Check((book->GetPageIndex(label) != wxNOT_FOUND));
if(dpi.GetPanes().Index(label) != wxNOT_FOUND) {
item->Enable(false);
}
}

int sel = win->GetPopupMenuSelectionFromUser(menu);
Expand Down

0 comments on commit b4e1e84

Please sign in to comment.