I've never sumitted a fix before, nor have I ever modified
the core code. But I wanted to try and fix the notebook tab Save/SaveAll
entries.
So... Is the following acceptable. If not, please comment.
If so, I'll submit it to sf
thanks
pecan
C:\Usr\Proj\cbBeta\trunk\src\sdk>PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\usr\bin;c:\usr\bin\subversion\bin
C:\Usr\Proj\cbBeta\trunk\src\sdk>SET APR_ICONV_PATH=C:\usr\bin\Subversion\iconv
C:\Usr\Proj\cbBeta\trunk\src\sdk>svn diff
Index: editormanager.cpp
===================================================================
--- editormanager.cpp (revision 1563)
+++ editormanager.cpp (working copy)
@@ -227,7 +227,20 @@
pop->AppendSeparator();
pop->Append(idNBTabSave, _("Save"));
if (GetPageCount() > 1)
- pop->Append(idNBTabSaveAll, _("Save all"));
+ { pop->Append(idNBTabSaveAll, _("Save all"));
+ // --begin pecan 12/19/2005 1:40 PM-------------------------
+ EditorBase* ed = Manager::Get()->GetEditorManager()->GetEditor(m_RightClickSelected);
+ int editorsModified = 0;
+ for (int i = 0; i < Manager::Get()->GetEditorManager()->GetEditorsCount(); ++i)
+ {
+ EditorBase* other = Manager::Get()->GetEditorManager()->GetEditor(i);
+ if (other == ed) continue;
+ if (other && other->GetModified() ) editorsModified++;
+ }
+ pop->Enable(idNBTabSaveAll, editorsModified>0 );
+ // --end pecan 12/19/2005 1:40 PM ---------------------------
+ }//if(getPage....
+
EditorBase* ed = Manager::Get()->GetEditorManager()->GetEditor(m_RightClickSelected);
if (ed)
pop->Enable(idNBTabSave, ed->GetModified());
@@ -269,6 +282,8 @@
EVT_MENU(idNBTabClose, EditorNotebook::OnClose)
EVT_MENU(idNBTabCloseAll, EditorNotebook::OnCloseAll)
EVT_MENU(idNBTabCloseAllOthers, EditorNotebook::OnCloseAllOthers)
+ EVT_MENU(idNBTabSave, EditorNotebook::OnSave) //pecan 12/19/2005 1:11 PM
+ EVT_MENU(idNBTabSaveAll, EditorNotebook::OnSaveAll) //pecan 12/19/2005 1:11 PM
EVT_MIDDLE_DOWN(EditorNotebook::OnMiddleDown)
EVT_RIGHT_DOWN(EditorNotebook::OnRightDown)
END_EVENT_TABLE()
...and I was wrong. You do need a call to Manager::Get() because we're in an embedded class there, had not seen that, sorry ;)
Here's what it looks like now:
pop->AppendSeparator();
pop->Append(idNBTabSave, _("Save"));
pop->Append(idNBTabSaveAll, _("Save all"));
EditorManager *em = Manager::Get()->GetEditorManager();
unsigned int num_modified = 0;
for (int i = 0; i < em->GetEditorsCount(); ++i)
{
EditorBase* ed = em->GetEditor(i);
if (ed && ed->GetModified() )
++num_modified;
}
pop->Enable(idNBTabSave, num_modified);
pop->Enable(idNBTabSaveAll, num_modified > 1 );
It always adds the menu items for consistency instead of only showing "all" on multiple tabs.
code from HEAD 1573 sdk/ediitormanager.cpp (12/20/2005 12:35 PM)
for (int i = 0; i < em->GetEditorsCount(); ++i)
{
EditorBase* ed = em->GetEditor(i);
if (ed && ed->GetModified() )
++num_modified;
}
pop->Enable(idNBTabSave, num_modified);
pop->Enable(idNBTabSaveAll, num_modified > 1 );
Put two tabs/editors up. Modify the left one.
If the left tab has been modified and the right one NOT,
then cliick on the right tab as save. It *doesn't* save. AND saveAll is disabled
because test is for "num_modified>1" and the cursor is on the
unmodified editor tab.
In my not so professional code in message 1 above, I ran across the same
problem. Thats why I tested to differentiate from "this editor" and
"other editors":
EditorBase* other = Manager::Get()->GetEditorManager()->GetEditor(i);
if (other == ed) continue;
if (other && other->GetModified() ) editorsModified++;
thanks
pecan
I've test the follow mods. They seem to work the way I believe
you want them to.
===================================================================
--- sdk/editormanager.cpp (revision 1573)
+++ sdk/editormanager.cpp (working copy)
@@ -237,8 +237,10 @@
if (ed && ed->GetModified() )
++num_modified;
}
- pop->Enable(idNBTabSave, num_modified);
- pop->Enable(idNBTabSaveAll, num_modified > 1 );
+ //pop->Enable(idNBTabSave, num_modified);
+ pop->Enable(idNBTabSave, em->GetEditor(m_RightClickSelected)->GetModified()); //pecan 12/20/2005 12:42 PM
+ //-pop->Enable(idNBTabSaveAll, num_modified > 1 );
+ pop->Enable(idNBTabSaveAll, num_modified > 0 );//pecan 12/20/2005 12:42 PM
PopupMenu(pop, event.GetPosition().x, event.GetPosition().y);
delete pop;
thanks
pecan