-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyWorkingCopyToolbar.m
173 lines (131 loc) · 4.91 KB
/
MyWorkingCopyToolbar.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//
// MyWorkingCopyToolbar.m
//
#import "MyWorkingCopyToolbar.h"
#import "NSString+MyAdditions.h"
#import "CommonUtils.h"
@implementation MyWorkingCopyToolbar
//----------------------------------------------------------------------------------------
// Private:
- (NSToolbarItem*) createItem: (NSString*) itsID
view: (NSView*) itsView,
GCoord minWidth, GCoord minHeight,
GCoord maxWidth, GCoord maxHeight
{
NSToolbarItem* item = [[NSToolbarItem alloc] initWithItemIdentifier: itsID];
[item setPaletteLabel: itsID];
[item setLabel: itsID];
[item setView: itsView];
[item setMinSize: NSMakeSize(minWidth, minHeight)];
[item setMaxSize: NSMakeSize(maxWidth, maxHeight)];
[items setObject: item forKey: itsID];
[item release];
return item;
}
//----------------------------------------------------------------------------------------
// Private:
- (NSToolbarItem*) createItem: (NSString*) itsID
label: (NSString*) itsLabel
image: (NSString*) imageName
help: (NSString*) itsHelp
{
NSToolbarItem* item = [[NSToolbarItem alloc] initWithItemIdentifier: itsID];
[item setPaletteLabel: itsLabel];
[item setLabel: itsLabel];
[item setToolTip: itsHelp ? itsHelp : itsLabel];
[item setTarget: controller];
[item setAction: NSSelectorFromString([itsID stringByAppendingString: @":"])];
[item setImage: [NSImage imageNamed: imageName]];
[items setObject: item forKey: itsID];
[item release];
return item;
}
//----------------------------------------------------------------------------------------
- (void) awakeFromNib
{
items = [[NSMutableDictionary alloc] init];
[self createItem: @"Filter" view: filterView, 74, 15, 74, 32];
[self createItem: @"Search" view: searchView, 60, 19, 130, 32];
[self createItem: @"View" view: modeView, 62, 20, 62, 20];
[self createItem: @"refresh" label: @"Refresh" image: @"Refresh"
help: @"Refresh the display.\n"
"Alt-click to also show repository updates."];
[self createItem: @"svnDiff" label: @"Diff" image: @"FileMerge"
help: @"Compare each selected file with its BASE revision.\n"
"Shift-click to compare with PREV revision.\n"
"Alt-click to compare other revisions."];
[self createItem: @"revealInFinder" label: @"Reveal" image: @"Finder"
help: @"Show the selected file in the Finder."];
[self createItem: @"svnUpdate" label: @"Update" image: @"checkout2"
help: @"Update this working copy to HEAD.\n"
"Alt-click to specify a different revision."];
[self createItem: @"openRepository" label: @"Repository" image: @"Repository"
help: @"Open repository window for this working copy."];
[self createItem: @"togglePropsView" label: @"Properties" image: @"Properties"
help: @"Show/Hide Subversion properties editor."];
[self createItem: @"toggleSidebar" label: @"Output" image: @"sidebar"
help: @"Show/Hide output of updates, commits, merges, etc."];
NSToolbar* toolbar = [[NSToolbar alloc] initWithIdentifier: @"WorkingCopyToolBar3"];
[toolbar setDelegate: self];
[toolbar setAllowsUserCustomization: YES];
[toolbar setAutosavesConfiguration: YES];
[toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
[toolbar setSizeMode: NSToolbarSizeModeDefault];
[window setToolbar: toolbar];
[toolbar release];
}
//----------------------------------------------------------------------------------------
- (void) dealloc
{
[items release];
[super dealloc];
}
//----------------------------------------------------------------------------------------
- (NSToolbarItem*) toolbar: (NSToolbar*) toolbar
itemForItemIdentifier: (NSString*) itemIdentifier
willBeInsertedIntoToolbar: (BOOL) flag
{
#pragma unused(toolbar, flag)
return [items objectForKey: itemIdentifier];
}
//----------------------------------------------------------------------------------------
- (NSArray*) toolbarDefaultItemIdentifiers: (NSToolbar*) toolbar
{
#pragma unused(toolbar)
return [NSArray arrayWithObjects:
@"View",
@"Filter",
@"Search",
@"revealInFinder",
@"svnDiff",
NSToolbarSeparatorItemIdentifier,
@"svnUpdate",
@"openRepository",
@"refresh",
NSToolbarFlexibleSpaceItemIdentifier,
@"togglePropsView",
@"toggleSidebar",
nil];
}
//----------------------------------------------------------------------------------------
- (NSArray*) toolbarAllowedItemIdentifiers: (NSToolbar*) toolbar
{
#pragma unused(toolbar)
return [NSArray arrayWithObjects:
@"View",
@"Filter",
@"Search",
@"revealInFinder",
@"svnDiff",
@"svnUpdate",
@"openRepository",
@"refresh",
@"togglePropsView",
@"toggleSidebar",
NSToolbarSeparatorItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
nil];
}
//----------------------------------------------------------------------------------------
@end // MyWorkingCopyToolbar