[PATCH 4/5] git-gui: Factor out URL inputbox construction to location_input
This will make it easier to introduce custom locators.
This patch has been sponsored by Novartis.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
git-gui/lib/choose_repository.tcl | 6 +---
git-gui/lib/remote_add.tcl | 6 +---
git-gui/lib/remote_branch_delete.tcl | 11 +-------
git-gui/lib/transport.tcl | 46 ++++++++++++++++++++-------------
4 files changed, 31 insertions(+), 38 deletions(-)
diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 9091316..1c951ae 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -465,11 +465,7 @@ method _do_clone {} {
pack $args -fill both
label $args.origin_l -text [mc "Source Location:"]
- entry $args.origin_t \
- -textvariable @origin_url \
- -borderwidth 1 \
- -relief sunken \
- -width 50
+ location_input $args.origin_t @origin_url
button $args.origin_b \
-text [mc "Browse"] \
-command [cb _open_origin]
diff --git a/git-gui/lib/remote_add.tcl b/git-gui/lib/remote_add.tcl
index 89e88ee..b4a9ede 100644
--- a/git-gui/lib/remote_add.tcl
+++ b/git-gui/lib/remote_add.tcl
@@ -49,11 +49,7 @@ constructor dialog {} {
label $w.desc.loc_l -text [mc "Location:"]
set w_loc $w.desc.loc_t
- entry $w_loc \
- -borderwidth 1 \
- -relief sunken \
- -width 40 \
- -textvariable @location
+ location_input $w_loc @location
grid $w.desc.loc_l $w_loc -sticky we -padx {0 5}
grid columnconfigure $w.desc 1 -weight 1
diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
index a09b9ad..14a4c15 100644
--- a/git-gui/lib/remote_branch_delete.tcl
+++ b/git-gui/lib/remote_branch_delete.tcl
@@ -66,16 +66,7 @@ constructor dialog {} {
-text [mc "Arbitrary Location:"] \
-value url \
-variable @urltype
- entry $w.dest.url_t \
- -borderwidth 1 \
- -relief sunken \
- -width 50 \
- -textvariable @url \
- -validate key \
- -validatecommand {
- if {%d == 1 && [regexp {\s} %S]} {return 0}
- return 1
- }
+ location_input $w.dest.url_t @url
trace add variable @url write [cb _write_url]
grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
grid columnconfigure $w.dest 1 -weight 1
diff --git a/git-gui/lib/transport.tcl b/git-gui/lib/transport.tcl
index e419d78..b8ceebe 100644
--- a/git-gui/lib/transport.tcl
+++ b/git-gui/lib/transport.tcl
@@ -30,6 +30,21 @@ proc push_to {remote} {
console::exec $w $cmd
}
+proc location_input {widget urlvar} {
+ global repo_config
+
+ entry $widget \
+ -borderwidth 1 \
+ -relief sunken \
+ -width 50 \
+ -textvariable $urlvar \
+ -validate key \
+ -validatecommand {
+ if {%d == 1 && [regexp {\s} %S]} {return 0}
+ return 1
+ }
+}
+
proc start_push_anywhere_action {w} {
global push_urltype push_remote push_url push_thin push_tags
global push_force
@@ -77,11 +92,22 @@ proc start_push_anywhere_action {w} {
trace add variable push_remote write \
[list radio_selector push_urltype remote]
+proc push_anywhere_urltype {args} {
+ global push_urltype
+ set push_urltype url
+ warn_popup "blablabla"
+}
+
proc do_push_anywhere {} {
global all_remotes current_branch
global push_urltype push_remote push_url push_thin push_tags
global push_force
+ set push_url {}
+ set push_force 0
+ set push_thin 0
+ set push_tags 0
+
set w .push_setup
toplevel $w
wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
@@ -138,19 +164,8 @@ proc do_push_anywhere {} {
-text [mc "Arbitrary Location:"] \
-value url \
-variable push_urltype
- entry $w.dest.url_t \
- -borderwidth 1 \
- -relief sunken \
- -width 50 \
- -textvariable push_url \
- -validate key \
- -validatecommand {
- if {%d == 1 && [regexp {\s} %S]} {return 0}
- if {%d == 1 && [string length %S] > 0} {
- set push_urltype url
- }
- return 1
- }
+ location_input $w.dest.url_t push_url
+ trace add variable push_url write push_anywhere_urltype
grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
grid columnconfigure $w.dest 1 -weight 1
pack $w.dest -anchor nw -fill x -pady 5 -padx 5
@@ -171,11 +186,6 @@ proc do_push_anywhere {} {
grid columnconfigure $w.options 1 -weight 1
pack $w.options -anchor nw -fill x -pady 5 -padx 5
- set push_url {}
- set push_force 0
- set push_thin 0
- set push_tags 0
-
bind $w <Visibility> "grab $w; focus $w.buttons.create"
bind $w <Key-Escape> "destroy $w"
bind $w <Key-Return> [list start_push_anywhere_action $w]
--
tg: (4e2c8cc..) t/git-gui/ldialogs-refactor (depends on: t/git-gui/ldialogs-consistent t/git-gui/remote-add)