-
Notifications
You must be signed in to change notification settings - Fork 2
/
WorkingCopyDocument+ToolbarDelegate.m
116 lines (107 loc) · 3.53 KB
/
WorkingCopyDocument+ToolbarDelegate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// WorkingCopyController+Toolbar.m
// Diffly
//
// Created by Matt Mower on 29/01/2007.
// Copyright 2007 Matt Mower. See MIT-LICENSE for more information.
//
#import "WorkingCopyDocument+ToolbarDelegate.h"
@implementation WorkingCopyDocument (ToolbarDelegate)
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
if( [itemIdentifier isEqualToString:@"Refresh"] )
{
[item setLabel:@"Refresh"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"reload"]];
[item setTarget:self];
[item setAction:@selector(diff:)];
} else if( [itemIdentifier isEqualToString:@"Edit"] ) {
[item setLabel:@"Check In"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"Drawer"]];
[item setTarget:self];
[item setAction:@selector(toggleCommit:)];
} else if( [itemIdentifier isEqualToString:@"ShowFolders"] ) {
[item setLabel:@"Paths"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"Folder"]];
[item setTarget:self];
[item setAction:@selector(togglePaths:)];
} else if( [itemIdentifier isEqualToString:@"Filter"] ) {
[item setLabel:@"Filter"];
[item setPaletteLabel:[item label]];
[item setView:filterFieldView];
[item setMinSize:NSMakeSize( 32.0, 32.0 )];
[item setMaxSize:NSMakeSize( 196.0, 32.0 )];
} else if( [itemIdentifier isEqualToString:@"Select"] ) {
[item setLabel:@"Select"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"Add"]];
[item setTarget:self];
[item setAction:@selector(checkSelectedFiles:)];
} else if( [itemIdentifier isEqualToString:@"Deselect"] ) {
[item setLabel:@"Deselect"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"Remove"]];
[item setTarget:self];
[item setAction:@selector(uncheckSelectedFiles:)];
} else if( [itemIdentifier isEqualToString:@"Add"] ) {
[item setLabel:@"Add"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"add_file_32"]];
[item setTarget:self];
[item setAction:@selector(addFile:)];
} else if( [itemIdentifier isEqualToString:@"Remove"] ) {
[item setLabel:@"Remove"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"delete_file_32"]];
[item setTarget:self];
[item setAction:@selector(removeFile:)];
} else if( [itemIdentifier isEqualToString:@"Revert"] ) {
[item setLabel:@"Revert"];
[item setPaletteLabel:[item label]];
[item setImage:[NSImage imageNamed:@"rewind_32"]];
[item setTarget:self];
[item setAction:@selector(revertFile:)];
}
return [item autorelease];
}
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:NSToolbarSeparatorItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier,
@"Refresh",
@"Edit",
@"ShowFolders",
@"Filter",
@"Select",
@"Deselect",
@"Add",
@"Remove",
@"Revert",
nil];
}
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:@"Refresh",
@"Edit",
@"ShowFolders",
NSToolbarFlexibleSpaceItemIdentifier,
@"Revert",
@"Add",
@"Remove",
NSToolbarFlexibleSpaceItemIdentifier,
@"Select",
@"Deselect",
@"Toogle",
NSToolbarFlexibleSpaceItemIdentifier,
@"Filter",
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier,
nil];
}
@end