2010-02-03 10:55:53 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2010-02-02
|
2011-04-12 08:04:01 +00:00
|
|
|
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
2010-02-03 10:55:53 +00:00
|
|
|
#
|
2010-09-30 10:17:41 +00:00
|
|
|
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
2010-02-03 10:55:53 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2010-09-30 10:17:41 +00:00
|
|
|
# http://www.hardcoded.net/licenses/bsd_license
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
# Common interface for all editions' dg_cocoa unit.
|
|
|
|
|
2010-09-29 14:49:50 +00:00
|
|
|
from hscommon.cocoa.inter import signature, PyTable, PyOutline, PyGUIObject, PyFairware
|
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-04-12 10:21:01 +00:00
|
|
|
from .gui.problem_dialog import ProblemDialog
|
|
|
|
from .gui.problem_table import ProblemTable
|
2010-09-24 13:48:59 +00:00
|
|
|
from .gui.result_table import ResultTable
|
2010-02-11 19:54:06 +00:00
|
|
|
from .gui.stats_label import StatsLabel
|
2011-03-05 12:03:23 +00:00
|
|
|
from .gui.extra_fairware_reminder import ExtraFairwareReminder
|
2010-02-05 19:10:54 +00:00
|
|
|
|
2010-09-29 14:49:50 +00:00
|
|
|
class PyDupeGuruBase(PyFairware):
|
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
|
|
|
|
2011-01-13 15:20:03 +00:00
|
|
|
def loadSession(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.load()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
2010-08-13 11:06:18 +00:00
|
|
|
def loadResultsFrom_(self, filename):
|
|
|
|
self.py.load_from(filename)
|
|
|
|
|
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
|
|
|
|
2011-01-13 15:20:03 +00:00
|
|
|
def saveSession(self):
|
2010-02-07 14:26:50 +00:00
|
|
|
self.py.save()
|
2010-02-03 10:55:53 +00:00
|
|
|
|
2010-08-13 11:06:18 +00:00
|
|
|
def saveResultsAs_(self, filename):
|
|
|
|
self.py.save_as(filename)
|
|
|
|
|
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
|
|
|
|
2010-09-25 13:37:18 +00:00
|
|
|
def hardlinkMarked(self):
|
|
|
|
self.py.delete_marked(replace_with_hardlinks=True)
|
|
|
|
|
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
|
|
|
|
2010-04-12 15:43:24 +00:00
|
|
|
def invokeCommand_(self, cmd):
|
|
|
|
self.py.invoke_command(cmd)
|
|
|
|
|
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
|
|
|
|
2010-04-12 10:21:01 +00:00
|
|
|
@signature('i@:')
|
|
|
|
def scanWasProblematic(self):
|
|
|
|
return bool(self.py.results.problems)
|
2010-02-03 10:55:53 +00:00
|
|
|
|
2011-01-13 15:20:03 +00:00
|
|
|
@signature('i@:')
|
|
|
|
def resultsAreModified(self):
|
|
|
|
return self.py.results.is_modified
|
|
|
|
|
2011-01-29 10:07:33 +00:00
|
|
|
def deltaColumns(self):
|
|
|
|
return list(self.py.data.DELTA_COLUMNS)
|
|
|
|
|
2010-02-03 10:55:53 +00:00
|
|
|
#---Properties
|
2010-09-25 10:28:34 +00:00
|
|
|
@signature('v@:c')
|
2010-02-03 10:55:53 +00:00
|
|
|
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
|
|
|
|
2010-09-25 10:28:34 +00:00
|
|
|
@signature('v@:c')
|
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
|
|
|
|
2010-09-25 10:28:34 +00:00
|
|
|
@signature('v@:c')
|
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
|
|
|
|
2010-09-25 10:28:34 +00:00
|
|
|
@signature('v@:c')
|
|
|
|
def setIgnoreHardlinkMatches_(self, ignore_hardlink_matches):
|
|
|
|
self.py.options['ignore_hardlink_matches'] = ignore_hardlink_matches
|
|
|
|
|
2010-02-03 10:55:53 +00:00
|
|
|
#---Worker
|
|
|
|
def getJobProgress(self):
|
2010-09-24 07:56:08 +00:00
|
|
|
try:
|
|
|
|
return self.py.progress.last_progress
|
|
|
|
except AttributeError:
|
|
|
|
# I have *no idea* why this can possible happen (last_progress is always set by
|
|
|
|
# create_job() *before* any threaded job notification, which shows the progress panel,
|
2010-10-04 07:40:46 +00:00
|
|
|
# is sent), but it happens anyway, so there we go. ref: #106
|
2010-09-24 07:56:08 +00:00
|
|
|
return -1
|
2010-02-03 10:55:53 +00:00
|
|
|
|
|
|
|
def getJobDesc(self):
|
2010-10-04 07:40:46 +00:00
|
|
|
try:
|
|
|
|
return self.py.progress.last_desc
|
|
|
|
except AttributeError:
|
|
|
|
# see getJobProgress
|
|
|
|
return ''
|
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
|
|
|
|
2010-09-24 13:48:59 +00:00
|
|
|
class PyResultTable(PyTable):
|
|
|
|
py_class = ResultTable
|
2010-02-11 16:52:18 +00:00
|
|
|
|
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-09-24 13:48:59 +00:00
|
|
|
@signature('@@:ii')
|
|
|
|
def valueForRow_column_(self, row_index, column):
|
|
|
|
return self.py.get_row_value(row_index, column)
|
2010-02-11 16:52:18 +00:00
|
|
|
|
|
|
|
@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-09-24 13:48:59 +00:00
|
|
|
@signature('i@:')
|
|
|
|
def selectedDupeCount(self):
|
|
|
|
return self.py.selected_dupe_count
|
2010-02-12 10:34:00 +00:00
|
|
|
|
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
|
|
|
|
|
2010-04-12 10:21:01 +00:00
|
|
|
|
|
|
|
class PyProblemDialog(PyGUIObject):
|
|
|
|
py_class = ProblemDialog
|
|
|
|
|
|
|
|
def revealSelected(self):
|
|
|
|
self.py.reveal_selected_dupe()
|
|
|
|
|
|
|
|
|
|
|
|
class PyProblemTable(PyTable):
|
|
|
|
py_class = ProblemTable
|
2011-03-05 12:03:23 +00:00
|
|
|
|
|
|
|
class PyExtraFairwareReminder(PyGUIObject):
|
|
|
|
py_class = ExtraFairwareReminder
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
self.py.start()
|
|
|
|
|
|
|
|
def updateButton(self):
|
|
|
|
self.py.update_button()
|
|
|
|
|
|
|
|
# model --> view
|
|
|
|
def start_timer(self):
|
|
|
|
self.cocoa.startTimer()
|
|
|
|
|
|
|
|
def stop_timer(self):
|
|
|
|
self.cocoa.stopTimer()
|
|
|
|
|
|
|
|
def enable_button(self):
|
|
|
|
self.cocoa.enableButton()
|
|
|
|
|
|
|
|
def set_button_text(self, text):
|
|
|
|
self.cocoa.setButtonText_(text)
|
|
|
|
|