Patch #837 2006-02-15 19:03

mortenmacfly

Enhancement for compiler interface GUI: Clear buttons
Download
837-Enhancement_for.patch (8.6 KB)
Category
Application::Refinement
Status
Accepted
Close date
2006-02-16 09:40
Assigned to
 
Index: plugins/compilergcc/compileroptionsdlg.h
===================================================================
--- plugins/compilergcc/compileroptionsdlg.h    (revision 2006)
+++ plugins/compilergcc/compileroptionsdlg.h    (working copy)
@@ -67,9 +67,11 @@
         void OnAddDirClick(wxCommandEvent& event);
         void OnEditDirClick(wxCommandEvent& event);
         void OnRemoveDirClick(wxCommandEvent& event);
+        void OnClearDirClick(wxCommandEvent& event);
         void OnAddVarClick(wxCommandEvent& event);
         void OnEditVarClick(wxCommandEvent& event);
         void OnRemoveVarClick(wxCommandEvent& event);
+        void OnClearVarClick(wxCommandEvent& event);
         void OnSetDefaultCompilerClick(wxCommandEvent& event);
         void OnAddCompilerClick(wxCommandEvent& event);
         void OnEditCompilerClick(wxCommandEvent& event);
Index: plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- plugins/compilergcc/compileroptionsdlg.cpp    (revision 2006)
+++ plugins/compilergcc/compileroptionsdlg.cpp    (working copy)
@@ -43,9 +43,11 @@
 BEGIN_EVENT_TABLE(CompilerOptionsDlg, wxPanel)
     EVT_UPDATE_UI(            XRCID("btnEditDir"),        CompilerOptionsDlg::OnUpdateUI)
     EVT_UPDATE_UI(            XRCID("btnDelDir"),            CompilerOptionsDlg::OnUpdateUI)
+    EVT_UPDATE_UI(            XRCID("btnClearDir"),            CompilerOptionsDlg::OnUpdateUI)
     EVT_UPDATE_UI(            XRCID("spnDirs"),            CompilerOptionsDlg::OnUpdateUI)
     EVT_UPDATE_UI(            XRCID("btnEditVar"),        CompilerOptionsDlg::OnUpdateUI)
     EVT_UPDATE_UI(            XRCID("btnDeleteVar"),        CompilerOptionsDlg::OnUpdateUI)
+    EVT_UPDATE_UI(            XRCID("btnClearVar"),        CompilerOptionsDlg::OnUpdateUI)
     EVT_UPDATE_UI(            XRCID("cmbCompilerPolicy"),    CompilerOptionsDlg::OnUpdateUI)
     EVT_UPDATE_UI(            XRCID("cmbLinkerPolicy"),    CompilerOptionsDlg::OnUpdateUI)
     EVT_UPDATE_UI(            XRCID("cmbIncludesPolicy"),    CompilerOptionsDlg::OnUpdateUI)
@@ -97,6 +99,7 @@
     EVT_LISTBOX_DCLICK(        XRCID("lstLibDirs"),        CompilerOptionsDlg::OnEditDirClick)
     EVT_LISTBOX_DCLICK(        XRCID("lstResDirs"),        CompilerOptionsDlg::OnEditDirClick)
     EVT_BUTTON(                XRCID("btnDelDir"),            CompilerOptionsDlg::OnRemoveDirClick)
+    EVT_BUTTON(                XRCID("btnClearDir"),            CompilerOptionsDlg::OnClearDirClick)
     EVT_BUTTON(                XRCID("btnAddLib"),            CompilerOptionsDlg::OnAddLibClick)
     EVT_BUTTON(                XRCID("btnEditLib"),        CompilerOptionsDlg::OnEditLibClick)
     EVT_LISTBOX_DCLICK(        XRCID("lstLibs"),           CompilerOptionsDlg::OnEditLibClick)
@@ -112,6 +115,7 @@
     EVT_BUTTON(                XRCID("btnAddVar"),            CompilerOptionsDlg::OnAddVarClick)
     EVT_BUTTON(                XRCID("btnEditVar"),        CompilerOptionsDlg::OnEditVarClick)
     EVT_BUTTON(                XRCID("btnDeleteVar"),        CompilerOptionsDlg::OnRemoveVarClick)
+    EVT_BUTTON(                XRCID("btnClearVar"),        CompilerOptionsDlg::OnClearVarClick)
     EVT_BUTTON(                XRCID("btnMasterPath"),        CompilerOptionsDlg::OnMasterPathClick)
     EVT_BUTTON(                XRCID("btnAutoDetect"),        CompilerOptionsDlg::OnAutoDetectClick)
     EVT_BUTTON(                XRCID("btnCcompiler"),        CompilerOptionsDlg::OnSelectProgramClick)
@@ -1074,6 +1078,19 @@
     }
 }
 
+void CompilerOptionsDlg::OnClearDirClick(wxCommandEvent& event)
+{
+    wxListBox* control = GetDirsListBox();
+    if (!control || control->GetSelection() < 0)
+        return;
+    if (cbMessageBox(_("Remove all directories from the list?"),
+                    _("Confirmation"),
+                    wxOK | wxCANCEL | wxICON_QUESTION) == wxID_OK)
+    {
+        control->Clear();
+    }
+}
+
 void CompilerOptionsDlg::OnAddVarClick(wxCommandEvent& event)
 {
     CompileOptionsBase* base = GetVarsOwner();
@@ -1145,6 +1162,32 @@
     }
 }
 
+void CompilerOptionsDlg::OnClearVarClick(wxCommandEvent& event)
+{
+    wxListBox* lstVars = XRCCTRL(*this, "lstVars", wxListBox);
+    if (lstVars->IsEmpty())
+        return;
+
+  CompileOptionsBase* base = GetVarsOwner();
+  if (!base)
+    return;
+
+    if (cbMessageBox(_("Are you sure you want to clear all variables?"),
+                   _("Confirmation"),
+                   wxYES | wxNO | wxICON_QUESTION) == wxID_YES)
+    {
+    // Unset all variables of lstVars
+    for (int i=0; i<lstVars->GetCount(); i++)
+    {
+      wxString key = lstVars->GetString(i).BeforeFirst(_T('=')).Trim(true);
+      if (!key.IsEmpty())
+        base->UnsetVar(key);
+    }
+
+    lstVars->Clear();
+    }
+}
+
 void CompilerOptionsDlg::OnSetDefaultCompilerClick(wxCommandEvent& event)
 {
     wxComboBox* cmb = XRCCTRL(*this, "cmbCompiler", wxComboBox);
@@ -1542,10 +1585,11 @@
download for full patch...
mortenmacfly 2006-02-15 19:04

Based on the "clear patch" here: http://forums.codeblocks.org/index.php?topic=2332.0?

In addition I've prepared another patch that adds the same buttons (clear) to the other compiler settings listboxes as well (where it is appropriate).

I am open for dicussions on this: I think (for me) the most important was the clear for the libraries. But if you think of the same situation as described in the post stated above, the clear buttons for the other elements might be useful as well. Furthermore this leads to a more "consistent" GUI. If you agree you might inspect/apply the patch then... Do you agree?

I have used the SVN diff, the patch is at least compatible to revision 2006-2012.

mandrav 2006-02-16 09:40

Patch applied. Thank you.

Although you forgot to do it for "Programs/Additional paths" ;)

mortenmacfly 2006-02-16 12:34

> Although you forgot to do it for "Programs/Additional paths" ;)

Ooops - you are right. I missed that becasue I was focusing on the GUI that appears if you choose the "Build options" of a project. I have added another patch though BerliOS to fix that. Sorry.