summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorritsuka <[email protected]>2014-12-03 19:53:42 +0000
committerritsuka <[email protected]>2014-12-03 19:53:42 +0000
commit7e2bbec65b9cfc5e288376002e739b7151dae8f6 (patch)
treed3cbc0a0fe5bdf34fe5a5a08b4bf5d5da4b48cc4
parentd22ffc275a7ce636d8e47555838945ffad45cdbc (diff)
MacGui: moved the main window toolbar to the xib.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6578 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--macosx/Controller.h1
-rw-r--r--macosx/Controller.m186
-rw-r--r--macosx/English.lproj/MainMenu.xib80
3 files changed, 100 insertions, 167 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h
index c67e4044e..e4ab18336 100644
--- a/macosx/Controller.h
+++ b/macosx/Controller.h
@@ -277,7 +277,6 @@ extern NSString *keyTitleTag;
- (NSDictionary *) registrationDictionaryForGrowl;
-(void)showGrowlDoneNotification:(NSString *) filePath;
- (IBAction)showDebugOutputPanel:(id)sender;
-- (void)setupToolbar;
- (void) prepareJobForPreview;
- (void) remindUserOfSleepOrShutdown;
diff --git a/macosx/Controller.m b/macosx/Controller.m
index 4ee3b1b83..23c60c863 100644
--- a/macosx/Controller.m
+++ b/macosx/Controller.m
@@ -33,17 +33,6 @@ NSString *dragDropFiles = @"dragDropFiles";
// DockTile update freqency in total percent increment
#define dockTileUpdateFrequency 0.1f
-/* We setup the toolbar values here ShowPreviewIdentifier */
-static NSString * ToggleDrawerIdentifier = @"Toggle Drawer Item Identifier";
-static NSString * StartEncodingIdentifier = @"Start Encoding Item Identifier";
-static NSString * PauseEncodingIdentifier = @"Pause Encoding Item Identifier";
-static NSString * ShowQueueIdentifier = @"Show Queue Item Identifier";
-static NSString * AddToQueueIdentifier = @"Add to Queue Item Identifier";
-static NSString * ShowPictureIdentifier = @"Show Picture Window Item Identifier";
-static NSString * ShowPreviewIdentifier = @"Show Preview Window Item Identifier";
-static NSString * ShowActivityIdentifier = @"Debug Output Item Identifier";
-static NSString * ChooseSourceIdentifier = @"Choose Source Item Identifier";
-
@interface HBController () <HBPresetsViewControllerDelegate>
// The current selected preset.
@@ -578,8 +567,6 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
/* Bottom */
[fStatusField setStringValue: @""];
-
- [self setupToolbar];
/* Register HBController's Window as a receiver for files/folders drag & drop operations */
[fWindow registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
@@ -975,144 +962,17 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
#pragma mark -
#pragma mark Toolbar
-// ============================================================
-// NSToolbar Related Methods
-// ============================================================
-
-- (void) setupToolbar {
- NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: @"HandBrake Toolbar"] autorelease];
-
- [toolbar setAllowsUserCustomization: YES];
- [toolbar setAutosavesConfiguration: YES];
- [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
-
- [toolbar setDelegate: self];
-
- [fWindow setToolbar: toolbar];
-}
-
-- (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier:
- (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
- NSToolbarItem * item = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
-
- if ([itemIdent isEqualToString: ToggleDrawerIdentifier])
- {
- [item setLabel: @"Toggle Presets"];
- [item setPaletteLabel: @"Toggler Presets"];
- [item setToolTip: @"Open/Close Preset Drawer"];
- [item setImage: [NSImage imageNamed: @"presets"]];
- [item setTarget: self];
- [item setAction: @selector(toggleDrawer:)];
- [item setAutovalidates: NO];
- }
- else if ([itemIdent isEqualToString: StartEncodingIdentifier])
- {
- [item setLabel: @"Start"];
- [item setPaletteLabel: @"Start Encoding"];
- [item setToolTip: @"Start Encoding"];
- [item setImage: [NSImage imageNamed: @"encode"]];
- [item setTarget: self];
- [item setAction: @selector(Rip:)];
- }
- else if ([itemIdent isEqualToString: ShowQueueIdentifier])
- {
- [item setLabel: @"Show Queue"];
- [item setPaletteLabel: @"Show Queue"];
- [item setToolTip: @"Show Queue"];
- [item setImage: [NSImage imageNamed: @"showqueue"]];
- [item setTarget: self];
- [item setAction: @selector(showQueueWindow:)];
- [item setAutovalidates: NO];
- }
- else if ([itemIdent isEqualToString: AddToQueueIdentifier])
- {
- [item setLabel: @"Add to Queue"];
- [item setPaletteLabel: @"Add to Queue"];
- [item setToolTip: @"Add to Queue"];
- [item setImage: [NSImage imageNamed: @"addqueue"]];
- [item setTarget: self];
- [item setAction: @selector(addToQueue:)];
- }
- else if ([itemIdent isEqualToString: PauseEncodingIdentifier])
- {
- [item setLabel: @"Pause"];
- [item setPaletteLabel: @"Pause Encoding"];
- [item setToolTip: @"Pause Encoding"];
- [item setImage: [NSImage imageNamed: @"pauseencode"]];
- [item setTarget: self];
- [item setAction: @selector(Pause:)];
- }
- else if ([itemIdent isEqualToString: ShowPictureIdentifier])
- {
- [item setLabel: @"Picture Settings"];
- [item setPaletteLabel: @"Show Picture Settings"];
- [item setToolTip: @"Show Picture Settings"];
- [item setImage: [NSImage imageNamed: @"picturesettings"]];
- [item setTarget: self];
- [item setAction: @selector(showPicturePanel:)];
- }
- else if ([itemIdent isEqualToString: ShowPreviewIdentifier])
- {
- [item setLabel: @"Preview Window"];
- [item setPaletteLabel: @"Show Preview"];
- [item setToolTip: @"Show Preview"];
- //[item setImage: [NSImage imageNamed: @"pref-picture"]];
- [item setImage: [NSImage imageNamed: @"preview"]];
- [item setTarget: self];
- [item setAction: @selector(showPreviewWindow:)];
- }
- else if ([itemIdent isEqualToString: ShowActivityIdentifier])
- {
- [item setLabel: @"Activity Window"];
- [item setPaletteLabel: @"Show Activity Window"];
- [item setToolTip: @"Show Activity Window"];
- [item setImage: [NSImage imageNamed: @"activity"]];
- [item setTarget: self];
- [item setAction: @selector(showDebugOutputPanel:)];
- [item setAutovalidates: NO];
- }
- else if ([itemIdent isEqualToString: ChooseSourceIdentifier])
- {
- [item setLabel: @"Source"];
- [item setPaletteLabel: @"Source"];
- [item setToolTip: @"Choose Video Source"];
- [item setImage: [NSImage imageNamed: @"source"]];
- [item setTarget: self];
- [item setAction: @selector(browseSources:)];
- }
- else
- {
- return nil;
- }
-
- return item;
-}
-
-- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
-{
- return [NSArray arrayWithObjects: ChooseSourceIdentifier, NSToolbarSeparatorItemIdentifier, StartEncodingIdentifier,
- PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
- NSToolbarSpaceItemIdentifier, ShowPictureIdentifier, ShowPreviewIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier, nil];
-}
-
-- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
-{
- return [NSArray arrayWithObjects: StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier,
- ChooseSourceIdentifier, ShowQueueIdentifier, ShowPictureIdentifier, ShowPreviewIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier,
- NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
- NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil];
-}
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
{
- NSString * ident = [toolbarItem itemIdentifier];
+ SEL action = toolbarItem.action;
if (self.core)
{
if (self.core.state == HBStateScanning)
{
- if ([ident isEqualToString: ChooseSourceIdentifier])
+ if (action == @selector(browseSources:))
{
[toolbarItem setImage: [NSImage imageNamed: @"stopencode"]];
[toolbarItem setLabel: @"Cancel Scan"];
@@ -1121,12 +981,12 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
return YES;
}
- if ([ident isEqualToString: StartEncodingIdentifier] || [ident isEqualToString: AddToQueueIdentifier])
+ if (action == @selector(Rip:) || action == @selector(addToQueue:))
return NO;
}
else
{
- if ([ident isEqualToString: ChooseSourceIdentifier])
+ if (action == @selector(browseSources:))
{
[toolbarItem setImage: [NSImage imageNamed: @"source"]];
[toolbarItem setLabel: @"Source"];
@@ -1140,7 +1000,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
if (queueState == HBStateWorking || queueState == HBStateSearching || queueState == HBStateMuxing)
{
- if ([ident isEqualToString: StartEncodingIdentifier])
+ if (action == @selector(Rip:))
{
[toolbarItem setImage: [NSImage imageNamed: @"stopencode"]];
[toolbarItem setLabel: @"Stop"];
@@ -1148,7 +1008,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
[toolbarItem setToolTip: @"Stop Encoding"];
return YES;
}
- if ([ident isEqualToString: PauseEncodingIdentifier])
+ if (action == @selector(Pause:))
{
[toolbarItem setImage: [NSImage imageNamed: @"pauseencode"]];
[toolbarItem setLabel: @"Pause"];
@@ -1158,17 +1018,17 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
}
if (SuccessfulScan)
{
- if ([ident isEqualToString: AddToQueueIdentifier])
+ if (action == @selector(addToQueue:))
return YES;
- if ([ident isEqualToString: ShowPictureIdentifier])
+ if (action == @selector(showPicturePanel:))
return YES;
- if ([ident isEqualToString: ShowPreviewIdentifier])
+ if (action == @selector(showPreviewWindow:))
return YES;
}
}
else if (queueState == HBStatePaused)
{
- if ([ident isEqualToString: PauseEncodingIdentifier])
+ if (action == @selector(Pause:))
{
[toolbarItem setImage: [NSImage imageNamed: @"encode"]];
[toolbarItem setLabel: @"Resume"];
@@ -1176,13 +1036,13 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
[toolbarItem setToolTip: @"Resume Encoding"];
return YES;
}
- if ([ident isEqualToString: StartEncodingIdentifier])
+ if (action == @selector(Rip:))
return YES;
- if ([ident isEqualToString: AddToQueueIdentifier])
+ if (action == @selector(addToQueue:))
return YES;
- if ([ident isEqualToString: ShowPictureIdentifier])
+ if (action == @selector(showPicturePanel:))
return YES;
- if ([ident isEqualToString: ShowPreviewIdentifier])
+ if (action == @selector(showPreviewWindow:))
return YES;
}
else if (queueState == HBStateScanning)
@@ -1191,7 +1051,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
}
else if (queueState == HBStateWorkDone || queueState == HBStateScanDone || SuccessfulScan)
{
- if ([ident isEqualToString: StartEncodingIdentifier])
+ if (action == @selector(Rip:))
{
[toolbarItem setImage: [NSImage imageNamed: @"encode"]];
if (hb_count(self.core.hb_handle) > 0)
@@ -1202,25 +1062,25 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
[toolbarItem setToolTip: @"Start Encoding"];
return YES;
}
- if ([ident isEqualToString: AddToQueueIdentifier])
+ if (action == @selector(addToQueue:))
return YES;
- if ([ident isEqualToString: ShowPictureIdentifier])
+ if (action == @selector(showPicturePanel:))
return YES;
- if ([ident isEqualToString: ShowPreviewIdentifier])
+ if (action == @selector(showPreviewWindow:))
return YES;
}
}
/* If there are any pending queue items, make sure the start/stop button is active */
- if ([ident isEqualToString: StartEncodingIdentifier] && fPendingCount > 0)
+ if (action == @selector(Rip:) && fPendingCount > 0)
return YES;
- if ([ident isEqualToString: ShowQueueIdentifier])
+ if (action == @selector(showQueueWindow:))
return YES;
- if ([ident isEqualToString: ToggleDrawerIdentifier])
+ if (action == @selector(toggleDrawer:))
return YES;
- if ([ident isEqualToString: ChooseSourceIdentifier])
+ if (action == @selector(browseSources:))
return YES;
- if ([ident isEqualToString: ShowActivityIdentifier])
+ if (action == @selector(showDebugOutputPanel:))
return YES;
return NO;
diff --git a/macosx/English.lproj/MainMenu.xib b/macosx/English.lproj/MainMenu.xib
index 10275f694..5d73eab3e 100644
--- a/macosx/English.lproj/MainMenu.xib
+++ b/macosx/English.lproj/MainMenu.xib
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14C68k" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14C68k" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1060" identifier="macosx"/>
<development version="5100" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -417,10 +417,73 @@
</popUpButton>
</subviews>
</view>
+ <toolbar key="toolbar" implicitIdentifier="E92CA47A-01F7-432A-A61C-28FE4D58C2CD" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="regular" id="7g3-gy-bUl">
+ <allowedToolbarItems>
+ <toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="ZEH-cS-zXY"/>
+ <toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="wjB-Tl-5qq"/>
+ <toolbarItem implicitItemIdentifier="B3BAB305-77BF-4967-B8E6-D11F40EF822B" label="Source" paletteLabel="Source" tag="-1" image="source" id="8r8-nZ-dYs">
+ <connections>
+ <action selector="browseSources:" target="240" id="LD2-b1-vqJ"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="4CAB4280-DF01-4BDC-B23B-98BD6E6190F4" label="Start" paletteLabel="Start" tag="-1" image="encode" id="byg-kj-sEM">
+ <connections>
+ <action selector="Rip:" target="240" id="0B6-IB-70f"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="E4C5E251-DD8D-4288-AC80-AF8E654B7A32" label="Pause" paletteLabel="Pause" tag="-1" image="pauseencode" id="wTQ-KF-5KW">
+ <connections>
+ <action selector="Pause:" target="240" id="mIG-m6-Stn"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="69E83092-D0D1-48A5-BF46-99EFB3EC630A" label="Add To Queue" paletteLabel="Add To Queue" tag="-1" image="addqueue" id="DZZ-Fe-wjw">
+ <connections>
+ <action selector="addToQueue:" target="240" id="3oq-nG-Sdo"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="6EFCA879-A80D-45D7-A846-EAD85261F864" label="Show Queue" paletteLabel="Show Queue" tag="-1" image="showqueue" id="HCx-ku-nF7">
+ <connections>
+ <action selector="showQueueWindow:" target="240" id="Rur-8T-VEx"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="CBA63584-4A4E-43E5-8096-9C20B59AC580" label="Picture Settings" paletteLabel="Picture Settings" tag="-1" image="picturesettings" id="2uP-T2-02Q">
+ <connections>
+ <action selector="showPicturePanel:" target="240" id="tlM-Jx-yzk"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="DAAC2346-2B39-4A35-A62B-C12826F6AB42" label="Preview Window" paletteLabel="Preview Window" tag="-1" image="preview" id="dK4-jt-v4K">
+ <connections>
+ <action selector="showPreviewWindow:" target="240" id="C49-TV-CDw"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="D9753B5B-F09B-451E-9FD8-E8DD979FBFA2" label="Activity Window" paletteLabel="Activity Window" tag="-1" image="activity" id="p7Q-L3-zcW">
+ <connections>
+ <action selector="showDebugOutputPanel:" target="240" id="TTZ-YA-vgx"/>
+ </connections>
+ </toolbarItem>
+ <toolbarItem implicitItemIdentifier="B774D9D7-AE89-4C1A-8685-D631473867F6" label="Toggle Presets" paletteLabel="Toggle Presets" tag="-1" image="presets" id="9ll-Jg-YAB">
+ <connections>
+ <action selector="toggleDrawer:" target="240" id="gY0-Xe-pxb"/>
+ </connections>
+ </toolbarItem>
+ </allowedToolbarItems>
+ <defaultToolbarItems>
+ <toolbarItem reference="8r8-nZ-dYs"/>
+ <toolbarItem reference="byg-kj-sEM"/>
+ <toolbarItem reference="wTQ-KF-5KW"/>
+ <toolbarItem reference="DZZ-Fe-wjw"/>
+ <toolbarItem reference="HCx-ku-nF7"/>
+ <toolbarItem reference="wjB-Tl-5qq"/>
+ <toolbarItem reference="2uP-T2-02Q"/>
+ <toolbarItem reference="dK4-jt-v4K"/>
+ <toolbarItem reference="p7Q-L3-zcW"/>
+ <toolbarItem reference="9ll-Jg-YAB"/>
+ </defaultToolbarItems>
+ </toolbar>
<connections>
<outlet property="delegate" destination="240" id="433"/>
</connections>
- <point key="canvasLocation" x="507" y="501"/>
+ <point key="canvasLocation" x="488" y="424"/>
</window>
<menu title="MainMenu" systemMenu="main" id="29" userLabel="MainMenu">
<items>
@@ -937,4 +1000,15 @@ DQ
<customObject id="4963" customClass="SUUpdater"/>
<userDefaultsController representsSharedInstance="YES" id="5676"/>
</objects>
+ <resources>
+ <image name="activity" width="24" height="24"/>
+ <image name="addqueue" width="12" height="12"/>
+ <image name="encode" width="24" height="24"/>
+ <image name="pauseencode" width="24" height="24"/>
+ <image name="picturesettings" width="24" height="24"/>
+ <image name="presets" width="24" height="24"/>
+ <image name="preview" width="24" height="24"/>
+ <image name="showqueue" width="24" height="24"/>
+ <image name="source" width="24" height="24"/>
+ </resources>
</document>