1
# git-gui Tools menu dialogs
6
field w_name ; # new remote name widget
7
field w_cmd ; # new remote location widget
9
field name {}; # name of the tool
10
field command {}; # command to execute
11
field add_global 0; # add to the --global config
12
field no_console 0; # disable using the console
13
field needs_file 0; # ensure filename is set
14
field confirm 0; # ask for confirmation
15
field ask_branch 0; # ask for a revision
16
field ask_args 0; # ask for additional args
18
constructor dialog {} {
19
global repo_config use_ttk NS
22
wm title $top [mc "%s (%s): Add Tool" [appname] [reponame]]
24
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
28
${NS}::label $w.header -text [mc "Add New Tool Command"] \
29
-font font_uibold -anchor center
30
pack $w.header -side top -fill x
32
${NS}::frame $w.buttons
33
${NS}::checkbutton $w.buttons.global \
34
-text [mc "Add globally"] \
36
pack $w.buttons.global -side left -padx 5
37
${NS}::button $w.buttons.create -text [mc Add] \
40
pack $w.buttons.create -side right
41
${NS}::button $w.buttons.cancel -text [mc Cancel] \
42
-command [list destroy $w]
43
pack $w.buttons.cancel -side right -padx 5
44
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
46
${NS}::labelframe $w.desc -text [mc "Tool Details"]
48
${NS}::label $w.desc.name_cmnt -anchor w\
49
-text [mc "Use '/' separators to create a submenu tree:"]
50
grid x $w.desc.name_cmnt -sticky we -padx {0 5} -pady {0 2}
51
${NS}::label $w.desc.name_l -text [mc "Name:"]
52
set w_name $w.desc.name_t
53
${NS}::entry $w_name \
57
-validatecommand [cb _validate_name %d %S]
58
grid $w.desc.name_l $w_name -sticky we -padx {0 5}
60
${NS}::label $w.desc.cmd_l -text [mc "Command:"]
61
set w_cmd $w.desc.cmd_t
64
-textvariable @command
65
grid $w.desc.cmd_l $w_cmd -sticky we -padx {0 5} -pady {0 3}
67
grid columnconfigure $w.desc 1 -weight 1
68
pack $w.desc -anchor nw -fill x -pady 5 -padx 5
70
${NS}::checkbutton $w.confirm \
71
-text [mc "Show a dialog before running"] \
72
-variable @confirm -command [cb _check_enable_dlg]
74
${NS}::labelframe $w.dlg -labelwidget $w.confirm
76
${NS}::checkbutton $w.dlg.askbranch \
77
-text [mc "Ask the user to select a revision (sets \$REVISION)"] \
78
-variable @ask_branch -state disabled
79
pack $w.dlg.askbranch -anchor w -padx 15
81
${NS}::checkbutton $w.dlg.askargs \
82
-text [mc "Ask the user for additional arguments (sets \$ARGS)"] \
83
-variable @ask_args -state disabled
84
pack $w.dlg.askargs -anchor w -padx 15
86
pack $w.dlg -anchor nw -fill x -pady {0 8} -padx 5
88
${NS}::checkbutton $w.noconsole \
89
-text [mc "Don't show the command output window"] \
91
pack $w.noconsole -anchor w -padx 5
93
${NS}::checkbutton $w.needsfile \
94
-text [mc "Run only if a diff is selected (\$FILENAME not empty)"] \
96
pack $w.needsfile -anchor w -padx 5
98
bind $w <Visibility> [cb _visible]
99
bind $w <Key-Escape> [list destroy $w]
100
bind $w <Key-Return> [cb _add]\;break
104
method _check_enable_dlg {} {
106
$w.dlg.askbranch configure -state normal
107
$w.dlg.askargs configure -state normal
109
$w.dlg.askbranch configure -state disabled
110
$w.dlg.askargs configure -state disabled
118
error_popup [mc "Please supply a name for the tool."]
123
set item "guitool.$name.cmd"
125
if {[info exists repo_config($item)]} {
126
error_popup [mc "Tool '%s' already exists." $name]
131
set cmd [list git config]
132
if {$add_global} { lappend cmd --global }
134
if {$no_console} { lappend items "guitool.$name.noconsole" }
135
if {$needs_file} { lappend items "guitool.$name.needsfile" }
137
if {$ask_args} { lappend items "guitool.$name.argprompt" }
138
if {$ask_branch} { lappend items "guitool.$name.revprompt" }
139
if {!$ask_args && !$ask_branch} {
140
lappend items "guitool.$name.confirm"
145
eval $cmd [list $item $command]
146
foreach citem $items { eval $cmd [list $citem yes] }
148
error_popup [mc "Could not add tool:\n%s" $err]
150
set repo_config($item) $command
151
foreach citem $items { set repo_config($citem) yes }
159
method _validate_name {d S} {
161
if {[regexp {[~?*&\[\0\"\\\{]} $S]} {
178
field w ; # widget path
179
field w_names ; # name list
181
constructor dialog {} {
182
global repo_config global_config system_config use_ttk NS
187
wm title $top [mc "%s (%s): Remove Tool" [appname] [reponame]]
189
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
193
${NS}::label $w.header -text [mc "Remove Tool Commands"] \
194
-font font_uibold -anchor center
195
pack $w.header -side top -fill x
197
${NS}::frame $w.buttons
198
${NS}::button $w.buttons.create -text [mc Remove] \
200
-command [cb _remove]
201
pack $w.buttons.create -side right
202
${NS}::button $w.buttons.cancel -text [mc Cancel] \
203
-command [list destroy $w]
204
pack $w.buttons.cancel -side right -padx 5
205
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
208
set w_names $w.list.l
212
-selectmode extended \
213
-exportselection false
214
pack $w.list.l -side left -fill both -expand 1
215
pack $w.list -fill both -expand 1 -pady 5 -padx 5
218
foreach fullname [tools_list] {
219
# Cannot delete system tools
220
if {[info exists system_config(guitool.$fullname.cmd)]} continue
222
$w_names insert end $fullname
223
if {![info exists global_config(guitool.$fullname.cmd)]} {
224
$w_names itemconfigure end -foreground blue
229
if {$local_cnt > 0} {
230
${NS}::label $w.colorlbl -foreground blue \
231
-text [mc "(Blue denotes repository-local tools)"]
232
pack $w.colorlbl -fill x -pady 5 -padx 5
235
bind $w <Visibility> [cb _visible]
236
bind $w <Key-Escape> [list destroy $w]
237
bind $w <Key-Return> [cb _remove]\;break
242
foreach i [$w_names curselection] {
243
set name [$w_names get $i]
245
catch { git config --remove-section guitool.$name }
246
catch { git config --global --remove-section guitool.$name }
264
field w ; # widget path
265
field w_rev {}; # revision browser
266
field w_args {}; # arguments
268
field is_ask_args 0; # has arguments field
269
field is_ask_revs 0; # has revision browser
271
field is_ok 0; # ok to start
272
field argstr {}; # arguments
274
constructor dialog {fullname} {
275
global M1B use_ttk NS
277
set title [get_config "guitool.$fullname.title"]
279
regsub {/} $fullname { / } title
282
make_dialog top w -autodelete 0
283
wm title $top "[mc "%s (%s):" [appname] [reponame]] $title"
285
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
289
set prompt [get_config "guitool.$fullname.prompt"]
291
set command [get_config "guitool.$fullname.cmd"]
292
set prompt [mc "Run Command: %s" $command]
295
${NS}::label $w.header -text $prompt -font font_uibold -anchor center
296
pack $w.header -side top -fill x
298
set argprompt [get_config "guitool.$fullname.argprompt"]
299
set revprompt [get_config "guitool.$fullname.revprompt"]
301
set is_ask_args [expr {$argprompt ne {}}]
302
set is_ask_revs [expr {$revprompt ne {}}]
305
if {$argprompt eq {yes} || $argprompt eq {true} || $argprompt eq {1}} {
306
set argprompt [mc "Arguments"]
309
${NS}::labelframe $w.arg -text $argprompt
311
set w_args $w.arg.txt
312
${NS}::entry $w_args \
314
-textvariable @argstr
315
pack $w_args -padx 5 -pady 5 -fill both
316
pack $w.arg -anchor nw -fill both -pady 5 -padx 5
320
if {$revprompt eq {yes} || $revprompt eq {true} || $revprompt eq {1}} {
321
set revprompt [mc "Revision"]
324
if {[is_config_true "guitool.$fullname.revunmerged"]} {
325
set w_rev [::choose_rev::new_unmerged $w.rev $revprompt]
327
set w_rev [::choose_rev::new $w.rev $revprompt]
330
pack $w.rev -anchor nw -fill both -expand 1 -pady 5 -padx 5
333
${NS}::frame $w.buttons
335
${NS}::button $w.buttons.visualize \
336
-text [mc Visualize] \
337
-command [cb _visualize]
338
pack $w.buttons.visualize -side left
340
${NS}::button $w.buttons.ok \
343
pack $w.buttons.ok -side right
344
${NS}::button $w.buttons.cancel \
345
-text [mc "Cancel"] \
346
-command [cb _cancel]
347
pack $w.buttons.cancel -side right -padx 5
348
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
350
bind $w <$M1B-Key-Return> [cb _start]
351
bind $w <Key-Return> [cb _start]
352
bind $w <Key-Escape> [cb _cancel]
353
wm protocol $w WM_DELETE_WINDOW [cb _cancel]
355
bind $w <Visibility> [cb _visible]
370
} elseif {$is_ask_revs} {
376
wm protocol $w WM_DELETE_WINDOW {}
381
if {[catch {$w_rev commit_or_die}]} {
387
method _visualize {} {
388
global current_branch
391
do_gitk [list --left-right "$current_branch...$rev"]
399
set name [_rev $this]
403
set env(REVISION) $name
407
set env(ARGS) $argstr