2010-02-03 10:55:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2010-02-02
|
|
|
|
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
|
|
|
#
|
|
|
|
# This software is licensed under the "HS" License as described in the "LICENSE" file,
|
|
|
|
# which should be included with this package. The terms are also available at
|
|
|
|
# http://www.hardcoded.net/licenses/hs_license
|
|
|
|
|
|
|
|
# Common interface for all editions' dg_cocoa unit.
|
|
|
|
|
2010-02-07 15:29:39 +00:00
|
|
|
from hsutil.cocoa.inter import signature, PyOutline, PyGUIObject, PyRegistrable
|
2010-02-03 10:55:53 +00:00
|
|
|
|
2010-02-05 19:10:54 +00:00
|
|
|
from .gui.details_panel import DetailsPanel
|
2010-02-07 14:26:50 +00:00
|
|
|
from .gui.directory_tree import DirectoryTree
|
2010-02-05 19:10:54 +00:00
|
|
|
|
2010-02-03 10:55:53 +00:00
|
|
|
# Fix py2app's problems on relative imports
|
|
|
|
from core import app, app_cocoa, data, directories, engine, export, ignore, results, fs, scanner
|
|
|
|
from hsutil import conflict
|
|
|
|
|
2010-02-07 15:29:39 +00:00
|
|
|
class PyDupeGuruBase(PyRegistrable):
|
2010-02-03 10:55:53 +00:00
|
|
|
#---Directories
|
|
|
|
def addDirectory_(self, directory):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.add_directory(directory)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def removeDirectory_(self, index):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.remove_directory(index)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
#---Results
|
|
|
|
def clearIgnoreList(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.scanner.ignore_list.Clear()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def doScan(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.start_scanning()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def exportToXHTMLwithColumns_(self, column_ids):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.export_to_xhtml(column_ids)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def loadIgnoreList(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.load_ignore_list()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def loadResults(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.load()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def markAll(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.results.mark_all()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def markNone(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.results.mark_none()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def markInvert(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.results.mark_invert()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def purgeIgnoreList(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.PurgeIgnoreList()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def toggleSelectedMark(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.ToggleSelectedMarkState()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def saveIgnoreList(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.save_ignore_list()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def saveResults(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.save()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def selectedResultNodePaths(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.selected_result_node_paths()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def selectResultNodePaths_(self,node_paths):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.SelectResultNodePaths(node_paths)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def selectedPowerMarkerNodePaths(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.selected_powermarker_node_paths()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def selectPowerMarkerNodePaths_(self,node_paths):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.SelectPowerMarkerNodePaths(node_paths)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
#---Actions
|
|
|
|
def addSelectedToIgnoreList(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.add_selected_to_ignore_list()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def deleteMarked(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.delete_marked()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def applyFilter_(self, filter):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.apply_filter(filter)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def makeSelectedReference(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.make_selected_reference()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def copyOrMove_markedTo_recreatePath_(self, copy, destination, recreate_path):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.copy_or_move_marked(copy, destination, recreate_path)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def openSelected(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.open_selected()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def removeMarked(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.results.perform_on_marked(lambda x:True, True)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def removeSelected(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.remove_selected()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def renameSelected_(self,newname):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.RenameSelected(newname)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def revealSelected(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.reveal_selected()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
#---Misc
|
|
|
|
def sortDupesBy_ascending_(self, key, asc):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.sort_dupes(key, asc)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def sortGroupsBy_ascending_(self, key, asc):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.sort_groups(key, asc)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
#---Information
|
|
|
|
def getIgnoreListCount(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return len(self.py.scanner.ignore_list)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def getMarkCount(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.results.mark_count
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def getStatLine(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.stat_line
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def getOperationalErrorCount(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.last_op_error_count
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
#---Data
|
|
|
|
@signature('i@:i')
|
|
|
|
def getOutlineViewMaxLevel_(self, tag):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.GetOutlineViewMaxLevel(tag)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
@signature('@@:i@')
|
|
|
|
def getOutlineView_childCountsForPath_(self, tag, node_path):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.GetOutlineViewChildCounts(tag, node_path)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def getOutlineView_valuesForIndexes_(self, tag, node_path):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.GetOutlineViewValues(tag, node_path)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def getOutlineView_markedAtIndexes_(self, tag, node_path):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.GetOutlineViewMarked(tag, node_path)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
#---Properties
|
|
|
|
def setMixFileKind_(self, mix_file_kind):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.scanner.mix_file_kind = mix_file_kind
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def setDisplayDeltaValues_(self, display_delta_values):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.display_delta_values= display_delta_values
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def setEscapeFilterRegexp_(self, escape_filter_regexp):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.options['escape_filter_regexp'] = escape_filter_regexp
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def setRemoveEmptyFolders_(self, remove_empty_folders):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.options['clean_empty_dirs'] = remove_empty_folders
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
#---Worker
|
|
|
|
def getJobProgress(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.progress.last_progress
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def getJobDesc(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
return self.py.progress.last_desc
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def cancelJob(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.progress.job_cancelled = True
|
2010-02-03 10:55:53 +00:00
|
|
|
|
2010-02-05 19:10:54 +00:00
|
|
|
|
2010-02-07 15:19:14 +00:00
|
|
|
class PyDetailsPanel(PyGUIObject):
|
|
|
|
py_class = DetailsPanel
|
2010-02-05 19:10:54 +00:00
|
|
|
@signature('i@:')
|
|
|
|
def numberOfRows(self):
|
|
|
|
return self.py.row_count()
|
|
|
|
|
|
|
|
@signature('@@:@i')
|
|
|
|
def valueForColumn_row_(self, column, row):
|
|
|
|
return self.py.row(row)[int(column)]
|
|
|
|
|
2010-02-07 14:26:50 +00:00
|
|
|
|
|
|
|
class PyDirectoryOutline(PyOutline):
|
|
|
|
py_class = DirectoryTree
|
|
|
|
|
|
|
|
def addDirectory_(self, path):
|
|
|
|
self.py.add_directory(path)
|
|
|
|
|