Re: [Kicad-developers] [Patch] Unify close menu item creation for non-main windows

2019-08-14 Thread Jeff Young
Hi Ian,

I merged your patch.  Thanks for your contribution!

Cheers,
Jeff.


> On 14 Aug 2019, at 00:40, Ian McInerney  wrote:
> 
> Right now the addition of the Close item for the non-main windows is 
> scattered in the menu creation functions. This means it is easy to leave out 
> the accelerator key entry when adding a new one (yes, I forgot that in 
> cvpcb...). This patch will push the creation of the menu item into a common 
> method in CONDITIONAL_MENU that is then just called by each window. It also 
> introduces a tooltip for the item that includes the app name. This unifies 
> all the close items, and ensures they have the proper CTRL-W accelerator key 
> assigned.
> 
> Note that this does not unify the one for the simulation window. That window 
> is a wxFormbuilder window so its menu is not a CONDITIONAL_MENU and can't use 
> this.
> 
> -Ian
> <0001-Unify-menu-item-creation-for-closing-a-window.patch>___
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp


___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


[Kicad-developers] [Patch] Unify close menu item creation for non-main windows

2019-08-13 Thread Ian McInerney
Right now the addition of the Close item for the non-main windows is
scattered in the menu creation functions. This means it is easy to leave
out the accelerator key entry when adding a new one (yes, I forgot that in
cvpcb...). This patch will push the creation of the menu item into a common
method in CONDITIONAL_MENU that is then just called by each window. It also
introduces a tooltip for the item that includes the app name. This unifies
all the close items, and ensures they have the proper CTRL-W accelerator
key assigned.

Note that this does not unify the one for the simulation window. That
window is a wxFormbuilder window so its menu is not a CONDITIONAL_MENU and
can't use this.

-Ian
From 0fd6b672ce8b99f681497e1dba2746e2e84e5840 Mon Sep 17 00:00:00 2001
From: Ian McInerney 
Date: Wed, 14 Aug 2019 01:34:05 +0200
Subject: [PATCH] Unify menu item creation for closing a window

* Push a function into CONDITIONAL_MENU that adds the item
* Modify the tooltip for close and exit items to have the
  program name

Fixes: lp:1835454
* https://bugs.launchpad.net/kicad/+bug/1835454
---
 3d-viewer/3d_viewer/3d_menubar.cpp   |  3 +--
 common/tool/conditional_menu.cpp | 14 +++---
 cvpcb/menubar.cpp|  2 +-
 eeschema/libedit/menubar_libedit.cpp |  2 +-
 eeschema/menubar.cpp |  2 +-
 eeschema/toolbars_viewlib.cpp|  3 +--
 gerbview/menubar.cpp |  2 +-
 include/tool/conditional_menu.h  | 18 +++---
 kicad/menubar.cpp|  2 +-
 pagelayout_editor/menubar.cpp|  2 +-
 pcbnew/menubar_footprint_editor.cpp  |  3 +--
 pcbnew/menubar_pcb_editor.cpp|  2 +-
 pcbnew/toolbars_footprint_viewer.cpp |  3 +--
 13 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/3d-viewer/3d_viewer/3d_menubar.cpp b/3d-viewer/3d_viewer/3d_menubar.cpp
index 0b887430e..273403b59 100644
--- a/3d-viewer/3d_viewer/3d_menubar.cpp
+++ b/3d-viewer/3d_viewer/3d_menubar.cpp
@@ -54,8 +54,7 @@ void EDA_3D_VIEWER::CreateMenuBar()
export_xpm, SELECTION_CONDITIONS::ShowAlways );
 
 fileMenu->AddSeparator();
-fileMenu->AddItem( wxID_CLOSE, _( "Close\tCTRL+W" ), "",
-   exit_xpm,   SELECTION_CONDITIONS::ShowAlways );
+fileMenu->AddClose( _( "3D Viewer" ) );
 
 fileMenu->Resolve();
 
diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp
index f55756d2e..fdda4686a 100644
--- a/common/tool/conditional_menu.cpp
+++ b/common/tool/conditional_menu.cpp
@@ -99,17 +99,25 @@ void CONDITIONAL_MENU::AddSeparator( int aOrder )
 }
 
 
-void CONDITIONAL_MENU::AddQuitOrClose( KIFACE_I* aKiface )
+void CONDITIONAL_MENU::AddClose( wxString aAppname )
+{
+AddItem( wxID_CLOSE, _( "Close\tCTRL+W" ), wxString::Format( "Close %s", aAppname ), exit_xpm,
+SELECTION_CONDITIONS::ShowAlways );
+}
+
+
+void CONDITIONAL_MENU::AddQuitOrClose( KIFACE_I* aKiface, wxString aAppname )
 {
 if( !aKiface || aKiface->IsSingle() ) // not when under a project mgr
 {
 // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via
 // wxID_EXIT
-AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways );
+AddItem( wxID_EXIT, _( "Quit" ), wxString::Format( "Quit %s", aAppname ), exit_xpm,
+SELECTION_CONDITIONS::ShowAlways );
 }
 else
 {
-AddItem( wxID_CLOSE, _( "Close\tCTRL+W" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways );
+AddClose( aAppname );
 }
 }
 
diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp
index 5ecae291d..c0d9e9088 100644
--- a/cvpcb/menubar.cpp
+++ b/cvpcb/menubar.cpp
@@ -47,7 +47,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
 
 fileMenu->AddItem( CVPCB_ACTIONS::saveAssociations, SELECTION_CONDITIONS::ShowAlways );
 fileMenu->AddSeparator();
-fileMenu->AddItem( wxID_CLOSE, _( "Close" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways );
+fileMenu->AddClose( _( "Assign Footprints" ) );
 
 fileMenu->Resolve();
 
diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp
index 4d1dfa875..a1c2b1bfc 100644
--- a/eeschema/libedit/menubar_libedit.cpp
+++ b/eeschema/libedit/menubar_libedit.cpp
@@ -82,7 +82,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
 fileMenu->AddMenu( submenuExport,  EE_CONDITIONS::ShowAlways );
 
 fileMenu->AddSeparator();
-fileMenu->AddItem( wxID_CLOSE, _( "Close\tCTRL+W" ), "", exit_xpm, EE_CONDITIONS::ShowAlways );
+fileMenu->AddClose( _( "Library Editor" ) );
 
 fileMenu->Resolve();
 
diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp
index 1f0d70e70..74c529843 100644
--- a/eeschema/menubar.cpp
+++ b/eeschema/menubar.cpp
@@ -115,7 +115,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
 fileMenu->AddItem( ACTIONS::plot,  EE_CONDITIONS::ShowAlways );
 
 fileMenu->AddSeparator();
-