mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
Moved core*.app_cocoa to cocoa/inter.
--HG-- rename : core_me/app_cocoa.py => cocoa/inter/app_me.py rename : core_pe/app_cocoa.py => cocoa/inter/app_pe.py rename : core_se/app_cocoa.py => cocoa/inter/app_se.py
This commit is contained in:
0
cocoa/inter/__init__.py
Normal file
0
cocoa/inter/__init__.py
Normal file
200
cocoa/inter/app.py
Normal file
200
cocoa/inter/app.py
Normal file
@@ -0,0 +1,200 @@
|
||||
import logging
|
||||
|
||||
from jobprogress import job
|
||||
from hscommon import cocoa
|
||||
from hscommon.cocoa import install_exception_hook, pythonify
|
||||
from hscommon.cocoa.inter import signature, PyFairware
|
||||
from hscommon.cocoa.objcmin import (NSNotificationCenter, NSUserDefaults,
|
||||
NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSUserDomainMask,
|
||||
NSWorkspace)
|
||||
from hscommon.trans import tr
|
||||
|
||||
from core.app import JobType
|
||||
|
||||
JOBID2TITLE = {
|
||||
JobType.Scan: tr("Scanning for duplicates"),
|
||||
JobType.Load: tr("Loading"),
|
||||
JobType.Move: tr("Moving"),
|
||||
JobType.Copy: tr("Copying"),
|
||||
JobType.Delete: tr("Sending to Trash"),
|
||||
}
|
||||
|
||||
class PyDupeGuruBase(PyFairware):
|
||||
def _init(self, modelclass):
|
||||
logging.basicConfig(level=logging.WARNING, format='%(levelname)s %(message)s')
|
||||
install_exception_hook()
|
||||
appdata = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0]
|
||||
self.py = modelclass(self, appdata)
|
||||
self.progress = cocoa.ThreadedJobPerformer()
|
||||
|
||||
def bindCocoa_(self, cocoa):
|
||||
self.cocoa = cocoa
|
||||
|
||||
#---Directories
|
||||
def addDirectory_(self, directory):
|
||||
return self.py.add_directory(directory)
|
||||
|
||||
def removeDirectory_(self, index):
|
||||
self.py.remove_directory(index)
|
||||
|
||||
#---Results
|
||||
def clearIgnoreList(self):
|
||||
self.py.scanner.ignore_list.Clear()
|
||||
|
||||
def doScan(self):
|
||||
return self.py.start_scanning()
|
||||
|
||||
def exportToXHTMLwithColumns_(self, column_ids):
|
||||
return self.py.export_to_xhtml(column_ids)
|
||||
|
||||
def loadSession(self):
|
||||
self.py.load()
|
||||
|
||||
def loadResultsFrom_(self, filename):
|
||||
self.py.load_from(filename)
|
||||
|
||||
def markAll(self):
|
||||
self.py.mark_all()
|
||||
|
||||
def markNone(self):
|
||||
self.py.mark_none()
|
||||
|
||||
def markInvert(self):
|
||||
self.py.mark_invert()
|
||||
|
||||
def purgeIgnoreList(self):
|
||||
self.py.purge_ignore_list()
|
||||
|
||||
def toggleSelectedMark(self):
|
||||
self.py.toggle_selected_mark_state()
|
||||
|
||||
def saveSession(self):
|
||||
self.py.save()
|
||||
|
||||
def saveResultsAs_(self, filename):
|
||||
self.py.save_as(filename)
|
||||
|
||||
#---Actions
|
||||
def addSelectedToIgnoreList(self):
|
||||
self.py.add_selected_to_ignore_list()
|
||||
|
||||
def deleteMarked(self):
|
||||
self.py.delete_marked()
|
||||
|
||||
def hardlinkMarked(self):
|
||||
self.py.delete_marked(replace_with_hardlinks=True)
|
||||
|
||||
def applyFilter_(self, filter):
|
||||
self.py.apply_filter(filter)
|
||||
|
||||
def makeSelectedReference(self):
|
||||
self.py.make_selected_reference()
|
||||
|
||||
def copyOrMove_markedTo_recreatePath_(self, copy, destination, recreate_path):
|
||||
self.py.copy_or_move_marked(copy, destination, recreate_path)
|
||||
|
||||
def openSelected(self):
|
||||
self.py.open_selected()
|
||||
|
||||
def removeMarked(self):
|
||||
self.py.remove_marked()
|
||||
|
||||
def renameSelected_(self,newname):
|
||||
return self.py.rename_selected(newname)
|
||||
|
||||
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)
|
||||
|
||||
def getMarkCount(self):
|
||||
return self.py.results.mark_count
|
||||
|
||||
@signature('i@:')
|
||||
def scanWasProblematic(self):
|
||||
return bool(self.py.results.problems)
|
||||
|
||||
@signature('i@:')
|
||||
def resultsAreModified(self):
|
||||
return self.py.results.is_modified
|
||||
|
||||
def deltaColumns(self):
|
||||
return list(self.py.DELTA_COLUMNS)
|
||||
|
||||
#---Properties
|
||||
@signature('v@:c')
|
||||
def setMixFileKind_(self, mix_file_kind):
|
||||
self.py.scanner.mix_file_kind = mix_file_kind
|
||||
|
||||
@signature('v@:c')
|
||||
def setEscapeFilterRegexp_(self, escape_filter_regexp):
|
||||
self.py.options['escape_filter_regexp'] = escape_filter_regexp
|
||||
|
||||
@signature('v@:c')
|
||||
def setRemoveEmptyFolders_(self, remove_empty_folders):
|
||||
self.py.options['clean_empty_dirs'] = remove_empty_folders
|
||||
|
||||
@signature('v@:c')
|
||||
def setIgnoreHardlinkMatches_(self, ignore_hardlink_matches):
|
||||
self.py.options['ignore_hardlink_matches'] = ignore_hardlink_matches
|
||||
|
||||
#---Worker
|
||||
def getJobProgress(self):
|
||||
try:
|
||||
return self.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,
|
||||
# is sent), but it happens anyway, so there we go. ref: #106
|
||||
return -1
|
||||
|
||||
def getJobDesc(self):
|
||||
try:
|
||||
return self.progress.last_desc
|
||||
except AttributeError:
|
||||
# see getJobProgress
|
||||
return ''
|
||||
|
||||
def cancelJob(self):
|
||||
self.progress.job_cancelled = True
|
||||
|
||||
def jobCompleted_(self, jobid):
|
||||
self.py._job_completed(jobid)
|
||||
|
||||
#---Registration
|
||||
def appName(self):
|
||||
return self.py.NAME
|
||||
|
||||
#--- model --> view
|
||||
def open_path(self, path):
|
||||
NSWorkspace.sharedWorkspace().openFile_(str(path))
|
||||
|
||||
def reveal_path(self, path):
|
||||
NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(str(path), '')
|
||||
|
||||
def start_job(self, jobid, func, args=()):
|
||||
try:
|
||||
j = self.progress.create_job()
|
||||
args = tuple([j] + list(args))
|
||||
self.progress.run_threaded(func, args=args)
|
||||
except job.JobInProgressError:
|
||||
NSNotificationCenter.defaultCenter().postNotificationName_object_('JobInProgress', self)
|
||||
else:
|
||||
ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid}
|
||||
NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud)
|
||||
|
||||
def get_default(self, key_name):
|
||||
raw = NSUserDefaults.standardUserDefaults().objectForKey_(key_name)
|
||||
result = pythonify(raw)
|
||||
return result
|
||||
|
||||
def set_default(self, key_name, value):
|
||||
NSUserDefaults.standardUserDefaults().setObject_forKey_(value, key_name)
|
||||
|
||||
def show_extra_fairware_reminder(self):
|
||||
self.cocoa.showExtraFairwareReminder()
|
||||
69
cocoa/inter/app_me.py
Normal file
69
cocoa/inter/app_me.py
Normal file
@@ -0,0 +1,69 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2006/11/16
|
||||
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "BSD" 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/bsd_license
|
||||
|
||||
import logging
|
||||
from appscript import app, k, CommandError
|
||||
import time
|
||||
import os.path as op
|
||||
|
||||
from hscommon.cocoa import as_fetch
|
||||
from hscommon.trans import tr
|
||||
|
||||
from core.app import JobType
|
||||
from core_me.app import DupeGuru as DupeGuruBase
|
||||
from .app import JOBID2TITLE
|
||||
|
||||
JobType.RemoveDeadTracks = 'jobRemoveDeadTracks'
|
||||
JobType.ScanDeadTracks = 'jobScanDeadTracks'
|
||||
|
||||
JOBID2TITLE.update({
|
||||
JobType.RemoveDeadTracks: tr("Removing dead tracks from your iTunes Library"),
|
||||
JobType.ScanDeadTracks: tr("Scanning the iTunes Library"),
|
||||
})
|
||||
|
||||
class DupeGuruME(DupeGuruBase):
|
||||
def __init__(self, view, appdata):
|
||||
appdata = op.join(appdata, 'dupeGuru Music Edition')
|
||||
DupeGuruBase.__init__(self, view, appdata)
|
||||
self.dead_tracks = []
|
||||
|
||||
def remove_dead_tracks(self):
|
||||
def do(j):
|
||||
a = app('iTunes')
|
||||
a.activate(timeout=0)
|
||||
for index, track in enumerate(j.iter_with_progress(self.dead_tracks)):
|
||||
if index % 100 == 0:
|
||||
time.sleep(.1)
|
||||
try:
|
||||
track.delete(timeout=0)
|
||||
except CommandError as e:
|
||||
logging.warning('Error while trying to remove a track from iTunes: %s' % str(e))
|
||||
|
||||
self.view.start_job(JobType.RemoveDeadTracks, do)
|
||||
|
||||
def scan_dead_tracks(self):
|
||||
def do(j):
|
||||
a = app('iTunes')
|
||||
a.activate(timeout=0)
|
||||
try:
|
||||
[source] = [s for s in a.sources(timeout=0) if s.kind(timeout=0) == k.library]
|
||||
[library] = source.library_playlists(timeout=0)
|
||||
except ValueError:
|
||||
logging.warning('Some unexpected iTunes configuration encountered')
|
||||
return
|
||||
self.dead_tracks = []
|
||||
tracks = as_fetch(library.file_tracks, k.file_track)
|
||||
for index, track in enumerate(j.iter_with_progress(tracks)):
|
||||
if index % 100 == 0:
|
||||
time.sleep(.1)
|
||||
if track.location(timeout=0) == k.missing_value:
|
||||
self.dead_tracks.append(track)
|
||||
logging.info('Found %d dead tracks' % len(self.dead_tracks))
|
||||
|
||||
self.view.start_job(JobType.ScanDeadTracks, do)
|
||||
|
||||
199
cocoa/inter/app_pe.py
Normal file
199
cocoa/inter/app_pe.py
Normal file
@@ -0,0 +1,199 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2006/11/13
|
||||
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "BSD" 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/bsd_license
|
||||
|
||||
import os.path as op
|
||||
import plistlib
|
||||
import logging
|
||||
import re
|
||||
|
||||
from appscript import app, its, CommandError, ApplicationNotFoundError
|
||||
|
||||
from hscommon import io
|
||||
from hscommon.util import remove_invalid_xml
|
||||
from hscommon.path import Path
|
||||
from hscommon.cocoa.objcmin import NSUserDefaults, NSURL
|
||||
from hscommon.trans import tr
|
||||
|
||||
from core import directories
|
||||
from core_pe import _block_osx
|
||||
from core_pe.photo import Photo as PhotoBase
|
||||
from core_pe.app import DupeGuru as DupeGuruBase
|
||||
|
||||
IPHOTO_PATH = Path('iPhoto Library')
|
||||
|
||||
class Photo(PhotoBase):
|
||||
HANDLED_EXTS = PhotoBase.HANDLED_EXTS.copy()
|
||||
HANDLED_EXTS.update({'psd', 'nef', 'cr2', 'orf'})
|
||||
|
||||
def _plat_get_dimensions(self):
|
||||
return _block_osx.get_image_size(str(self.path))
|
||||
|
||||
def _plat_get_blocks(self, block_count_per_side, orientation):
|
||||
try:
|
||||
blocks = _block_osx.getblocks(str(self.path), block_count_per_side, orientation)
|
||||
except Exception as e:
|
||||
raise IOError('The reading of "%s" failed with "%s"' % (str(self.path), str(e)))
|
||||
if not blocks:
|
||||
raise IOError('The picture %s could not be read' % str(self.path))
|
||||
return blocks
|
||||
|
||||
|
||||
class IPhoto(Photo):
|
||||
@property
|
||||
def display_folder_path(self):
|
||||
return IPHOTO_PATH
|
||||
|
||||
def get_iphoto_database_path():
|
||||
ud = NSUserDefaults.standardUserDefaults()
|
||||
prefs = ud.persistentDomainForName_('com.apple.iApps')
|
||||
if prefs is None:
|
||||
raise directories.InvalidPathError()
|
||||
if 'iPhotoRecentDatabases' not in prefs:
|
||||
raise directories.InvalidPathError()
|
||||
plisturl = NSURL.URLWithString_(prefs['iPhotoRecentDatabases'][0])
|
||||
return Path(plisturl.path())
|
||||
|
||||
def get_iphoto_pictures(plistpath):
|
||||
if not io.exists(plistpath):
|
||||
return []
|
||||
s = io.open(plistpath, 'rt', encoding='utf-8').read()
|
||||
# There was a case where a guy had 0x10 chars in his plist, causing expat errors on loading
|
||||
s = remove_invalid_xml(s, replace_with='')
|
||||
# It seems that iPhoto sometimes doesn't properly escape & chars. The regexp below is to find
|
||||
# any & char that is not a &-based entity (&, ", etc.). based on TextMate's XML
|
||||
# bundle's regexp
|
||||
s, count = re.subn(r'&(?![a-zA-Z0-9_-]+|#[0-9]+|#x[0-9a-fA-F]+;)', '', s)
|
||||
if count:
|
||||
logging.warning("%d invalid XML entities replacement made", count)
|
||||
plist = plistlib.readPlistFromBytes(s.encode('utf-8'))
|
||||
result = []
|
||||
for photo_data in plist['Master Image List'].values():
|
||||
if photo_data['MediaType'] != 'Image':
|
||||
continue
|
||||
photo_path = Path(photo_data['ImagePath'])
|
||||
photo = IPhoto(photo_path)
|
||||
result.append(photo)
|
||||
return result
|
||||
|
||||
class Directories(directories.Directories):
|
||||
def __init__(self):
|
||||
directories.Directories.__init__(self, fileclasses=[Photo])
|
||||
try:
|
||||
self.iphoto_libpath = get_iphoto_database_path()
|
||||
self.set_state(self.iphoto_libpath[:-1], directories.DirectoryState.Excluded)
|
||||
except directories.InvalidPathError:
|
||||
self.iphoto_libpath = None
|
||||
|
||||
def _get_files(self, from_path, j):
|
||||
if from_path == IPHOTO_PATH:
|
||||
if self.iphoto_libpath is None:
|
||||
return []
|
||||
is_ref = self.get_state(from_path) == directories.DirectoryState.Reference
|
||||
photos = get_iphoto_pictures(self.iphoto_libpath)
|
||||
for photo in photos:
|
||||
photo.is_ref = is_ref
|
||||
return photos
|
||||
else:
|
||||
return directories.Directories._get_files(self, from_path, j)
|
||||
|
||||
@staticmethod
|
||||
def get_subfolders(path):
|
||||
if path == IPHOTO_PATH:
|
||||
return []
|
||||
else:
|
||||
return directories.Directories.get_subfolders(path)
|
||||
|
||||
def add_path(self, path):
|
||||
if path == IPHOTO_PATH:
|
||||
if path not in self:
|
||||
self._dirs.append(path)
|
||||
else:
|
||||
directories.Directories.add_path(self, path)
|
||||
|
||||
def has_iphoto_path(self):
|
||||
return any(path == IPHOTO_PATH for path in self._dirs)
|
||||
|
||||
def has_any_file(self):
|
||||
# If we don't do that, it causes a hangup in the GUI when we click Start Scanning because
|
||||
# checking if there's any file to scan involves reading the whole library. If we have the
|
||||
# iPhoto library, we assume we have at least one file.
|
||||
if self.has_iphoto_path():
|
||||
return True
|
||||
else:
|
||||
return directories.Directories.has_any_file(self)
|
||||
|
||||
|
||||
class DupeGuruPE(DupeGuruBase):
|
||||
def __init__(self, view, appdata):
|
||||
appdata = op.join(appdata, 'dupeGuru Picture Edition')
|
||||
DupeGuruBase.__init__(self, view, appdata)
|
||||
self.directories = Directories()
|
||||
|
||||
def _do_delete(self, j, replace_with_hardlinks):
|
||||
def op(dupe):
|
||||
j.add_progress()
|
||||
return self._do_delete_dupe(dupe, replace_with_hardlinks)
|
||||
|
||||
marked = [dupe for dupe in self.results.dupes if self.results.is_marked(dupe)]
|
||||
j.start_job(self.results.mark_count, tr("Sending dupes to the Trash"))
|
||||
if any(isinstance(dupe, IPhoto) for dupe in marked):
|
||||
j.add_progress(0, desc=tr("Talking to iPhoto. Don't touch it!"))
|
||||
try:
|
||||
a = app('iPhoto')
|
||||
a.activate(timeout=0)
|
||||
a.select(a.photo_library_album(timeout=0), timeout=0)
|
||||
except (CommandError, RuntimeError, ApplicationNotFoundError):
|
||||
pass
|
||||
self.results.perform_on_marked(op, True)
|
||||
|
||||
def _do_delete_dupe(self, dupe, replace_with_hardlinks):
|
||||
if isinstance(dupe, IPhoto):
|
||||
try:
|
||||
a = app('iPhoto')
|
||||
[photo] = a.photo_library_album().photos[its.image_path == str(dupe.path)]()
|
||||
a.remove(photo, timeout=0)
|
||||
except ValueError:
|
||||
msg = "Could not find photo '{}' in iPhoto Library".format(str(dupe.path))
|
||||
raise EnvironmentError(msg)
|
||||
except (CommandError, RuntimeError) as e:
|
||||
raise EnvironmentError(str(e))
|
||||
else:
|
||||
DupeGuruBase._do_delete_dupe(self, dupe, replace_with_hardlinks)
|
||||
|
||||
def _create_file(self, path):
|
||||
if (self.directories.iphoto_libpath is not None) and (path in self.directories.iphoto_libpath[:-1]):
|
||||
return IPhoto(path)
|
||||
return DupeGuruBase._create_file(self, path)
|
||||
|
||||
def copy_or_move(self, dupe, copy, destination, dest_type):
|
||||
if isinstance(dupe, IPhoto):
|
||||
copy = True
|
||||
return DupeGuruBase.copy_or_move(self, dupe, copy, destination, dest_type)
|
||||
|
||||
def selected_dupe_path(self):
|
||||
if not self.selected_dupes:
|
||||
return None
|
||||
return self.selected_dupes[0].path
|
||||
|
||||
def selected_dupe_ref_path(self):
|
||||
if not self.selected_dupes:
|
||||
return None
|
||||
ref = self.results.get_group_of_duplicate(self.selected_dupes[0]).ref
|
||||
if ref is self.selected_dupes[0]: # we don't want the same pic to be displayed on both sides
|
||||
return None
|
||||
return ref.path
|
||||
|
||||
def start_scanning(self):
|
||||
result = DupeGuruBase.start_scanning(self)
|
||||
if self.directories.has_iphoto_path():
|
||||
try:
|
||||
app('iPhoto')
|
||||
except ApplicationNotFoundError:
|
||||
return 4
|
||||
return result
|
||||
|
||||
73
cocoa/inter/app_se.py
Normal file
73
cocoa/inter/app_se.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-05-24
|
||||
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "BSD" 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/bsd_license
|
||||
|
||||
import logging
|
||||
import os.path as op
|
||||
|
||||
from hscommon import io
|
||||
from hscommon.path import Path
|
||||
from hscommon.cocoa.objcmin import NSWorkspace
|
||||
|
||||
from core import fs
|
||||
from core.directories import Directories as DirectoriesBase, DirectoryState
|
||||
from core_se.app import DupeGuru as DupeGuruBase
|
||||
|
||||
def is_bundle(str_path):
|
||||
sw = NSWorkspace.sharedWorkspace()
|
||||
uti, error = sw.typeOfFile_error_(str_path, None)
|
||||
if error is not None:
|
||||
logging.warning('There was an error trying to detect the UTI of %s', str_path)
|
||||
return sw.type_conformsToType_(uti, 'com.apple.bundle') or sw.type_conformsToType_(uti, 'com.apple.package')
|
||||
|
||||
class Bundle(fs.Folder):
|
||||
@classmethod
|
||||
def can_handle(cls, path):
|
||||
return not io.islink(path) and io.isdir(path) and is_bundle(str(path))
|
||||
|
||||
|
||||
class Directories(DirectoriesBase):
|
||||
ROOT_PATH_TO_EXCLUDE = list(map(Path, ['/Library', '/Volumes', '/System', '/bin', '/sbin', '/opt', '/private', '/dev']))
|
||||
HOME_PATH_TO_EXCLUDE = [Path('Library')]
|
||||
def __init__(self):
|
||||
DirectoriesBase.__init__(self, fileclasses=[Bundle, fs.File])
|
||||
|
||||
def _default_state_for_path(self, path):
|
||||
result = DirectoriesBase._default_state_for_path(self, path)
|
||||
if result is not None:
|
||||
return result
|
||||
if path in self.ROOT_PATH_TO_EXCLUDE:
|
||||
return DirectoryState.Excluded
|
||||
if path[:2] == Path('/Users') and path[3:] in self.HOME_PATH_TO_EXCLUDE:
|
||||
return DirectoryState.Excluded
|
||||
|
||||
def _get_folders(self, from_folder, j):
|
||||
# We don't want to scan bundle's subfolder even in Folders mode. Bundle's integrity has to
|
||||
# stay intact.
|
||||
if is_bundle(str(from_folder.path)):
|
||||
# just yield the current folder and bail
|
||||
state = self.get_state(from_folder.path)
|
||||
if state != DirectoryState.Excluded:
|
||||
from_folder.is_ref = state == DirectoryState.Reference
|
||||
yield from_folder
|
||||
return
|
||||
else:
|
||||
for folder in DirectoriesBase._get_folders(self, from_folder, j):
|
||||
yield folder
|
||||
|
||||
@staticmethod
|
||||
def get_subfolders(path):
|
||||
result = DirectoriesBase.get_subfolders(path)
|
||||
return [p for p in result if not is_bundle(str(p))]
|
||||
|
||||
|
||||
class DupeGuru(DupeGuruBase):
|
||||
def __init__(self, view, appdata):
|
||||
appdata = op.join(appdata, 'dupeGuru')
|
||||
DupeGuruBase.__init__(self, view, appdata)
|
||||
self.directories = Directories()
|
||||
|
||||
13
cocoa/inter/details_panel.py
Normal file
13
cocoa/inter/details_panel.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from hscommon.cocoa.inter import signature, PyGUIObject
|
||||
|
||||
from core.gui.details_panel import DetailsPanel
|
||||
|
||||
class PyDetailsPanel(PyGUIObject):
|
||||
py_class = DetailsPanel
|
||||
@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)]
|
||||
14
cocoa/inter/directory_outline.py
Normal file
14
cocoa/inter/directory_outline.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from hscommon.cocoa.inter import PyOutline
|
||||
|
||||
from core.gui.directory_tree import DirectoryTree
|
||||
|
||||
class PyDirectoryOutline(PyOutline):
|
||||
py_class = DirectoryTree
|
||||
|
||||
def addDirectory_(self, path):
|
||||
self.py.add_directory(path)
|
||||
|
||||
# python --> cocoa
|
||||
def refresh_states(self):
|
||||
# Under cocoa, both refresh() and refresh_states() do the same thing.
|
||||
self.cocoa.refresh()
|
||||
25
cocoa/inter/extra_fairware_reminder.py
Normal file
25
cocoa/inter/extra_fairware_reminder.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from hscommon.cocoa.inter import PyGUIObject
|
||||
|
||||
from core.gui.extra_fairware_reminder import ExtraFairwareReminder
|
||||
|
||||
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)
|
||||
31
cocoa/inter/prioritize_dialog.py
Normal file
31
cocoa/inter/prioritize_dialog.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from hscommon.cocoa.inter import PyGUIObject, PySelectableList
|
||||
|
||||
from core.gui.prioritize_dialog import PrioritizeDialog
|
||||
from .prioritize_list import PyPrioritizeList
|
||||
|
||||
class PyPrioritizeDialog(PyGUIObject):
|
||||
py_class = PrioritizeDialog
|
||||
|
||||
def categoryList(self):
|
||||
if not hasattr(self, '_categoryList'):
|
||||
self._categoryList = PySelectableList.alloc().initWithPy_(self.py.category_list)
|
||||
return self._categoryList
|
||||
|
||||
def criteriaList(self):
|
||||
if not hasattr(self, '_criteriaList'):
|
||||
self._criteriaList = PySelectableList.alloc().initWithPy_(self.py.criteria_list)
|
||||
return self._criteriaList
|
||||
|
||||
def prioritizationList(self):
|
||||
if not hasattr(self, '_prioritizationList'):
|
||||
self._prioritizationList = PyPrioritizeList.alloc().initWithPy_(self.py.prioritization_list)
|
||||
return self._prioritizationList
|
||||
|
||||
def addSelected(self):
|
||||
self.py.add_selected()
|
||||
|
||||
def removeSelected(self):
|
||||
self.py.remove_selected()
|
||||
|
||||
def performReprioritization(self):
|
||||
self.py.perform_reprioritization()
|
||||
7
cocoa/inter/prioritize_list.py
Normal file
7
cocoa/inter/prioritize_list.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from hscommon.cocoa.inter import signature, PySelectableList
|
||||
|
||||
class PyPrioritizeList(PySelectableList):
|
||||
@signature('v@:@i')
|
||||
def moveIndexes_toIndex_(self, indexes, dest_index):
|
||||
self.py.move_indexes(indexes, dest_index)
|
||||
|
||||
10
cocoa/inter/problem_dialog.py
Normal file
10
cocoa/inter/problem_dialog.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from hscommon.cocoa.inter import PyGUIObject
|
||||
|
||||
from core.gui.problem_dialog import ProblemDialog
|
||||
|
||||
class PyProblemDialog(PyGUIObject):
|
||||
py_class = ProblemDialog
|
||||
|
||||
def revealSelected(self):
|
||||
self.py.reveal_selected_dupe()
|
||||
|
||||
6
cocoa/inter/problem_table.py
Normal file
6
cocoa/inter/problem_table.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from hscommon.cocoa.inter import PyTable
|
||||
|
||||
from core.gui.problem_table import ProblemTable
|
||||
|
||||
class PyProblemTable(PyTable):
|
||||
py_class = ProblemTable
|
||||
49
cocoa/inter/result_table.py
Normal file
49
cocoa/inter/result_table.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from hscommon.cocoa.inter import signature, PyTable
|
||||
|
||||
from core.gui.result_table import ResultTable
|
||||
|
||||
class PyResultTable(PyTable):
|
||||
py_class = ResultTable
|
||||
|
||||
@signature('c@:')
|
||||
def powerMarkerMode(self):
|
||||
return self.py.power_marker
|
||||
|
||||
@signature('v@:c')
|
||||
def setPowerMarkerMode_(self, value):
|
||||
self.py.power_marker = value
|
||||
|
||||
@signature('c@:')
|
||||
def deltaValuesMode(self):
|
||||
return self.py.delta_values
|
||||
|
||||
@signature('v@:c')
|
||||
def setDeltaValuesMode_(self, value):
|
||||
self.py.delta_values = value
|
||||
|
||||
@signature('@@:ii')
|
||||
def valueForRow_column_(self, row_index, column):
|
||||
return self.py.get_row_value(row_index, column)
|
||||
|
||||
@signature('c@:@')
|
||||
def renameSelected_(self, newname):
|
||||
return self.py.rename_selected(newname)
|
||||
|
||||
@signature('v@:ic')
|
||||
def sortBy_ascending_(self, key, asc):
|
||||
self.py.sort(key, asc)
|
||||
|
||||
def markSelected(self):
|
||||
self.py.app.toggle_selected_mark_state()
|
||||
|
||||
def removeSelected(self):
|
||||
self.py.app.remove_selected()
|
||||
|
||||
@signature('i@:')
|
||||
def selectedDupeCount(self):
|
||||
return self.py.selected_dupe_count
|
||||
|
||||
# python --> cocoa
|
||||
def invalidate_markings(self):
|
||||
self.cocoa.invalidateMarkings()
|
||||
|
||||
9
cocoa/inter/stats_label.py
Normal file
9
cocoa/inter/stats_label.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from hscommon.cocoa.inter import PyGUIObject
|
||||
|
||||
from core.gui.stats_label import StatsLabel
|
||||
|
||||
class PyStatsLabel(PyGUIObject):
|
||||
py_class = StatsLabel
|
||||
|
||||
def display(self):
|
||||
return self.py.display
|
||||
Reference in New Issue
Block a user