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-11 16:52:18 +00:00
|
|
|
from .gui.result_tree import ResultTree
|
2010-02-11 19:54:06 +00:00
|
|
|
from .gui.stats_label import StatsLabel
|
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-11 17:47:45 +00:00
|
|
|
self.py.mark_all()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def markNone(self):
|
2010-02-11 17:47:45 +00:00
|
|
|
self.py.mark_none()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def markInvert(self):
|
2010-02-11 17:47:45 +00:00
|
|
|
self.py.mark_invert()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def purgeIgnoreList(self):
|
2010-02-12 12:39:50 +00:00
|
|
|
self.py.purge_ignore_list()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def toggleSelectedMark(self):
|
2010-02-11 16:52:18 +00:00
|
|
|
self.py.toggle_selected_mark_state()
|
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
|
|
|
|
|
|
|
#---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-12 12:39:50 +00:00
|
|
|
self.py.remove_marked()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def renameSelected_(self,newname):
|
2010-02-12 11:43:50 +00:00
|
|
|
return self.py.rename_selected(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
|
|
|
|
|
|
|
#---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 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
|
|
|
|
|
|
|
#---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 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-11 16:52:18 +00:00
|
|
|
def jobCompleted_(self, jobid):
|
|
|
|
self.py._job_completed(jobid)
|
|
|
|
|
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)
|
|
|
|
|
2010-02-11 16:52:18 +00:00
|
|
|
|
|
|
|
class PyResultOutline(PyOutline):
|
|
|
|
py_class = ResultTree
|
|
|
|
|
2010-02-11 18:22:31 +00:00
|
|
|
@signature('c@:')
|
|
|
|
def powerMarkerMode(self):
|
|
|
|
return self.py.power_marker
|
|
|
|
|
2010-02-11 16:52:18 +00:00
|
|
|
@signature('v@:c')
|
|
|
|
def setPowerMarkerMode_(self, value):
|
|
|
|
self.py.power_marker = value
|
|
|
|
|
2010-02-11 18:22:31 +00:00
|
|
|
@signature('c@:')
|
|
|
|
def deltaValuesMode(self):
|
|
|
|
return self.py.delta_values
|
|
|
|
|
|
|
|
@signature('v@:c')
|
|
|
|
def setDeltaValuesMode_(self, value):
|
|
|
|
self.py.delta_values = value
|
|
|
|
|
2010-02-11 16:52:18 +00:00
|
|
|
@signature('@@:@i')
|
|
|
|
def valueForPath_column_(self, path, column):
|
|
|
|
return self.py.get_node_value(path, column)
|
|
|
|
|
|
|
|
@signature('c@:@')
|
|
|
|
def renameSelected_(self, newname):
|
2010-02-12 12:52:40 +00:00
|
|
|
return self.py.rename_selected(newname)
|
2010-02-11 16:52:18 +00:00
|
|
|
|
2010-02-11 20:03:22 +00:00
|
|
|
@signature('v@:ic')
|
2010-02-11 16:52:18 +00:00
|
|
|
def sortBy_ascending_(self, key, asc):
|
|
|
|
self.py.sort(key, asc)
|
|
|
|
|
|
|
|
def markSelected(self):
|
|
|
|
self.py.app.toggle_selected_mark_state()
|
|
|
|
|
2010-02-12 16:15:48 +00:00
|
|
|
def removeSelected(self):
|
|
|
|
self.py.app.remove_selected()
|
|
|
|
|
2010-02-12 10:34:00 +00:00
|
|
|
def rootChildrenCounts(self):
|
|
|
|
return self.py.root_children_counts()
|
|
|
|
|
2010-02-12 10:21:39 +00:00
|
|
|
# python --> cocoa
|
|
|
|
def invalidate_markings(self):
|
|
|
|
self.cocoa.invalidateMarkings()
|
|
|
|
|
2010-02-11 19:54:06 +00:00
|
|
|
|
|
|
|
class PyStatsLabel(PyGUIObject):
|
|
|
|
py_class = StatsLabel
|
|
|
|
|
|
|
|
def display(self):
|
|
|
|
return self.py.display
|
|
|
|
|