[#12] dgse cocoa: Added custom command invocation.

This commit is contained in:
Virgil Dupras 2010-04-12 17:43:24 +02:00
parent 699023992c
commit 5c80ac1c74
7 changed files with 1078 additions and 810 deletions

View File

@ -20,6 +20,7 @@ http://www.hardcoded.net/licenses/hs_license
- (void)clearIgnoreList;
- (void)purgeIgnoreList;
- (NSString *)exportToXHTMLwithColumns:(NSArray *)aColIds;
- (void)invokeCommand:(NSString *)cmd;
- (NSNumber *)doScan;

View File

@ -48,6 +48,7 @@ http://www.hardcoded.net/licenses/hs_license
- (IBAction)exportToXHTML:(id)sender;
- (IBAction)filter:(id)sender;
- (IBAction)ignoreSelected:(id)sender;
- (IBAction)invokeCustomCommand:(id)sender;
- (IBAction)markAll:(id)sender;
- (IBAction)markInvert:(id)sender;
- (IBAction)markNone:(id)sender;

View File

@ -200,6 +200,13 @@ http://www.hardcoded.net/licenses/hs_license
[py addSelectedToIgnoreList];
}
- (IBAction)invokeCustomCommand:(id)sender
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *cmd = [ud stringForKey:@"CustomCommand"];
[py invokeCommand:cmd];
}
- (IBAction)markAll:(id)sender
{
[py markAll];

View File

@ -2,18 +2,18 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10C540</string>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">740</string>
<string key="IBDocument.AppKitVersion">1038.25</string>
<string key="IBDocument.HIToolboxVersion">458.00</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">740</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="598"/>
<integer value="219"/>
<integer value="29"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -1146,7 +1146,7 @@
<object class="NSMenuItem" id="578499792">
<reference key="NSMenu" ref="600111647"/>
<string key="NSTitle">Clear Ignore List</string>
<string key="NSKeyEquiv">I</string>
<string key="NSKeyEquiv">G</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="852972005"/>
@ -1231,7 +1231,7 @@
<object class="NSMenuItem" id="904423169">
<reference key="NSMenu" ref="600111647"/>
<string key="NSTitle">Add Selected to Ignore List</string>
<string key="NSKeyEquiv">i</string>
<string key="NSKeyEquiv">g</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="852972005"/>
@ -1275,6 +1275,15 @@
<reference key="NSOnImage" ref="852972005"/>
<reference key="NSMixedImage" ref="218295580"/>
</object>
<object class="NSMenuItem" id="517397504">
<reference key="NSMenu" ref="600111647"/>
<string key="NSTitle">Invoke Custom Command</string>
<string key="NSKeyEquiv">i</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="852972005"/>
<reference key="NSMixedImage" ref="218295580"/>
</object>
<object class="NSMenuItem" id="564101661">
<reference key="NSMenu" ref="600111647"/>
<string key="NSTitle">Rename Selected</string>
@ -2204,6 +2213,14 @@
</object>
<int key="connectionID">1176</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">invokeCustomCommand:</string>
<reference key="source" ref="339936126"/>
<reference key="destination" ref="517397504"/>
</object>
<int key="connectionID">1178</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -2530,6 +2547,7 @@
<reference ref="564101661"/>
<reference ref="630362403"/>
<reference ref="747820446"/>
<reference ref="517397504"/>
</object>
<reference key="parent" ref="528113253"/>
</object>
@ -3066,6 +3084,11 @@
<reference key="object" ref="747820446"/>
<reference key="parent" ref="600111647"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1177</int>
<reference key="object" ref="517397504"/>
<reference key="parent" ref="600111647"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -3117,6 +3140,7 @@
<string>1171.IBPluginDependency</string>
<string>1172.IBPluginDependency</string>
<string>1173.IBPluginDependency</string>
<string>1177.IBPluginDependency</string>
<string>134.IBPluginDependency</string>
<string>134.ImportedFromIB2</string>
<string>136.IBPluginDependency</string>
@ -3355,6 +3379,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
@ -3374,9 +3399,9 @@
<boolean value="YES"/>
<boolean value="YES"/>
<boolean value="YES"/>
<string>{{109, 366}, {557, 400}}</string>
<string>{{439, 345}, {557, 400}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{109, 366}, {557, 400}}</string>
<string>{{439, 345}, {557, 400}}</string>
<boolean value="YES"/>
<boolean value="YES"/>
<boolean value="YES"/>
@ -3423,7 +3448,7 @@
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{286, 475}, {361, 293}}</string>
<string>{{286, 455}, {361, 313}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3561,7 +3586,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">1176</int>
<int key="maxID">1178</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -3776,8 +3801,17 @@
<string key="className">ResultWindow</string>
<string key="superclassName">ResultWindowBase</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">removeDeadTracks:</string>
<string key="NS.object.0">id</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>resetColumnsToDefault:</string>
<string>startDuplicateScan:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
@ -3799,6 +3833,7 @@
<string>exportToXHTML:</string>
<string>filter:</string>
<string>ignoreSelected:</string>
<string>invokeCustomCommand:</string>
<string>markAll:</string>
<string>markInvert:</string>
<string>markNone:</string>
@ -3848,6 +3883,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@ -4500,7 +4536,7 @@
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../../me/dupeguru.xcodeproj</string>
<string key="IBDocument.LastKnownRelativeProjectPath">../../se/dupeguru.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@ from __future__ import unicode_literals
import os
import os.path as op
import logging
import subprocess
from send2trash import send2trash
from hsutil import io, files
@ -218,6 +219,22 @@ class DupeGuru(RegistrableApplication, Broadcaster):
rows.append(row)
return export.export_to_xhtml(colnames, rows)
def invoke_command(self, cmd):
"""Calls command `cmd` with %d and %r placeholders replaced.
Using the current selection, %d is replaced with the currently selected dupe and %r is
replaced with that dupe's ref file. If there's no selection, the command is not invoked.
If the dupe is a ref, %d and %r will be the same.
"""
if not self.selected_dupes:
return
dupe = self.selected_dupes[0]
group = self.results.get_group_of_duplicate(dupe)
ref = group.ref
cmd = cmd.replace('%d', unicode(dupe.path))
cmd = cmd.replace('%r', unicode(ref.path))
subprocess.Popen(cmd, shell=True)
def load(self):
self._start_job(JOB_LOAD, self._do_load)
self.load_ignore_list()

View File

@ -95,6 +95,9 @@ class PyDupeGuruBase(PyRegistrable):
def revealSelected(self):
self.py.reveal_selected()
def invokeCommand_(self, cmd):
self.py.invoke_command(cmd)
#---Information
def getIgnoreListCount(self):
return len(self.py.scanner.ignore_list)