[Gitk PATCH 4/6] gitk: Add accelerator hints

Previous thread: git status options feature suggestion by Caleb Cushing on Wednesday, October 8, 2008 - 10:34 pm. (2 messages)

Next thread: Fwd: git status options feature suggestion by Caleb Cushing on Wednesday, October 8, 2008 - 11:27 pm. (26 messages)
From: Robin Rosenberg
Date: Wednesday, October 8, 2008 - 11:09 pm

(This is a resend to include gitk maintainer Paul Mackerras)

I finally got tired of pressing Alt and some letter to activate menus in Gitk. 
For example in "any" program you can press Alt-F to have the File menu drop 
down and then select the underscored character to select the wanted menu.

This series makes it possible. Friends of TCL may think my solution is too
hack-ish. It doesn't fix all of the similary problem (mostly button) but 
that is the subject of later patches as it looks like it requires other
means.

Git gui has the same problem, but again, subject to another series. 


--

From: Robin Rosenberg
Date: Wednesday, October 8, 2008 - 11:09 pm

These are the undescores menu items that can be selected with the Alt+letter,
key combination on Windows and Linux or Command+letter on Macs.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 gitk |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/gitk b/gitk
index 2eaa2ae..050019c 100755
--- a/gitk
+++ b/gitk
@@ -1750,6 +1750,33 @@ proc setoptions {} {
     option add *Entry.font uifont startupFile
 }
 
