mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 22:51:39 +00:00
xibless-ified DirectoryPanel.
--HG-- branch : xibless
This commit is contained in:
@@ -16,27 +16,33 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
@interface DirectoryPanel : NSWindowController <NSOpenSavePanelDelegate>
|
||||
{
|
||||
IBOutlet NSPopUpButton *addButtonPopUp;
|
||||
IBOutlet NSPopUpButton *loadRecentButtonPopUp;
|
||||
IBOutlet HSOutlineView *outlineView;
|
||||
IBOutlet NSButton *removeButton;
|
||||
IBOutlet NSButton *loadResultsButton;
|
||||
|
||||
AppDelegateBase *_app;
|
||||
PyDupeGuru *model;
|
||||
HSRecentFiles *_recentDirectories;
|
||||
DirectoryOutline *outline;
|
||||
BOOL _alwaysShowPopUp;
|
||||
NSPopUpButton *addButtonPopUp;
|
||||
NSPopUpButton *loadRecentButtonPopUp;
|
||||
HSOutlineView *outlineView;
|
||||
NSButton *removeButton;
|
||||
NSButton *loadResultsButton;
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSPopUpButton *addButtonPopUp;
|
||||
@property (readwrite, retain) NSPopUpButton *loadRecentButtonPopUp;
|
||||
@property (readwrite, retain) HSOutlineView *outlineView;
|
||||
@property (readwrite, retain) NSButton *removeButton;
|
||||
@property (readwrite, retain) NSButton *loadResultsButton;
|
||||
|
||||
- (id)initWithParentApp:(AppDelegateBase *)aParentApp;
|
||||
|
||||
- (void)fillPopUpMenu; // Virtual
|
||||
- (void)adjustUIToLocalization;
|
||||
|
||||
- (IBAction)askForDirectory:(id)sender;
|
||||
- (IBAction)popupAddDirectoryMenu:(id)sender;
|
||||
- (IBAction)popupLoadRecentMenu:(id)sender;
|
||||
- (IBAction)removeSelectedDirectory:(id)sender;
|
||||
- (void)askForDirectory;
|
||||
- (void)popupAddDirectoryMenu:(id)sender;
|
||||
- (void)popupLoadRecentMenu:(id)sender;
|
||||
- (void)removeSelectedDirectory;
|
||||
|
||||
- (void)addDirectory:(NSString *)directory;
|
||||
- (void)refreshRemoveButtonText;
|
||||
|
||||
@@ -7,16 +7,24 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
*/
|
||||
|
||||
#import "DirectoryPanel.h"
|
||||
#import "DirectoryPanel_UI.h"
|
||||
#import "Dialogs.h"
|
||||
#import "Utils.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "Consts.h"
|
||||
|
||||
@implementation DirectoryPanel
|
||||
|
||||
@synthesize addButtonPopUp;
|
||||
@synthesize loadRecentButtonPopUp;
|
||||
@synthesize outlineView;
|
||||
@synthesize removeButton;
|
||||
@synthesize loadResultsButton;
|
||||
|
||||
- (id)initWithParentApp:(AppDelegateBase *)aParentApp
|
||||
{
|
||||
self = [super initWithWindowNibName:@"DirectoryPanel"];
|
||||
[self window];
|
||||
self = [super initWithWindow:nil];
|
||||
[self setWindow:createDirectoryPanel_UI(self)];
|
||||
_app = aParentApp;
|
||||
model = [_app model];
|
||||
[[self window] setTitle:[model appName]];
|
||||
@@ -47,7 +55,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
- (void)fillPopUpMenu
|
||||
{
|
||||
NSMenu *m = [addButtonPopUp menu];
|
||||
NSMenuItem *mi = [m addItemWithTitle:TR(@"Add New Folder...") action:@selector(askForDirectory:) keyEquivalent:@""];
|
||||
NSMenuItem *mi = [m addItemWithTitle:TR(@"Add New Folder...") action:@selector(askForDirectory) keyEquivalent:@""];
|
||||
[mi setTarget:self];
|
||||
[m addItem:[NSMenuItem separatorItem]];
|
||||
}
|
||||
@@ -75,7 +83,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
/* Actions */
|
||||
|
||||
- (IBAction)askForDirectory:(id)sender
|
||||
- (void)askForDirectory
|
||||
{
|
||||
NSOpenPanel *op = [NSOpenPanel openPanel];
|
||||
[op setCanChooseFiles:YES];
|
||||
@@ -90,10 +98,10 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)popupAddDirectoryMenu:(id)sender
|
||||
- (void)popupAddDirectoryMenu:(id)sender
|
||||
{
|
||||
if ((!_alwaysShowPopUp) && ([[_recentDirectories filepaths] count] == 0)) {
|
||||
[self askForDirectory:sender];
|
||||
[self askForDirectory];
|
||||
}
|
||||
else {
|
||||
[addButtonPopUp selectItem:nil];
|
||||
@@ -101,7 +109,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)popupLoadRecentMenu:(id)sender
|
||||
- (void)popupLoadRecentMenu:(id)sender
|
||||
{
|
||||
if ([[[_app recentResults] filepaths] count] > 0) {
|
||||
NSMenu *m = [loadRecentButtonPopUp menu];
|
||||
@@ -120,7 +128,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)removeSelectedDirectory:(id)sender
|
||||
- (void)removeSelectedDirectory
|
||||
{
|
||||
[[self window] makeKeyAndOrderFront:nil];
|
||||
[[outline model] removeSelectedDirectory];
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/* Class = "NSTableColumn"; headerCell.title = "State"; ObjectID = "13"; */
|
||||
"13.headerCell.title" = "State";
|
||||
|
||||
/* Class = "NSTableColumn"; headerCell.title = "Name"; ObjectID = "15"; */
|
||||
"15.headerCell.title" = "Name";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Scan"; ObjectID = "48"; */
|
||||
"48.title" = "Scan";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Normal"; ObjectID = "55"; */
|
||||
"55.title" = "Normal";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Reference"; ObjectID = "56"; */
|
||||
"56.title" = "Reference";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Excluded"; ObjectID = "57"; */
|
||||
"57.title" = "Excluded";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Select folders to scan and press \"Scan\"."; ObjectID = "71"; */
|
||||
"71.title" = "Select folders to scan and press \"Scan\".";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Load Results"; ObjectID = "73"; */
|
||||
"73.title" = "Load Results";
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,3 +52,13 @@
|
||||
"Problems!" = "Problems!";
|
||||
"There were problems processing some (or all) of the files. The cause of these problems are described in the table below. Those files were not removed from your results." = "There were problems processing some (or all) of the files. The cause of these problems are described in the table below. Those files were not removed from your results.";
|
||||
"Reveal Selected" = "Reveal Selected";
|
||||
|
||||
/* Directory Panel */
|
||||
"State" = "State";
|
||||
"Name" = "Name";
|
||||
"Scan" = "Scan";
|
||||
"Normal" = "Normal";
|
||||
"Reference" = "Reference";
|
||||
"Excluded" = "Excluded";
|
||||
"Select folders to scan and press \"Scan\"." = "Select folders to scan and press \"Scan\".";
|
||||
"Load Results" = "Load Results";
|
||||
|
||||
@@ -27,8 +27,6 @@ col.autoResizable = True
|
||||
col = table.addColumn('2', "Reference", 172)
|
||||
col.autoResizable = True
|
||||
|
||||
result.ignoreMargin = True
|
||||
table.packToCorner(Pack.UpperLeft)
|
||||
table.fill(Pack.Right)
|
||||
table.fill(Pack.Below)
|
||||
table.packToCorner(Pack.UpperLeft, margin=0)
|
||||
table.fill(Pack.LowerRight, margin=0)
|
||||
table.setAnchor(Pack.UpperLeft, growX=True, growY=True)
|
||||
|
||||
59
cocoa/base/ui/directory_panel.py
Normal file
59
cocoa/base/ui/directory_panel.py
Normal file
@@ -0,0 +1,59 @@
|
||||
ownerclass = 'DirectoryPanel'
|
||||
ownerimport = 'DirectoryPanel.h'
|
||||
|
||||
result = Window(425, 300, "dupeGuru")
|
||||
promptLabel = Label(result, "Select folders to scan and press \"Scan\".")
|
||||
directoryOutline = OutlineView(result)
|
||||
directoryOutline.OBJC_CLASS = 'HSOutlineView'
|
||||
addButton = Button(result, "")
|
||||
removeButton = Button(result, "")
|
||||
loadResultsButton = Button(result, "Load Results")
|
||||
scanButton = Button(result, "Scan")
|
||||
addPopup = Popup(None)
|
||||
loadRecentPopup = Popup(None)
|
||||
|
||||
owner.outlineView = directoryOutline
|
||||
owner.removeButton = removeButton
|
||||
owner.loadResultsButton = loadResultsButton
|
||||
owner.addButtonPopUp = addPopup
|
||||
owner.loadRecentButtonPopUp = loadRecentPopup
|
||||
|
||||
result.autosaveName = 'DirectoryPanel'
|
||||
result.canMinimize = False
|
||||
result.minSize = Size(370, 270)
|
||||
addButton.image = 'NSAddTemplate'
|
||||
removeButton.image = 'NSRemoveTemplate'
|
||||
for button in (addButton, removeButton):
|
||||
button.style = const.NSTexturedRoundedBezelStyle
|
||||
button.imagePosition = const.NSImageOnly
|
||||
scanButton.keyEquivalent = '\\r'
|
||||
addButton.action = Action(owner, 'popupAddDirectoryMenu:')
|
||||
removeButton.action = Action(owner, 'removeSelectedDirectory')
|
||||
loadResultsButton.action = Action(owner, 'popupLoadRecentMenu:')
|
||||
scanButton.action = Action(None, 'startScanning:')
|
||||
|
||||
directoryOutline.font = Font(FontFamily.System, FontSize.SmallSystem)
|
||||
col = directoryOutline.addColumn('name', "Name", 100)
|
||||
col.editable = False
|
||||
col.autoResizable = True
|
||||
col = directoryOutline.addColumn('state', "State", 85)
|
||||
col.editable = True
|
||||
col.autoResizable = False
|
||||
col.dataCell = Popup(None, ["Normal", "Reference", "Excluded"])
|
||||
col.dataCell.controlSize = const.NSSmallControlSize
|
||||
|
||||
for button in (addButton, removeButton):
|
||||
button.width = 28
|
||||
for button in (loadResultsButton, scanButton):
|
||||
button.width = 118
|
||||
|
||||
buttonLayout = HLayout(left=[addButton, removeButton], right=[loadResultsButton, scanButton])
|
||||
promptLabel.packToCorner(Pack.UpperLeft)
|
||||
promptLabel.fill(Pack.Right)
|
||||
directoryOutline.packRelativeTo(promptLabel, Pack.Below)
|
||||
buttonLayout.packRelativeTo(directoryOutline, Pack.Below, margin=8)
|
||||
directoryOutline.fill(Pack.LowerRight)
|
||||
|
||||
promptLabel.setAnchor(Pack.UpperLeft, growX=True)
|
||||
directoryOutline.setAnchor(Pack.UpperLeft, growX=True, growY=True)
|
||||
buttonLayout.setAnchor(Pack.Below)
|
||||
Reference in New Issue
Block a user