Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
inket committed Jul 21, 2012
1 parent 7a3ae1a commit 95cf70e
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 20 deletions.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (C) 2012 inket

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

See http://www.gnu.org/licenses/gpl-3.0.txt for details.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Safari 5 tabs on Safari 6, cosy.

![Before](http://i.imgur.com/TBcMt.png)

![After](http://i.imgur.com/Wo89C.png)


#### Known Issues
- Safari opens with Safari 6 tabs style before switching to the old style--because SIMBL waits for it to finish launching before injecting the plug-in.


#### License
This program is licensed under GNU GPL v3.0 (see LICENSE)
6 changes: 6 additions & 0 deletions cosyTabs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
B26DE59415B7871900EDFD3F /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B26DE59315B7871900EDFD3F /* CoreFoundation.framework */; };
B26DE59A15B7871900EDFD3F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B26DE59815B7871900EDFD3F /* InfoPlist.strings */; };
B26DE5A315B78DC500EDFD3F /* cosyTabs.m in Sources */ = {isa = PBXBuildFile; fileRef = B26DE5A215B78DC500EDFD3F /* cosyTabs.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -17,6 +18,8 @@
B26DE59715B7871900EDFD3F /* cosyTabs-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "cosyTabs-Info.plist"; sourceTree = "<group>"; };
B26DE59915B7871900EDFD3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B26DE59B15B7871900EDFD3F /* cosyTabs-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "cosyTabs-Prefix.pch"; sourceTree = "<group>"; };
B26DE5A115B78DC500EDFD3F /* cosyTabs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cosyTabs.h; sourceTree = "<group>"; };
B26DE5A215B78DC500EDFD3F /* cosyTabs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = cosyTabs.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -60,6 +63,8 @@
isa = PBXGroup;
children = (
B26DE59615B7871900EDFD3F /* Supporting Files */,
B26DE5A115B78DC500EDFD3F /* cosyTabs.h */,
B26DE5A215B78DC500EDFD3F /* cosyTabs.m */,
);
path = cosyTabs;
sourceTree = "<group>";
Expand Down Expand Up @@ -136,6 +141,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B26DE5A315B78DC500EDFD3F /* cosyTabs.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
29 changes: 9 additions & 20 deletions cosyTabs/cosyTabs-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,14 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFPlugInDynamicRegisterFunction</key>
<string></string>
<key>CFPlugInDynamicRegistration</key>
<string>NO</string>
<key>CFPlugInFactories</key>
<dict>
<key>00000000-0000-0000-0000-000000000000</key>
<string>MyFactoryFunction</string>
</dict>
<key>CFPlugInTypes</key>
<dict>
<key>00000000-0000-0000-0000-000000000000</key>
<array>
<string>00000000-0000-0000-0000-000000000000</string>
</array>
</dict>
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 inket. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>cosyTabs</string>
<key>SIMBLTargetApplications</key>
<array>
<dict>
<key>BundleIdentifier</key>
<string>com.apple.Safari</string>
</dict>
</array>
</dict>
</plist>
13 changes: 13 additions & 0 deletions cosyTabs/cosyTabs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// cosyTabs.h
// cosyTabs
//
// Created by inket on 19/07/2012.
// Copyright (c) 2012 inket. Licensed under GNU GPL v3.0. See LICENSE for details.
//

#import <objc/runtime.h>

@interface cosyTabs : NSObject

@end
65 changes: 65 additions & 0 deletions cosyTabs/cosyTabs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// cosyTabs.m
// cosyTabs
//
// Created by inket on 19/07/2012.
// Copyright (c) 2012 inket. Licensed under GNU GPL v3.0. See LICENSE for details.
//

#import "cosyTabs.h"
#define MAX_TAB_WIDTH 250 // Maximum tab width in Safari 5 is 250px, amirite?

static cosyTabs* plugin = nil;

@implementation NSObject (cosyTabs)

- (double)new_availableWidthForButtonsWhenUnclipped {
unsigned long long numberOfTabs = (unsigned long long)[self performSelector:@selector(numberOfTabs)];

double defaultAvailableWidth = [self new_availableWidthForButtonsWhenUnclipped];
double customAvailableWidth = (double)(MAX_TAB_WIDTH*numberOfTabs);

if (defaultAvailableWidth <= customAvailableWidth)
return defaultAvailableWidth;

return customAvailableWidth;
}

- (void)new_tabViewDidChangeNumberOfTabViewItems:(id)arg1 {
[self new_tabViewDidChangeNumberOfTabViewItems:arg1];

[self performSelector:@selector(refreshButtons)];
}

@end


@implementation cosyTabs

#pragma mark SIMBL methods and loading

+ (cosyTabs*)sharedInstance {
if (plugin == nil)
plugin = [[cosyTabs alloc] init];

return plugin;
}

+ (void)load {
[[cosyTabs sharedInstance] loadPlugin];
NSLog(@"cosyTabs loaded.");
}

- (void)loadPlugin {
Class class = NSClassFromString(@"TabBarView");

Method new = class_getInstanceMethod(class, @selector(new_availableWidthForButtonsWhenUnclipped));
Method old = class_getInstanceMethod(class, @selector(_availableWidthForButtonsWhenUnclipped));
method_exchangeImplementations(new, old);

new = class_getInstanceMethod(class, @selector(new_tabViewDidChangeNumberOfTabViewItems:));
old = class_getInstanceMethod(class, @selector(tabViewDidChangeNumberOfTabViewItems:));
method_exchangeImplementations(new, old);
}

@end

0 comments on commit 95cf70e

Please sign in to comment.