Skip to content

Commit

Permalink
Added a progressbar to the dock icon
Browse files Browse the repository at this point in the history
  • Loading branch information
griff committed Dec 19, 2009
1 parent 2705015 commit 612959f
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 9 deletions.
89 changes: 82 additions & 7 deletions App/English.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1723"/>
<integer value="371"/>
<integer value="81"/>
<integer value="518"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -12809,16 +12809,16 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{59, 140}, {1082, 612}}</string>
<string>{{58, 142}, {1082, 612}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{59, 140}, {1082, 612}}</string>
<string>{{58, 142}, {1082, 612}}</string>
<integer value="1"/>
<string>{{33, 99}, {480, 360}}</string>
<boolean value="YES"/>
<string>{3.40282e+38, 3.40282e+38}</string>
<string>{403, 478}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{292, 752}, {616, 0}}</string>
<string>{{291, 754}, {616, 0}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -13149,7 +13149,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">1796</int>
<int key="maxID">1797</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -13273,8 +13273,17 @@
<string key="className">ChaptersTableView</string>
<string key="superclassName">UndoTableView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">paste:</string>
<string key="NS.object.0">id</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>copy:</string>
<string>paste:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -13342,6 +13351,18 @@
<string key="minorKey">App/src/FilesUndoController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">GTMLargeTypeWindow</string>
<string key="superclassName">NSPanel</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">copy:</string>
<string key="NS.object.0">id</string>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Externals/google-toolbox-for-mac/AppKit/GTMLargeTypeWindow.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">GenreDataSource</string>
<string key="superclassName">NSObject</string>
Expand Down Expand Up @@ -13430,6 +13451,41 @@
<string key="minorKey">App/src/MetaEditPanel.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Externals/google-toolbox-for-mac/AppKit/GTMCarbonEvent.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Externals/google-toolbox-for-mac/AppKit/GTMDelegatingTableColumn.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Externals/google-toolbox-for-mac/Foundation/GTMHTTPServer.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Externals/google-toolbox-for-mac/Foundation/GTMNSAppleEventDescriptor+Foundation.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Externals/google-toolbox-for-mac/Foundation/GTMNSObject+KeyValueObserving.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
Expand Down Expand Up @@ -13459,6 +13515,17 @@
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="773377197">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Externals/google-toolbox-for-mac/AppKit/GTMTheme.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSWindow</string>
<reference key="sourceIdentifier" ref="773377197"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">PictureEditor</string>
<string key="superclassName">NSObject</string>
Expand Down Expand Up @@ -14353,6 +14420,14 @@
<string key="minorKey">AppKit.framework/Headers/NSObjectController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSPanel</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSPanel.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSPopUpButton</string>
<string key="superclassName">NSButton</string>
Expand Down
4 changes: 2 additions & 2 deletions App/src/MZWriteQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ - (void)startNextItem
return;
}
}
[self stop];
[self saveQueueWithError:NULL];
[[NSNotificationCenter defaultCenter]
postNotificationName:MZQueueCompleted
object:self];
[self stop];
[self saveQueueWithError:NULL];
}

- (void)itemStopped
Expand Down
2 changes: 2 additions & 0 deletions App/src/QueueController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import <Cocoa/Cocoa.h>
#import <Growl/Growl.h>
#import "MZWriteQueue.h"
#import "UKDockProgressIndicator.h"

@interface QueueController : NSObject <NSUserInterfaceValidations,GrowlApplicationBridgeDelegate> {
NSArrayController* filesController;
Expand All @@ -23,6 +24,7 @@
NSInteger targetProgress;
NSInteger progress;
NSDate* startTime;
UKDockProgressIndicator* dockIndicator;
}
@property (nonatomic, retain) IBOutlet NSArrayController* filesController;
@property (nonatomic, retain) IBOutlet NSWindow* mainWindow;
Expand Down
8 changes: 8 additions & 0 deletions App/src/QueueController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ -(id)init
{
controller = nil;
writeQueue = [[MZWriteQueue sharedQueue] retain];
dockIndicator = [[UKDockProgressIndicator alloc] init];
[self registerAsObserver];
}
return self;
Expand All @@ -50,6 +51,7 @@ -(void)dealloc
[filesController release];
[startTime release];
[menuItem release];
[dockIndicator release];
[super dealloc];
}

