-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |