added how many unread mentions there are to the timeline window title
This commit is contained in:
parent
ce5ee9f2ee
commit
9ba76d7bc7
6 changed files with 75 additions and 13 deletions
|
@ -12,20 +12,27 @@
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
|
|
||||||
|
|
||||||
@interface Controller : NSObject {
|
@interface Controller : NSObject <NSWindowDelegate> {
|
||||||
IBOutlet WebView *timelineView;
|
IBOutlet WebView *timelineView;
|
||||||
|
IBOutlet NSWindow *timelineViewWindow;
|
||||||
IBOutlet WebView *mentionsView;
|
IBOutlet WebView *mentionsView;
|
||||||
|
IBOutlet NSWindow *mentionsViewWindow;
|
||||||
ViewDelegate *viewDelegate;
|
ViewDelegate *viewDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (retain, nonatomic) IBOutlet WebView *timelineView;
|
@property (retain, nonatomic) IBOutlet WebView *timelineView;
|
||||||
|
@property (retain, nonatomic) IBOutlet NSWindow *timelineViewWindow;
|
||||||
@property (retain, nonatomic) IBOutlet WebView *mentionsView;
|
@property (retain, nonatomic) IBOutlet WebView *mentionsView;
|
||||||
|
@property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow;
|
||||||
@property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate;
|
@property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate;
|
||||||
|
|
||||||
- (void)initWebViews;
|
- (void)initWebViews;
|
||||||
- (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId;
|
- (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId;
|
||||||
- (NSString *)pluginURL;
|
- (NSString *)pluginURL;
|
||||||
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
||||||
|
- (void)unreadMentions:(NSInteger)count;
|
||||||
|
- (void)mentionsWindowDidExpose:(id)sender;
|
||||||
|
|
||||||
|
|
||||||
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
||||||
|
|
||||||
|
|
20
Controller.m
20
Controller.m
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
@implementation Controller
|
@implementation Controller
|
||||||
|
|
||||||
@synthesize timelineView, mentionsView, viewDelegate;
|
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, viewDelegate;
|
||||||
|
|
||||||
- (void)awakeFromNib {
|
- (void)awakeFromNib {
|
||||||
[self initWebViews];
|
[self initWebViews];
|
||||||
|
@ -78,7 +78,6 @@
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark Notifications
|
#pragma mark Notifications
|
||||||
|
|
||||||
- (IBAction)openNewTweetWindow:(id)sender {
|
- (IBAction)openNewTweetWindow:(id)sender {
|
||||||
|
@ -93,7 +92,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)openNewTweetWindowWithString:(NSString *)aString {
|
- (void)openNewTweetWindowWithString:(NSString *)aString {
|
||||||
NSLog(@"testing");
|
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
|
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
|
||||||
[newTweet withString:aString];
|
[newTweet withString:aString];
|
||||||
|
@ -121,6 +119,22 @@
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)unreadMentions:(NSInteger)count {
|
||||||
|
if (![mentionsViewWindow isVisible] && count > 0) {
|
||||||
|
[timelineViewWindow setTitle:[NSString stringWithFormat:@"Twittia (@%i)", count]];
|
||||||
|
} else {
|
||||||
|
[timelineViewWindow setTitle:[NSString stringWithFormat:@"Twittia"]];
|
||||||
|
[mentionsView stringByEvaluatingJavaScriptFromString:@"twittia_instance.unread_mentions = 0;"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mentions window has been visible
|
||||||
|
- (void)windowDidUpdate:(NSNotification *)notification {
|
||||||
|
if ([notification object] == mentionsViewWindow) {
|
||||||
|
[self unreadMentions:0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* CARBON */
|
/* CARBON */
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<integer value="559"/>
|
|
||||||
<integer value="536"/>
|
|
||||||
<integer value="81"/>
|
<integer value="81"/>
|
||||||
|
<integer value="535"/>
|
||||||
|
<integer value="559"/>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
@ -1299,6 +1299,30 @@
|
||||||
</object>
|
</object>
|
||||||
<int key="connectionID">564</int>
|
<int key="connectionID">564</int>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="IBConnectionRecord">
|
||||||
|
<object class="IBOutletConnection" key="connection">
|
||||||
|
<string key="label">timelineViewWindow</string>
|
||||||
|
<reference key="source" ref="408500656"/>
|
||||||
|
<reference key="destination" ref="1010634651"/>
|
||||||
|
</object>
|
||||||
|
<int key="connectionID">565</int>
|
||||||
|
</object>
|
||||||
|
<object class="IBConnectionRecord">
|
||||||
|
<object class="IBOutletConnection" key="connection">
|
||||||
|
<string key="label">mentionsViewWindow</string>
|
||||||
|
<reference key="source" ref="408500656"/>
|
||||||
|
<reference key="destination" ref="134415325"/>
|
||||||
|
</object>
|
||||||
|
<int key="connectionID">566</int>
|
||||||
|
</object>
|
||||||
|
<object class="IBConnectionRecord">
|
||||||
|
<object class="IBOutletConnection" key="connection">
|
||||||
|
<string key="label">delegate</string>
|
||||||
|
<reference key="source" ref="134415325"/>
|
||||||
|
<reference key="destination" ref="408500656"/>
|
||||||
|
</object>
|
||||||
|
<int key="connectionID">569</int>
|
||||||
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||||
<object class="NSArray" key="orderedObjects">
|
<object class="NSArray" key="orderedObjects">
|
||||||
|
@ -2261,9 +2285,9 @@
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<integer value="1"/>
|
<integer value="1"/>
|
||||||
<string>{{42, 357}, {397, 581}}</string>
|
<string>{{152, 238}, {397, 581}}</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>{{42, 357}, {397, 581}}</string>
|
<string>{{152, 238}, {397, 581}}</string>
|
||||||
<boolean value="YES"/>
|
<boolean value="YES"/>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.WebKitIBPlugin</string>
|
<string>com.apple.WebKitIBPlugin</string>
|
||||||
|
@ -2318,7 +2342,7 @@
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<nil key="sourceID"/>
|
<nil key="sourceID"/>
|
||||||
<int key="maxID">564</int>
|
<int key="maxID">569</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||||
|
@ -2326,18 +2350,26 @@
|
||||||
<object class="IBPartialClassDescription">
|
<object class="IBPartialClassDescription">
|
||||||
<string key="className">Controller</string>
|
<string key="className">Controller</string>
|
||||||
<string key="superclassName">NSObject</string>
|
<string key="superclassName">NSObject</string>
|
||||||
|
<object class="NSMutableDictionary" key="actions">
|
||||||
|
<string key="NS.key.0">mentionsWindowDidExpose:</string>
|
||||||
|
<string key="NS.object.0">id</string>
|
||||||
|
</object>
|
||||||
<object class="NSMutableDictionary" key="outlets">
|
<object class="NSMutableDictionary" key="outlets">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<object class="NSArray" key="dict.sortedKeys">
|
<object class="NSArray" key="dict.sortedKeys">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<string>mentionsView</string>
|
<string>mentionsView</string>
|
||||||
|
<string>mentionsViewWindow</string>
|
||||||
<string>timelineView</string>
|
<string>timelineView</string>
|
||||||
|
<string>timelineViewWindow</string>
|
||||||
<string>viewDelegate</string>
|
<string>viewDelegate</string>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableArray" key="dict.values">
|
<object class="NSMutableArray" key="dict.values">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<string>WebView</string>
|
<string>WebView</string>
|
||||||
|
<string>NSWindow</string>
|
||||||
<string>WebView</string>
|
<string>WebView</string>
|
||||||
|
<string>NSWindow</string>
|
||||||
<string>ViewDelegate</string>
|
<string>ViewDelegate</string>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
function Twittia(action, oauth_key, oauth_secret) {
|
function Twittia(action, oauth_key, oauth_secret) {
|
||||||
this.body = document.getElementById("body");
|
|
||||||
this.max_length = 100;
|
this.max_length = 100;
|
||||||
this.since_id;
|
this.since_id;
|
||||||
this.timeout = 2 * 60 * 1000;
|
this.timeout = 2 * 60 * 1000;
|
||||||
|
@ -7,6 +6,12 @@ function Twittia(action, oauth_key, oauth_secret) {
|
||||||
this.oauth_key = oauth_key;
|
this.oauth_key = oauth_key;
|
||||||
this.oauth_secret = oauth_secret;
|
this.oauth_secret = oauth_secret;
|
||||||
this.getNewData();
|
this.getNewData();
|
||||||
|
this.unread_mentions = 0;
|
||||||
|
|
||||||
|
this.body = document.createElement("ol");
|
||||||
|
this.body.className = this.action;
|
||||||
|
document.getElementsByTagName("body")[0].appendChild(this.body);
|
||||||
|
|
||||||
setTimeout(function() { loadPlugin(controller.pluginURL()) }, 1);
|
setTimeout(function() { loadPlugin(controller.pluginURL()) }, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +34,10 @@ Twittia.prototype.newStatus = function(status, supress_new_with_timeout) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
setTimeout(function() { _this.getNewData() }, this.timeout);
|
setTimeout(function() { _this.getNewData() }, this.timeout);
|
||||||
}
|
}
|
||||||
|
if(this.action == "mentions") {
|
||||||
|
this.unread_mentions += status.length;
|
||||||
|
controller.unreadMentions_(this.unread_mentions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Twittia.prototype.getItem = function(status) {
|
Twittia.prototype.getItem = function(status) {
|
||||||
|
@ -62,7 +71,7 @@ Twittia.prototype.getItem = function(status) {
|
||||||
template.in_reply.parentNode.parentNode.insertBefore(retweeted, template.in_reply.parent);
|
template.in_reply.parentNode.parentNode.insertBefore(retweeted, template.in_reply.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status.in_reply_to_screen_name != null) template.in_reply.innerText = status.in_reply_to_screen_name;
|
if(status.in_reply_to_status_id != null) template.in_reply.innerText = status.in_reply_to_screen_name;
|
||||||
else template.in_reply.parentNode.className = "hidden";
|
else template.in_reply.parentNode.className = "hidden";
|
||||||
template.in_reply.href = "http://twitter.com/" + status.in_reply_to_screen_name + "/status/" + status.in_reply_to_status_id;
|
template.in_reply.href = "http://twitter.com/" + status.in_reply_to_screen_name + "/status/" + status.in_reply_to_status_id;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
<key>CFBundleURLSchemes</key>
|
<key>CFBundleURLSchemes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>twittia</string>
|
<string>twittia</string>
|
||||||
|
<string>twitter</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
|
|
|
@ -9,6 +9,5 @@
|
||||||
<script type="text/javascript" src="TwittiaCore.js"></script>
|
<script type="text/javascript" src="TwittiaCore.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<ol id="body" class="messages"></ol>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in a new issue