Changeset 149

Show
Ignore:
Timestamp:
02/25/06 17:40:36
Author:
youpy
Message:

Use Mac::Glue to add spotlight comment

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Publish/Spotlight.pm

    r145 r149  
    55use Encode; 
    66use File::Spec; 
    7 use Mac::AppleScript qw(RunAppleScript)
     7use Mac::Glue
    88 
    99sub register { 
     
    4040            $comment =~ s/<[^>]*>//g; 
    4141            $comment =~ s/\n//g; 
    42             $comment =~ s/"/\\"/g; 
    43             $comment = encode("shift_jis", $comment); # xxx 
    44  
    45             my $script = <<SCRIPT; 
    46 tell application "Finder" 
    47   set comment of ((POSIX file "$path") as file) to "$comment" 
    48 end tell 
    49 SCRIPT 
    50  
    51             RunAppleScript($script) or $context->error("$path: $!"); 
     42            $comment = encode("shift_jis", $comment); # xxx 
     43             
     44            my $finder = Mac::Glue->new("Finder"); 
     45            my $file = $finder->obj(file => $path); 
     46            $file->prop('comment')->set(to => $comment); 
    5247        } 
    5348    }