git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: pasky@suse.cz
To: git@vger.kernel.org
Cc: spearce@spearce.org
Subject: [PATCH 4/5] git-gui: Factor out URL inputbox construction to location_input
Date: Thu, 25 Sep 2008 00:12:53 +0200	[thread overview]
Message-ID: <20080924221732.904804942@suse.cz> (raw)
In-Reply-To: 20080924221249.037449176@suse.cz

[-- Attachment #1: t/git-gui/ldialogs-refactor.diff --]
[-- Type: text/plain, Size: 4566 bytes --]

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)

  parent reply	other threads:[~2008-09-24 22:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
2008-09-24 22:12 ` [PATCH 1/5] git-gui: Avoid using the term URL when specifying repositories pasky
2008-09-24 22:12 ` [PATCH 2/5] git-gui: Make input boxes in init/clone/open dialogs consistent pasky
2008-09-24 22:12 ` [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu pasky
2008-09-24 22:23   ` Petr Baudis
2008-09-24 22:12 ` pasky [this message]
2008-09-24 22:12 ` [PATCH 5/5] git-gui: Support for user-provided locator templates pasky
2008-09-25 21:26 ` [PATCH 0/5] git-gui: Support for "Locators" - address templates Daniel Barkalow
2008-09-26 14:33   ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080924221732.904804942@suse.cz \
    --to=pasky@suse.cz \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).