mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
Localized Fairware dialogs to french and made a few fixes here and there.
This commit is contained in:
28
core/app.py
28
core/app.py
@@ -18,7 +18,7 @@ from hscommon.reg import RegistrableApplication
|
||||
from hscommon.notify import Broadcaster
|
||||
from hscommon.path import Path
|
||||
from hscommon.conflict import smart_move, smart_copy
|
||||
from hscommon.util import delete_if_empty, first, escape
|
||||
from hscommon.util import delete_if_empty, first, escape, nonone
|
||||
from hscommon.trans import tr
|
||||
|
||||
from . import directories, results, scanner, export, fs
|
||||
@@ -29,6 +29,8 @@ JOB_MOVE = 'job_move'
|
||||
JOB_COPY = 'job_copy'
|
||||
JOB_DELETE = 'job_delete'
|
||||
|
||||
HAD_FIRST_LAUNCH_PREFERENCE = 'HadFirstLaunch'
|
||||
|
||||
class NoScannableFileError(Exception):
|
||||
pass
|
||||
|
||||
@@ -36,6 +38,9 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
def __init__(self, data_module, appdata):
|
||||
RegistrableApplication.__init__(self, appid=1)
|
||||
Broadcaster.__init__(self)
|
||||
self.is_first_run = not self.get_default(HAD_FIRST_LAUNCH_PREFERENCE, False)
|
||||
if self.is_first_run:
|
||||
self.set_default(HAD_FIRST_LAUNCH_PREFERENCE, True)
|
||||
self.appdata = appdata
|
||||
if not op.exists(self.appdata):
|
||||
os.makedirs(self.appdata)
|
||||
@@ -50,6 +55,7 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
}
|
||||
self.selected_dupes = []
|
||||
|
||||
#--- Private
|
||||
def _do_delete(self, j, replace_with_hardlinks):
|
||||
def op(dupe):
|
||||
j.add_progress()
|
||||
@@ -129,6 +135,13 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
# func(j, *args)
|
||||
raise NotImplementedError()
|
||||
|
||||
def _get_default(self, key_name, fallback_value=None):
|
||||
raise NotImplementedError()
|
||||
|
||||
def _set_default(self, key_name, value):
|
||||
raise NotImplementedError()
|
||||
|
||||
#--- Public
|
||||
def add_directory(self, d):
|
||||
try:
|
||||
self.directories.add_path(Path(d))
|
||||
@@ -350,6 +363,19 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
def without_ref(self, dupes):
|
||||
return [dupe for dupe in dupes if self.results.get_group_of_duplicate(dupe).ref is not dupe]
|
||||
|
||||
def get_default(self, key, fallback_value=None):
|
||||
result = nonone(self._get_default(key), fallback_value)
|
||||
if fallback_value is not None and not isinstance(result, type(fallback_value)):
|
||||
# we don't want to end up with garbage values from the prefs
|
||||
try:
|
||||
result = type(fallback_value)(result)
|
||||
except Exception:
|
||||
result = fallback_value
|
||||
return result
|
||||
|
||||
def set_default(self, key, value):
|
||||
self._set_default(key, value)
|
||||
|
||||
#--- Properties
|
||||
@property
|
||||
def stat_line(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ import os.path as op
|
||||
|
||||
from jobprogress import job
|
||||
from hscommon import cocoa
|
||||
from hscommon.cocoa import install_exception_hook
|
||||
from hscommon.cocoa import install_exception_hook, pythonify
|
||||
from hscommon.cocoa.objcmin import (NSNotificationCenter, NSUserDefaults,
|
||||
NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSUserDomainMask,
|
||||
NSWorkspace)
|
||||
@@ -29,7 +29,7 @@ JOBID2TITLE = {
|
||||
|
||||
class DupeGuru(app.DupeGuru):
|
||||
def __init__(self, data_module, appdata_subdir):
|
||||
LOGGING_LEVEL = logging.DEBUG if NSUserDefaults.standardUserDefaults().boolForKey_('debug') else logging.WARNING
|
||||
LOGGING_LEVEL = logging.DEBUG if self.get_default('debug') else logging.WARNING
|
||||
logging.basicConfig(level=LOGGING_LEVEL, format='%(levelname)s %(message)s')
|
||||
logging.debug('started in debug mode')
|
||||
install_exception_hook()
|
||||
@@ -58,7 +58,15 @@ class DupeGuru(app.DupeGuru):
|
||||
ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid}
|
||||
NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud)
|
||||
|
||||
#---Public
|
||||
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)
|
||||
|
||||
#--- Public
|
||||
def start_scanning(self):
|
||||
self._select_dupes([])
|
||||
try:
|
||||
|
||||
@@ -18,10 +18,6 @@ from .gui.problem_table import ProblemTable
|
||||
from .gui.result_table import ResultTable
|
||||
from .gui.stats_label import StatsLabel
|
||||
|
||||
# Fix py2app's problems on relative imports
|
||||
from core import app, app_cocoa, data, directories, engine, export, ignore, results, fs, scanner
|
||||
from hscommon import conflict
|
||||
|
||||
class PyDupeGuruBase(PyFairware):
|
||||
#---Directories
|
||||
def addDirectory_(self, directory):
|
||||
|
||||
Reference in New Issue
Block a user