1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-10-31 22:05:58 +00:00

Converted stats_label to objp.

--HG--
branch : objp
This commit is contained in:
Virgil Dupras 2012-01-11 15:14:59 -05:00
parent a7eeb7db89
commit 0c7d73854d
10 changed files with 82 additions and 30 deletions

View File

@ -14,6 +14,7 @@ build
dist dist
install install
installer_tmp-cache installer_tmp-cache
cocoa/autogen
cocoa/*/Info.plist cocoa/*/Info.plist
cocoa/*/build cocoa/*/build
cocoa/*/*.app cocoa/*/*.app

View File

@ -17,7 +17,7 @@ from setuptools import setup, Extension
from hscommon import sphinxgen from hscommon import sphinxgen
from hscommon.build import (add_to_pythonpath, print_and_do, copy_packages, filereplace, from hscommon.build import (add_to_pythonpath, print_and_do, copy_packages, filereplace,
get_module_version, build_all_cocoa_locs, move_all, copy_sysconfig_files_for_embed) get_module_version, build_all_cocoa_locs, move_all, copy_sysconfig_files_for_embed, copy_all)
from hscommon import loc from hscommon import loc
def parse_args(): def parse_args():
@ -38,6 +38,7 @@ def parse_args():
def build_cocoa(edition, dev): def build_cocoa(edition, dev):
build_cocoa_proxy_module() build_cocoa_proxy_module()
build_cocoa_bridging_interfaces()
print("Building dg_cocoa.plugin") print("Building dg_cocoa.plugin")
specific_packages = { specific_packages = {
'se': ['core_se'], 'se': ['core_se'],
@ -56,6 +57,8 @@ def build_cocoa(edition, dev):
os.mkdir('build/py') os.mkdir('build/py')
sys.path.insert(0, 'build') sys.path.insert(0, 'build')
collect_dependencies('build/dg_cocoa.py', 'build/py', excludes=['PyQt4']) collect_dependencies('build/dg_cocoa.py', 'build/py', excludes=['PyQt4'])
# Views are not referenced by python code, so they're not found by the collector.
copy_all('build/inter/*.so', 'build/py/inter')
del sys.path[0] del sys.path[0]
copy_sysconfig_files_for_embed('build/py') copy_sysconfig_files_for_embed('build/py')
os.chdir(cocoa_project_path) os.chdir(cocoa_project_path)
@ -170,6 +173,25 @@ def build_cocoa_proxy_module():
) )
move_all('CocoaProxy*', 'cocoalib/cocoa') move_all('CocoaProxy*', 'cocoalib/cocoa')
def build_cocoa_bridging_interfaces():
print("Building Cocoa Bridging Interfaces")
import objp.o2p
import objp.p2o
add_to_pythonpath('cocoa')
add_to_pythonpath('cocoalib')
from inter.stats_label import PyStatsLabel
objp.o2p.generate_objc_code(PyStatsLabel, 'cocoa/autogen')
objp.p2o.generate_python_proxy_code('cocoa/base/bridge/StatsLabelView.h', 'build/StatsLabelView.m')
exts = [
Extension("StatsLabelView", ['build/StatsLabelView.m', 'build/ObjP.m'],
extra_link_args=["-framework", "Foundation"]),
]
setup(
script_args = ['build_ext', '--inplace'],
ext_modules = exts,
)
move_all('StatsLabelView*', 'cocoa/inter')
def build_pe_modules(ui): def build_pe_modules(ui):
print("Building PE Modules") print("Building PE Modules")
exts = [ exts = [

View File

@ -1,14 +0,0 @@
/*
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 <Cocoa/Cocoa.h>
#import "PyGUI.h"
@interface PyStatsLabel : PyGUI
- (NSString *)display;
@end

View File

@ -25,7 +25,7 @@ http://www.hardcoded.net/licenses/bsd_license
/* Put a cute iTunes-like bottom bar */ /* Put a cute iTunes-like bottom bar */
[[self window] setContentBorderThickness:28 forEdge:NSMinYEdge]; [[self window] setContentBorderThickness:28 forEdge:NSMinYEdge];
table = [[ResultTable alloc] initWithPy:[py resultTable] view:matches]; table = [[ResultTable alloc] initWithPy:[py resultTable] view:matches];
statsLabel = [[StatsLabel alloc] initWithPy:[py statsLabel] labelView:stats]; statsLabel = [[StatsLabel alloc] initWithLabelView:stats];
problemDialog = [[ProblemDialog alloc] initWithPy:py]; problemDialog = [[ProblemDialog alloc] initWithPy:py];
[self initResultColumns]; [self initResultColumns];
[self fillColumnsMenu]; [self fillColumnsMenu];

View File

@ -7,11 +7,13 @@ http://www.hardcoded.net/licenses/bsd_license
*/ */
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "HSGUIController.h"
#import "PyStatsLabel.h" #import "PyStatsLabel.h"
@interface StatsLabel : HSGUIController {} @interface StatsLabel : NSObject {
- (id)initWithPy:(id)aPy labelView:(NSTextField *)aLabelView; PyStatsLabel *py;
NSTextField *view;
}
- (id)initWithLabelView:(NSTextField *)aLabelView;
- (PyStatsLabel *)py; - (PyStatsLabel *)py;
- (NSTextField *)labelView; - (NSTextField *)labelView;
@end @end

View File

@ -6,20 +6,31 @@ which should be included with this package. The terms are also available at
http://www.hardcoded.net/licenses/bsd_license http://www.hardcoded.net/licenses/bsd_license
*/ */
#import <Python.h>
#import "StatsLabel.h" #import "StatsLabel.h"
#import "Utils.h" #import "ObjP.h"
@implementation StatsLabel @implementation StatsLabel
- (id)initWithPy:(id)aPy labelView:(NSTextField *)aLabelView - (id)initWithLabelView:(NSTextField *)aLabelView
{ {
self = [super initWithPy:aPy view:aLabelView]; self = [self init];
[self connect]; view = [aLabelView retain];
PyGILState_STATE gilState = PyGILState_Ensure();
PyObject *pModule = PyImport_AddModule("__main__");
PyObject *pAppInstance = PyObject_GetAttrString(pModule, "APP_INSTANCE");
PyObject *pStatsLabel = PyObject_GetAttrString(pAppInstance, "stats_label");
PyObject *pCallback = ObjP_classInstanceWithRef(@"StatsLabelView", @"inter.StatsLabelView", self);
py = [[PyStatsLabel alloc] initWithModel:pStatsLabel Callback:pCallback];
PyGILState_Release(gilState);
[[self py] connect];
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[self disconnect]; [[self py] disconnect];
[py release];
[view release];
[super dealloc]; [super dealloc];
} }
@ -30,7 +41,7 @@ http://www.hardcoded.net/licenses/bsd_license
- (NSTextField *)labelView - (NSTextField *)labelView
{ {
return (NSTextField *)[self view]; return (NSTextField *)view;
} }
/* Python --> Cocoa */ /* Python --> Cocoa */

View File

@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>
@protocol StatsLabelView <NSObject>
- (void)refresh;
@end

View File

@ -1,5 +1,6 @@
from cocoa.inter import PyGUIObject from cocoa.inter2 import PyGUIObject
class PyStatsLabel(PyGUIObject): class PyStatsLabel(PyGUIObject):
def display(self):
return self.py.display def display(self) -> str:
return self.model.display

View File

@ -22,10 +22,15 @@ from inter.result_table import PyResultTable
from inter.stats_label import PyStatsLabel from inter.stats_label import PyStatsLabel
from inter.app_se import DupeGuru from inter.app_se import DupeGuru
# XXX temporary hack
APP_INSTANCE = None
class PyDupeGuru(PyDupeGuruBase): class PyDupeGuru(PyDupeGuruBase):
def init(self): def init(self):
self = super(PyDupeGuru,self).init() self = super(PyDupeGuru,self).init()
self._init(DupeGuru) self._init(DupeGuru)
global APP_INSTANCE
APP_INSTANCE = self.py
return self return self
#---Properties #---Properties

View File

@ -14,6 +14,8 @@
CE18004F14BDD854001B6329 /* Python in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE18004C14BDD837001B6329 /* Python */; }; CE18004F14BDD854001B6329 /* Python in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE18004C14BDD837001B6329 /* Python */; };
CE18005114BDD87B001B6329 /* py in Resources */ = {isa = PBXBuildFile; fileRef = CE18005014BDD87B001B6329 /* py */; }; CE18005114BDD87B001B6329 /* py in Resources */ = {isa = PBXBuildFile; fileRef = CE18005014BDD87B001B6329 /* py */; };
CE19BC6411199231007CCEB0 /* progress.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE19BC6111199231007CCEB0 /* progress.xib */; }; CE19BC6411199231007CCEB0 /* progress.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE19BC6111199231007CCEB0 /* progress.xib */; };
CE1D091814BE0C6400CA6B8C /* ObjP.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1D091514BE0C6400CA6B8C /* ObjP.m */; };
CE1D091914BE0C6400CA6B8C /* PyStatsLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1D091714BE0C6400CA6B8C /* PyStatsLabel.m */; };
CE27D3C412CCA43800859E67 /* HSAboutBox.m in Sources */ = {isa = PBXBuildFile; fileRef = CE27D3C312CCA43800859E67 /* HSAboutBox.m */; }; CE27D3C412CCA43800859E67 /* HSAboutBox.m in Sources */ = {isa = PBXBuildFile; fileRef = CE27D3C312CCA43800859E67 /* HSAboutBox.m */; };
CE31819D13D85D9B00B6D649 /* about.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE31819913D85D9B00B6D649 /* about.xib */; }; CE31819D13D85D9B00B6D649 /* about.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE31819913D85D9B00B6D649 /* about.xib */; };
CE31819E13D85D9B00B6D649 /* ErrorReportWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE31819B13D85D9B00B6D649 /* ErrorReportWindow.xib */; }; CE31819E13D85D9B00B6D649 /* ErrorReportWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE31819B13D85D9B00B6D649 /* ErrorReportWindow.xib */; };
@ -123,6 +125,10 @@
CE18004C14BDD837001B6329 /* Python */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = Python; path = ../../build/Python; sourceTree = "<group>"; }; CE18004C14BDD837001B6329 /* Python */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = Python; path = ../../build/Python; sourceTree = "<group>"; };
CE18005014BDD87B001B6329 /* py */ = {isa = PBXFileReference; lastKnownFileType = folder; name = py; path = ../../build/py; sourceTree = "<group>"; }; CE18005014BDD87B001B6329 /* py */ = {isa = PBXFileReference; lastKnownFileType = folder; name = py; path = ../../build/py; sourceTree = "<group>"; };
CE19BC6111199231007CCEB0 /* progress.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = progress.xib; sourceTree = "<group>"; }; CE19BC6111199231007CCEB0 /* progress.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = progress.xib; sourceTree = "<group>"; };
CE1D091414BE0C6400CA6B8C /* ObjP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjP.h; sourceTree = "<group>"; };
CE1D091514BE0C6400CA6B8C /* ObjP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjP.m; sourceTree = "<group>"; };
CE1D091614BE0C6400CA6B8C /* PyStatsLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PyStatsLabel.h; sourceTree = "<group>"; };
CE1D091714BE0C6400CA6B8C /* PyStatsLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PyStatsLabel.m; sourceTree = "<group>"; };
CE27D3C212CCA43800859E67 /* HSAboutBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HSAboutBox.h; path = ../../cocoalib/HSAboutBox.h; sourceTree = SOURCE_ROOT; }; CE27D3C212CCA43800859E67 /* HSAboutBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HSAboutBox.h; path = ../../cocoalib/HSAboutBox.h; sourceTree = SOURCE_ROOT; };
CE27D3C312CCA43800859E67 /* HSAboutBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSAboutBox.m; path = ../../cocoalib/HSAboutBox.m; sourceTree = SOURCE_ROOT; }; CE27D3C312CCA43800859E67 /* HSAboutBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSAboutBox.m; path = ../../cocoalib/HSAboutBox.m; sourceTree = SOURCE_ROOT; };
CE31819A13D85D9B00B6D649 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = ../en.lproj/about.xib; sourceTree = "<group>"; }; CE31819A13D85D9B00B6D649 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = ../en.lproj/about.xib; sourceTree = "<group>"; };
@ -214,7 +220,6 @@
CE89240914239CC30024CE4E /* PyPrioritizeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyPrioritizeList.h; path = ../base/PyPrioritizeList.h; sourceTree = "<group>"; }; CE89240914239CC30024CE4E /* PyPrioritizeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyPrioritizeList.h; path = ../base/PyPrioritizeList.h; sourceTree = "<group>"; };
CE8C53B61173248F0011B41F /* PyTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PyTable.h; sourceTree = "<group>"; }; CE8C53B61173248F0011B41F /* PyTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PyTable.h; sourceTree = "<group>"; };
CE8C53BB117324CE0011B41F /* HSTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HSTable.m; sourceTree = "<group>"; }; CE8C53BB117324CE0011B41F /* HSTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HSTable.m; sourceTree = "<group>"; };
CE91F210113BC22D0010360B /* PyStatsLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyStatsLabel.h; path = ../base/PyStatsLabel.h; sourceTree = SOURCE_ROOT; };
CE91F213113BC22D0010360B /* StatsLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StatsLabel.h; path = ../base/StatsLabel.h; sourceTree = SOURCE_ROOT; }; CE91F213113BC22D0010360B /* StatsLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StatsLabel.h; path = ../base/StatsLabel.h; sourceTree = SOURCE_ROOT; };
CE91F214113BC22D0010360B /* StatsLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StatsLabel.m; path = ../base/StatsLabel.m; sourceTree = SOURCE_ROOT; }; CE91F214113BC22D0010360B /* StatsLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StatsLabel.m; path = ../base/StatsLabel.m; sourceTree = SOURCE_ROOT; };
CE9777CB141F8C2500C13FB5 /* PrioritizeDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PrioritizeDialog.h; path = ../base/PrioritizeDialog.h; sourceTree = "<group>"; }; CE9777CB141F8C2500C13FB5 /* PrioritizeDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PrioritizeDialog.h; path = ../base/PrioritizeDialog.h; sourceTree = "<group>"; };
@ -384,6 +389,18 @@
path = ../../cocoalib/xib; path = ../../cocoalib/xib;
sourceTree = SOURCE_ROOT; sourceTree = SOURCE_ROOT;
}; };
CE1D091314BE0C6400CA6B8C /* autogen */ = {
isa = PBXGroup;
children = (
CE1D091414BE0C6400CA6B8C /* ObjP.h */,
CE1D091514BE0C6400CA6B8C /* ObjP.m */,
CE1D091614BE0C6400CA6B8C /* PyStatsLabel.h */,
CE1D091714BE0C6400CA6B8C /* PyStatsLabel.m */,
);
name = autogen;
path = ../autogen;
sourceTree = "<group>";
};
CE76FDBD111EE37C006618EA /* views */ = { CE76FDBD111EE37C006618EA /* views */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -495,10 +512,10 @@
CEFC7FB00FC9518F00CD5728 /* dgbase */ = { CEFC7FB00FC9518F00CD5728 /* dgbase */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
CE1D091314BE0C6400CA6B8C /* autogen */,
CE6DD4E4124CA3070089A48D /* PyResultTable.h */, CE6DD4E4124CA3070089A48D /* PyResultTable.h */,
CE6DD4E5124CA3070089A48D /* ResultTable.h */, CE6DD4E5124CA3070089A48D /* ResultTable.h */,
CE6DD4E6124CA3070089A48D /* ResultTable.m */, CE6DD4E6124CA3070089A48D /* ResultTable.m */,
CE91F210113BC22D0010360B /* PyStatsLabel.h */,
CE91F213113BC22D0010360B /* StatsLabel.h */, CE91F213113BC22D0010360B /* StatsLabel.h */,
CE91F214113BC22D0010360B /* StatsLabel.m */, CE91F214113BC22D0010360B /* StatsLabel.m */,
CE76FDD1111EE3A7006618EA /* DirectoryOutline.h */, CE76FDD1111EE3A7006618EA /* DirectoryOutline.h */,
@ -658,6 +675,8 @@
CE89240A14239CC30024CE4E /* PrioritizeList.m in Sources */, CE89240A14239CC30024CE4E /* PrioritizeList.m in Sources */,
CE5335FC142BBFAF008E5374 /* HSQuicklook.m in Sources */, CE5335FC142BBFAF008E5374 /* HSQuicklook.m in Sources */,
CE54A87E148046F9008EEA77 /* HSColumns.m in Sources */, CE54A87E148046F9008EEA77 /* HSColumns.m in Sources */,
CE1D091814BE0C6400CA6B8C /* ObjP.m in Sources */,
CE1D091914BE0C6400CA6B8C /* PyStatsLabel.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };