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>
|
||||
|
||||
|
||||
@interface Controller : NSObject {
|
||||
@interface Controller : NSObject <NSWindowDelegate> {
|
||||
IBOutlet WebView *timelineView;
|
||||
IBOutlet NSWindow *timelineViewWindow;
|
||||
IBOutlet WebView *mentionsView;
|
||||
IBOutlet NSWindow *mentionsViewWindow;
|
||||
ViewDelegate *viewDelegate;
|
||||
}
|
||||
|
||||
@property (retain, nonatomic) IBOutlet WebView *timelineView;
|
||||
@property (retain, nonatomic) IBOutlet NSWindow *timelineViewWindow;
|
||||
@property (retain, nonatomic) IBOutlet WebView *mentionsView;
|
||||
@property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow;
|
||||
@property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate;
|
||||
|
||||
- (void)initWebViews;
|
||||
- (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId;
|
||||
- (NSString *)pluginURL;
|
||||
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
||||
- (void)unreadMentions:(NSInteger)count;
|
||||
- (void)mentionsWindowDidExpose:(id)sender;
|
||||
|
||||
|
||||
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
||||
|
||||
|
|
22
Controller.m
22
Controller.m
|
@ -12,7 +12,7 @@
|
|||
|
||||
@implementation Controller
|
||||
|
||||
@synthesize timelineView, mentionsView, viewDelegate;
|
||||
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, viewDelegate;
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[self initWebViews];
|
||||
|
@ -43,7 +43,7 @@
|
|||
selector:@selector(sendTweet:)
|
||||
name:@"sendTweet"
|
||||
object:nil];
|
||||
|
||||
|
||||
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
|
||||
[appleEventManager setEventHandler:self
|
||||
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
|
||||
|
@ -78,7 +78,6 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Notifications
|
||||
|
||||
- (IBAction)openNewTweetWindow:(id)sender {
|
||||
|
@ -93,7 +92,6 @@
|
|||
}
|
||||
|
||||
- (void)openNewTweetWindowWithString:(NSString *)aString {
|
||||
NSLog(@"testing");
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
|
||||
[newTweet withString:aString];
|
||||
|
@ -121,6 +119,22 @@
|
|||
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 */
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="559"/>
|
||||
<integer value="536"/>
|
||||
<integer value="81"/>
|
||||
<integer value="535"/>
|
||||
<integer value="559"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
|
@ -1299,6 +1299,30 @@
|
|||
</object>
|
||||
<int key="connectionID">564</int>
|
||||
</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 class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
|
@ -2261,9 +2285,9 @@
|
|||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<integer value="1"/>
|
||||
<string>{{42, 357}, {397, 581}}</string>
|
||||
<string>{{152, 238}, {397, 581}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{42, 357}, {397, 581}}</string>
|
||||
<string>{{152, 238}, {397, 581}}</string>
|
||||
<boolean value="YES"/>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.WebKitIBPlugin</string>
|
||||
|
@ -2318,7 +2342,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">564</int>
|
||||
<int key="maxID">569</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -2326,18 +2350,26 @@
|
|||
<object class="IBPartialClassDescription">
|
||||
<string key="className">Controller</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">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>mentionsView</string>
|
||||
<string>mentionsViewWindow</string>
|
||||
<string>timelineView</string>
|
||||
<string>timelineViewWindow</string>
|
||||
<string>viewDelegate</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>WebView</string>
|
||||
<string>NSWindow</string>
|
||||
<string>WebView</string>
|
||||
<string>NSWindow</string>
|
||||
<string>ViewDelegate</string>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
function Twittia(action, oauth_key, oauth_secret) {
|
||||
this.body = document.getElementById("body");
|
||||
this.max_length = 100;
|
||||
this.since_id;
|
||||
this.timeout = 2 * 60 * 1000;
|
||||
|
@ -7,6 +6,12 @@ function Twittia(action, oauth_key, oauth_secret) {
|
|||
this.oauth_key = oauth_key;
|
||||
this.oauth_secret = oauth_secret;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -29,6 +34,10 @@ Twittia.prototype.newStatus = function(status, supress_new_with_timeout) {
|
|||
var _this = this;
|
||||
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) {
|
||||
|
@ -62,7 +71,7 @@ Twittia.prototype.getItem = function(status) {
|
|||
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";
|
||||
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>
|
||||
<array>
|
||||
<string>twittia</string>
|
||||
<string>twitter</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
|
|
@ -9,6 +9,5 @@
|
|||
<script type="text/javascript" src="TwittiaCore.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<ol id="body" class="messages"></ol>
|
||||
</body>
|
||||
</html>
|
Reference in a new issue