powered by nequal
Home » Mac_Growl » Timeline » 1245

Changeset 1245 -- 2009-10-02 11:33:58

Author
Ryusuke SEKIYAMA
Comment
- Modified to catch up with the change of Mac_AppleScript/trunk r1244. - Added constants Mac_Growl::PRIORITY_*. - Updated examples.

Diffs

Mac_Growl/trunk/Mac/Growl.php

@@ -52,6 +52,12 @@
const GROWL_HELPER_APP = 'GrowlHelperApp';
+    const PRIORITY_VERY_LOW = -2;
+    const PRIORITY_MODERATE = -1;
+    const PRIORITY_NORMAL   =  0;
+    const PRIORITY_HIGH     =  1;
+    const PRIORITY_EMERGENCY = 2;
+
// }}}
// {{{ properties
@@ -95,12 +101,15 @@
$defaultNotifications = $this->_notifications;
}
+        $tellOptions = Mac_AppleScript::OPTION_APPEND_BREAK;
+        $endOptions = Mac_AppleScript::OPTION_PREPEND_BREAK | Mac_AppleScript::OPTION_EXECUTE;
+
$script = new Mac_AppleScript();
-        $script->tellApplication(self::GROWL_HELPER_APP, Mac_AppleScript::APPEND_BREAK)
+        $script->tellApplication(self::GROWL_HELPER_APP, $tellOptions)
->registerAsApplication($this->_applicationName)
->allNotifications($this->_notifications)
->defaultNotifications($defaultNotifications)
-            ->endTell(null, Mac_AppleScript::PREPEND_BREAK, true);
+            ->endTell(null, $endOptions);
$this->_lastScript = (string)$script;
}
@@ -122,8 +131,11 @@
return; // @todo throw an exception
}
+        $tellOptions = Mac_AppleScript::OPTION_APPEND_BREAK;
+        $endOptions = Mac_AppleScript::OPTION_PREPEND_BREAK | Mac_AppleScript::OPTION_EXECUTE;
+
$script = new Mac_AppleScript();
-        $script->tellApplication(self::GROWL_HELPER_APP, Mac_AppleScript::APPEND_BREAK)
+        $script->tellApplication(self::GROWL_HELPER_APP, $tellOptions)
->notifyWithName($notification)
->title($title)
->description($description)
@@ -144,14 +156,14 @@
if (array_key_exists('icon', $options)) {
$icon = $options['icon'];
-                if (is_file($icon) && is_readable($icon)) {
+                if (is_string($icon) && is_file($icon) && is_readable($icon)) {
$script->imageFromLocation('file://' . realpath($icon));
} else {
// @todo throw an exception
}
}
}
-        $script->endTell(null, Mac_AppleScript::PREPEND_BREAK, true);
+        $script->endTell(null, $endOptions);
$this->_lastScript = (string)$script;
}
属性に変更があったパス: Mac_Growl/trunk/Mac/Growl.php
___________________________________________________________________
追加: svn:keywords
+ Id

Mac_Growl/trunk/examples/sample1.php

@@ -1,7 +1,7 @@
<?php
require_once 'Mac/Growl.php';
-$growl = new Mac_Growl('Mac_Growl_Example', array('Messages', 'Errors'));
+$growl = new Mac_Growl('Mac_Growl_Example', array('Messages', 'Stickies'));
$growl->register();
$growl->notify('Messages',
'from ' . $growl->getApplicationName(),

Mac_Growl/trunk/examples/sample2.php

@@ -1,14 +1,14 @@
<?php
require_once 'Mac/Growl.php';
-$growl = new Mac_Growl('Mac_Growl_Example', array('Messages', 'Errors'));
+$growl = new Mac_Growl('Mac_Growl_Example', array('Messages', 'Stickies'));
//$growl->register();
-$growl->notify('Messages',
+$growl->notify('Stickies',
'from ' . $growl->getApplicationName(),
'sticky=true, priority=1 and specifying an icon',
array(
'sticky' => true,
-                   'priority' => 1,
+                   'priority' => Mac_Growl::PRIORITY_HIGH,
'icon' => dirname(__FILE__) . '/icon.png',
));