Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
"Save all" button
raph:
Hi guys,
when working with c::b I noticed, that I missed a "Save all" feature, which saves files, projects and the workspace at once, so I made a little patch.
A new item is added to the file menu:
Since I never used the print button in the main toolbar, I decided to replace it with a "save all" button:
I'm not really good at graphics, but I created two icons for this (out of the existing ones) and attached them to this post (filenames contain hints, where they should be put into).
Here is the patch:
--- Code: ---Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp (revision 4079)
+++ src/sdk/editormanager.cpp (working copy)
@@ -913,7 +913,7 @@
for (int i = 0; i < m_pNotebook->GetPageCount(); ++i)
{
EditorBase* ed = InternalGetEditorBase(i);
- if (ed && !ed->Save())
+ if (ed && ed->GetModified() && !ed->Save())
{
wxString msg;
msg.Printf(_("File %s could not be saved..."), ed->GetFilename().c_str());
Index: src/sdk/projectmanager.cpp
===================================================================
--- src/sdk/projectmanager.cpp (revision 4079)
+++ src/sdk/projectmanager.cpp (working copy)
@@ -1015,7 +1015,8 @@
for (int i = 0; i < prjCount; ++i)
{
cbProject* project = m_pProjects->Item(i);
- if (SaveProject(project))
+ bool isModified = project->GetModified();
+ if (isModified && SaveProject(project))
++count;
}
UnfreezeTree(true);
Index: src/src/main.cpp
===================================================================
--- src/src/main.cpp (revision 4079)
+++ src/src/main.cpp (working copy)
@@ -127,6 +127,7 @@
int idFileOpenDefWorkspace = XRCID("idFileOpenDefWorkspace");
int idFileSaveWorkspace = XRCID("idFileSaveWorkspace");
int idFileSaveWorkspaceAs = XRCID("idFileSaveWorkspaceAs");
+int idFileSaveAll = XRCID("idFileSaveAll");
int idFileCloseWorkspace = XRCID("idFileCloseWorkspace");
int idFileClose = XRCID("idFileClose");
int idFileCloseAll = XRCID("idFileCloseAll");
@@ -264,6 +265,7 @@
EVT_UPDATE_UI(idFileSaveProjectAs, MainFrame::OnProjectMenuUpdateUI)
EVT_UPDATE_UI(idFileSaveProjectAllProjects, MainFrame::OnProjectMenuUpdateUI)
EVT_UPDATE_UI(idFileSaveProjectTemplate, MainFrame::OnProjectMenuUpdateUI)
+ EVT_UPDATE_UI(idFileSaveAll, MainFrame::OnProjectMenuUpdateUI)
EVT_UPDATE_UI(idFileCloseProject, MainFrame::OnProjectMenuUpdateUI)
EVT_UPDATE_UI(idFileCloseAllProjects, MainFrame::OnProjectMenuUpdateUI)
@@ -339,6 +341,7 @@
EVT_MENU(idFileOpenDefWorkspace, MainFrame::OnFileOpenDefWorkspace)
EVT_MENU(idFileSaveWorkspace, MainFrame::OnFileSaveWorkspace)
EVT_MENU(idFileSaveWorkspaceAs, MainFrame::OnFileSaveWorkspaceAs)
+ EVT_MENU(idFileSaveAll, MainFrame::OnFileSaveAll)
EVT_MENU(idFileCloseWorkspace, MainFrame::OnFileCloseWorkspace)
EVT_MENU(idFileClose, MainFrame::OnFileClose)
EVT_MENU(idFileCloseAll, MainFrame::OnFileCloseAll)
@@ -2337,6 +2340,20 @@
DoUpdateAppTitle();
}
+void MainFrame::OnFileSaveAll(wxCommandEvent& event)
+{
+ Manager::Get()->GetEditorManager()->SaveAll();
+ Manager::Get()->GetProjectManager()->SaveAllProjects();
+
+ if (Manager::Get()->GetProjectManager()->GetWorkspace()->GetModified()
+ && Manager::Get()->GetProjectManager()->SaveWorkspace())
+ {
+ AddToRecentProjectsHistory(Manager::Get()->GetProjectManager()->GetWorkspace()->GetFilename());
+ }
+ DoUpdateStatusBar();
+ DoUpdateAppTitle();
+}
+
void MainFrame::OnFileSaveProjectTemplate(wxCommandEvent& event)
{
TemplateManager::Get()->SaveUserTemplate(Manager::Get()->GetProjectManager()->GetActiveProject());
Index: src/src/main.h
===================================================================
--- src/src/main.h (revision 4079)
+++ src/src/main.h (working copy)
@@ -81,6 +81,7 @@
void OnFileOpenDefWorkspace(wxCommandEvent& event);
void OnFileSaveWorkspace(wxCommandEvent& event);
void OnFileSaveWorkspaceAs(wxCommandEvent& event);
+ void OnFileSaveAll(wxCommandEvent& event);
void OnFileCloseWorkspace(wxCommandEvent& event);
void OnFileClose(wxCommandEvent& event);
void OnFileCloseAll(wxCommandEvent& event);
Index: src/src/resources/main_menu.xrc
===================================================================
--- src/src/resources/main_menu.xrc (revision 4079)
+++ src/src/resources/main_menu.xrc (working copy)
@@ -101,8 +101,7 @@
<help>Save the active file under a different name</help>
</object>
<object class="wxMenuItem" name="idFileSaveAllFiles">
- <label>Save a&ll files</label>
- <accel>Ctrl-Shift-S</accel>
+ <label>Save all files</label>
<help>Save all modified files</help>
</object>
<object class="separator"/>
@@ -136,6 +135,13 @@
<help>Close current workspace</help>
</object>
<object class="separator"/>
+ <object class="wxMenuItem" name="idFileSaveAll">
+ <label>Save a&ll</label>
+ <bitmap>images\16x16\filesaveall.png</bitmap>
+ <accel>Ctrl-Shift-S</accel>
+ <help>Save all files, projects and the workspace</help>
+ </object>
+ <object class="separator"/>
<object class="wxMenuItem" name="idFileClose">
<label>&Close file</label>
<bitmap>images\16x16\fileclose.png</bitmap>
Index: src/src/resources/main_toolbar.xrc
===================================================================
--- src/src/resources/main_toolbar.xrc (revision 4079)
+++ src/src/resources/main_toolbar.xrc (working copy)
@@ -19,10 +19,10 @@
<longhelp>Save current file</longhelp>
<bitmap>images/filesave.png</bitmap>
</object>
- <object class="tool" name="idFilePrint">
- <tooltip>Print</tooltip>
- <longhelp>Print current file or all files</longhelp>
- <bitmap>images/fileprint.png</bitmap>
+ <object class="tool" name="idFileSaveAll">
+ <tooltip>Save all</tooltip>
+ <longhelp>Save all files, projects and the workspace</longhelp>
+ <bitmap>images/filesaveall.png</bitmap>
</object>
<object class="separator"/>
<object class="tool" name="idEditUndo">
Index: src/src/resources/main_toolbar_16x16.xrc
===================================================================
--- src/src/resources/main_toolbar_16x16.xrc (revision 4079)
+++ src/src/resources/main_toolbar_16x16.xrc (working copy)
@@ -18,10 +18,10 @@
<longhelp>Save current file</longhelp>
<bitmap>images/16x16/filesave.png</bitmap>
</object>
- <object class="tool" name="idFilePrint">
- <tooltip>Print</tooltip>
- <longhelp>Print current file or all files</longhelp>
- <bitmap>images/16x16/fileprint.png</bitmap>
+ <object class="tool" name="idFileSaveAll">
+ <tooltip>Save all</tooltip>
+ <longhelp>Save all files, projects and the workspace</longhelp>
+ <bitmap>images/16x16/filesaveall.png</bitmap>
</object>
<object class="separator"/>
<object class="tool" name="idEditUndo">
--- End code ---
You also find it on berlios.
Regards
raph
[attachment deleted by admin]
tiwag:
this got into svn in rev 4212, but it's buggy :P
the project file doesn't get saved in some circumstances
procedure how to produce the bug:
1* open an existing project
2* remove any file from the project
3* press the "Save All" button
4* close CB (no annoying reminder to save anything)
5* open the project again
6* enjoy the previously removed files in your project again :shock:
brgds, tiwag
update:
it seems, that removing a file from the project doesn't mark the project modified
you can close CB or close workspace without any warning about a modified project
mandrav:
--- Quote from: tiwag on July 04, 2007, 08:21:03 am ---this got into svn in rev 4212, but it's buggy :P
the project file doesn't get saved in some circumstances
procedure how to produce the bug:
1* open an existing project
2* remove any file from the project
3* press the "Save All" button
4* close CB (no annoying reminder to save anything)
5* open the project again
6* enjoy the previously removed files in your project again :shock:
brgds, tiwag
update:
it seems, that removing a file from the project doesn't mark the project modified
you can close CB or close workspace without any warning about a modified project
--- End quote ---
I could not reproduce it the way you described, but following your instructions wrong the first time (:P) I stumbled upon the bug. It is now fixed.
tiwag:
--- Quote from: mandrav on July 04, 2007, 10:15:06 am ---... I could not reproduce it the way you described, but following your instructions wrong the first time (:P) I stumbled upon the bug.
--- End quote ---
:P
thanks for the fix !
thomas:
Hmm... to be honest, I'm unhappy such a feature is being built-in now.
Could that not have gone into a plugin that adds this button? Then people who think they need it, could load that plugin.
To me, it is really not only a useless feature, but something that actually hinders workflow. There's a function that I will 100% certain never want to use, and it's placed in the middle between "save" and "undo", which are the two most often used buttons.
If you accidentially save a file (overwriting the one on disk) you can always hit "undo". But there is no undo for saving a project or a workspace. So now, when you temporarily add a compiler option to a project to make a build, you have to pay attention to no accidentially hit some stupid button, or you can do a svn revert right away too...
Navigation
[0] Message Index
[#] Next page
Go to full version