From 9de5a48b1ff8455ce3e8a666d5c50e50c07133d3 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 4 Apr 2017 20:59:25 -0400 Subject: [PATCH] Un-xibless-ified DeletionOptions --- build.py | 1 - cocoa/Base.lproj/DeletionOptions.xib | 143 +++++++++++++++++++++++++++ cocoa/DeletionOptions.h | 16 +-- cocoa/DeletionOptions.m | 13 ++- cocoa/ui/deletion_options.py | 49 --------- dupeGuru.xcodeproj/project.pbxproj | 48 +++++++-- 6 files changed, 199 insertions(+), 71 deletions(-) create mode 100644 cocoa/Base.lproj/DeletionOptions.xib delete mode 100644 cocoa/ui/deletion_options.py diff --git a/build.py b/build.py index 872ef74..f07dc91 100644 --- a/build.py +++ b/build.py @@ -80,7 +80,6 @@ def build_xibless(dest='cocoa/autogen'): import xibless ensure_folder(dest) FNPAIRS = [ - ('deletion_options.py', 'DeletionOptions_UI'), ('problem_dialog.py', 'ProblemDialog_UI'), ('directory_panel.py', 'DirectoryPanel_UI'), ('prioritize_dialog.py', 'PrioritizeDialog_UI'), diff --git a/cocoa/Base.lproj/DeletionOptions.xib b/cocoa/Base.lproj/DeletionOptions.xib new file mode 100644 index 0000000..c41303c --- /dev/null +++ b/cocoa/Base.lproj/DeletionOptions.xib @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Instead of sending files to trash, delete them directly. This option is usually used as a workaround when the normal deletion method doesn't work. + + + + + + + + + + + + diff --git a/cocoa/DeletionOptions.h b/cocoa/DeletionOptions.h index 05f2a28..599f0b2 100644 --- a/cocoa/DeletionOptions.h +++ b/cocoa/DeletionOptions.h @@ -1,5 +1,5 @@ /* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) +Copyright 2017 Virgil Dupras This software is licensed under the "GPLv3" License as described in the "LICENSE" file, which should be included with this package. The terms are also available at @@ -14,10 +14,10 @@ http://www.gnu.org/licenses/gpl-3.0.html PyDeletionOptions *model; - NSTextField *messageTextField; - NSButton *linkButton; - NSMatrix *linkTypeRadio; - NSButton *directButton; + IBOutlet NSTextField *messageTextField; + IBOutlet NSButton *linkButton; + IBOutlet NSMatrix *linkTypeRadio; + IBOutlet NSButton *directButton; } @property (readwrite, retain) NSTextField *messageTextField; @@ -27,7 +27,7 @@ http://www.gnu.org/licenses/gpl-3.0.html - (id)initWithPyRef:(PyObject *)aPyRef; -- (void)updateOptions; -- (void)proceed; -- (void)cancel; +- (IBAction)updateOptions:(id)sender; +- (IBAction)proceed:(id)sender; +- (IBAction)cancel:(id)sender; @end \ No newline at end of file diff --git a/cocoa/DeletionOptions.m b/cocoa/DeletionOptions.m index 2e12f67..f384d24 100644 --- a/cocoa/DeletionOptions.m +++ b/cocoa/DeletionOptions.m @@ -1,5 +1,5 @@ /* -Copyright 2015 Hardcoded Software (http://www.hardcoded.net) +Copyright 2017 Virgil Dupras This software is licensed under the "GPLv3" License as described in the "LICENSE" file, which should be included with this package. The terms are also available at @@ -7,7 +7,6 @@ http://www.gnu.org/licenses/gpl-3.0.html */ #import "DeletionOptions.h" -#import "DeletionOptions_UI.h" #import "HSPyUtil.h" @implementation DeletionOptions @@ -19,9 +18,9 @@ http://www.gnu.org/licenses/gpl-3.0.html - (id)initWithPyRef:(PyObject *)aPyRef { - self = [super initWithWindow:nil]; + self = [super initWithWindowNibName:@"DeletionOptions"]; + [self window]; model = [[PyDeletionOptions alloc] initWithModel:aPyRef]; - [self setWindow:createDeletionOptions_UI(self)]; [model bindCallback:createCallback(@"DeletionOptionsView", self)]; return self; } @@ -32,19 +31,19 @@ http://www.gnu.org/licenses/gpl-3.0.html [super dealloc]; } -- (void)updateOptions +- (IBAction)updateOptions:(id)sender { [model setLinkDeleted:[linkButton state] == NSOnState]; [model setUseHardlinks:[linkTypeRadio selectedColumn] == 1]; [model setDirect:[directButton state] == NSOnState]; } -- (void)proceed +- (IBAction)proceed:(id)sender { [NSApp stopModalWithCode:NSOKButton]; } -- (void)cancel +- (IBAction)cancel:(id)sender { [NSApp stopModalWithCode:NSCancelButton]; } diff --git a/cocoa/ui/deletion_options.py b/cocoa/ui/deletion_options.py deleted file mode 100644 index 5e6aebd..0000000 --- a/cocoa/ui/deletion_options.py +++ /dev/null @@ -1,49 +0,0 @@ -ownerclass = 'DeletionOptions' -ownerimport = 'DeletionOptions.h' - -result = Window(450, 240, "Deletion Options") -messageLabel = Label(result, "") -linkCheckbox = Checkbox(result, "Link deleted files") -linkLabel = Label(result, "After having deleted a duplicate, place a link targeting the " - "reference file to replace the deleted file.") -linkTypeChoice = RadioButtons(result, ["Symlink", "Hardlink"], columns=2) -directCheckbox = Checkbox(result, "Directly delete files") -directLabel = Label(result, "Instead of sending files to trash, delete them directly. This option " - "is usually used as a workaround when the normal deletion method doesn't work.") -proceedButton = Button(result, "Proceed") -cancelButton = Button(result, "Cancel") - -owner.linkButton = linkCheckbox -owner.linkTypeRadio = linkTypeChoice -owner.directButton = directCheckbox -owner.messageTextField = messageLabel - -result.canMinimize = False -result.canResize = False -linkLabel.controlSize = ControlSize.Small -directLabel.controlSize = ControlSize.Small -linkTypeChoice.controlSize = ControlSize.Small -proceedButton.keyEquivalent = '\\r' -cancelButton.keyEquivalent = '\\e' -linkCheckbox.action = directCheckbox.action = linkTypeChoice.action = Action(owner, 'updateOptions') -proceedButton.action = Action(owner, 'proceed') -cancelButton.action = Action(owner, 'cancel') - -linkLabel.height *= 2 # 2 lines -directLabel.height *= 3 # 3 lines -proceedButton.width = 92 -cancelButton.width = 92 - -mainLayout = VLayout([messageLabel, linkCheckbox, linkLabel, linkTypeChoice, directCheckbox, - directLabel]) -mainLayout.packToCorner(Pack.UpperLeft) -mainLayout.fill(Pack.Right) -buttonLayout = HLayout([cancelButton, proceedButton]) -buttonLayout.packToCorner(Pack.LowerRight) - -# indent the labels under checkboxes a little bit to the right -for indentedView in (linkLabel, directLabel, linkTypeChoice): - indentedView.x += 20 - indentedView.width -= 20 -# We actually don't want the link choice radio buttons to take all the width, it looks weird. -linkTypeChoice.width = 170 diff --git a/dupeGuru.xcodeproj/project.pbxproj b/dupeGuru.xcodeproj/project.pbxproj index 2291a3f..2e7e2df 100644 --- a/dupeGuru.xcodeproj/project.pbxproj +++ b/dupeGuru.xcodeproj/project.pbxproj @@ -53,7 +53,6 @@ CE9720F31E74E40300A598C9 /* ResultTable.m in Sources */ = {isa = PBXBuildFile; fileRef = CE9720E31E74E40300A598C9 /* ResultTable.m */; }; CE9720F41E74E40300A598C9 /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE9720E51E74E40300A598C9 /* ResultWindow.m */; }; CE9720F51E74E40300A598C9 /* StatsLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE9720E71E74E40300A598C9 /* StatsLabel.m */; }; - CE97213D1E74E41D00A598C9 /* DeletionOptions_UI.m in Sources */ = {isa = PBXBuildFile; fileRef = CE9720F81E74E41C00A598C9 /* DeletionOptions_UI.m */; }; CE97213E1E74E41D00A598C9 /* DetailsPanel_UI.m in Sources */ = {isa = PBXBuildFile; fileRef = CE9720FA1E74E41C00A598C9 /* DetailsPanel_UI.m */; }; CE97213F1E74E41D00A598C9 /* DetailsPanelPicture_UI.m in Sources */ = {isa = PBXBuildFile; fileRef = CE9720FC1E74E41C00A598C9 /* DetailsPanelPicture_UI.m */; }; CE9721401E74E41D00A598C9 /* DirectoryPanel_UI.m in Sources */ = {isa = PBXBuildFile; fileRef = CE9720FE1E74E41C00A598C9 /* DirectoryPanel_UI.m */; }; @@ -84,6 +83,7 @@ CE97215F1E74E41D00A598C9 /* XiblessSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = CE97213C1E74E41D00A598C9 /* XiblessSupport.m */; }; CE9EF6DF1E9345100089CA20 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE9EF6DD1E9345100089CA20 /* MainMenu.xib */; }; CED88C1F1E763F2700C9B98C /* py in Resources */ = {isa = PBXBuildFile; fileRef = CED88C1E1E763F2700C9B98C /* py */; }; + CEF093DE1E9474F700CD0BF3 /* DeletionOptions.xib in Resources */ = {isa = PBXBuildFile; fileRef = CEF093DC1E9474F700CD0BF3 /* DeletionOptions.xib */; }; CEFC8A251E74F23000965F37 /* dg_cocoa.py in Resources */ = {isa = PBXBuildFile; fileRef = CEFC8A231E74F23000965F37 /* dg_cocoa.py */; }; CEFC8A261E74F23000965F37 /* dupeguru.icns in Resources */ = {isa = PBXBuildFile; fileRef = CEFC8A241E74F23000965F37 /* dupeguru.icns */; }; CEFC8A281E74F28100965F37 /* help in Resources */ = {isa = PBXBuildFile; fileRef = CEFC8A271E74F28100965F37 /* help */; }; @@ -295,8 +295,6 @@ CE9720E51E74E40300A598C9 /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ResultWindow.m; path = cocoa/ResultWindow.m; sourceTree = ""; }; CE9720E61E74E40300A598C9 /* StatsLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StatsLabel.h; path = cocoa/StatsLabel.h; sourceTree = ""; }; CE9720E71E74E40300A598C9 /* StatsLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StatsLabel.m; path = cocoa/StatsLabel.m; sourceTree = ""; }; - CE9720F71E74E41C00A598C9 /* DeletionOptions_UI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeletionOptions_UI.h; path = cocoa/autogen/DeletionOptions_UI.h; sourceTree = ""; }; - CE9720F81E74E41C00A598C9 /* DeletionOptions_UI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DeletionOptions_UI.m; path = cocoa/autogen/DeletionOptions_UI.m; sourceTree = ""; }; CE9720F91E74E41C00A598C9 /* DetailsPanel_UI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetailsPanel_UI.h; path = cocoa/autogen/DetailsPanel_UI.h; sourceTree = ""; }; CE9720FA1E74E41C00A598C9 /* DetailsPanel_UI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DetailsPanel_UI.m; path = cocoa/autogen/DetailsPanel_UI.m; sourceTree = ""; }; CE9720FB1E74E41C00A598C9 /* DetailsPanelPicture_UI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetailsPanelPicture_UI.h; path = cocoa/autogen/DetailsPanelPicture_UI.h; sourceTree = ""; }; @@ -371,6 +369,22 @@ CE9EF6FB1E93455C0089CA20 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "cocoa/zh-Hans.lproj/MainMenu.strings"; sourceTree = ""; }; CE9EF6FD1E93455D0089CA20 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = cocoa/vi.lproj/MainMenu.strings; sourceTree = ""; }; CED88C1E1E763F2700C9B98C /* py */ = {isa = PBXFileReference; lastKnownFileType = folder; name = py; path = build/py; sourceTree = ""; }; + CEF093DD1E9474F700CD0BF3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = cocoa/Base.lproj/DeletionOptions.xib; sourceTree = ""; }; + CEF093E01E94750100CD0BF3 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = cocoa/fr.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093E21E94750300CD0BF3 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = cocoa/de.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093E41E94750500CD0BF3 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cocoa/cs.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093E61E94750700CD0BF3 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = cocoa/es.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093E81E94750900CD0BF3 /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = cocoa/el.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093EA1E94750E00CD0BF3 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = cocoa/it.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093EC1E94750F00CD0BF3 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = cocoa/nl.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093EE1E94751100CD0BF3 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = cocoa/pl.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093F01E94751200CD0BF3 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = cocoa/ko.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093F21E94751400CD0BF3 /* hy */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hy; path = cocoa/hy.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093F41E94751600CD0BF3 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "cocoa/pt-BR.lproj/DeletionOptions.strings"; sourceTree = ""; }; + CEF093F61E94751700CD0BF3 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = cocoa/ru.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093F81E94751900CD0BF3 /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uk; path = cocoa/uk.lproj/DeletionOptions.strings; sourceTree = ""; }; + CEF093FA1E94751B00CD0BF3 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "cocoa/zh-Hans.lproj/DeletionOptions.strings"; sourceTree = ""; }; + CEF093FC1E94751C00CD0BF3 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = cocoa/vi.lproj/DeletionOptions.strings; sourceTree = ""; }; CEFC8A231E74F23000965F37 /* dg_cocoa.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; name = dg_cocoa.py; path = cocoa/dg_cocoa.py; sourceTree = ""; }; CEFC8A241E74F23000965F37 /* dupeguru.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = dupeguru.icns; path = cocoa/dupeguru.icns; sourceTree = ""; }; CEFC8A271E74F28100965F37 /* help */ = {isa = PBXFileReference; lastKnownFileType = folder; name = help; path = build/help; sourceTree = ""; }; @@ -394,6 +408,7 @@ CE9EF6DD1E9345100089CA20 /* MainMenu.xib */, CE549CDA1E933C7600C75A05 /* ResultWindow.xib */, CE0559851E762105008EB4F8 /* IgnoreListDialog.xib */, + CEF093DC1E9474F700CD0BF3 /* DeletionOptions.xib */, ); name = xib; sourceTree = ""; @@ -527,8 +542,6 @@ CE9720F61E74E40E00A598C9 /* autogen */ = { isa = PBXGroup; children = ( - CE9720F71E74E41C00A598C9 /* DeletionOptions_UI.h */, - CE9720F81E74E41C00A598C9 /* DeletionOptions_UI.m */, CE9720F91E74E41C00A598C9 /* DetailsPanel_UI.h */, CE9720FA1E74E41C00A598C9 /* DetailsPanel_UI.m */, CE9720FB1E74E41C00A598C9 /* DetailsPanelPicture_UI.h */, @@ -703,6 +716,7 @@ CE65D0ED1E7783C40092126E /* ErrorReportWindow.xib in Resources */, CE549CDC1E933C7600C75A05 /* ResultWindow.xib in Resources */, CEFC8A251E74F23000965F37 /* dg_cocoa.py in Resources */, + CEF093DE1E9474F700CD0BF3 /* DeletionOptions.xib in Resources */, CE7CA6061E76337700874874 /* about.xib in Resources */, CE7CA6071E76337700874874 /* cocoalib.strings in Resources */, CE0559871E762105008EB4F8 /* IgnoreListDialog.xib in Resources */, @@ -729,7 +743,6 @@ CE9721511E74E41D00A598C9 /* PyDupeGuru.m in Sources */, CE9721401E74E41D00A598C9 /* DirectoryPanel_UI.m in Sources */, CE9720EC1E74E40300A598C9 /* DirectoryOutline.m in Sources */, - CE97213D1E74E41D00A598C9 /* DeletionOptions_UI.m in Sources */, CE9720EE1E74E40300A598C9 /* IgnoreListDialog.m in Sources */, CE9721501E74E41D00A598C9 /* PyDirectoryOutline.m in Sources */, CE9720F31E74E40300A598C9 /* ResultTable.m in Sources */, @@ -976,6 +989,29 @@ name = MainMenu.xib; sourceTree = ""; }; + CEF093DC1E9474F700CD0BF3 /* DeletionOptions.xib */ = { + isa = PBXVariantGroup; + children = ( + CEF093DD1E9474F700CD0BF3 /* Base */, + CEF093E01E94750100CD0BF3 /* fr */, + CEF093E21E94750300CD0BF3 /* de */, + CEF093E41E94750500CD0BF3 /* cs */, + CEF093E61E94750700CD0BF3 /* es */, + CEF093E81E94750900CD0BF3 /* el */, + CEF093EA1E94750E00CD0BF3 /* it */, + CEF093EC1E94750F00CD0BF3 /* nl */, + CEF093EE1E94751100CD0BF3 /* pl */, + CEF093F01E94751200CD0BF3 /* ko */, + CEF093F21E94751400CD0BF3 /* hy */, + CEF093F41E94751600CD0BF3 /* pt-BR */, + CEF093F61E94751700CD0BF3 /* ru */, + CEF093F81E94751900CD0BF3 /* uk */, + CEF093FA1E94751B00CD0BF3 /* zh-Hans */, + CEF093FC1E94751C00CD0BF3 /* vi */, + ); + name = DeletionOptions.xib; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */