texlive[52337] Master: Better handling of titlebar Close button

commits+siepo at tug.org commits+siepo at tug.org
Fri Oct 11 13:45:13 CEST 2019


Revision: 52337
          http://tug.org/svn/texlive?view=revision&revision=52337
Author:   siepo
Date:     2019-10-11 13:45:12 +0200 (Fri, 11 Oct 2019)
Log Message:
-----------
Better handling of titlebar Close button

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/tlshell/tlshell.tcl
    trunk/Master/tlpkg/installer/install-tl-gui.tcl
    trunk/Master/tlpkg/tltcl/tltcl.tcl

Modified: trunk/Master/texmf-dist/scripts/tlshell/tlshell.tcl
===================================================================
--- trunk/Master/texmf-dist/scripts/tlshell/tlshell.tcl	2019-10-10 23:54:04 UTC (rev 52336)
+++ trunk/Master/texmf-dist/scripts/tlshell/tlshell.tcl	2019-10-11 11:45:12 UTC (rev 52337)
@@ -167,8 +167,10 @@
   }
   if [winfo exists .tlmg.cancel] {
     bind .tlmg <Escape> {.tlmg.cancel invoke}
+    wm protocol WM_DELETE_WINDOW {cancel_or_destroy .tlmg.cancel .tlmg}
   } elseif {$type eq "ok"} {
     bind .tlmg <Escape> {.tlmg.ok invoke}
+    wm protocol WM_DELETE_WINDOW {cancel_or_destroy .tlmg.ok .tlmg}
   }
 
   ppack [ttk::frame .tlmg.tx] -in .tlmg.bg -side top -fill both -expand 1
@@ -796,6 +798,7 @@
   }
   ttk::button .loading.abo -text [__ "Abort"] -command abort_load
   ppack .loading.abo -in .loading.buttons -side right
+  wm protocol .loading {cancel_or_destroy .loading.abo .loading}
   wm resizable .loading 0 0
   place_dlg .loading .
 } ; # splash_loading
@@ -918,7 +921,8 @@
   ppack [ttk::label .tllg.status -textvariable ::busy -anchor w] \
       -in .tllg.bottom -side left
   bind .tllg <Escape> {.tllg.close invoke}
-  wm protocol .tllg WM_DELETE_WINDOW {.tllg.close invoke}
+  wm protocol .tllg WM_DELETE_WINDOW \
+      {cancel_or_destroy .tllg.close .tllg}
 
   # notebook pages and scrollbars
   ttk::frame .tllg.log
@@ -1271,7 +1275,8 @@
   ppack .tlr.cancel -in .tlr.closebuttons -side right
   bind .tlr <Escape> {.tlr.cancel invoke}
 
-  wm protocol .tlr WM_DELETE_WINDOW {.tlr.cancel invoke}
+  wm protocol .tlr WM_DELETE_WINDOW \
+      {cancel_or_destroy .tlr.cancel .tlr}
   wm resizable .tlr 1 0
   place_dlg .tlr .
 } ; # repository_dialog
@@ -2314,7 +2319,7 @@
     bind .pkg_popup <Leave> {.pkg_popup unpost}
   }
 
-  wm protocol . WM_DELETE_WINDOW {.q invoke}
+  wm protocol . WM_DELETE_WINDOW {cancel_or_destroy .q .}
   wm resizable . 1 1
   wm state . normal
 }

Modified: trunk/Master/tlpkg/installer/install-tl-gui.tcl
===================================================================
--- trunk/Master/tlpkg/installer/install-tl-gui.tcl	2019-10-10 23:54:04 UTC (rev 52336)
+++ trunk/Master/tlpkg/installer/install-tl-gui.tcl	2019-10-11 11:45:12 UTC (rev 52337)
@@ -539,11 +539,12 @@
     }
   }
   ppack .tled.ok_b -in .tled.buttons -side right -padx 5 -pady 5
-  ttk::button .tled.q_b -text [__ "Cancel"] -command {end_dlg "" .tled}
-  ppack .tled.q_b -in .tled.buttons -side right -padx 5 -pady 5
-  bind .tled <Escape> {.tled.q_b invoke}
+  ttk::button .tled.cancel_b -text [__ "Cancel"] -command {end_dlg "" .tled}
+  ppack .tled.cancel_b -in .tled.buttons -side right -padx 5 -pady 5
+  bind .tled <Escape> {.tled.cancel_b invoke}
 
-  wm protocol .tled WM_DELETE_WINDOW {.tled.q_b invoke}
+  wm protocol .tled WM_DELETE_WINDOW \
+      {cancel_or_destroy .tled.cancel_b .tled}
   wm resizable .tled 0 0
   place_dlg .tled .tltd
 } ; # edit_name
@@ -703,7 +704,8 @@
   bind .tltd <Return> commit_root
   bind .tltd <Escape> {destroy .tltd}
 
