Code

RelNotes: the first batch of topics graduated to 'master'
[git.git] / git-gui / lib / choose_repository.tcl
index 633cc572bbd076ff957c0b8194b6645e899e53ad..657f7d5dc19b13f36a31b833f04407b8ca0b2901 100644 (file)
@@ -22,9 +22,9 @@ field readtree_err        ; # Error output from read-tree (if any)
 field sorted_recent       ; # recent repositories (sorted)
 
 constructor pick {} {
-       global M1T M1B
+       global M1T M1B use_ttk NS
 
-       make_toplevel top w
+       make_dialog top w
        wm title $top [mc "Git Gui"]
 
        if {$top eq {.}} {
@@ -71,11 +71,11 @@ constructor pick {} {
 
        set w_body $w.body
        set opts $w_body.options
-       frame $w_body
+       ${NS}::frame $w_body
        text $opts \
                -cursor $::cursor_ptr \
                -relief flat \
-               -background [$w_body cget -background] \
+               -background [get_bg_color $w_body] \
                -wrap none \
                -spacing1 5 \
                -width 50 \
@@ -100,12 +100,17 @@ constructor pick {} {
        $opts insert end [mc "Clone Existing Repository"] link_clone
        $opts insert end "\n"
        if {$m_repo ne {}} {
+               if {[tk windowingsystem] eq "win32"} {
+                       set key L
+               } else {
+                       set key C
+               }
                $m_repo add command \
                        -command [cb _next clone] \
-                       -accelerator $M1T-C \
+                       -accelerator $M1T-$key \
                        -label [mc "Clone..."]
-               bind $top <$M1B-c> [cb _next clone]
-               bind $top <$M1B-C> [cb _next clone]
+               bind $top <$M1B-[string tolower $key]> [cb _next clone]
+               bind $top <$M1B-[string toupper $key]> [cb _next clone]
        }
 
        $opts tag conf link_open -foreground blue -underline 1
@@ -132,15 +137,15 @@ constructor pick {} {
                                -label [mc "Recent Repositories"]
                }
 
-               label $w_body.space
-               label $w_body.recentlabel \
+               ${NS}::label $w_body.space
+               ${NS}::label $w_body.recentlabel \
                        -anchor w \
                        -text [mc "Open Recent Repository:"]
                set w_recentlist $w_body.recentlist
                text $w_recentlist \
                        -cursor $::cursor_ptr \
                        -relief flat \
-                       -background [$w_body.recentlabel cget -background] \
+                       -background [get_bg_color $w_body.recentlabel] \
                        -wrap none \
                        -width 50 \
                        -height 10
@@ -176,10 +181,10 @@ constructor pick {} {
        }
        pack $w_body -fill x -padx 10 -pady 10
 
-       frame $w.buttons
+       ${NS}::frame $w.buttons
        set w_next $w.buttons.next
        set w_quit $w.buttons.quit
-       button $w_quit \
+       ${NS}::button $w_quit \
                -text [mc "Quit"] \
                -command exit
        pack $w_quit -side right -padx 5
@@ -203,19 +208,12 @@ constructor pick {} {
        wm deiconify $top
        tkwait variable @done
 
+       grab release $top
        if {$top eq {.}} {
                eval destroy [winfo children $top]
        }
 }
 
-proc _home {} {
-       if {[catch {set h $::env(HOME)}]
-               || ![file isdirectory $h]} {
-               set h .
-       }
-       return $h
-}
-
 method _center {} {
        set nx [winfo reqwidth $top]
        set ny [winfo reqheight $top]
@@ -235,6 +233,8 @@ proc _get_recentrepos {} {
        foreach p [get_config gui.recentrepo] {
                if {[_is_git [file join $p .git]]} {
                        lappend recent $p
+               } else {
+                       _unset_recentrepo $p
                }
        }
        return [lsort $recent]
@@ -243,6 +243,7 @@ proc _get_recentrepos {} {
 proc _unset_recentrepo {p} {
        regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p
        git config --global --unset gui.recentrepo "^$p\$"
+       load_config 1
 }
 
 proc _append_recentrepos {path} {
@@ -261,6 +262,7 @@ proc _append_recentrepos {path} {
 
        lappend recent $path
        git config --global --add gui.recentrepo $path
+       load_config 1
 
        while {[llength $recent] > 10} {
                _unset_recentrepo [lindex $recent 0]
@@ -280,9 +282,10 @@ method _open_recent_path {p} {
 }
 
 method _next {action} {
+       global NS
        destroy $w_body
        if {![winfo exists $w_next]} {
-               button $w_next -default active
+               ${NS}::button $w_next -default active
                pack $w_next -side right -padx 5 -before $w_quit
        }
        _do_$action $this
@@ -371,26 +374,25 @@ proc _objdir {path} {
 ## Create New Repository
 
 method _do_new {} {
+       global use_ttk NS
        $w_next conf \
                -state disabled \
                -command [cb _do_new2] \
                -text [mc "Create"]
 
-       frame $w_body
-       label $w_body.h \
-               -font font_uibold \
+       ${NS}::frame $w_body
+       ${NS}::label $w_body.h \
+               -font font_uibold -anchor center \
                -text [mc "Create New Repository"]
        pack $w_body.h -side top -fill x -pady 10
        pack $w_body -fill x -padx 10
 
-       frame $w_body.where
-       label $w_body.where.l -text [mc "Directory:"]
-       entry $w_body.where.t \
+       ${NS}::frame $w_body.where
+       ${NS}::label $w_body.where.l -text [mc "Directory:"]
+       ${NS}::entry $w_body.where.t \
                -textvariable @local_path \
-               -borderwidth 1 \
-               -relief sunken \
                -width 50
-       button $w_body.where.b \
+       ${NS}::button $w_body.where.b \
                -text [mc "Browse"] \
                -command [cb _new_local_path]
        set w_localpath $w_body.where.t
@@ -410,7 +412,7 @@ method _new_local_path {} {
        if {$local_path ne {}} {
                set p [file dirname $local_path]
        } else {
-               set p [_home]
+               set p [pwd]
        }
 
        set p [tk_chooseDirectory \
@@ -456,63 +458,57 @@ proc _new_ok {p} {
 ## Clone Existing Repository
 
 method _do_clone {} {
+       global use_ttk NS
        $w_next conf \
                -state disabled \
                -command [cb _do_clone2] \
                -text [mc "Clone"]
 
-       frame $w_body
-       label $w_body.h \
-               -font font_uibold \
+       ${NS}::frame $w_body
+       ${NS}::label $w_body.h \
+               -font font_uibold -anchor center \
                -text [mc "Clone Existing Repository"]
        pack $w_body.h -side top -fill x -pady 10
        pack $w_body -fill x -padx 10
 
        set args $w_body.args
-       frame $w_body.args
+       ${NS}::frame $w_body.args
        pack $args -fill both
 
-       label $args.origin_l -text [mc "Source Location:"]
-       entry $args.origin_t \
+       ${NS}::label $args.origin_l -text [mc "Source Location:"]
+       ${NS}::entry $args.origin_t \
                -textvariable @origin_url \
-               -borderwidth 1 \
-               -relief sunken \
                -width 50
-       button $args.origin_b \
+       ${NS}::button $args.origin_b \
                -text [mc "Browse"] \
                -command [cb _open_origin]
        grid $args.origin_l $args.origin_t $args.origin_b -sticky ew
 
-       label $args.where_l -text [mc "Target Directory:"]
-       entry $args.where_t \
+       ${NS}::label $args.where_l -text [mc "Target Directory:"]
+       ${NS}::entry $args.where_t \
                -textvariable @local_path \
-               -borderwidth 1 \
-               -relief sunken \
                -width 50
-       button $args.where_b \
+       ${NS}::button $args.where_b \
                -text [mc "Browse"] \
                -command [cb _new_local_path]
        grid $args.where_l $args.where_t $args.where_b -sticky ew
        set w_localpath $args.where_t
 
-       label $args.type_l -text [mc "Clone Type:"]
-       frame $args.type_f
+       ${NS}::label $args.type_l -text [mc "Clone Type:"]
+       ${NS}::frame $args.type_f
        set w_types [list]
-       lappend w_types [radiobutton $args.type_f.hardlink \
+       lappend w_types [${NS}::radiobutton $args.type_f.hardlink \
                -state disabled \
-               -anchor w \
                -text [mc "Standard (Fast, Semi-Redundant, Hardlinks)"] \
                -variable @clone_type \
                -value hardlink]
-       lappend w_types [radiobutton $args.type_f.full \
+       lappend w_types [${NS}::radiobutton $args.type_f.full \
                -state disabled \
-               -anchor w \
                -text [mc "Full Copy (Slower, Redundant Backup)"] \
                -variable @clone_type \
                -value full]
-       lappend w_types [radiobutton $args.type_f.shared \
+       lappend w_types [${NS}::radiobutton $args.type_f.shared \
                -state disabled \
-               -anchor w \
                -text [mc "Shared (Fastest, Not Recommended, No Backup)"] \
                -variable @clone_type \
                -value shared]
@@ -537,7 +533,7 @@ method _open_origin {} {
        if {$origin_url ne {} && [file isdirectory $origin_url]} {
                set p $origin_url
        } else {
-               set p [_home]
+               set p [pwd]
        }
 
        set p [tk_chooseDirectory \
@@ -1001,26 +997,25 @@ method _postcheckout_wait {fd_ph} {
 ## Open Existing Repository
 
 method _do_open {} {
+       global NS
        $w_next conf \
                -state disabled \
                -command [cb _do_open2] \
                -text [mc "Open"]
 
-       frame $w_body
-       label $w_body.h \
-               -font font_uibold \
+       ${NS}::frame $w_body
+       ${NS}::label $w_body.h \
+               -font font_uibold -anchor center \
                -text [mc "Open Existing Repository"]
        pack $w_body.h -side top -fill x -pady 10
        pack $w_body -fill x -padx 10
 
-       frame $w_body.where
-       label $w_body.where.l -text [mc "Repository:"]
-       entry $w_body.where.t \
+       ${NS}::frame $w_body.where
+       ${NS}::label $w_body.where.l -text [mc "Repository:"]
+       ${NS}::entry $w_body.where.t \
                -textvariable @local_path \
-               -borderwidth 1 \
-               -relief sunken \
                -width 50
-       button $w_body.where.b \
+       ${NS}::button $w_body.where.b \
                -text [mc "Browse"] \
                -command [cb _open_local_path]
 
@@ -1039,7 +1034,7 @@ method _open_local_path {} {
        if {$local_path ne {}} {
                set p $local_path
        } else {
-               set p [_home]
+               set p [pwd]
        }
 
        set p [tk_chooseDirectory \