Another tweak to improve visual behavior when activating the main window.

git-svn-id: http://munki.googlecode.com/svn/trunk@239 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Greg Neagle
2009-09-29 17:32:06 +00:00
parent 1d6996c38f
commit c61024cba0
@@ -268,53 +268,55 @@ on alert ended theObject with reply withReply
end alert ended
on activated theObject
set installitems to my itemstoinstall()
if (count of installitems) > 0 then
my initTable()
my updateTable()
show window "mainWindow"
set enabled of (menu item "installAllMenuItem" of menu "updateMenu" of menu 1) to true
else if visible of window "mainWindow" is false then
if visible of window "mainWindow" is false then
-- we haven't shown the main window yet
-- did managedsoftwareupdate --manual just finish?
set now to current date
tell application "System Events"
try
set ManagedInstallPrefsFile to "/Library/Preferences/ManagedInstalls.plist"
set ManagedInstallPrefs to value of property list file ManagedInstallPrefsFile
set lastCheckedDate to |LastCheckDate| of ManagedInstallPrefs
on error
set lastCheckedDate to date "Thursday, January 1, 1970 12:00:00 AM"
end try
end tell
if now - lastCheckedDate < 10 then
-- managedsoftwareupdate --manual just ran, but there are no updates
-- because if there were updates, count of installitems > 0
set installitems to my itemstoinstall()
if (count of installitems) > 0 then
my initTable()
my updateTable()
show window "mainWindow"
display alert "Your software is up to date." message ¬
"There is no new software for your computer at this time." default button "Quit" as informational attached to window 1
set enabled of (menu item "installAllMenuItem" of menu "updateMenu" of menu 1) to true
else
-- no items to install, managedsoftwareupdate didn't finish checking recently
-- so we are either checking or need to check
-- did managedsoftwareupdate --manual just finish?
set now to current date
tell application "System Events"
set processList to name of every process
end tell
if processList contains "MunkiStatus" then
-- we're currently checking, just bring the status window to the front
tell application "MunkiStatus" to activate
else
-- run managedsoftwareupdate --manual
try
-- touch a file to get launchd to run managedsoftwareupdate --manual as root
set triggerpath to quoted form of (managedInstallDir & "/.updatecheck.launchd")
do shell script "/usr/bin/touch " & triggerpath
-- when it's done, it sends an activate message or launches us again
set ManagedInstallPrefsFile to "/Library/Preferences/ManagedInstalls.plist"
set ManagedInstallPrefs to value of property list file ManagedInstallPrefsFile
set lastCheckedDate to |LastCheckDate| of ManagedInstallPrefs
on error
show window "mainWindow"
display alert "Cannot check for updates." message ¬
"There is a configuration problem with the managed software installer. Contact your systems administrator." default button "Quit" as informational attached to window 1
set lastCheckedDate to date "Thursday, January 1, 1970 12:00:00 AM"
end try
end tell
if now - lastCheckedDate < 10 then
-- managedsoftwareupdate --manual just ran, but there are no updates
-- because if there were updates, count of installitems > 0
show window "mainWindow"
display alert "Your software is up to date." message ¬
"There is no new software for your computer at this time." default button "Quit" as informational attached to window 1
else
-- no items to install, managedsoftwareupdate didn't finish checking recently
-- so we are either checking or need to check
tell application "System Events"
set processList to name of every process
end tell
if processList contains "MunkiStatus" then
-- we're currently checking, just bring the status window to the front
tell application "MunkiStatus" to activate
else
-- run managedsoftwareupdate --manual
try
-- touch a file to get launchd to run managedsoftwareupdate --manual as root
set triggerpath to quoted form of (managedInstallDir & "/.updatecheck.launchd")
do shell script "/usr/bin/touch " & triggerpath
-- when it's done, it sends an activate message or launches us again
on error
show window "mainWindow"
display alert "Cannot check for updates." message ¬
"There is a configuration problem with the managed software installer. Contact your systems administrator." default button "Quit" as informational attached to window 1
end try
end if
end if
end if
end if