-  wm protocol .tltd  WM_DELETE_WINDOW {.tltd.cancel_b invoke}
+  wm protocol .tltd  WM_DELETE_WINDOW \
+      {cancel_or_destroy .tltd.cancel_b .tltd}
   wm resizable .tltd 1 0
   place_dlg .tltd
 } ; # texdir_setup
@@ -744,11 +746,12 @@
   ppack .td.cancel -in .td.f -side right
   bind .td <Escape> {.td.cancel invoke}
 
-  wm protocol .td WM_DELETE_WINDOW {.td.cancel invoke}
+  wm protocol .td WM_DELETE_WINDOW \
+      {cancel_or_destroy .td.cancel .td}
   wm resizable .td 1 0
   place_dlg .td .
   tkwait window .td
-  if {$::dialog_ans ne ""} {
+  if {[info exists ::dialog_ans] && $::dialog_ans ne ""} {
     set ::vars($d) [forward_slashify $::dialog_ans]
     if $::vars(instopt_portable) {
       if {$d eq "TEXMFLOCAL"} {set ::vars(TEXMFHOME) $::vars($d)}
@@ -961,7 +964,8 @@
   bind .tlbin.lst <ButtonRelease-1> \
       {toggle_bin [.tlbin.lst identify item %x %y]}
 
-  wm protocol .tlbin WM_DELETE_WINDOW {.tlbin.cancel invoke}
+  wm protocol .tlbin WM_DELETE_WINDOW \
+      {cancel_or_destroy .tlbin.cancel .tlbin}
   wm resizable .tlbin 1 1
   place_dlg .tlbin .
 }; # select_binaries
@@ -1017,7 +1021,8 @@
   # we already made sure that $::vars(selected_scheme) has a valid value
   .tlschm.lst selection set [list $::vars(selected_scheme)]
 
-  wm protocol .tlschm WM_DELETE_WINDOW {tlschm.cancel invoke}
+  wm protocol .tlschm WM_DELETE_WINDOW \
+      {cancel_or_destroy tlschm.cancel .tlschm}
   wm resizable .tlschm 1 0
   place_dlg .tlschm .
 }; # select_scheme
@@ -1138,7 +1143,8 @@
         [list [mark_sym $::vars($c)] [__ $::coll_descs($c)]]
   }
 
-  wm protocol .tlcoll WM_DELETE_WINDOW {.tlcoll.cancel invoke}
+  wm protocol .tlcoll WM_DELETE_WINDOW \
+      {cancel_or_destroy .tlcoll.cancel .tlcoll}
   wm resizable .tlcoll 1 1
   place_dlg .tlcoll .
 }; # select_collections
@@ -1299,7 +1305,8 @@
 
     check_sym_entries
 
-    wm protocol .edsyms  WM_DELETE_WINDOW {.edsyms.cancel invoke}
+    wm protocol .edsyms  WM_DELETE_WINDOW \
+        {cancel_or_destroy .edsyms.cancel .edsyms}
     wm resizable .edsyms 1 0
     place_dlg .edsyms .
   } ; # edit_symlinks

Modified: trunk/Master/tlpkg/tltcl/tltcl.tcl
===================================================================
--- trunk/Master/tlpkg/tltcl/tltcl.tcl	2019-10-10 23:54:04 UTC (rev 52336)
+++ trunk/Master/tlpkg/tltcl/tltcl.tcl	2019-10-11 11:45:12 UTC (rev 52337)
@@ -451,6 +451,10 @@
 
 # for example code, look at dialog.tcl, part of Tk itself
 
+# In most cases, it is not necessary to explicitly define a handler for
+# the WM_DELETE_WINDOW protocol. But if the cancel- or abort button would do
+# anything special, then the close icon should not bypass this.
+
 # widget classes which can be enabled and disabled.
 # The text widget class is not included here.
 
@@ -468,7 +472,6 @@
   wm withdraw $wnd
   if [winfo viewable $p] {wm transient $wnd $p}
   if $::plain_unix {wm attributes $wnd -type dialog}
-  wm protocol $wnd WM_DELETE_WINDOW {destroy $wnd}
 }
 
 # Place a dialog centered wrt its parent.
@@ -515,6 +518,15 @@
   destroy $wnd
 } ; # end_dlg
 
+# a possibly useful callback for WM_DELETE_WINDOW
+proc cancel_or_destroy {ctrl topl} {
+  if [winfo exists $ctrl] {
+    $ctrl invoke
+  } elseif [winfo exists $topl] {
+    destroy $topl
+  }
+}
+
 ##### directories #####
 
 # slash flipping
@@ -576,6 +588,8 @@
     ppack [ttk::button .browser.cancel -text [__ "Cancel"]] \
         -in .browser.fr1 -side right
     bind .browser <Escape> {.browser.cancel invoke}
+    wm protocol .browser WM_DELETE_WINDOW \
+        {cancel_or_destroy .browser.cancel .browser}
     .browser.ok configure -command {
       set ::dialog_ans [.browser.tree focus]
       destroy .browser



More information about the tex-live-commits mailing list