Code

git-gui: use themed tk widgets with Tk 8.5
[git.git] / lib / branch_delete.tcl
index c7573c6c7215cd4cd11f322ae3dba5b77b938078..867938ec6a63ba77cc6efd700080e194d23d620f 100644 (file)
@@ -9,49 +9,48 @@ field w_check         ; # revision picker for merge test
 field w_delete        ; # delete button
 
 constructor dialog {} {
-       global current_branch
+       global current_branch use_ttk NS
 
-       make_toplevel top w
-       wm title $top "[appname] ([reponame]): Delete Branch"
+       make_dialog top w
+       wm withdraw $w
+       wm title $top [append "[appname] ([reponame]): " [mc "Delete Branch"]]
        if {$top ne {.}} {
                wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
        }
 
-       label $w.header -text {Delete Local Branch} -font font_uibold
+       ${NS}::label $w.header -text [mc "Delete Local Branch"] \
+               -font font_uibold -anchor center
        pack $w.header -side top -fill x
 
-       frame $w.buttons
+       ${NS}::frame $w.buttons
        set w_delete $w.buttons.delete
-       button $w_delete \
-               -text Delete \
+       ${NS}::button $w_delete \
+               -text [mc Delete] \
                -default active \
                -state disabled \
                -command [cb _delete]
        pack $w_delete -side right
-       button $w.buttons.cancel \
-               -text {Cancel} \
+       ${NS}::button $w.buttons.cancel \
+               -text [mc Cancel] \
                -command [list destroy $w]
        pack $w.buttons.cancel -side right -padx 5
        pack $w.buttons -side bottom -fill x -pady 10 -padx 10
 
-       labelframe $w.list -text {Local Branches}
+       ${NS}::labelframe $w.list -text [mc "Local Branches"]
        set w_heads $w.list.l
-       listbox $w_heads \
+       slistbox $w_heads \
                -height 10 \
                -width 70 \
                -selectmode extended \
-               -exportselection false \
-               -yscrollcommand [list $w.list.sby set]
-       scrollbar $w.list.sby -command [list $w.list.l yview]
-       pack $w.list.sby -side right -fill y
+               -exportselection false
        pack $w.list.l -side left -fill both -expand 1
        pack $w.list -fill both -expand 1 -pady 5 -padx 5
 
        set w_check [choose_rev::new \
                $w.check \
-               {Delete Only If Merged Into} \
+               [mc "Delete Only If Merged Into"] \
                ]
-       $w_check none {Always (Do not perform merge test.)}
+       $w_check none [mc "Always (Do not perform merge checks)"]
        pack $w.check -anchor nw -fill x -pady 5 -padx 5
 
        foreach h [load_all_heads] {
@@ -67,6 +66,7 @@ constructor dialog {} {
        "
        bind $w <Key-Escape> [list destroy $w]
        bind $w <Key-Return> [cb _delete]\;break
+       wm deiconify $w
        tkwait window $w
 }
 
@@ -100,7 +100,7 @@ method _delete {} {
                lappend to_delete [list $b $o]
        }
        if {$not_merged ne {}} {
-               set msg "The following branches are not completely merged into [$w_check get]:
+               set msg "[mc "The following branches are not completely merged into %s:" [$w_check get]]
 
  - [join $not_merged "\n - "]"
                tk_messageBox \
@@ -112,9 +112,7 @@ method _delete {} {
        }
        if {$to_delete eq {}} return
        if {$check_cmt eq {}} {
-               set msg {Recovering deleted branches is difficult.
-
-Delete the selected branches?}
+               set msg [mc "Recovering deleted branches is difficult.\n\nDelete the selected branches?"]
                if {[tk_messageBox \
                        -icon warning \
                        -type yesno \
@@ -129,7 +127,7 @@ Delete the selected branches?}
        foreach i $to_delete {
                set b [lindex $i 0]
                set o [lindex $i 1]
-               if {[catch {git update-ref -d "refs/heads/$b" $o} err]} {
+               if {[catch {git branch -D $b} err]} {
                        append failed " - $b: $err\n"
                }
        }
@@ -140,7 +138,7 @@ Delete the selected branches?}
                        -type ok \
                        -title [wm title $w] \
                        -parent $w \
-                       -message "Failed to delete branches:\n$failed"
+                       -message [mc "Failed to delete branches:\n%s" $failed]
        }
 
        destroy $w