-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOMLayoutItemFactory.m
556 lines (441 loc) · 21.1 KB
/
OMLayoutItemFactory.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
/*
Copyright (C) 2011 Quentin Mathe
Author: Quentin Mathe <[email protected]>
Date: November 2011
License: Modified BSD (see COPYING)
*/
#import <IconKit/IconKit.h>
#import "OMLayoutItemFactory.h"
#import "OMBrowserController.h"
#import "OMBrowserContentController.h"
@implementation OMLayoutItemFactory
- (NSDateFormatter *) dateFormatter
{
NSDateFormatter *formatter = AUTORELEASE([[NSDateFormatter alloc]
initWithDateFormat: @"%1m %B %Y %H:%M" allowNaturalLanguage: YES]);
[formatter setFormatterBehavior: NSDateFormatterBehavior10_0];
return formatter;
}
- (ETOutlineLayout *) listLayoutForBrowser
{
ETOutlineLayout *layout = [ETOutlineLayout layoutWithObjectGraphContext: [self objectGraphContext]];
// TODO: Retrieve the header names from -[ETPropertyDescription displayName]
NSArray *headerNames = A(@"", @"Name", @"Modification Date", @"Creation Date",
@"Size", @"Type", @"Tags");
[layout setDisplayedProperties: A(@"icon", @"name", @"modificationDate", @"creationDate",
@"sizeDescription", @"typeDescription", @"tagDescription")];
[layout setFormatter: [self dateFormatter] forProperty: @"modificationDate"];
[layout setFormatter: [self dateFormatter] forProperty: @"creationDate"];
[layout setEditable: YES forProperty: @"name"];
[layout setContentFont: [NSFont controlContentFontOfSize: 12]];
[[layout tableView] setUsesAlternatingRowBackgroundColors: YES];
// TODO: Support textAlignment property in ETColumnFragment or something similar...
[(NSCell *)[(NSTableColumn *)[layout columnForProperty: @"sizeDescription"] dataCell] setAlignment: NSRightTextAlignment];
[[layout columnForProperty: @"name"] setWidth: 180];
[[layout columnForProperty: @"modificationDate"] setWidth: 180];
[[layout columnForProperty: @"creationDate"] setWidth: 180];
[layout setSortable: YES];
// FIXME: Assertion at ETCollection+HOM.m:885
/*[[layout displayedProperties] zipWithCollection: headerNames andBlock:
^ void (NSString *property, NSString *headerName)
{
[layout setDisplayName: headerName forProperty: property];
}];
or
[[layout displayedProperties] enumerateObjectsUsingBlock:
^ void (id obj, NSUInteger i, BOOL stop*)
{
[layout setDisplayName: [headerNames objectAtIndex: i] forProperty: obj];
}*/
NSUInteger n = [[layout displayedProperties] count];
for (NSUInteger i = 0; i < n; i++)
{
[layout setDisplayName: [headerNames objectAtIndex: i]
forProperty: [[layout displayedProperties] objectAtIndex: i]];
}
return layout;
}
- (ETOutlineLayout *) iconLayoutForBrowser
{
return [ETIconLayout layoutWithObjectGraphContext: [self objectGraphContext]];
}
- (ETOutlineLayout *) columnLayoutForBrowser
{
return [ETBrowserLayout layoutWithObjectGraphContext: [self objectGraphContext]];
}
- (ETLayout *) noteLayoutForBrowser
{
return nil;
}
- (ETLayoutItem *) buttonWithIconNamed: (NSString *)aName target: (id)aTarget action: (SEL)anAction
{
NSImage *icon = [[IKIcon iconWithIdentifier: aName] image];
return [self buttonWithImage: icon target: aTarget action: anAction];
}
- (NSSize) defaultBrowserSize
{
return NSMakeSize(900, 500);
}
- (NSSize) defaultBrowserTopBarSize
{
NSSize size = [self defaultBrowserSize];
size.height= [self defaultIconAndLabelBarHeight];
return size;
}
- (NSSize) defaultBrowserBodySize
{
NSSize size = [self defaultBrowserSize];
size.height -= [self defaultBrowserTopBarSize].height;
return size;
}
- (CGFloat) defaultSourceListWidth
{
return 180;
}
- (NSSize) defaultSourceListSize
{
NSSize size = [self defaultBrowserSize];
size.width = [self defaultSourceListWidth];
return size;
}
- (CGFloat) defaultContentViewWidth
{
return [self defaultBrowserBodySize].width - [self defaultSourceListWidth];
}
- (CGFloat) defaultTagFilterEditorHeight
{
return 100;
}
- (CGFloat) defaultInspectorWidth
{
return 400;
}
- (ETLayoutItemGroup *) browserWithGroup: (id <ETCollection>)aGroup editingContext: (COEditingContext *)aContext;
{
OMBrowserController *controller = AUTORELEASE([[OMBrowserController alloc]
initWithObjectGraphContext: [self objectGraphContext]]);
[controller setPersistentObjectContext: aContext];
ETLayoutItemGroup *topBar = [self browserTopBarWithController: controller];
ETLayoutItemGroup *body = [self browserBodyWithGroup: (id <ETCollection>)aGroup controller: controller];
ETLayoutItemGroup *browser = [self itemGroupWithSize: [self defaultBrowserSize]];
[browser setAutoresizingMask: ETAutoresizingFlexibleWidth | ETAutoresizingFlexibleHeight];
[browser setController: controller];
[browser setRepresentedObject: aGroup]; /* For OMBrowserController template lookup needs */
[browser setShouldMutateRepresentedObject: NO];
[browser setLayout: [ETColumnLayout layoutWithObjectGraphContext: [self objectGraphContext]]];
[browser addItems: A(topBar, body)];
ETLog(@"\n%@\n", [browser descriptionWithOptions: [NSMutableDictionary dictionaryWithObjectsAndKeys:
A(@"frame", @"autoresizingMask"), kETDescriptionOptionValuesForKeyPaths,
@"items", kETDescriptionOptionTraversalKey, nil]]);
return browser;
}
- (ETLayoutItemGroup *) browserBodyWithGroup: (id <ETCollection>)aGroup controller: (id)aController
{
ETLayoutItemGroup *sourceList = [self sourceListWithGroup: aGroup controller: aController];
ETLayoutItemGroup *contentViewWrapper = [self contentViewWrapperWithGroup: [[aGroup contentArray] firstObject]
controller: aController];
ETLayoutItemGroup *body = [self itemGroupWithSize: [self defaultBrowserBodySize]];
NSLog(@"Groups in source list %@", [aGroup contentArray]);
[body setIdentifier: @"browserBody"];
[body setRepresentedObject: aGroup];
[body setAutoresizingMask: ETAutoresizingFlexibleWidth | ETAutoresizingFlexibleHeight];
[body setLayout: [ETLineLayout layoutWithObjectGraphContext: [self objectGraphContext]]];
[body addItems: A(sourceList, contentViewWrapper)];
return body;
}
- (ETLayoutItem *) viewPopUpWithController: (OMBrowserController *)aController
{
// TODO: The Column View doesn't seem like a good fit for an Object Manager
// unlike a File Manager
NSArray *choices = A(_(@"Icon"), _(@"List"), _(@"Column"));
NSArray *templateLayouts =
A([self iconLayoutForBrowser], [self listLayoutForBrowser], [self columnLayoutForBrowser]);
ETLayoutItem *popUpItem = [self popUpMenuWithItemTitles: choices
representedObjects: templateLayouts
target: aController
action: @selector(changePresentationViewFromPopUp:)];
[aController setViewPopUpItem: popUpItem];
[[popUpItem view] selectItemAtIndex: 1];
return popUpItem;
}
- (ETLayoutItemGroup *) browserTopBarWithController: (id)aController
{
ETLayoutItemGroup *itemGroup = [self itemGroupWithSize: [self defaultBrowserTopBarSize]];
ETLayoutItem *newGroupItem = [self buttonWithIconNamed: @"list-add"
target: aController
action: @selector(addNewTag:)];
ETLayoutItem *newObjectItem = [self buttonWithIconNamed: @"list-add"
target: aController
action: @selector(addNewObject:)];
ETLayoutItem *removeItem = [self buttonWithIconNamed: @"list-remove"
target: aController
action: @selector(delete:)];
ETLayoutItem *searchFieldItem = [self searchFieldWithTarget: aController
action: @selector(search:)];
ETLayoutItem *filterFieldItem = [self searchFieldWithTarget: aController
action: @selector(filter:)];
ETLayoutItemGroup *leftItemGroup = [self itemGroup];
ETLayoutItemGroup *rightItemGroup = [self itemGroup];
[searchFieldItem setWidth: 140];
[(NSSearchFieldCell *)[[searchFieldItem view] cell] setSendsSearchStringImmediately: YES];
[searchFieldItem setIdentifier: @"searchField"];
[filterFieldItem setWidth: 200];
[[[[filterFieldItem view] cell] cancelButtonCell] setAction: @selector(resetTagFiltering:)];
[[[[filterFieldItem view] cell] cancelButtonCell] setTarget: aController];
[filterFieldItem setIdentifier: @"tagFilterField"];
[itemGroup setIdentifier: @"browserTopBar"];
[itemGroup setAutoresizingMask: ETAutoresizingFlexibleWidth];
[itemGroup setLayout: [ETLineLayout layoutWithObjectGraphContext: [self objectGraphContext]]];
[[itemGroup layout] setSeparatorTemplateItem: [self flexibleSpaceSeparator]];
[leftItemGroup setLayout: [ETLineLayout layoutWithObjectGraphContext: [self objectGraphContext]]];
[[leftItemGroup layout] setIsContentSizeLayout: YES];
[leftItemGroup addItems:
A([self barElementFromItem: newGroupItem withLabel: _(@"New Tag…")],
[self barElementFromItem: newObjectItem withLabel: _(@"New Object")],
[self barElementFromItem: removeItem withLabel: _(@"Delete")])];
[rightItemGroup setLayout: [ETLineLayout layoutWithObjectGraphContext: [self objectGraphContext]]];
[[rightItemGroup layout] setIsContentSizeLayout: YES];
[rightItemGroup addItems:
A([self barElementFromItem: [self viewPopUpWithController: aController] withLabel: _(@"View")],
[self barElementFromItem: filterFieldItem withLabel: _(@"Tag Filter")],
[self barElementFromItem: searchFieldItem withLabel: _(@"Search")])];
[itemGroup addItems: A(leftItemGroup, rightItemGroup)];
return itemGroup;
}
- (ETLayoutItemGroup *) sourceListWithGroup: (id <ETCollection>)aGroup controller: (id)aController
{
ETLayoutItemGroup *itemGroup = [self itemGroupWithSize: [self defaultSourceListSize]];
ETSelectTool *tool = [ETSelectTool tool];
[tool setAllowsEmptySelection: NO];
[itemGroup setIdentifier: @"browserSourceList"];
[itemGroup setAutoresizingMask: ETAutoresizingFlexibleHeight];
[itemGroup setRepresentedObject: aGroup];
[itemGroup setLayout: [ETOutlineLayout layoutWithObjectGraphContext: [self objectGraphContext]]];
[[itemGroup layout] setContentFont: [NSFont controlContentFontOfSize: [NSFont smallSystemFontSize]]];
[[itemGroup layout] setDisplayedProperties: A(@"icon", @"displayName")];
[[[itemGroup layout] columnForProperty: @"displayName"] setWidth: [self defaultSourceListWidth]];
[[[itemGroup layout] columnForProperty: @"icon"] setWidth: 32]; // 20 if not two levels deep
[[itemGroup layout] setAttachedTool: tool];
[[[itemGroup layout] tableView] setHeaderView: nil];
//float indent = [[[itemGroup layout] outlineView] indentationPerLevel];
//[[[itemGroup layout] outlineView] setIndentationPerLevel: 0];
#ifndef GNUSTEP
[[[itemGroup layout] tableView] setSelectionHighlightStyle: NSTableViewSelectionHighlightStyleSourceList];
NSSize cellSpacing = [[[itemGroup layout] tableView] intercellSpacing];
cellSpacing.height += 3;
[[[itemGroup layout] tableView] setIntercellSpacing: cellSpacing];
#endif
[itemGroup setHasVerticalScroller: YES];
//[itemGroup setSource: itemGroup];
//[itemGroup reload];
for (id listObject in aGroup)
{
ETLayoutItemGroup *listItem = [self itemGroupWithRepresentedObject: listObject];
[listItem setSelectable: NO];
[listItem setSource: listItem];
// TODO: Could be better to change -lookUpTemplateProvider to look up
// controllers recursively upwards rather than just on the base item
// then we wouldn't have to set a controller on each list item (one on
// the source list would be ok).
[listItem setController: AUTORELEASE([[ETController alloc] initWithObjectGraphContext: [self objectGraphContext]])];
[[listItem controller] setTemplate: [ETItemTemplate templateWithItem: [self item] objectClass: Nil objectGraphContext: [self objectGraphContext]]
forType: [[listItem controller] currentGroupType]];
if ([[listObject name] isEqual: @"WHAT"])
{
[[listItem controller] setTemplate: [ETItemTemplate templateWithItem: [self itemGroup] objectClass: Nil objectGraphContext: [self objectGraphContext]]
forType: [ETUTI typeWithClass: [COTagGroup class]]];
}
[listItem reload];
[itemGroup addItem: listItem];
}
[aController setSourceListItem: itemGroup];
NSOutlineView *ov = (NSOutlineView *)[[itemGroup layout] tableView];
[ov reloadData];
[ov expandItem: [itemGroup firstItem]];
[ov expandItem: [itemGroup itemAtIndex: 1]];
return itemGroup;
}
- (ETLayoutItemGroup *) contentViewWrapperWithGroup: (id <ETCollection>)aGroup controller: (id)aController
{
ETLayoutItemGroup *contentView = [self contentViewWithGroup: [[aGroup contentArray] firstObject]
controller: aController];
// TODO: The width should be computed by the body layout
NSSize size = NSMakeSize([self defaultContentViewWidth], [self defaultBrowserBodySize].height);
ETLayoutItemGroup *itemGroup = [self itemGroupWithSize: size];
[itemGroup setIdentifier: @"contentViewWrapper"];
[itemGroup setAutoresizingMask: ETAutoresizingFlexibleWidth | ETAutoresizingFlexibleHeight];
[itemGroup setLayout: [ETColumnLayout layoutWithObjectGraphContext: [self objectGraphContext]]];
[itemGroup addItem: contentView];
return itemGroup;
}
- (ETLayoutItemGroup *) contentViewWithGroup: (id <ETCollection>)aGroup controller: (id)aController
{
// TODO: The width should be computed by the body layout
NSSize size = NSMakeSize([self defaultContentViewWidth], [self defaultBrowserBodySize].height);
ETLayoutItemGroup *itemGroup = [self itemGroupWithSize: size];
OMBrowserContentController *contentController = AUTORELEASE([[OMBrowserContentController alloc]
initWithObjectGraphContext: [self objectGraphContext]]);
ETSelectTool *tool = [ETSelectTool tool];
[tool setAllowsMultipleSelection: YES];
[itemGroup setIdentifier: @"contentView"];
[itemGroup setRepresentedObject: aGroup];
/* The controller templates are set up in -[MBEntityViewController init] */
//[itemGroup setController: AUTORELEASE([[MBEntityViewController alloc] init])];
[itemGroup setAutoresizingMask: ETAutoresizingFlexibleWidth | ETAutoresizingFlexibleHeight];
[itemGroup setHasVerticalScroller: YES];
[itemGroup setSource: itemGroup];
[itemGroup setLayout: [self listLayoutForBrowser]];
[[itemGroup layout] setAttachedTool: tool];
[itemGroup setController: contentController];
[[itemGroup controller] setPersistentObjectContext: [aController persistentObjectContext]];
[itemGroup reload];
[aController setContentViewItem: itemGroup];
return itemGroup;
}
- (ETTokenLayout *) tokenLayoutForTagFilterEditor
{
ETTokenLayout *layout = [ETTokenLayout layoutWithObjectGraphContext: [self objectGraphContext]];
[layout setEditedProperty: @"name"];
return layout;
}
- (ETLayoutItemGroup *) tagFilterEditorWithTagLibrary: (COTagLibrary *)aTagLibrary
size: (NSSize)aSize
controller: (id)aController
{
ETLayoutItemGroup *itemGroup = [self itemGroupWithSize: aSize];
ETController *tagController = AUTORELEASE([[ETController alloc]
initWithObjectGraphContext: [self objectGraphContext]]);
[tagController setPersistentObjectContext: [aController persistentObjectContext]];
ETItemTemplate *tagTemplate =
[ETItemTemplate templateWithItem: [self item]
entityName: @"COTag"
objectGraphContext: [self objectGraphContext]];
[tagController setTemplate: tagTemplate forType: [tagController currentObjectType]];
[itemGroup setIdentifier: @"tagFilterEditor"];
[itemGroup setController: tagController];
[itemGroup setRepresentedObject: aTagLibrary];
[itemGroup setShouldMutateRepresentedObject: YES];
[itemGroup setAutoresizingMask: ETAutoresizingFlexibleWidth | ETAutoresizingFlexibleHeight];
[itemGroup setSize: aSize];
[itemGroup setSource: itemGroup];
[itemGroup setLayout: [self tokenLayoutForTagFilterEditor]];
[itemGroup reload];
return itemGroup;
}
- (ETLayoutItemGroup *) inspectorWithObject: (id)anObject
size: (NSSize)aSize
controller: (id)aController
{
ETModelDescriptionRenderer *renderer = [ETModelDescriptionRenderer renderer];
// NOTE: Could add back later 'icon' and 'content'
[renderer setRenderedPropertyNames: A(@"name", @"typeDescription", @"sizeDescription",
@"modificationDate", @"creationDate", @"revisionDescription", @"tags")];
[(ETLayoutItem *)[[renderer templateItems] mappedCollection] setWidth: 200];
//[[[renderer entityLayout] positionalLayout] setIsContentSizeLayout: YES];
ETLayoutItemGroup *itemGroup = [renderer renderObject: anObject];
[itemGroup setIdentifier: @"inspector"];
// FIXME: Remove ETAutoresizingFlexibleLeftMargin
[itemGroup setAutoresizingMask: ETAutoresizingFlexibleHeight | ETAutoresizingFlexibleLeftMargin];
[itemGroup setSize: aSize];
return itemGroup;
}
@end
@implementation ETApplication (ObjectManager)
- (NSMenuItem *) objectMenuItem
{
NSMenuItem *menuItem = (id)[[self mainMenu] itemWithTag: ETObjectMenuTag];
if (menuItem != nil)
return menuItem;
menuItem = [NSMenuItem menuItemWithTitle: _(@"Object")
tag: ETObjectMenuTag
action: NULL];
NSMenu *menu = [menuItem submenu];
[menu addItemWithTitle: _(@"New Object From Template…")
action: @selector(addNewObjectFromTemplate:)
keyEquivalent: @"n"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSShiftKeyMask];
[menu addItemWithTitle: _(@"New Object")
action: @selector(addNewObject:)
keyEquivalent: @"n"];
[menu addItemWithTitle: _(@"New Tag")
action: @selector(addNewTag:)
keyEquivalent: @"n"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
[menu addItemWithTitle: _(@"New Smart Group")
action: @selector(addNewGroup:)
keyEquivalent: @"n"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSControlKeyMask];
[menu addItemWithTitle: _(@"Open")
action: @selector(open:)
keyEquivalent: @"o"];
[menu addItem: [NSMenuItem separatorItem]];
[menu addItemWithTitle: _(@"Close")
action: @selector(performClose:)
keyEquivalent: @"w"];
[menu addItem: [NSMenuItem separatorItem]];
[menu addItemWithTitle: _(@"Mark Current Version as…")
action: @selector(markVersion:)
keyEquivalent: @"s"];
[menu addItemWithTitle: _(@"Revert to…")
action: @selector(revertTo:)
keyEquivalent: @"r"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
[menu addItemWithTitle: _(@"Browse History")
action: @selector(browseHistory:)
keyEquivalent: @"h"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
[menu addItem: [NSMenuItem separatorItem]];
[menu addItemWithTitle: _(@"Import…")
action: @selector(import:)
keyEquivalent: @"i"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
[menu addItemWithTitle: _(@"Export…")
action: @selector(export:)
keyEquivalent: @"e"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
return menuItem;
}
- (NSMenuItem *) viewMenuItem
{
OMLayoutItemFactory *itemFactory = [OMLayoutItemFactory factory];
NSMenuItem *menuItem = (id)[[self mainMenu] itemWithTitle: _(@"View")];
if (menuItem != nil)
return menuItem;
menuItem = [NSMenuItem menuItemWithTitle: _(@"View")
tag: 0
action: NULL];
NSMenu *menu = [menuItem submenu];
[menu addItemWithTitle: _(@"Icon")
action: @selector(changePresentationViewFromMenuItem:)
keyEquivalent: @"1"];
[[menu lastItem] setRepresentedObject: [itemFactory iconLayoutForBrowser]];
[menu addItemWithTitle: _(@"List")
action: @selector(changePresentationViewFromMenuItem:)
keyEquivalent: @"2"];
[[menu lastItem] setRepresentedObject: [itemFactory listLayoutForBrowser]];
[menu addItemWithTitle: _(@"Note")
action: @selector(changePresentationViewFromMenuItem:)
keyEquivalent: @"3"];
[[menu lastItem] setRepresentedObject: [itemFactory noteLayoutForBrowser]];
[menu addItem: [NSMenuItem separatorItem]];
[menu addItemWithTitle: _(@"Show Inspector")
action: @selector(toggleInspector:)
keyEquivalent: @"i"];
// NOTE: On Mac OS 10.7, using NSAlternateKeyMask doesn't work (probably a reserved keyboard shortcut)
[menu addItemWithTitle: _(@"New Inspector")
action: @selector(showInspectorInStandaloneWindow:)
keyEquivalent: @"i"];
[[menu lastItem] setKeyEquivalentModifierMask: NSCommandKeyMask | NSControlKeyMask];
[menu addItem: [NSMenuItem separatorItem]];
[menu addItemWithTitle: _(@"Infos")
action: @selector(changeInspectorFromMenuItem:)
keyEquivalent: @"7"];
[menu addItemWithTitle: _(@"Tags")
action: @selector(changeInspectorFromMenuItem:)
keyEquivalent: @"8"];
[menu addItemWithTitle: _(@"History")
action: @selector(changeInspectorFromMenuItem:)
keyEquivalent: @"9"];
return menuItem;
}
@end