* [PATCH (GITK) v3 0/6] Enhance popup dialogs in gitk.
@ 2008-11-02 18:59 Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Alexander Gavrilov
0 siblings, 1 reply; 21+ messages in thread
From: Alexander Gavrilov @ 2008-11-02 18:59 UTC (permalink / raw)
To: git; +Cc: Paul Mackerras
This is a resend of my gitk patches rebased on top of the current
master. I also split the first patch into three parts.
Alexander Gavrilov (6):
gitk: Add Return and Escape bindings to dialogs.
gitk: Make gitk dialog windows transient.
gitk: Add accelerators to frequently used menu commands.
gitk: Make cherry-pick call git-citool on conflicts.
gitk: Implement a user-friendly Edit View dialog.
gitk: Explicitly position popup windows.
gitk | 375 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 303 insertions(+), 72 deletions(-)
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs. 2008-11-02 18:59 [PATCH (GITK) v3 0/6] Enhance popup dialogs in gitk Alexander Gavrilov @ 2008-11-02 18:59 ` Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Alexander Gavrilov 2008-11-07 11:41 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Paul Mackerras 0 siblings, 2 replies; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-02 18:59 UTC (permalink / raw) To: git; +Cc: Paul Mackerras It is often more convenient to dismiss or accept a dialog using the keyboard, than by clicking buttons on the screen. This commit adds key binding to make it possible with gitk's dialogs. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- gitk | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/gitk b/gitk index 3fe1b47..edef9e2 100755 --- a/gitk +++ b/gitk @@ -1746,6 +1746,8 @@ proc show_error {w top msg} { pack $w.ok -side bottom -fill x bind $top <Visibility> "grab $top; focus $top" bind $top <Key-Return> "destroy $top" + bind $top <Key-space> "destroy $top" + bind $top <Key-Escape> "destroy $top" tkwait window $top } @@ -1769,6 +1771,9 @@ proc confirm_popup msg { button $w.cancel -text [mc Cancel] -command "destroy $w" pack $w.cancel -side right -fill x bind $w <Visibility> "grab $w; focus $w" + bind $w <Key-Return> "set confirm_ok 1; destroy $w" + bind $w <Key-space> "set confirm_ok 1; destroy $w" + bind $w <Key-Escape> "destroy $w" tkwait window $w return $confirm_ok } @@ -2611,6 +2616,7 @@ proc keys {} { -justify left -bg white -border 2 -relief groove pack $w.m -side top -fill both -padx 2 -pady 2 button $w.ok -text [mc "Close"] -command "destroy $w" -default active + bind $w <Key-Escape> [list destroy $w] pack $w.ok -side bottom bind $w <Visibility> "focus $w.ok" bind $w <Key-Escape> "destroy $w" @@ -3533,6 +3539,7 @@ proc vieweditor {top n title} { frame $top.buts button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n] button $top.buts.can -text [mc "Cancel"] -command [list destroy $top] + bind $top <Escape> [list destroy $top] grid $top.buts.ok $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a @@ -7793,6 +7800,8 @@ proc mkpatch {} { frame $top.buts button $top.buts.gen -text [mc "Generate"] -command mkpatchgo button $top.buts.can -text [mc "Cancel"] -command mkpatchcan + bind $top <Key-Return> mkpatchgo + bind $top <Key-Escape> mkpatchcan grid $top.buts.gen $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a @@ -7864,6 +7873,8 @@ proc mktag {} { frame $top.buts button $top.buts.gen -text [mc "Create"] -command mktaggo button $top.buts.can -text [mc "Cancel"] -command mktagcan + bind $top <Key-Return> mktaggo + bind $top <Key-Escape> mktagcan grid $top.buts.gen $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a @@ -7967,6 +7978,8 @@ proc writecommit {} { frame $top.buts button $top.buts.gen -text [mc "Write"] -command wrcomgo button $top.buts.can -text [mc "Cancel"] -command wrcomcan + bind $top <Key-Return> wrcomgo + bind $top <Key-Escape> wrcomcan grid $top.buts.gen $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a @@ -8014,6 +8027,8 @@ proc mkbranch {} { frame $top.buts button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top] button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}" + bind $top <Key-Return> [list mkbrgo $top] + bind $top <Key-Escape> "catch {destroy $top}" grid $top.buts.go $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a @@ -8138,6 +8153,7 @@ proc resethead {} { button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w" pack $w.ok -side left -fill x -padx 20 -pady 20 button $w.cancel -text [mc Cancel] -command "destroy $w" + bind $w <Key-Escape> [list destroy $w] pack $w.cancel -side right -fill x -padx 20 -pady 20 bind $w <Visibility> "grab $w; focus $w" tkwait window $w @@ -8315,6 +8331,7 @@ proc showrefs {} { pack $top.f.l -side left grid $top.f - -sticky ew -pady 2 button $top.close -command [list destroy $top] -text [mc "Close"] + bind $top <Key-Escape> [list destroy $top] grid $top.close - grid columnconfigure $top 0 -weight 1 grid rowconfigure $top 0 -weight 1 @@ -9666,6 +9683,8 @@ proc choosefont {font which} { frame $top.buts button $top.buts.ok -text [mc "OK"] -command fontok -default active button $top.buts.can -text [mc "Cancel"] -command fontcan -default normal + bind $top <Key-Return> fontok + bind $top <Key-Escape> fontcan grid $top.buts.ok $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a @@ -9845,6 +9864,8 @@ proc doprefs {} { frame $top.buts button $top.buts.ok -text [mc "OK"] -command prefsok -default active button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal + bind $top <Key-Return> prefsok + bind $top <Key-Escape> prefscan grid $top.buts.ok $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient. 2008-11-02 18:59 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Alexander Gavrilov @ 2008-11-02 18:59 ` Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Alexander Gavrilov 2008-11-07 11:41 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Paul Mackerras 2008-11-07 11:41 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Paul Mackerras 1 sibling, 2 replies; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-02 18:59 UTC (permalink / raw) To: git; +Cc: Paul Mackerras Transient windows are always kept above their parent, and don't occupy any space in the taskbar, which is useful for dialogs. Also, when transient is used, it is important to bind windows to the correct parent. This commit adds transient annotations to all dialogs, ensures usage of the correct parent for error and confirmation popups, and, as a side job, makes gitk preserve the create tag dialog window in case of errors. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- gitk | 46 ++++++++++++++++++++++++++++------------------ 1 files changed, 28 insertions(+), 18 deletions(-) diff --git a/gitk b/gitk index edef9e2..41d3d2d 100755 --- a/gitk +++ b/gitk @@ -1751,19 +1751,19 @@ proc show_error {w top msg} { tkwait window $top } -proc error_popup msg { +proc error_popup {msg {owner .}} { set w .error toplevel $w - wm transient $w . + wm transient $w $owner show_error $w $w $msg } -proc confirm_popup msg { +proc confirm_popup {msg {owner .}} { global confirm_ok set confirm_ok 0 set w .confirm toplevel $w - wm transient $w . + wm transient $w $owner message $w.m -text $msg -justify center -aspect 400 pack $w.m -side top -fill x -padx 20 -pady 20 button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w" @@ -2546,6 +2546,7 @@ proc about {} { } toplevel $w wm title $w [mc "About gitk"] + wm transient $w . message $w.m -text [mc " Gitk - a commit viewer for git @@ -2574,6 +2575,7 @@ proc keys {} { } toplevel $w wm title $w [mc "Gitk key bindings"] + wm transient $w . message $w.m -text " [mc "Gitk key bindings:"] @@ -3503,6 +3505,7 @@ proc vieweditor {top n title} { toplevel $top wm title $top $title + wm transient $top . label $top.nl -text [mc "Name"] entry $top.name -width 20 -textvariable newviewname($n) grid $top.nl $top.name -sticky w -pady 5 @@ -3572,9 +3575,7 @@ proc newviewok {top n} { if {[catch { set newargs [shellsplit $newviewargs($n)] } err]} { - error_popup "[mc "Error in commit selection arguments:"] $err" - wm raise $top - focus $top + error_popup "[mc "Error in commit selection arguments:"] $err" $top return } set files {} @@ -7770,6 +7771,7 @@ proc mkpatch {} { set patchtop $top catch {destroy $top} toplevel $top + wm transient $top . label $top.title -text [mc "Generate patch"] grid $top.title - -pady 10 label $top.from -text [mc "From:"] @@ -7836,7 +7838,7 @@ proc mkpatchgo {} { set cmd [lrange $cmd 1 end] lappend cmd >$fname & if {[catch {eval exec $cmd} err]} { - error_popup "[mc "Error creating patch:"] $err" + error_popup "[mc "Error creating patch:"] $err" $patchtop } catch {destroy $patchtop} unset patchtop @@ -7856,6 +7858,7 @@ proc mktag {} { set mktagtop $top catch {destroy $top} toplevel $top + wm transient $top . label $top.title -text [mc "Create tag"] grid $top.title - -pady 10 label $top.id -text [mc "ID:"] @@ -7888,18 +7891,18 @@ proc domktag {} { set id [$mktagtop.sha1 get] set tag [$mktagtop.tag get] if {$tag == {}} { - error_popup [mc "No tag name specified"] - return + error_popup [mc "No tag name specified"] $mktagtop + return 0 } if {[info exists tagids($tag)]} { - error_popup [mc "Tag \"%s\" already exists" $tag] - return + error_popup [mc "Tag \"%s\" already exists" $tag] $mktagtop + return 0 } if {[catch { exec git tag $tag $id } err]} { - error_popup "[mc "Error creating tag:"] $err" - return + error_popup "[mc "Error creating tag:"] $err" $mktagtop + return 0 } set tagids($tag) $id @@ -7908,6 +7911,7 @@ proc domktag {} { addedtag $id dispneartags 0 run refill_reflist + return 1 } proc redrawtags {id} { @@ -7946,7 +7950,7 @@ proc mktagcan {} { } proc mktaggo {} { - domktag + if {![domktag]} return mktagcan } @@ -7957,6 +7961,7 @@ proc writecommit {} { set wrcomtop $top catch {destroy $top} toplevel $top + wm transient $top . label $top.title -text [mc "Write commit to file"] grid $top.title - -pady 10 label $top.id -text [mc "ID:"] @@ -7994,7 +7999,7 @@ proc wrcomgo {} { set cmd "echo $id | [$wrcomtop.cmd get]" set fname [$wrcomtop.fname get] if {[catch {exec sh -c $cmd >$fname &} err]} { - error_popup "[mc "Error writing commit:"] $err" + error_popup "[mc "Error writing commit:"] $err" $wrcomtop } catch {destroy $wrcomtop} unset wrcomtop @@ -8013,6 +8018,7 @@ proc mkbranch {} { set top .makebranch catch {destroy $top} toplevel $top + wm transient $top . label $top.title -text [mc "Create new branch"] grid $top.title - -pady 10 label $top.id -text [mc "ID:"] @@ -8044,12 +8050,12 @@ proc mkbrgo {top} { set cmdargs {} set old_id {} if {$name eq {}} { - error_popup [mc "Please specify a name for the new branch"] + error_popup [mc "Please specify a name for the new branch"] $top return } if {[info exists headids($name)]} { if {![confirm_popup [mc \ - "Branch '%s' already exists. Overwrite?" $name]]} { + "Branch '%s' already exists. Overwrite?" $name] $top]} { return } set old_id $headids($name) @@ -8310,6 +8316,7 @@ proc showrefs {} { } toplevel $top wm title $top [mc "Tags and heads: %s" [file tail [pwd]]] + wm transient $top . text $top.list -background $bgcolor -foreground $fgcolor \ -selectbackground $selectbgcolor -font mainfont \ -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \ @@ -9637,6 +9644,7 @@ proc mkfontdisp {font top which} { proc choosefont {font which} { global fontparam fontlist fonttop fontattr + global prefstop set fontparam(which) $which set fontparam(font) $font @@ -9650,6 +9658,7 @@ proc choosefont {font which} { font create sample eval font config sample [font actual $font] toplevel $top + wm transient $top $prefstop wm title $top [mc "Gitk font chooser"] label $top.l -textvariable fontparam(which) pack $top.l -side top @@ -9766,6 +9775,7 @@ proc doprefs {} { } toplevel $top wm title $top [mc "Gitk preferences"] + wm transient $top . label $top.ldisp -text [mc "Commit list display options"] grid $top.ldisp - -sticky w -pady 10 label $top.spacer -text " " -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands. 2008-11-02 18:59 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Alexander Gavrilov @ 2008-11-02 18:59 ` Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov 2008-11-07 11:50 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Paul Mackerras 2008-11-07 11:41 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Paul Mackerras 1 sibling, 2 replies; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-02 18:59 UTC (permalink / raw) To: git; +Cc: Paul Mackerras This commit documents keyboard accelerators used for menu commands in the menu, as it is usually done, and adds some more, e.g. F4 to invoke Edit View. The changes include a workaround for handling Shift-F4 on systems where XKB binds special XF86_Switch_VT_* symbols to Ctrl-Alt-F* combinations. Tk often receives these codes when Shift-F* is pressed, so it is necessary to bind the relevant actions to them as well. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- gitk | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-) diff --git a/gitk b/gitk index 41d3d2d..f747c70 100755 --- a/gitk +++ b/gitk @@ -1801,6 +1801,11 @@ proc setoptions {} { # command to invoke for command, or {variable value} for radiobutton proc makemenu {m items} { menu $m + if {[tk windowingsystem] eq {aqua}} { + set M1T Cmd + } else { + set M1T Ctrl + } foreach i $items { set name [mc [lindex $i 1]] set type [lindex $i 2] @@ -1826,7 +1831,9 @@ proc makemenu {m items} { -value [lindex $thing 1] } } - eval $m add $params [lrange $i 4 end] + set tail [lrange $i 4 end] + regsub -all {\$M1T\y} $tail $M1T tail + eval $m add $params $tail if {$type eq "cascade"} { makemenu $m.$submenu $thing } @@ -1860,17 +1867,17 @@ proc makewindow {} { makemenu .bar { {mc "File" cascade { {mc "Update" command updatecommits -accelerator F5} - {mc "Reload" command reloadcommits} + {mc "Reload" command reloadcommits -accelerator $M1T-F5} {mc "Reread references" command rereadrefs} - {mc "List references" command showrefs} - {mc "Quit" command doquit} + {mc "List references" command showrefs -accelerator F2} + {mc "Quit" command doquit -accelerator $M1T-Q} }} {mc "Edit" cascade { {mc "Preferences" command doprefs} }} {mc "View" cascade { - {mc "New view..." command {newview 0}} - {mc "Edit view..." command editview -state disabled} + {mc "New view..." command {newview 0} -accelerator Shift-F4} + {mc "Edit view..." command editview -state disabled -accelerator F4} {mc "Delete view" command delview -state disabled} {xx "" separator} {mc "All files" radiobutton {selectedview 0} -command {showview 0}} @@ -2232,7 +2239,12 @@ proc makewindow {} { bindkey <Key-Return> {dofind 1 1} bindkey ? {dofind -1 1} bindkey f nextfile - bindkey <F5> updatecommits + bind . <F5> updatecommits + bind . <$M1B-F5> reloadcommits + bind . <F2> showrefs + bind . <Shift-F4> {newview 0} + catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} } + bind . <F4> edit_or_newview bind . <$M1B-q> doquit bind . <$M1B-f> {dofind 1 1} bind . <$M1B-g> {dofind 1 0} @@ -3483,6 +3495,16 @@ proc newview {ishighlight} { vieweditor $top $nextviewnum [mc "Gitk view definition"] } +proc edit_or_newview {} { + global curview + + if {$curview > 0} { + editview + } else { + newview 0 + } +} + proc editview {} { global curview global viewname viewperm newviewname newviewperm -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts. 2008-11-02 18:59 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Alexander Gavrilov @ 2008-11-02 18:59 ` Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 5/6] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov 2008-11-07 11:51 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Paul Mackerras 2008-11-07 11:50 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Paul Mackerras 1 sibling, 2 replies; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-02 18:59 UTC (permalink / raw) To: git; +Cc: Paul Mackerras Now that git-gui has facilities to help users resolve conflicts, it makes sense to launch it from other GUI tools when they happen. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- gitk | 40 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 1 deletions(-) diff --git a/gitk b/gitk index f747c70..71f1b27 100755 --- a/gitk +++ b/gitk @@ -8110,6 +8110,32 @@ proc mkbrgo {top} { } } +proc exec_citool {tool_args {baseid {}}} { + global commitinfo env + + set save_env [array get env GIT_AUTHOR_*] + + if {$baseid ne {}} { + if {![info exists commitinfo($baseid)]} { + getcommit $baseid + } + set author [lindex $commitinfo($baseid) 1] + set date [lindex $commitinfo($baseid) 2] + if {[regexp {^\s*(\S.*\S|\S)\s*<(.*)>\s*$} \ + $author author name email] + && $date ne {}} { + set env(GIT_AUTHOR_NAME) $name + set env(GIT_AUTHOR_EMAIL) $email + set env(GIT_AUTHOR_DATE) $date + } + } + + eval exec git citool $tool_args & + + array unset env GIT_AUTHOR_* + array set env $save_env +} + proc cherrypick {} { global rowmenuid curview global mainhead mainheadid @@ -8128,7 +8154,19 @@ proc cherrypick {} { # no error occurs, and exec takes that as an indication of error... if {[catch {exec sh -c "git cherry-pick -r $rowmenuid 2>&1"} err]} { notbusy cherrypick - error_popup $err + if {[regexp -line \ + {Entry '(.*)' would be overwritten by merge} $err msg fname]} { + error_popup [mc "Cherry-pick failed: +file '%s' had local modifications. + +Please commit, reset or stash your changes." $fname] + } elseif {[regexp -line {^CONFLICT \(.*\):} $err msg]} { + # Force citool to read MERGE_MSG + file delete [file join [gitdir] "GITGUI_MSG"] + exec_citool {} $rowmenuid + } else { + error_popup $err + } return } set newhead [exec git rev-parse HEAD] -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH (GITK) v3 5/6] gitk: Implement a user-friendly Edit View dialog. 2008-11-02 18:59 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov @ 2008-11-02 18:59 ` Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows Alexander Gavrilov 2008-11-07 11:51 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Paul Mackerras 1 sibling, 1 reply; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-02 18:59 UTC (permalink / raw) To: git; +Cc: Paul Mackerras Originally gitk required the user to specify all limiting options manually in the same field with the list of commits. It is rather unfriendly for new users, who may not know which options can be used, or, indeed, that it is possible to specify them at all. This patch modifies the dialog to present the most useful options as individual fields. Note that options that may be useful to an extent, but produce a severely broken view, are deliberately not included. It is still possible to specify options in the commit list field, but when the dialog is reopened, they will be extracted into their own separate fields. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- gitk | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 163 insertions(+), 44 deletions(-) diff --git a/gitk b/gitk index 71f1b27..5b4eaa2 100755 --- a/gitk +++ b/gitk @@ -3479,8 +3479,8 @@ proc shellsplit {str} { # Code to implement multiple views proc newview {ishighlight} { - global nextviewnum newviewname newviewperm newishighlight - global newviewargs revtreeargs viewargscmd newviewargscmd curview + global nextviewnum newviewname newishighlight + global revtreeargs viewargscmd newviewopts curview set newishighlight $ishighlight set top .gitkview @@ -3489,9 +3489,9 @@ proc newview {ishighlight} { return } set newviewname($nextviewnum) "[mc "View"] $nextviewnum" - set newviewperm($nextviewnum) 0 - set newviewargs($nextviewnum) [shellarglist $revtreeargs] - set newviewargscmd($nextviewnum) $viewargscmd($curview) + set newviewopts($nextviewnum,perm) 0 + set newviewopts($nextviewnum,cmd) $viewargscmd($curview) + decode_view_opts $nextviewnum $revtreeargs vieweditor $top $nextviewnum [mc "Gitk view definition"] } @@ -3505,53 +3505,167 @@ proc edit_or_newview {} { } } +set known_view_options { + {perm b . {} {mc "Remember this view"}} + {args t50= + {} {mc "Commits to include (arguments to git log):"}} + {all b * "--all" {mc "Use all refs"}} + {dorder b . {"--date-order" "-d"} {mc "Strictly sort by date"}} + {lright b . "--left-right" {mc "Mark branch sides"}} + {since t15 + {"--since=*" "--after=*"} {mc "Since date:"}} + {until t15 . {"--until=*" "--before=*"} {mc "Until date:"}} + {limit t10 + "--max-count=*" {mc "Max count:"}} + {skip t10 . "--skip=*" {mc "Skip:"}} + {first b . "--first-parent" {mc "Limit to first parent"}} + {cmd t50= + {} {mc "Command to generate more commits to include:"}} + } + +proc encode_view_opts {n} { + global known_view_options newviewopts + + set rargs [list] + foreach opt $known_view_options { + set patterns [lindex $opt 3] + if {$patterns eq {}} continue + set pattern [lindex $patterns 0] + + set val $newviewopts($n,[lindex $opt 0]) + + if {[lindex $opt 1] eq "b"} { + if {$val} { + lappend rargs $pattern + } + } else { + set val [string trim $val] + if {$val ne {}} { + set pfix [string range $pattern 0 end-1] + lappend rargs $pfix$val + } + } + } + return [concat $rargs [shellsplit $newviewopts($n,args)]] +} + +proc decode_view_opts {n view_args} { + global known_view_options newviewopts + + foreach opt $known_view_options { + if {[lindex $opt 1] eq "b"} { + set val 0 + } else { + set val {} + } + set newviewopts($n,[lindex $opt 0]) $val + } + set oargs [list] + foreach arg $view_args { + if {[regexp -- {^-([0-9]+)$} $arg arg cnt] + && ![info exists found(limit)]} { + set newviewopts($n,limit) $cnt + set found(limit) 1 + continue + } + catch { unset val } + foreach opt $known_view_options { + set id [lindex $opt 0] + if {[info exists found($id)]} continue + foreach pattern [lindex $opt 3] { + if {![string match $pattern $arg]} continue + if {[lindex $opt 1] ne "b"} { + set size [string length $pattern] + set val [string range $arg [expr {$size-1}] end] + } else { + set val 1 + } + set newviewopts($n,$id) $val + set found($id) 1 + break + } + if {[info exists val]} break + } + if {[info exists val]} continue + lappend oargs $arg + } + set newviewopts($n,args) [shellarglist $oargs] +} + proc editview {} { global curview - global viewname viewperm newviewname newviewperm - global viewargs newviewargs viewargscmd newviewargscmd + global viewname viewperm newviewname newviewopts + global viewargs viewargscmd set top .gitkvedit-$curview if {[winfo exists $top]} { raise $top return } - set newviewname($curview) $viewname($curview) - set newviewperm($curview) $viewperm($curview) - set newviewargs($curview) [shellarglist $viewargs($curview)] - set newviewargscmd($curview) $viewargscmd($curview) + set newviewname($curview) $viewname($curview) + set newviewopts($curview,perm) $viewperm($curview) + set newviewopts($curview,cmd) $viewargscmd($curview) + decode_view_opts $curview $viewargs($curview) vieweditor $top $curview "Gitk: edit view $viewname($curview)" } proc vieweditor {top n title} { - global newviewname newviewperm viewfiles bgcolor + global newviewname newviewopts viewfiles bgcolor + global known_view_options toplevel $top wm title $top $title wm transient $top . + + # View name + frame $top.nfr label $top.nl -text [mc "Name"] entry $top.name -width 20 -textvariable newviewname($n) - grid $top.nl $top.name -sticky w -pady 5 - checkbutton $top.perm -text [mc "Remember this view"] \ - -variable newviewperm($n) - grid $top.perm - -pady 5 -sticky w - message $top.al -aspect 1000 \ - -text [mc "Commits to include (arguments to git log):"] - grid $top.al - -sticky w -pady 5 - entry $top.args -width 50 -textvariable newviewargs($n) \ - -background $bgcolor - grid $top.args - -sticky ew -padx 5 - - message $top.ac -aspect 1000 \ - -text [mc "Command to generate more commits to include:"] - grid $top.ac - -sticky w -pady 5 - entry $top.argscmd -width 50 -textvariable newviewargscmd($n) \ - -background white - grid $top.argscmd - -sticky ew -padx 5 - - message $top.l -aspect 1000 \ + pack $top.nfr -in $top -fill x -pady 5 -padx 3 + pack $top.nl -in $top.nfr -side left -padx {0 30} + pack $top.name -in $top.nfr -side left + + # View options + set cframe $top.nfr + set cexpand 0 + set cnt 0 + foreach opt $known_view_options { + set id [lindex $opt 0] + set type [lindex $opt 1] + set flags [lindex $opt 2] + set title [eval [lindex $opt 4]] + set lxpad 0 + + if {$flags eq "+" || $flags eq "*"} { + set cframe $top.fr$cnt + incr cnt + frame $cframe + pack $cframe -in $top -fill x -pady 3 -padx 3 + set cexpand [expr {$flags eq "*"}] + } else { + set lxpad 5 + } + + if {$type eq "b"} { + checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id) + pack $cframe.c_$id -in $cframe -side left \ + -padx [list $lxpad 0] -expand $cexpand -anchor w + } elseif {[regexp {^t(\d+)$} $type type sz]} { + message $cframe.l_$id -aspect 1500 -text $title + entry $cframe.e_$id -width $sz -background $bgcolor \ + -textvariable newviewopts($n,$id) + pack $cframe.l_$id -in $cframe -side left -padx [list $lxpad 0] + pack $cframe.e_$id -in $cframe -side left -expand 1 -fill x + } elseif {[regexp {^t(\d+)=$} $type type sz]} { + message $cframe.l_$id -aspect 1500 -text $title + entry $cframe.e_$id -width $sz -background $bgcolor \ + -textvariable newviewopts($n,$id) + pack $cframe.l_$id -in $cframe -side top -pady [list 3 0] -anchor w + pack $cframe.e_$id -in $cframe -side top -fill x + } + } + + # Path list + message $top.l -aspect 1500 \ -text [mc "Enter files and directories to include, one per line:"] - grid $top.l - -sticky w - text $top.t -width 40 -height 10 -background $bgcolor -font uifont + pack $top.l -in $top -side top -pady [list 7 0] -anchor w -padx 3 + text $top.t -width 40 -height 5 -background $bgcolor -font uifont if {[info exists viewfiles($n)]} { foreach f $viewfiles($n) { $top.t insert end $f @@ -3560,15 +3674,19 @@ proc vieweditor {top n title} { $top.t delete {end - 1c} end $top.t mark set insert 0.0 } - grid $top.t - -sticky ew -padx 5 + pack $top.t -in $top -side top -pady [list 0 5] -fill both -expand 1 -padx 3 frame $top.buts button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n] + button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1] button $top.buts.can -text [mc "Cancel"] -command [list destroy $top] + bind $top <Control-Return> [list newviewok $top $n] + bind $top <F5> [list newviewok $top $n 1] bind $top <Escape> [list destroy $top] - grid $top.buts.ok $top.buts.can + grid $top.buts.ok $top.buts.apply $top.buts.can grid columnconfigure $top.buts 0 -weight 1 -uniform a grid columnconfigure $top.buts 1 -weight 1 -uniform a - grid $top.buts - -pady 10 -sticky ew + grid columnconfigure $top.buts 2 -weight 1 -uniform a + pack $top.buts -in $top -side top -fill x focus $top.t } @@ -3589,13 +3707,13 @@ proc allviewmenus {n op args} { # doviewmenu $viewhlmenu 1 [list addvhighlight $n] $op $args } -proc newviewok {top n} { +proc newviewok {top n {apply 0}} { global nextviewnum newviewperm newviewname newishighlight global viewname viewfiles viewperm selectedview curview - global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu + global viewargs viewargscmd newviewopts viewhlmenu if {[catch { - set newargs [shellsplit $newviewargs($n)] + set newargs [encode_view_opts $n] } err]} { error_popup "[mc "Error in commit selection arguments:"] $err" $top return @@ -3611,10 +3729,10 @@ proc newviewok {top n} { # creating a new view incr nextviewnum set viewname($n) $newviewname($n) - set viewperm($n) $newviewperm($n) + set viewperm($n) $newviewopts($n,perm) set viewfiles($n) $files set viewargs($n) $newargs - set viewargscmd($n) $newviewargscmd($n) + set viewargscmd($n) $newviewopts($n,cmd) addviewmenu $n if {!$newishighlight} { run showview $n @@ -3623,7 +3741,7 @@ proc newviewok {top n} { } } else { # editing an existing view - set viewperm($n) $newviewperm($n) + set viewperm($n) $newviewopts($n,perm) if {$newviewname($n) ne $viewname($n)} { set viewname($n) $newviewname($n) doviewmenu .bar.view 5 [list showview $n] \ @@ -3632,15 +3750,16 @@ proc newviewok {top n} { # entryconf [list -label $viewname($n) -value $viewname($n)] } if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \ - $newviewargscmd($n) ne $viewargscmd($n)} { + $newviewopts($n,cmd) ne $viewargscmd($n)} { set viewfiles($n) $files set viewargs($n) $newargs - set viewargscmd($n) $newviewargscmd($n) + set viewargscmd($n) $newviewopts($n,cmd) if {$curview == $n} { run reloadcommits } } } + if {$apply} return catch {destroy $top} } -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-02 18:59 ` [PATCH (GITK) v3 5/6] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov @ 2008-11-02 18:59 ` Alexander Gavrilov 2008-11-07 11:57 ` Paul Mackerras 0 siblings, 1 reply; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-02 18:59 UTC (permalink / raw) To: git; +Cc: Paul Mackerras For some reason, on Windows all transient windows are placed in the upper left corner of the screen. Thus, it is necessary to explicitly position the windows relative to their parent. For simplicity this patch uses the function that is used internally by Tk dialogs. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- I wrapped the call to tk::PlaceWindow in a helper function to minimize the number of places to change if something happens to it. -- Alexander gitk | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gitk b/gitk index 5b4eaa2..7d153a3 100755 --- a/gitk +++ b/gitk @@ -1739,7 +1739,13 @@ proc removehead {id name} { unset headids($name) } -proc show_error {w top msg} { +proc center_window {window origin} { + # Use a handy function from Tk. Note that it + # calls 'update' to figure out dimensions. + tk::PlaceWindow $window widget $origin +} + +proc show_error {w top msg {owner {}}} { message $w.m -text $msg -justify center -aspect 400 pack $w.m -side top -fill x -padx 20 -pady 20 button $w.ok -text [mc OK] -command "destroy $top" @@ -1748,6 +1754,9 @@ proc show_error {w top msg} { bind $top <Key-Return> "destroy $top" bind $top <Key-space> "destroy $top" bind $top <Key-Escape> "destroy $top" + if {$owner ne {}} { + center_window $top $owner + } tkwait window $top } @@ -1755,7 +1764,7 @@ proc error_popup {msg {owner .}} { set w .error toplevel $w wm transient $w $owner - show_error $w $w $msg + show_error $w $w $msg $owner } proc confirm_popup {msg {owner .}} { @@ -1774,6 +1783,7 @@ proc confirm_popup {msg {owner .}} { bind $w <Key-Return> "set confirm_ok 1; destroy $w" bind $w <Key-space> "set confirm_ok 1; destroy $w" bind $w <Key-Escape> "destroy $w" + center_window $w $owner tkwait window $w return $confirm_ok } @@ -2572,6 +2582,7 @@ Use and redistribute under the terms of the GNU General Public License"] \ bind $w <Visibility> "focus $w.ok" bind $w <Key-Escape> "destroy $w" bind $w <Key-Return> "destroy $w" + center_window $w . } proc keys {} { @@ -2635,6 +2646,7 @@ proc keys {} { bind $w <Visibility> "focus $w.ok" bind $w <Key-Escape> "destroy $w" bind $w <Key-Return> "destroy $w" + center_window $w . } # Procedures for manipulating the file list window at the @@ -3687,6 +3699,7 @@ proc vieweditor {top n title} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid columnconfigure $top.buts 2 -weight 1 -uniform a pack $top.buts -in $top -side top -fill x + center_window $top . focus $top.t } @@ -7950,6 +7963,7 @@ proc mkpatch {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.fname + center_window $top . } proc mkpatchrev {} { @@ -8024,6 +8038,7 @@ proc mktag {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.tag + center_window $top . } proc domktag {} { @@ -8131,6 +8146,7 @@ proc writecommit {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.fname + center_window $top . } proc wrcomgo {} { @@ -8181,6 +8197,7 @@ proc mkbranch {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.name + center_window $top . } proc mkbrgo {top} { @@ -8341,6 +8358,7 @@ proc resethead {} { bind $w <Key-Escape> [list destroy $w] pack $w.cancel -side right -fill x -padx 20 -pady 20 bind $w <Visibility> "grab $w; focus $w" + center_window $w . tkwait window $w if {!$confirm_ok} return if {[catch {set fd [open \ @@ -8526,6 +8544,7 @@ proc showrefs {} { bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break} set reflist {} refill_reflist + center_window $top . } proc sel_reflist {w x y} { @@ -9878,6 +9897,7 @@ proc choosefont {font which} { grid columnconfigure $top.buts 1 -weight 1 -uniform a pack $top.buts -side bottom -fill x trace add variable fontparam write chg_fontparam + center_window $top $prefstop } else { raise $top $top.c itemconf text -text $which @@ -10060,6 +10080,7 @@ proc doprefs {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - - -pady 10 -sticky ew bind $top <Visibility> "focus $top.buts.ok" + center_window $top . } proc choose_extdiff {} { -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-02 18:59 ` [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows Alexander Gavrilov @ 2008-11-07 11:57 ` Paul Mackerras 2008-11-07 14:39 ` Alex Riesen ` (2 more replies) 0 siblings, 3 replies; 21+ messages in thread From: Paul Mackerras @ 2008-11-07 11:57 UTC (permalink / raw) To: Alexander Gavrilov; +Cc: git Alexander Gavrilov writes: > For some reason, on Windows all transient windows are placed > in the upper left corner of the screen. Thus, it is necessary > to explicitly position the windows relative to their parent. > For simplicity this patch uses the function that is used > internally by Tk dialogs. Is there any reason to call tk::PlaceWindow under Linux or MacOS? If not I'd rather add an if statement so we only call it on Windows. Paul. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-07 11:57 ` Paul Mackerras @ 2008-11-07 14:39 ` Alex Riesen 2008-11-07 16:37 ` Johannes Sixt 2008-11-09 11:12 ` Paul Mackerras 2008-11-09 14:53 ` Alexander Gavrilov 2008-11-11 11:00 ` Alexander Gavrilov 2 siblings, 2 replies; 21+ messages in thread From: Alex Riesen @ 2008-11-07 14:39 UTC (permalink / raw) To: Paul Mackerras; +Cc: Alexander Gavrilov, git 2008/11/7 Paul Mackerras <paulus@samba.org>: > Alexander Gavrilov writes: > >> For some reason, on Windows all transient windows are placed >> in the upper left corner of the screen. Thus, it is necessary >> to explicitly position the windows relative to their parent. >> For simplicity this patch uses the function that is used >> internally by Tk dialogs. > > Is there any reason to call tk::PlaceWindow under Linux or MacOS? > If not I'd rather add an if statement so we only call it on Windows. > Yes, please. I rather like the smart placement in compiz. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-07 14:39 ` Alex Riesen @ 2008-11-07 16:37 ` Johannes Sixt 2008-11-09 10:26 ` Alex Riesen 2008-11-09 11:12 ` Paul Mackerras 1 sibling, 1 reply; 21+ messages in thread From: Johannes Sixt @ 2008-11-07 16:37 UTC (permalink / raw) To: Alex Riesen; +Cc: Paul Mackerras, Alexander Gavrilov, git Alex Riesen schrieb: > 2008/11/7 Paul Mackerras <paulus@samba.org>: >> Is there any reason to call tk::PlaceWindow under Linux or MacOS? >> If not I'd rather add an if statement so we only call it on Windows. >> > > Yes, please. I rather like the smart placement in compiz. Just out of curiosity because I don't use compiz: Did you mean "Yes, please call tk::PlaceWindow on Linux" or "Yes, please add the if statement" ? ;) -- Hannes ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-07 16:37 ` Johannes Sixt @ 2008-11-09 10:26 ` Alex Riesen 0 siblings, 0 replies; 21+ messages in thread From: Alex Riesen @ 2008-11-09 10:26 UTC (permalink / raw) To: Johannes Sixt; +Cc: Paul Mackerras, Alexander Gavrilov, git Johannes Sixt, Fri, Nov 07, 2008 17:37:20 +0100: > Alex Riesen schrieb: > > 2008/11/7 Paul Mackerras <paulus@samba.org>: > >> Is there any reason to call tk::PlaceWindow under Linux or MacOS? > >> If not I'd rather add an if statement so we only call it on Windows. > >> > > > > Yes, please. I rather like the smart placement in compiz. > > Just out of curiosity because I don't use compiz: Did you mean > "Yes, please call tk::PlaceWindow on Linux" > or > "Yes, please add the if statement" That one. So PlaceWindow is NOT called. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-07 14:39 ` Alex Riesen 2008-11-07 16:37 ` Johannes Sixt @ 2008-11-09 11:12 ` Paul Mackerras 1 sibling, 0 replies; 21+ messages in thread From: Paul Mackerras @ 2008-11-09 11:12 UTC (permalink / raw) To: Alex Riesen; +Cc: Alexander Gavrilov, git Alex Riesen writes: > > Is there any reason to call tk::PlaceWindow under Linux or MacOS? > > If not I'd rather add an if statement so we only call it on Windows. > > > > Yes, please. I rather like the smart placement in compiz. Do you mean "please add the if statement", i.e. don't call tk::PlaceWindow under Linux? Like Johannes Sixt, I find your request ambiguous. :) Paul. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-07 11:57 ` Paul Mackerras 2008-11-07 14:39 ` Alex Riesen @ 2008-11-09 14:53 ` Alexander Gavrilov 2008-11-10 11:47 ` Paul Mackerras 2008-11-11 11:00 ` Alexander Gavrilov 2 siblings, 1 reply; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-09 14:53 UTC (permalink / raw) To: Paul Mackerras; +Cc: git On Friday 07 November 2008 14:57:05 Paul Mackerras wrote: > Alexander Gavrilov writes: > > > For some reason, on Windows all transient windows are placed > > in the upper left corner of the screen. Thus, it is necessary > > to explicitly position the windows relative to their parent. > > For simplicity this patch uses the function that is used > > internally by Tk dialogs. > > Is there any reason to call tk::PlaceWindow under Linux or MacOS? > If not I'd rather add an if statement so we only call it on Windows. I don't know about MacOS, but in Linux it does seem unnecessary, so: --- >8 --- Subject: [PATCH] gitk: Explicitly position popup windows. For some reason, on Windows all transient windows are placed in the upper left corner of the screen. Thus, it is necessary to explicitly position the windows relative to their parent. For simplicity this patch uses the function that is used internally by Tk dialogs. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- gitk | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gitk b/gitk index 1363d20..d72412c 100755 --- a/gitk +++ b/gitk @@ -1739,7 +1739,17 @@ proc removehead {id name} { unset headids($name) } -proc show_error {w top msg} { +proc center_window {window origin} { + # Let platforms with a real window manager + # deal with it on their own + if {$::tcl_platform(platform) ne {windows}} return + + # Use a handy function from Tk. Note that it + # calls 'update' to figure out dimensions. + tk::PlaceWindow $window widget $origin +} + +proc show_error {w top msg {owner {}}} { message $w.m -text $msg -justify center -aspect 400 pack $w.m -side top -fill x -padx 20 -pady 20 button $w.ok -text [mc OK] -command "destroy $top" @@ -1748,6 +1758,9 @@ proc show_error {w top msg} { bind $top <Key-Return> "destroy $top" bind $top <Key-space> "destroy $top" bind $top <Key-Escape> "destroy $top" + if {$owner ne {}} { + center_window $top $owner + } tkwait window $top } @@ -1755,7 +1768,7 @@ proc error_popup {msg {owner .}} { set w .error toplevel $w wm transient $w $owner - show_error $w $w $msg + show_error $w $w $msg $owner } proc confirm_popup {msg {owner .}} { @@ -1774,6 +1787,7 @@ proc confirm_popup {msg {owner .}} { bind $w <Key-Return> "set confirm_ok 1; destroy $w" bind $w <Key-space> "set confirm_ok 1; destroy $w" bind $w <Key-Escape> "destroy $w" + center_window $w $owner tkwait window $w return $confirm_ok } @@ -2572,6 +2586,7 @@ Use and redistribute under the terms of the GNU General Public License"] \ bind $w <Visibility> "focus $w.ok" bind $w <Key-Escape> "destroy $w" bind $w <Key-Return> "destroy $w" + center_window $w . } proc keys {} { @@ -2635,6 +2650,7 @@ proc keys {} { bind $w <Visibility> "focus $w.ok" bind $w <Key-Escape> "destroy $w" bind $w <Key-Return> "destroy $w" + center_window $w . } # Procedures for manipulating the file list window at the @@ -3687,6 +3703,7 @@ proc vieweditor {top n title} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid columnconfigure $top.buts 2 -weight 1 -uniform a pack $top.buts -in $top -side top -fill x + center_window $top . focus $top.t } @@ -7950,6 +7967,7 @@ proc mkpatch {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.fname + center_window $top . } proc mkpatchrev {} { @@ -8024,6 +8042,7 @@ proc mktag {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.tag + center_window $top . } proc domktag {} { @@ -8131,6 +8150,7 @@ proc writecommit {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.fname + center_window $top . } proc wrcomgo {} { @@ -8181,6 +8201,7 @@ proc mkbranch {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - -pady 10 -sticky ew focus $top.name + center_window $top . } proc mkbrgo {top} { @@ -8341,6 +8362,7 @@ proc resethead {} { bind $w <Key-Escape> [list destroy $w] pack $w.cancel -side right -fill x -padx 20 -pady 20 bind $w <Visibility> "grab $w; focus $w" + center_window $w . tkwait window $w if {!$confirm_ok} return if {[catch {set fd [open \ @@ -8526,6 +8548,7 @@ proc showrefs {} { bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break} set reflist {} refill_reflist + center_window $top . } proc sel_reflist {w x y} { @@ -9878,6 +9901,7 @@ proc choosefont {font which} { grid columnconfigure $top.buts 1 -weight 1 -uniform a pack $top.buts -side bottom -fill x trace add variable fontparam write chg_fontparam + center_window $top $prefstop } else { raise $top $top.c itemconf text -text $which @@ -10060,6 +10084,7 @@ proc doprefs {} { grid columnconfigure $top.buts 1 -weight 1 -uniform a grid $top.buts - - -pady 10 -sticky ew bind $top <Visibility> "focus $top.buts.ok" + center_window $top . } proc choose_extdiff {} { -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-09 14:53 ` Alexander Gavrilov @ 2008-11-10 11:47 ` Paul Mackerras 2008-11-10 12:15 ` Alexander Gavrilov 0 siblings, 1 reply; 21+ messages in thread From: Paul Mackerras @ 2008-11-10 11:47 UTC (permalink / raw) To: Alexander Gavrilov; +Cc: git Alexander Gavrilov writes: > I don't know about MacOS, but in Linux it does seem unnecessary, so: OK. Do you mostly develop on windows or on linux? > + if {$::tcl_platform(platform) ne {windows}} return Any particular reason why you used $tcl_platform(platform) rather than if {[tk windowingsystem] != "win32"} like we do elsewhere in gitk? Paul. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-10 11:47 ` Paul Mackerras @ 2008-11-10 12:15 ` Alexander Gavrilov 0 siblings, 0 replies; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-10 12:15 UTC (permalink / raw) To: Paul Mackerras; +Cc: git On Mon, Nov 10, 2008 at 2:47 PM, Paul Mackerras <paulus@samba.org> wrote: > Alexander Gavrilov writes: > >> I don't know about MacOS, but in Linux it does seem unnecessary, so: > > OK. Do you mostly develop on windows or on linux? I use Linux at home (using a VirtualBox to compile msysgit when I need to), and Windows at work. Actually, since last Thursday I also have to use MacOS at work for some things, but I haven't figured out anything beyond the bare minimum yet. >> + if {$::tcl_platform(platform) ne {windows}} return > > Any particular reason why you used $tcl_platform(platform) rather than > if {[tk windowingsystem] != "win32"} like we do elsewhere in gitk? No partucular reason, I simply copied that from git-gui. Alexander. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows. 2008-11-07 11:57 ` Paul Mackerras 2008-11-07 14:39 ` Alex Riesen 2008-11-09 14:53 ` Alexander Gavrilov @ 2008-11-11 11:00 ` Alexander Gavrilov 2 siblings, 0 replies; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-11 11:00 UTC (permalink / raw) To: Paul Mackerras; +Cc: git On Fri, Nov 7, 2008 at 2:57 PM, Paul Mackerras <paulus@samba.org> wrote: > Alexander Gavrilov writes: > >> For some reason, on Windows all transient windows are placed >> in the upper left corner of the screen. Thus, it is necessary >> to explicitly position the windows relative to their parent. >> For simplicity this patch uses the function that is used >> internally by Tk dialogs. > > Is there any reason to call tk::PlaceWindow under Linux or MacOS? > If not I'd rather add an if statement so we only call it on Windows. I checked it on MacOS, and there the consequences of wm transient are even worse that on Windows, so scrap this patch -- I'll redo it to fix both cases. Alexander ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts. 2008-11-02 18:59 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 5/6] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov @ 2008-11-07 11:51 ` Paul Mackerras 1 sibling, 0 replies; 21+ messages in thread From: Paul Mackerras @ 2008-11-07 11:51 UTC (permalink / raw) To: Alexander Gavrilov; +Cc: git Alexander Gavrilov writes: > Now that git-gui has facilities to help users resolve > conflicts, it makes sense to launch it from other GUI > tools when they happen. The resolution capabilities of git citool seem to be that it detects the conflict markers and lets you run meld on the 3 versions. Have I missed anything there? Do people find that fixing things manually in meld is sufficient, or do we really want something more powerful? Paul. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands. 2008-11-02 18:59 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov @ 2008-11-07 11:50 ` Paul Mackerras 2008-11-09 11:21 ` Alexander Gavrilov 1 sibling, 1 reply; 21+ messages in thread From: Paul Mackerras @ 2008-11-07 11:50 UTC (permalink / raw) To: Alexander Gavrilov; +Cc: git Alexander Gavrilov writes: > - eval $m add $params [lrange $i 4 end] > + set tail [lrange $i 4 end] > + regsub -all {\$M1T\y} $tail $M1T tail > + eval $m add $params $tail This is solving the problem that the $M1T doesn't get expanded in the call below because it's inside {}. If we are going to have a magic string that gets expanded like this, I'd rather it didn't look like a variable reference, because that is confusing. Alternatively, we could define a [meta] function that does this: proc meta {x} { if {[tk windowingsystem] eq "aqua"} { return Cmd-$x } return Ctrl-$x } and then use -accelerator [meta F5] in the makemenu call, and not have any magic string substitution in makemenu. That will work since the eval will evaluate the []. Paul. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands. 2008-11-07 11:50 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Paul Mackerras @ 2008-11-09 11:21 ` Alexander Gavrilov 0 siblings, 0 replies; 21+ messages in thread From: Alexander Gavrilov @ 2008-11-09 11:21 UTC (permalink / raw) To: Paul Mackerras; +Cc: git On Friday 07 November 2008 14:50:03 Paul Mackerras wrote: > Alexander Gavrilov writes: > > > - eval $m add $params [lrange $i 4 end] > > + set tail [lrange $i 4 end] > > + regsub -all {\$M1T\y} $tail $M1T tail > > + eval $m add $params $tail > > This is solving the problem that the $M1T doesn't get expanded in the > call below because it's inside {}. If we are going to have a magic > string that gets expanded like this, I'd rather it didn't look like a > variable reference, because that is confusing. How about "Meta1" then? > Alternatively, we could define a [meta] function that does this: > > proc meta {x} { > if {[tk windowingsystem] eq "aqua"} { > return Cmd-$x > } > return Ctrl-$x > } > > and then use -accelerator [meta F5] in the makemenu call, and not have > any magic string substitution in makemenu. That will work since the > eval will evaluate the []. For some reason it didn't work. Maybe I did something wrong. --- >8 --- Subject: [PATCH] gitk: Add accelerators to frequently used menu commands. This commit documents keyboard accelerators used for menu commands in the menu, as it is usually done, and adds some more, e.g. F4 to invoke Edit View. The changes include a workaround for handling Shift-F4 on systems where XKB binds special XF86_Switch_VT_* symbols to Ctrl-Alt-F* combinations. Tk often receives these codes when Shift-F* is pressed, so it is necessary to bind the relevant actions to them as well. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> --- gitk | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-) diff --git a/gitk b/gitk index 41d3d2d..a9618dc 100755 --- a/gitk +++ b/gitk @@ -1801,6 +1801,11 @@ proc setoptions {} { # command to invoke for command, or {variable value} for radiobutton proc makemenu {m items} { menu $m + if {[tk windowingsystem] eq {aqua}} { + set Meta1 Cmd + } else { + set Meta1 Ctrl + } foreach i $items { set name [mc [lindex $i 1]] set type [lindex $i 2] @@ -1826,7 +1831,9 @@ proc makemenu {m items} { -value [lindex $thing 1] } } - eval $m add $params [lrange $i 4 end] + set tail [lrange $i 4 end] + regsub -all {\yMeta1\y} $tail $Meta1 tail + eval $m add $params $tail if {$type eq "cascade"} { makemenu $m.$submenu $thing } @@ -1860,17 +1867,17 @@ proc makewindow {} { makemenu .bar { {mc "File" cascade { {mc "Update" command updatecommits -accelerator F5} - {mc "Reload" command reloadcommits} + {mc "Reload" command reloadcommits -accelerator Meta1-F5} {mc "Reread references" command rereadrefs} - {mc "List references" command showrefs} - {mc "Quit" command doquit} + {mc "List references" command showrefs -accelerator F2} + {mc "Quit" command doquit -accelerator Meta1-Q} }} {mc "Edit" cascade { {mc "Preferences" command doprefs} }} {mc "View" cascade { - {mc "New view..." command {newview 0}} - {mc "Edit view..." command editview -state disabled} + {mc "New view..." command {newview 0} -accelerator Shift-F4} + {mc "Edit view..." command editview -state disabled -accelerator F4} {mc "Delete view" command delview -state disabled} {xx "" separator} {mc "All files" radiobutton {selectedview 0} -command {showview 0}} @@ -2232,7 +2239,12 @@ proc makewindow {} { bindkey <Key-Return> {dofind 1 1} bindkey ? {dofind -1 1} bindkey f nextfile - bindkey <F5> updatecommits + bind . <F5> updatecommits + bind . <$M1B-F5> reloadcommits + bind . <F2> showrefs + bind . <Shift-F4> {newview 0} + catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} } + bind . <F4> edit_or_newview bind . <$M1B-q> doquit bind . <$M1B-f> {dofind 1 1} bind . <$M1B-g> {dofind 1 0} @@ -3483,6 +3495,16 @@ proc newview {ishighlight} { vieweditor $top $nextviewnum [mc "Gitk view definition"] } +proc edit_or_newview {} { + global curview + + if {$curview > 0} { + editview + } else { + newview 0 + } +} + proc editview {} { global curview global viewname viewperm newviewname newviewperm -- 1.6.0.3.15.gb8d36 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient. 2008-11-02 18:59 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Alexander Gavrilov @ 2008-11-07 11:41 ` Paul Mackerras 1 sibling, 0 replies; 21+ messages in thread From: Paul Mackerras @ 2008-11-07 11:41 UTC (permalink / raw) To: Alexander Gavrilov; +Cc: git Alexander Gavrilov writes: > Transient windows are always kept above their parent, > and don't occupy any space in the taskbar, which is useful > for dialogs. Also, when transient is used, it is important > to bind windows to the correct parent. > > This commit adds transient annotations to all dialogs, > ensures usage of the correct parent for error and > confirmation popups, and, as a side job, makes gitk > preserve the create tag dialog window in case of errors. > > Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Thanks, applied. Paul. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs. 2008-11-02 18:59 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Alexander Gavrilov @ 2008-11-07 11:41 ` Paul Mackerras 1 sibling, 0 replies; 21+ messages in thread From: Paul Mackerras @ 2008-11-07 11:41 UTC (permalink / raw) To: Alexander Gavrilov; +Cc: git Alexander Gavrilov writes: > It is often more convenient to dismiss or accept a > dialog using the keyboard, than by clicking buttons > on the screen. This commit adds key binding to make > it possible with gitk's dialogs. Thanks, applied. Paul. ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2008-11-11 11:01 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-11-02 18:59 [PATCH (GITK) v3 0/6] Enhance popup dialogs in gitk Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 5/6] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov 2008-11-02 18:59 ` [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows Alexander Gavrilov 2008-11-07 11:57 ` Paul Mackerras 2008-11-07 14:39 ` Alex Riesen 2008-11-07 16:37 ` Johannes Sixt 2008-11-09 10:26 ` Alex Riesen 2008-11-09 11:12 ` Paul Mackerras 2008-11-09 14:53 ` Alexander Gavrilov 2008-11-10 11:47 ` Paul Mackerras 2008-11-10 12:15 ` Alexander Gavrilov 2008-11-11 11:00 ` Alexander Gavrilov 2008-11-07 11:51 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Paul Mackerras 2008-11-07 11:50 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Paul Mackerras 2008-11-09 11:21 ` Alexander Gavrilov 2008-11-07 11:41 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Paul Mackerras 2008-11-07 11:41 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Paul Mackerras
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).