Expand Down Expand Up @@ -82,6 +84,9 @@ - (void)awakeFromNib
name:MZQueueCompleted
object:nil];

[dockIndicator setMinValue:0];
[dockIndicator bind:@"maxValue" toObject:self withKeyPath:@"targetProgress" options:nil];
[dockIndicator bind:@"doubleValue" toObject:self withKeyPath:@"progress" options:nil];

// Hide progress bar
NSRect contentRect = [[mainWindow contentView] bounds];
Expand All @@ -100,6 +105,7 @@ - (void)awakeFromNib
[pendingLabel setFrameOrigin:pendingRect.origin];
[progressBar setHidden:YES];
[[mainWindow contentView] setAutoresizesSubviews:YES];
[dockIndicator setHidden:YES];
}
}

Expand Down Expand Up @@ -162,6 +168,7 @@ - (void)updateUI
[progressBar stopAnimation:self];
[mainWindow setFrame:windowFrame display:YES animate:NO];
[[mainWindow contentView] setAutoresizesSubviews:YES];
[dockIndicator setHidden:YES];
}
/*
MZLoggerDebug(@"Diff %@ %@ %f", NSStringFromRect(windowFrame), NSStringFromRect(mainRect),
Expand All @@ -188,6 +195,7 @@ - (void)updateUI
[progressBar startAnimation:self];
[mainWindow setFrame:windowFrame display:YES animate:NO];
[[mainWindow contentView] setAutoresizesSubviews:YES];
[dockIndicator setHidden:NO];
}
/*
MZLoggerDebug(@"Diff %@ %@ %f", NSStringFromRect(windowFrame), NSStringFromRect(mainRect),
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
UKDOCKPROGRESSINDICATOR
-----------------------

A class that shows a small determinate progress bar overlaid over your application's dock icon.

This is intended as a drop-in replacement for the NSProgressIndicator view, as it understands the same messages. You can even have the dock progress indicator forward all calls to the view, thus driving both without changing your existing code.


LICENSE:

(c) 2005 by M. Uli Kusterer. You may redistribute, modify, use in
commercial products free of charge, however distributing modified copies
requires that you clearly mark them as having been modified by you, while
maintaining the original markings and copyrights. I don't like getting bug
reports about code I wasn't involved in.

I'd also appreciate if you gave credit in your app's about screen or a similar
place. A simple "Thanks to M. Uli Kusterer" is quite sufficient.
Also, I rarely turn down any postcards, gifts, complementary copies of
applications etc.


REVISION HISTORY:
0.1 - Initial release.


CONTACT:
Get the newest version at http://www.zathras.de
E-Mail me at witness (at) zathras (dot) de or witness (dot) of (dot) teachtext (at) gmx (dot) net
52 changes: 52 additions & 0 deletions Externals/UKDockProgressIndicator/UKDockProgressIndicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// UKDockProgressIndicator.h
// Doublette
//
// Created by Uli Kusterer on 30.04.05.
// Copyright 2005 M. Uli Kusterer. All rights reserved.
//

// -----------------------------------------------------------------------------
// Headers:
// -----------------------------------------------------------------------------

#import <Cocoa/Cocoa.h>


/* A class that displays a determinate progress indicator (progress bar)
on top of the app's icon in the dock. Use it just like an NSProgressIndicator.
You can even have it call through to another progress indicator if desired. */

// -----------------------------------------------------------------------------
// Class Declarationâ:
// -----------------------------------------------------------------------------

@interface UKDockProgressIndicator : NSObject
{
IBOutlet NSProgressIndicator* progress; // A progress indicator view to call through to.
double max;
double min;
double current;
}

// NSProgressIndicator compatibility stuff:
// These forward to "progress" if you've hooked that up in IB.
-(void) setMinValue: (double)mn;
-(double) minValue;

-(void) setMaxValue: (double)mn;
-(double) maxValue;

-(void) setDoubleValue: (double)mn;
-(double) doubleValue;

-(void) setNeedsDisplay: (BOOL)mn;
-(void) display;

-(void) setHidden: (BOOL)flag;
-(BOOL) isHidden;

// private:
-(void) updateDockTile;

@end

0 comments on commit 612959f

Please sign in to comment.