1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-23 07:01:39 +00:00

Modernized progress window GUI

Following the refactoring that has been initiated in pdfmasher's
"vala" branch, I pushed more progress window logic into the
core.

The UI code is now a bit dumber than it used to be, and the core
now directly decides when the progress window is shown and
hidden. The "job finished" notification is also directly sent by the
core. Job description update logic is handled by a core gui
textfield.

Job description contsants also moved to the core, triggering
a localisation migration from "ui" to "core".
This commit is contained in:
Virgil Dupras
2013-08-03 16:27:36 -04:00
parent 8e15d89a2e
commit e5ce6680ca
33 changed files with 615 additions and 727 deletions

View File

@@ -16,19 +16,14 @@ from .CocoaProxy import CocoaProxy
proxy = CocoaProxy()
try:
from jobprogress.performer import ThreadedJobPerformer as ThreadedJobPerformerBase
class ThreadedJobPerformer(ThreadedJobPerformerBase):
def _async_run(self, *args):
proxy.createPool()
try:
ThreadedJobPerformerBase._async_run(self, *args)
finally:
proxy.destroyPool()
except ImportError:
# jobprogress isn't used in all HS apps
pass
def autoreleasepool(func):
def wrapper(*args, **kwargs):
proxy.createPool()
try:
func(*args, **kwargs)
finally:
proxy.destroyPool()
return wrapper
def as_fetch(as_list, as_type, step_size=1000):
"""When fetching items from a very big list through applescript, the connection with the app
@@ -113,3 +108,10 @@ class CocoaHandler(logging.Handler):
def install_cocoa_logger():
logging.getLogger().addHandler(CocoaHandler())
def patch_threaded_job_performer():
# _async_run, under cocoa, has to be run within an autorelease pool to prevent leaks.
# You only need this patch is you use one of CocoaProxy's function (which allocate objc
# structures) inside a threaded job.
from jobprogress.performer import ThreadedJobPerformer
ThreadedJobPerformer._async_run = autoreleasepool(ThreadedJobPerformer._async_run)

View File

@@ -17,10 +17,12 @@ http://www.hardcoded.net/licenses/bsd_license
NSInteger progress;
HSTextField *jobdescTextField;
HSTextField *progressdescTextField;
NSWindow *parentWindow;
}
- (id)initWithPyRef:(PyObject *)aPyRef view:(NSView *)aView;
- (PyProgressWindow *)model;
- (void)setParentWindow:(NSWindow *)aParentWindow;
- (void)setProgress:(NSInteger)aProgress;
- (void)showWindow;

View File

@@ -17,6 +17,7 @@ http://www.hardcoded.net/licenses/bsd_license
[[ProgressController mainProgressController] setWorker:self];
jobdescTextField = [[HSTextField alloc] initWithPyRef:[[self model] jobdescTextField] view:[[ProgressController mainProgressController] descText]];
progressdescTextField = [[HSTextField alloc] initWithPyRef:[[self model] progressdescTextField] view:[[ProgressController mainProgressController] statusText]];
parentWindow = nil;
return self;
}
@@ -26,6 +27,11 @@ http://www.hardcoded.net/licenses/bsd_license
}
/* Public */
- (void)setParentWindow:(NSWindow *)aParentWindow
{
parentWindow = aParentWindow;
}
- (void)setProgress:(NSInteger)aProgress
{
progress = aProgress;
@@ -33,7 +39,12 @@ http://www.hardcoded.net/licenses/bsd_license
- (void)showWindow
{
[[ProgressController mainProgressController] show];
if (parentWindow != nil) {
[[ProgressController mainProgressController] showSheetForParent:parentWindow];
}
else {
[[ProgressController mainProgressController] show];
}
}
- (void)closeWindow