Changeset 3246 for lang/objective-c

Show
Ignore:
Timestamp:
12/18/07 02:31:48 (5 years ago)
Author:
mootoh
Message:

re-writing with RubyCocoa?.

Location:
lang/objective-c/SafariHatenaBookmark
Files:
2 added
1 removed
6 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-c/SafariHatenaBookmark/Menu.nib/classes.nib

    r3208 r3246  
    1414                </dict> 
    1515                <dict> 
    16                         <key>ACTIONS</key> 
    17                         <dict> 
    18                                 <key>bookmark</key> 
    19                                 <string>id</string> 
    20                                 <key>diary</key> 
    21                                 <string>id</string> 
    22                                 <key>haiku</key> 
    23                                 <string>id</string> 
    24                         </dict> 
    2516                        <key>CLASS</key> 
    2617                        <string>SHBController</string> 
     
    2920                        <key>OUTLETS</key> 
    3021                        <dict> 
    31                                 <key>topMenu</key> 
    32                                 <string>NSMenu</string> 
     22                                <key>top_menu</key> 
     23                                <string>id</string> 
    3324                        </dict> 
    3425                        <key>SUPERCLASS</key> 
  • lang/objective-c/SafariHatenaBookmark/PluginLoader.h

    r3208 r3246  
    1111@interface PluginLoader : NSObject { 
    1212} 
    13 + (PluginLoader *) sharedInstance; 
    1413 
    1514@end 
  • lang/objective-c/SafariHatenaBookmark/PluginLoader.m

    r3208 r3246  
    77 
    88#import "PluginLoader.h" 
    9 #import "SHBController.h" 
     9//#import "SHBController.h" 
     10#import <RubyCocoa/RubyCocoa.h> 
    1011 
    1112@implementation PluginLoader 
    12 /** 
    13  * A special method called by SIMBL once the application has started and all classes are initialized. 
    14  */ 
    15 + (void) load 
     13 
     14+ (void) install 
    1615{ 
    1716//        MySamplePlugin* plugin = [MySamplePlugin sharedInstance]; 
     
    1918 
    2019        NSLog(@"PluginLoader:load"); 
    21         [[SHBController alloc] init];} 
    22  
    23 /** 
    24  * @return the single static instance of the plugin object 
    25  */ 
    26 + (PluginLoader *) sharedInstance 
    27 { 
    28         static PluginLoader* plugin = nil; 
    29  
    30         if (plugin == nil) 
    31                 plugin = [[PluginLoader alloc] init]; 
    32  
    33         return plugin; 
     20        //[[SHBController alloc] init]; 
     21         
     22  static int installed = 0; 
     23  if (! installed) { 
     24    if (RBBundleInit("shb_init.rb", self, nil)) 
     25      NSLog(@"PluginLoader.install: failed"); 
     26    else 
     27      installed = 1; 
     28  } 
    3429} 
    3530@end 
  • lang/objective-c/SafariHatenaBookmark/SHBController.m

    r3211 r3246  
    4848- (void) progressStarted: (NSNotification*) n 
    4949{ 
    50     WebView* webView = [n object]; 
    51     WebDataSource* source = [[webView mainFrame] provisionalDataSource]; 
    52     if (! source) { 
    53         // source = [[webView mainFrame] provisionalDataSource]; 
    54     } 
    55     NSURL* cur_url = [[source request] URL]; 
     50  WebView* webView = [n object]; 
     51  WebDataSource* source = [[webView mainFrame] provisionalDataSource]; 
     52  if (! source) { 
     53    // source = [[webView mainFrame] provisionalDataSource]; 
     54  } 
     55  NSURL* cur_url = [[source request] URL]; 
    5656 
    57     NSLog(@"progressStarted: cur_url = %@", cur_url); 
     57  NSLog(@"progressStarted: cur_url = %@", cur_url); 
    5858 
    5959  // construct request 
     
    8080- (void) progressFinished: (NSNotification*) n 
    8181{ 
    82     WebView* webView = [n object]; 
    83     //NSURL* url = WebFrameRequestURL([webView mainFrame]); 
    84     WebDataSource* source = [[webView mainFrame] provisionalDataSource]; 
    85     if (! source) { 
    86         // source = [[webView mainFrame] provisionalDataSource]; 
    87     } 
    88     NSURL* url = [[source request] URL]; 
    89     NSLog(@"progressFinished: url = %@", url); 
     82  WebView* webView = [n object]; 
     83  //NSURL* url = WebFrameRequestURL([webView mainFrame]); 
     84  WebDataSource* source = [[webView mainFrame] provisionalDataSource]; 
     85  if (! source) { 
     86    // source = [[webView mainFrame] provisionalDataSource]; 
     87  } 
     88  NSURL* url = [[source request] URL]; 
     89  NSLog(@"progressFinished: url = %@", url); 
    9090} 
    9191 
     
    118118// callbacks 
    119119- (void) connection : (NSURLConnection *) connection 
    120          didReceiveResponse : (NSURLResponse *) response { 
     120didReceiveResponse : (NSURLResponse *) response { 
    121121  NSDictionary *dicHead = [(NSHTTPURLResponse *)response allHeaderFields]; 
    122122  NSLog(@"didReceiveResponse : %@", [dicHead objectForKey:@"Status"]); 
     
    125125 
    126126- (void) connection : (NSURLConnection *) connection 
    127          didReceiveData : (NSData *) data { 
     127didReceiveData : (NSData *) data { 
    128128  [receivedData appendData:data]; 
    129129} 
    130130 
    131  - (void) connection : (NSURLConnection *) connection  
    132         didFailWithError : (NSError *) error { 
    133         NSLog(@"didFailWithError 1"); 
    134         // [connection release]; 
    135         [receivedData release];  
    136         NSLog(@"didFailWithError 2"); 
     131- (void) connection : (NSURLConnection *) connection  
     132didFailWithError : (NSError *) error { 
     133  NSLog(@"didFailWithError 1"); 
     134  // [connection release]; 
     135  [receivedData release];        
     136  NSLog(@"didFailWithError 2"); 
    137137} 
    138138 
    139139- (void) connectionDidFinishLoading:(NSURLConnection *)connection { 
    140         NSLog(@"connectionDidFinishLoading: succeeded to load %d bytes", [receivedData length]); 
     140  NSLog(@"connectionDidFinishLoading: succeeded to load %d bytes", [receivedData length]); 
    141141  NSString *result = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding]; 
    142142  NSLog(@"connectionDidFinishLoading: result=%@", result); 
    143   id json = [result JSONValue]; 
    144   NSLog(@"connectionDidFinishLoading: id=%@", json); 
    145    
    146 //      [connection release]; 
    147         [receivedData release]; 
     143  //id json = [result JSONValue]; 
     144  //NSLog(@"connectionDidFinishLoading: id=%@", json); 
     145 
     146  //    [connection release]; 
     147  [receivedData release]; 
    148148} 
    149149 
    150  
    151150@end 
  • lang/objective-c/SafariHatenaBookmark/SafariHatenaBookmark.xcodeproj/project.pbxproj

    r3211 r3246  
    88 
    99/* Begin PBXBuildFile section */ 
     10                868C20510D16E39E00CA07C9 /* shb_init.rb in Resources */ = {isa = PBXBuildFile; fileRef = 868C20500D16E39E00CA07C9 /* shb_init.rb */; }; 
    1011                86A7D1C40D16634600D35D4C /* Info in Resources */ = {isa = PBXBuildFile; fileRef = 86A7D1C30D16634600D35D4C /* Info */; }; 
    1112                86A7D1C80D16635D00D35D4C /* Menu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 86A7D1C70D16635D00D35D4C /* Menu.nib */; }; 
    12                 86A7D1D10D16639600D35D4C /* SHBController.m in Sources */ = {isa = PBXBuildFile; fileRef = 86A7D1CE0D16639600D35D4C /* SHBController.m */; }; 
    1313                86A7D1D20D16639600D35D4C /* PluginLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 86A7D1D00D16639600D35D4C /* PluginLoader.m */; }; 
     14                86B04CD30D16DDD300EB7A83 /* RubyCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86B04CD20D16DDD300EB7A83 /* RubyCocoa.framework */; }; 
     15                86B04CE10D16DE6B00EB7A83 /* shb_controller.rb in Resources */ = {isa = PBXBuildFile; fileRef = 86B04CE00D16DE6B00EB7A83 /* shb_controller.rb */; }; 
    1416                86C597AA0D166CC10000340D /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86C597A90D166CC10000340D /* WebKit.framework */; }; 
    15                 86C597D00D1673140000340D /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86C597CF0D1673140000340D /* JSON.framework */; }; 
    1617                8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; 
    1718                8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; 
     
    2425                1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; 
    2526                32DBCF630370AF2F00C91783 /* SafariHatenaBookmark_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SafariHatenaBookmark_Prefix.pch; sourceTree = "<group>"; }; 
     27                868C20500D16E39E00CA07C9 /* shb_init.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = shb_init.rb; sourceTree = "<group>"; }; 
    2628                86A7D1C30D16634600D35D4C /* Info */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info; sourceTree = "<group>"; }; 
    2729                86A7D1C70D16635D00D35D4C /* Menu.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = Menu.nib; sourceTree = "<group>"; }; 
    28                 86A7D1CD0D16639600D35D4C /* SHBController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SHBController.h; sourceTree = "<group>"; }; 
    2930                86A7D1CE0D16639600D35D4C /* SHBController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SHBController.m; sourceTree = "<group>"; }; 
    3031                86A7D1CF0D16639600D35D4C /* PluginLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginLoader.h; sourceTree = "<group>"; }; 
    3132                86A7D1D00D16639600D35D4C /* PluginLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PluginLoader.m; sourceTree = "<group>"; }; 
     33                86B04CD20D16DDD300EB7A83 /* RubyCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RubyCocoa.framework; path = /System/Library/Frameworks/RubyCocoa.framework; sourceTree = "<absolute>"; }; 
     34                86B04CE00D16DE6B00EB7A83 /* shb_controller.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = shb_controller.rb; sourceTree = "<group>"; }; 
    3235                86C597A90D166CC10000340D /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = /System/Library/Frameworks/WebKit.framework; sourceTree = "<absolute>"; }; 
    33                 86C597CF0D1673140000340D /* JSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JSON.framework; sourceTree = "<group>"; }; 
    3436                8D5B49B6048680CD000E48DA /* SafariHatenaBookmark.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SafariHatenaBookmark.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 
    3537                8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 
     
    4446                                8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, 
    4547                                86C597AA0D166CC10000340D /* WebKit.framework in Frameworks */, 
    46                                 86C597D00D1673140000340D /* JSON.framework in Frameworks */, 
     48                                86B04CD30D16DDD300EB7A83 /* RubyCocoa.framework in Frameworks */, 
    4749                        ); 
    4850                        runOnlyForDeploymentPostprocessing = 0; 
     
    6668                        isa = PBXGroup; 
    6769                        children = ( 
     70                                86B04CD20D16DDD300EB7A83 /* RubyCocoa.framework */, 
    6871                                1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, 
    6972                                1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, 
     
    8689                        isa = PBXGroup; 
    8790                        children = ( 
    88                                 86A7D1CD0D16639600D35D4C /* SHBController.h */, 
    8991                                86A7D1CE0D16639600D35D4C /* SHBController.m */, 
    90                                 86C597CF0D1673140000340D /* JSON.framework */, 
    9192                                86C597A90D166CC10000340D /* WebKit.framework */, 
    9293                                86A7D1CF0D16639600D35D4C /* PluginLoader.h */, 
    9394                                86A7D1D00D16639600D35D4C /* PluginLoader.m */, 
     95                                86B04CE00D16DE6B00EB7A83 /* shb_controller.rb */, 
     96                                868C20500D16E39E00CA07C9 /* shb_init.rb */, 
    9497                        ); 
    9598                        name = Classes; 
     
    176179                                86A7D1C40D16634600D35D4C /* Info in Resources */, 
    177180                                86A7D1C80D16635D00D35D4C /* Menu.nib in Resources */, 
     181                                86B04CE10D16DE6B00EB7A83 /* shb_controller.rb in Resources */, 
     182                                868C20510D16E39E00CA07C9 /* shb_init.rb in Resources */, 
    178183                        ); 
    179184                        runOnlyForDeploymentPostprocessing = 0; 
     
    186191                        buildActionMask = 2147483647; 
    187192                        files = ( 
    188                                 86A7D1D10D16639600D35D4C /* SHBController.m in Sources */, 
    189193                                86A7D1D20D16639600D35D4C /* PluginLoader.m in Sources */, 
    190194                        );