+# Menu command wrapper. Intercepts any -label arguments, 
+# removes the & and adds the -underline argument necessary
+# to implement the menu accelerator.
+proc mcw {menubar args} {
+    set ai [lsearch $args "-label"]
+    if { $ai > 0 } {
+	set label [lindex $args [expr {$ai + 1}]]
+	foreach {l u} [::tk::UnderlineAmpersand $label] {
+	    lset args [expr {$ai + 1}] $l
+	}
+	lappend args -underline
+	lappend args $u
+    }
+    set cmd [ list $menubar ]
+    foreach a $args {
+	lappend cmd $a
+    }
+    eval $cmd
+}
+
+# Wrapper for mc to remove ampersands used for accelerators.
+proc mca {label} {
+    set tl8 [mc $label]
+    foreach {l u} [::tk::UnderlineAmpersand $tl8] break
+    return $l
+}
+
 proc makewindow {} {
     global canv canv2 canv3 linespc charspc ctext cflist cscroll
     global tabstop
-- 
1.6.0.2.308.gef4a

--

From: Robin Rosenberg
Date: Wednesday, October 8, 2008 - 11:09 pm

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 gitk |   88 +++++++++++++++++++++++++++++++++---------------------------------
 1 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/gitk b/gitk
index 050019c..6298b0a 100755
--- a/gitk
+++ b/gitk
@@ -1795,31 +1795,31 @@ proc makewindow {} {
     global have_tk85
 
     menu .bar
-    .bar add cascade -label [mc "File"] -menu .bar.file
+    mcw .bar add cascade -label [mc "File"] -menu .bar.file
     menu .bar.file
-    .bar.file add command -label [mc "Update"] -command updatecommits
-    .bar.file add command -label [mc "Reload"] -command reloadcommits
-    .bar.file add command -label [mc "Reread references"] -command rereadrefs
-    .bar.file add command -label [mc "List references"] -command showrefs
-    .bar.file add command -label [mc "Quit"] -command doquit
+    mcw .bar.file add command -label [mc "Update"] -command updatecommits
+    mcw .bar.file add command -label [mc "Reload"] -command reloadcommits
+    mcw .bar.file add command -label [mc "Reread references"] -command rereadrefs
+    mcw .bar.file add command -label [mc "List references"] -command showrefs
+    mcw .bar.file add command -label [mc "Quit"] -command doquit
     menu .bar.edit
-    .bar add cascade -label [mc "Edit"] -menu .bar.edit
-    .bar.edit add command -label [mc "Preferences"] -command doprefs
+    mcw .bar add cascade -label [mc "Edit"] -menu .bar.edit
+    mcw .bar.edit add command -label [mc "Preferences"] -command doprefs
 
     menu .bar.view
-    .bar add cascade -label [mc "View"] -menu .bar.view
-    .bar.view add command -label [mc "New view..."] -command {newview 0}
-    .bar.view add command -label [mc "Edit view..."] -command editview \
+    mcw .bar add cascade -label [mc "View"] -menu .bar.view
+    mcw .bar.view add command -label [mc "New view..."] -command {newview 0}
+    mcw .bar.view add command -label [mc "Edit view..."] -command editview \
 	-state disabled
-    .bar.view add command ...
From: Robin Rosenberg
Date: Wednesday, October 8, 2008 - 11:09 pm

We intend to change the source strings. This is a "null" update
using make update-po to make the real changes easier to see later on.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 po/de.po |  443 ++++++++++++++++++++++++++++---------------------------
 po/es.po |  500 +++++++++++++++++++++++++++++++++-----------------------------
 po/it.po |  489 +++++++++++++++++++++++++++++++++----------------------------
 po/sv.po |  431 +++++++++++++++++++++++++++--------------------------
 4 files changed, 978 insertions(+), 885 deletions(-)

diff --git a/po/de.po b/po/de.po
index 04ee570..af18389 100644
--- a/po/de.po
+++ b/po/de.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: git-gui\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-05-24 22:32+0200\n"
+"POT-Creation-Date: 2008-10-07 23:06+0200\n"
 "PO-Revision-Date: 2008-05-24 22:40+0200\n"
 "Last-Translator: Christian Stimming <stimming@tuhh.de>\n"
 "Language-Team: German\n"
@@ -15,17 +15,17 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: gitk:102
+#: gitk:113
 msgid "Couldn't get list of unmerged files:"
 msgstr "Liste der nicht-zusammengef
From: Robin Rosenberg
Date: Wednesday, October 8, 2008 - 11:09 pm

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 gitk |   66 +++++++++++++++++++++++++++++++++---------------------------------
 1 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/gitk b/gitk
index 6298b0a..79de9a6 100755
--- a/gitk
+++ b/gitk
@@ -1795,31 +1795,31 @@ proc makewindow {} {
     global have_tk85
 
     menu .bar
-    mcw .bar add cascade -label [mc "File"] -menu .bar.file
+    mcw .bar add cascade -label [mc "&File"] -menu .bar.file
     menu .bar.file
-    mcw .bar.file add command -label [mc "Update"] -command updatecommits
-    mcw .bar.file add command -label [mc "Reload"] -command reloadcommits
-    mcw .bar.file add command -label [mc "Reread references"] -command rereadrefs
-    mcw .bar.file add command -label [mc "List references"] -command showrefs
-    mcw .bar.file add command -label [mc "Quit"] -command doquit
+    mcw .bar.file add command -label [mc "&Update"] -command updatecommits
+    mcw .bar.file add command -label [mc "&Reload"] -command reloadcommits
+    mcw .bar.file add command -label [mc "R&eread references"] -command rereadrefs
+    mcw .bar.file add command -label [mc "&List references"] -command showrefs
+    mcw .bar.file add command -label [mc "&Quit"] -command doquit
     menu .bar.edit
-    mcw .bar add cascade -label [mc "Edit"] -menu .bar.edit
-    mcw .bar.edit add command -label [mc "Preferences"] -command doprefs
+    mcw .bar add cascade -label [mc "&Edit"] -menu .bar.edit
+    mcw .bar.edit add command -label [mc "&Preferences"] -command doprefs
 
     menu .bar.view
-    mcw .bar add cascade -label [mc "View"] -menu .bar.view
-    mcw .bar.view add command -label [mc "New view..."] -command {newview 0}
-    mcw .bar.view add command -label [mc "Edit view..."] -command editview \
+    mcw .bar add cascade -label [mc "&View"] -menu .bar.view
+    mcw .bar.view add command -label [mc "&New view..."] -command {newview 0}
+    mcw .bar.view add command -label [mc "&Edit view..."] -command ...
From: Robin Rosenberg
Date: Wednesday, October 8, 2008 - 11:09 pm

make update-po

Also unmade all new "fuzzy" tags

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 po/de.po |   92 +++++++++++++++++++++++++++++++++++++------------------------
 po/es.po |   92 +++++++++++++++++++++++++++++++++++++------------------------
 po/it.po |   92 +++++++++++++++++++++++++++++++++++++------------------------
 po/sv.po |   92 +++++++++++++++++++++++++++++++++++++------------------------
 4 files changed, 224 insertions(+), 144 deletions(-)

diff --git a/po/de.po b/po/de.po
index af18389..aea76a7 100644
--- a/po/de.po
+++ b/po/de.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: git-gui\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-10-07 23:06+0200\n"
+"POT-Creation-Date: 2008-10-07 23:08+0200\n"
 "PO-Revision-Date: 2008-05-24 22:40+0200\n"
 "Last-Translator: Christian Stimming <stimming@tuhh.de>\n"
 "Language-Team: German\n"
@@ -67,67 +67,67 @@ msgid "Cancel"
 msgstr "Abbrechen"
 
 #: gitk:1798
-msgid "File"
+msgid "&File"
 msgstr "Datei"
 
 #: gitk:1800
-msgid "Update"
+msgid "&Update"
 msgstr "Aktualisieren"
 
 #: gitk:1801
-msgid "Reload"
+msgid "&Reload"
 msgstr "Neu laden"
 
 #: gitk:1802
-msgid "Reread references"
+msgid "R&eread references"
 msgstr "Zweige neu laden"
 
 #: gitk:1803
-msgid "List references"
+msgid "&List references"
 msgstr "Zweige/Markierungen auflisten"
 
 #: gitk:1804
-msgid "Quit"
+msgid "&Quit"
 msgstr "Beenden"
 
 #: gitk:1806
-msgid "Edit"
+msgid "&Edit"
 msgstr "Bearbeiten"
 
 #: gitk:1807
-msgid "Preferences"
+msgid "&Preferences"
 msgstr "Einstellungen"
 
-#: gitk:1810 gitk:3193
-msgid "View"
+#: gitk:1810
+msgid "&View"
 msgstr "Ansicht"
 
 #: gitk:1811
-msgid "New view..."
+msgid "&New view..."
 msgstr "Neue Ansicht..."
 
 #: gitk:1812
-msgid "Edit view..."
+msgid "&Edit view..."
 msgstr "Ansicht bearbeiten..."
 
 #: gitk:1814
-msgid "Delete view"
+msgid "&Delete view"
 msgstr "Ansicht l
From: Robin Rosenberg
Date: Wednesday, October 8, 2008 - 11:09 pm

---
 po/sv.po |   60 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/po/sv.po b/po/sv.po
index c1c3ed2..af3da51 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -69,67 +69,67 @@ msgstr "Avbryt"
 
 #: gitk:1798
 msgid "&File"
-msgstr "Arkiv"
+msgstr "&Arkiv"
 
 #: gitk:1800
 msgid "&Update"
-msgstr "Uppdatera"
+msgstr "&Uppdatera"
 
 #: gitk:1801
 msgid "&Reload"
-msgstr "Ladda om"
+msgstr "&Ladda om"
 
 #: gitk:1802
 msgid "R&eread references"
-msgstr "L
From: Paul Mackerras
Date: Friday, October 10, 2008 - 6:40 pm

Where did you find out about ::tk::UnderlineAmpersand?  Is it part of

	return [string map {"&" ""} [mc $label]]

instead, perhaps?

Paul.
--

From: Robin Rosenberg
Date: Saturday, October 11, 2008 - 4:39 am

I found it here. http://wiki.tcl.tk/1632. It hints that it may not be unoffical. Seems to
original from: http://groups.google.com/group/comp.lang.perl.tk/browse_thread/thread/5b6f4c6a4a9f17b4...

so if someone thinks there is a problem we could replace it with UnderlineAmpersand
In theory we should translate && to & also, which UnderLineAmpersand does.

-- robin
--

From: Paul Mackerras
Date: Friday, October 10, 2008 - 7:44 pm

It'll do for a first cut, but there would be a nicer way to do it, I
think.

Also, I think patches 2 and 4 should be combined into one, as should
patches 5 and 6.  I'll do that and apply the series as 4 commits,
unless you have an objection.

Paul.
--

From: Robin Rosenberg
Date: Saturday, October 11, 2008 - 4:14 am

I split the commits to simplify review. My thought about squashing would
be different, but I have no strong opinions here. I was thinking 1+2, 4+5, 3+5, 6

-- robin
--

From: Paul Mackerras
Date: Saturday, October 18, 2008 - 5:11 am

Have a look at what I just pushed out.  It adds infrastructure to let
us use "&" in menu items to specify an alt+letter accelerator, but in
a different way to your patches.  If you'd like to redo your patch to
add "&" to the menu items, that would be good.

Paul.
--

From: Robin Rosenberg
Date: Sunday, October 19, 2008 - 2:19 pm

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---


Looks fine. Seems to work too. Then we want to do the same thing
with buttons. Btw, is it only for me that the "popup menu key" does
not work for in gitk?

This patch does not include re-generated po's, nor the updated swedish translation.

-- robin

 gitk |   72 +++++++++++++++++++++++++++++++++---------------------------------
 1 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/gitk b/gitk
index 3678de1..e65c0ce 100755
--- a/gitk
+++ b/gitk
@@ -1817,26 +1817,26 @@ proc makewindow {} {
     # The "mc" arguments here are purely so that xgettext
     # sees the following string as needing to be translated
     makemenu .bar {
-	{mc "File" cascade {
-	    {mc "Update" command updatecommits -accelerator F5}
-	    {mc "Reload" command reloadcommits}
-	    {mc "Reread references" command rereadrefs}
-	    {mc "List references" command showrefs}
-	    {mc "Quit" command doquit}
+	{mc "&File" cascade {
+	    {mc "&Update" command updatecommits -accelerator F5}
+	    {mc "&Reload" command reloadcommits}
+	    {mc "R&eread references" command rereadrefs}
+	    {mc "&List references" command showrefs}
+	    {mc "&Quit" command doquit}
 	}}
-	{mc "Edit" cascade {
-	    {mc "Preferences" command doprefs}
+	{mc "&Edit" cascade {
+	    {mc "&Preferences" command doprefs}
 	}}
-	{mc "View" cascade {
-	    {mc "New view..." command {newview 0}}
-	    {mc "Edit view..." command editview -state disabled}
-	    {mc "Delete view" command delview -state disabled}
+	{mc "&View" cascade {
+	    {mc "&New view..." command {newview 0}}
+	    {mc "&Edit view..." command editview -state disabled}
+	    {mc "&Delete view" command delview -state disabled}
 	    {xx "" separator}
-	    {mc "All files" radiobutton {selectedview 0} -command {showview 0}}
+	    {mc "&All files" radiobutton {selectedview 0} -command {showview 0}}
 	}}
-	{mc "Help" cascade {
-	    {mc "About gitk" command about}
-	    {mc "Key ...
From: Robin Rosenberg
Date: Sunday, October 19, 2008 - 3:00 pm

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 gitk |   80 +++++++++++++++++++++++++++++++++---------------------------------
 1 files changed, 40 insertions(+), 40 deletions(-)

This one is slightly better than the first one.  Works with gitk id...id too.

-- robin

diff --git a/gitk b/gitk
index 3678de1..df039b9 100755
--- a/gitk
+++ b/gitk
@@ -1817,26 +1817,26 @@ proc makewindow {} {
     # The "mc" arguments here are purely so that xgettext
     # sees the following string as needing to be translated
     makemenu .bar {
-	{mc "File" cascade {
-	    {mc "Update" command updatecommits -accelerator F5}
-	    {mc "Reload" command reloadcommits}
-	    {mc "Reread references" command rereadrefs}
-	    {mc "List references" command showrefs}
-	    {mc "Quit" command doquit}
+	{mc "&File" cascade {
+	    {mc "&Update" command updatecommits -accelerator F5}
+	    {mc "&Reload" command reloadcommits}
+	    {mc "R&eread references" command rereadrefs}
+	    {mc "&List references" command showrefs}
+	    {mc "&Quit" command doquit}
 	}}
-	{mc "Edit" cascade {
-	    {mc "Preferences" command doprefs}
+	{mc "&Edit" cascade {
+	    {mc "&Preferences" command doprefs}
 	}}
-	{mc "View" cascade {
-	    {mc "New view..." command {newview 0}}
-	    {mc "Edit view..." command editview -state disabled}
-	    {mc "Delete view" command delview -state disabled}
+	{mc "&View" cascade {
+	    {mc "&New view..." command {newview 0}}
+	    {mc "&Edit view..." command editview -state disabled}
+	    {mc "&Delete view" command delview -state disabled}
 	    {xx "" separator}
-	    {mc "All files" radiobutton {selectedview 0} -command {showview 0}}
+	    {mc "&All files" radiobutton {selectedview 0} -command {showview 0}}
 	}}
-	{mc "Help" cascade {
-	    {mc "About gitk" command about}
-	    {mc "Key bindings" command keys}
+	{mc "&Help" cascade {
+	    {mc "&About gitk" command about}
+	    {mc "&Key bindings" command keys}
 	}}
     }
     . configure -menu ...
From: Paul Mackerras
Date: Monday, October 20, 2008 - 4:21 pm

With that patch, I'm finding that pressing Alt-f pops up the File
menu, but also triggers the binding for 'f' in the main window (scroll
diff window to the next file), which is annoying.  I'm not sure why, I
will need to track that down.

Paul.
--

Previous thread: git status options feature suggestion by Caleb Cushing on Wednesday, October 8, 2008 - 10:34 pm. (2 messages)

Next thread: Fwd: git status options feature suggestion by Caleb Cushing on Wednesday, October 8, 2008 - 11:27 pm. (26 messages)