[38506] trunk/base/src/macports1.0/macports.tcl

rhwood at macports.org rhwood at macports.org
Wed Jul 23 02:43:15 PDT 2008


Revision: 38506
          http://trac.macosforge.org/projects/macports/changeset/38506
Author:   rhwood at macports.org
Date:     2008-07-23 02:43:14 -0700 (Wed, 23 Jul 2008)
Log Message:
-----------
Armahg's patch to macports::ui_init for the GSOC08 frameworks project.

This patch allows users of the Tcl API for MacPorts to define custom ui_*
procedures message handling mechanisms.

Closes #15913, committing per email and IRC conversation.

Modified Paths:
--------------
    trunk/base/src/macports1.0/macports.tcl

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2008-07-23 07:51:09 UTC (rev 38505)
+++ trunk/base/src/macports1.0/macports.tcl	2008-07-23 09:43:14 UTC (rev 38506)
@@ -76,6 +76,13 @@
 # ui_channels returns a list of channels to output the message to, empty for
 #     no message.
 # if these functions are not provided, defaults are used.
+# Clients of the library may optionally provide ui_init with the following
+# prototype.
+#     proc ui_init {priority prefix channels message}
+# ui_init needs to correctly define the proc ::ui_$priority {message} or throw
+# an error.
+# if this function is not provided or throws an error, default procedures for
+# ui_$priority are defined.
 
 # ui_options accessor
 proc macports::ui_isset {val} {
@@ -118,15 +125,19 @@
             set prefix [ui_prefix_default $priority]
         }
 
-        if {$nbchans == 1} {
-            set chan [lindex $channels 0]
-            proc ::ui_$priority {str} [subst { puts $chan "$prefix\$str" }]
-        } else {
-            proc ::ui_$priority {str} [subst {
-                foreach chan \$channels {
-                    puts $chan "$prefix\$str"
-                }
-            }]
+        try {
+            ::ui_init $priority $prefix $channels $message
+        } catch * {
+            if {$nbchans == 1} {
+                set chan [lindex $channels 0]
+                proc ::ui_$priority {str} [subst { puts $chan "$prefix\$str" }]
+            } else {
+                proc ::ui_$priority {str} [subst {
+                    foreach chan \$channels {
+                        puts $chan "$prefix\$str"
+                    }
+                }]
+            }
         }
 
         # Call ui_$priority
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080723/eb443162/attachment.html 


More information about the macports-changes mailing list