Changeset 118304


Ignore:
Timestamp:
Mar 29, 2014, 7:21:58 PM (10 years ago)
Author:
cal@…
Message:

base: Delay displaying notes for installed ports until the end of the current operation

Mostly written by Jeremy Lavergne (snc).

Location:
trunk/base/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/macports.tcl

    r118298 r118304  
    12951295    }
    12961296
     1297    # notifications callback
     1298    if {[info exists macports::ui_options(notifications_append)]} {
     1299        $workername alias ui_notifications_append $macports::ui_options(notifications_append)
     1300    } else {
     1301        # provide a no-op if notifications_append wasn't set. See http://wiki.tcl.tk/3044
     1302        $workername alias ui_notifications_append return -level 0
     1303    }
     1304
    12971305    $workername alias ui_prefix ui_prefix
    12981306    $workername alias ui_channels ui_channels
  • trunk/base/src/port/port.tcl

    r117702 r118304  
    46404640        }
    46414641
     4642        # Print notifications of just-activated ports.
     4643        portclient::notifications::display
     4644
    46424645        # semaphore to exit
    46434646        if {$action_status == -999} break
     
    51685171}
    51695172
     5173namespace eval portclient::notifications {
     5174    ##
     5175    # Ports whose notifications to display; these were either installed
     5176    # or requested to be installed.
     5177    variable notificationsToPrint
     5178    array set notificationsToPrint {}
     5179
     5180    ##
     5181    # Add a port to the list for printing notifications.
     5182    #
     5183    # @param name
     5184    #        The name of the port.
     5185    # @param note
     5186    #        A list of notes to be stored for the given port.
     5187    proc append {name notes} {
     5188        variable notificationsToPrint
     5189
     5190        set notificationsToPrint($name) $notes
     5191    }
     5192
     5193    ##
     5194    # Print port notifications.
     5195    #
     5196    proc display {} {
     5197        global env
     5198        variable notificationsToPrint
     5199
     5200        # Display notes at the end of the activation phase.
     5201        if {[array size notificationsToPrint] > 0} {
     5202            ui_notice "--->  Some of the ports you installed have notes:"
     5203            foreach {name notes} [array get notificationsToPrint] {
     5204                ui_notice "  $name has the following notes:"
     5205
     5206                # If env(COLUMNS) exists, limit each line's width to this width.
     5207                if {[info exists env(COLUMNS)]} {
     5208                    set maxlen $env(COLUMNS)
     5209
     5210                    foreach note $notes {
     5211                        foreach line [split $note "\n"] {
     5212                            set joiner ""
     5213                            set lines ""
     5214                            set newline "    "
     5215
     5216                            foreach word [split $line " "] {
     5217                                if {[string length $newline] + [string length $word] >= $maxlen} {
     5218                                    lappend lines $newline
     5219                                    set newline "    "
     5220                                    set joiner ""
     5221                                }
     5222                                ::append newline $joiner $word
     5223                                set joiner " "
     5224                            }
     5225                            if {$newline ne {}} {
     5226                                lappend lines $newline
     5227                            }
     5228                            ui_notice [join $lines "\n"]
     5229                        }
     5230                    }
     5231                } else {
     5232                    foreach note $notes {
     5233                        ui_notice $note
     5234                    }
     5235                }
     5236            }
     5237        }
     5238    }
     5239}
     5240
    51705241
    51715242##########################################
     
    52225293    set ui_options(progress_generic)  portclient::progress::generic
    52235294}
     5295
     5296set ui_options(notifications_append) portclient::notifications::append
    52245297
    52255298# Get arguments remaining after option processing
  • trunk/base/src/port1.0/portactivate.tcl

    r116820 r118304  
    6161
    6262proc portactivate::activate_main {args} {
    63     global env subport version revision portvariants user_options PortInfo startupitem.autostart UI_PREFIX
     63    global subport version revision portvariants user_options PortInfo
    6464
    6565    registry_activate $subport $version $revision $portvariants [array get user_options]
    66 
    67     # Display notes at the end of the activation phase.
    68     if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {
    69         ui_notice ""
    70         foreach note $PortInfo(notes) {
    71             # If env(COLUMNS) exists, limit each line's width to this width.
    72             if {[info exists env(COLUMNS)]} {
    73                 set maxlen $env(COLUMNS)
    74 
    75                 foreach line [split $note "\n"] {
    76                     set joiner ""
    77                     set lines ""
    78                     set newline ""
    79 
    80                     foreach word [split $line " "] {
    81                         if {[string length $newline] + [string length $word] >= $maxlen} {
    82                             lappend lines $newline
    83                             set newline ""
    84                             set joiner ""
    85                         }
    86                         append newline $joiner $word
    87                         set joiner " "
    88                     }
    89                     if {$newline ne {}} {
    90                         lappend lines $newline
    91                     }
    92                     ui_notice [join $lines "\n"]
    93                 }
    94             } else {
    95                 ui_notice $note
    96             }
    97         }
    98         ui_notice ""
     66    if {[info exists PortInfo(notes)] && [llength $PortInfo(notes)] > 0} {
     67        ui_notifications_append $subport $PortInfo(notes)
    9968    }
    10069
Note: See TracChangeset for help on using the changeset viewer.