Converted ME's preference panel to xibless and thus completed its transition to waf-based building.

--HG--
branch : xibless
rename : cocoa/se/ui/preferences_panel.py => cocoa/base/ui/preferences_panel.py
This commit is contained in:
Virgil Dupras 2012-07-28 19:07:37 -04:00
parent 903ecd9eae
commit cb35dc7897
8 changed files with 124 additions and 3633 deletions

View File

@ -19,7 +19,7 @@ from setuptools import setup, Extension
from hscommon import sphinxgen
from hscommon.build import (add_to_pythonpath, print_and_do, copy_packages, filereplace,
get_module_version, move_all, copy_sysconfig_files_for_embed, copy_all, move,
get_module_version, move_all, copy_sysconfig_files_for_embed, copy_all, move, copy,
create_osx_app_structure)
from hscommon import loc
@ -32,8 +32,8 @@ def parse_args():
help="Build only the help file")
parser.add_option('--loc', action='store_true', dest='loc',
help="Build only localization")
parser.add_option('--cocoamod', action='store_true', dest='cocoamod',
help="Build only Cocoa modules")
parser.add_option('--cocoa-compile', action='store_true', dest='cocoa_compile',
help="Build only Cocoa modules and executables")
parser.add_option('--xibless', action='store_true', dest='xibless',
help="Build only xibless UIs")
parser.add_option('--updatepot', action='store_true', dest='updatepot',
@ -43,6 +43,16 @@ def parse_args():
(options, args) = parser.parse_args()
return options
def cocoa_compile_command(edition):
return '{0} waf configure --edition {1} && {0} waf'.format(sys.executable, edition)
def cocoa_app_path(edition):
return {
'se': 'build/dupeGuru.app',
'me': 'build/dupeGuru ME.app',
'pe': 'build/dupeGuru PE.app',
}[edition]
def build_xibless(edition):
import xibless
if not op.exists('cocoa/autogen'):
@ -60,14 +70,12 @@ def build_xibless(edition):
xibless.generate('cocoa/base/ui/prioritize_dialog.py', 'cocoa/autogen/PrioritizeDialog_UI', localizationTable='Localizable')
xibless.generate('cocoa/base/ui/result_window.py', 'cocoa/autogen/ResultWindow_UI', localizationTable='Localizable')
xibless.generate('cocoa/base/ui/main_menu.py', 'cocoa/autogen/MainMenu_UI', localizationTable='Localizable')
xibless.generate('cocoa/base/ui/preferences_panel.py', 'cocoa/autogen/PreferencesPanel_UI',
localizationTable='Localizable', args={'edition': edition})
if edition == 'pe':
xibless.generate('cocoa/pe/ui/details_panel.py', 'cocoa/autogen/DetailsPanel_UI', localizationTable='Localizable')
else:
xibless.generate('cocoa/base/ui/details_panel.py', 'cocoa/autogen/DetailsPanel_UI', localizationTable='Localizable')
if edition == 'se':
xibless.generate('cocoa/se/ui/preferences_panel.py', 'cocoa/autogen/PreferencesPanel_UI', localizationTable='Localizable')
if edition == 'me':
xibless.generate('cocoa/se/ui/preferences_panel.py', 'cocoa/autogen/PreferencesPanel_UI', localizationTable='Localizable')
def build_cocoa(edition, dev):
ed = lambda s: s.format(edition)
@ -102,18 +110,14 @@ def build_cocoa(edition, dev):
filereplace('InfoTemplate.plist', 'Info.plist', version=app_version)
print("Compiling with WAF")
os.chdir('..')
os.system('{0} waf configure --edition {1} && {0} waf'.format(sys.executable, edition))
os.system(cocoa_compile_command(edition))
os.chdir('..')
print("Creating the .app folder")
image_path = ed('cocoa/{}/dupeguru.icns')
resources = [image_path, 'cocoa/base/dsa_pub.pem', 'build/dg_cocoa.py',
'build/py', 'build/help'] + glob.glob('cocoa/base/*.lproj')
frameworks = ['build/Python', 'cocoalib/Sparkle.framework']
app_path = {
'se': 'build/dupeGuru.app',
'me': 'build/dupeGuru ME.app',
'pe': 'build/dupeGuru PE.app',
}[edition]
app_path = cocoa_app_path(edition)
create_osx_app_structure(app_path, 'cocoa/build/dupeGuru', ed('cocoa/{}/Info.plist'),
resources, frameworks, symlink_resources=dev)
print("Creating the run.py file")
@ -308,9 +312,13 @@ def main():
build_updatepot()
elif options.mergepot:
build_mergepot()
elif options.cocoamod:
elif options.cocoa_compile:
build_cocoa_proxy_module()
build_cocoa_bridging_interfaces(edition)
os.chdir('cocoa')
os.system(cocoa_compile_command(edition))
os.chdir('..')
copy('cocoa/build/dupeGuru', op.join(cocoa_app_path(edition), 'Contents/MacOS/dupeGuru'))
elif options.xibless:
build_xibless(edition)
else:

View File

@ -124,6 +124,19 @@
"Folders" = "Folders";
"Font size:" = "Font size:";
"dupeGuru ME Preferences" = "dupeGuru ME Preferences";
"Filename - Fields" = "Filename - Fields";
"Tags" = "Tags";
"Audio Content" = "Audio Content";
"Filename - Fields (No Order)" = "Filename - Fields (No Order)";
"Tags to scan:" = "Tags to scan:";
"Track" = "Track";
"Artist" = "Artist";
"Album" = "Album";
"Title" = "Title";
"Genre" = "Genre";
"Year" = "Year";
/* Main Menu */
"Bring All to Front" = "Bring All to Front";
"Window" = "Window";

View File

@ -15,6 +15,8 @@ helpMenu = result.addMenu("Help")
appMenu.addItem("About dupeGuru", Action(owner, 'showAboutBox'))
appMenu.addItem("Check for update...", Action(owner.updater, 'checkForUpdates:'))
appMenu.addSeparator()
appMenu.addItem("Preferences...", Action(owner, 'showPreferencesPanel'), 'cmd+,')
appMenu.addSeparator()
NSApp.servicesMenu = appMenu.addMenu("Services")
appMenu.addSeparator()
appMenu.addItem("Hide dupeGuru", Action(NSApp, 'hide:'), 'cmd+h')

View File

@ -1,8 +1,25 @@
result = Window(410, 345, "dupeGuru Preferences")
edition = args.get('edition', 'se')
dialogTitles = {
'se': "dupeGuru Preferences",
'me': "dupeGuru ME Preferences",
'pe': "dupeGuru PE Preferences",
}
dialogHeights = {
'se': 345,
'me': 365,
'pe': 270,
}
scanTypeNames = {
'se': ["Filename", "Content", "Folders"],
'me': ["Filename", "Filename - Fields", "Filename - Fields (No Order)", "Tags", "Content", "Audio Content"],
'pe': ["Contents", "EXIF Timestamp"],
}
result = Window(410, dialogHeights[edition], dialogTitles[edition])
tabView = TabView(result)
basicTab = tabView.addTab("Basic")
advancedTab = tabView.addTab("Advanced")
scanTypePopup = Popup(basicTab.view, ["Filename", "Content", "Folders"])
scanTypePopup = Popup(basicTab.view, scanTypeNames[edition])
scanTypeLabel = Label(basicTab.view, "Scan Type:")
thresholdSlider = Slider(basicTab.view, 1, 100, 80)
# XXX add a number formatter to this
@ -16,10 +33,20 @@ wordWeightingBox = Checkbox(basicTab.view, "Word weighting")
matchSimilarWordsBox = Checkbox(basicTab.view, "Match similar words")
mixKindBox = Checkbox(basicTab.view, "Can mix file kind")
removeEmptyFoldersBox = Checkbox(basicTab.view, "Remove empty folders on delete or move")
ignoreSmallFilesBox = Checkbox(basicTab.view, "Ignore files smaller than:")
smallFilesThresholdText = TextField(basicTab.view, "")
smallFilesThresholdSuffixLabel = Label(basicTab.view, "KB")
checkForUpdatesBox = Checkbox(basicTab.view, "Automatically check for updates")
if edition == 'se':
ignoreSmallFilesBox = Checkbox(basicTab.view, "Ignore files smaller than:")
smallFilesThresholdText = TextField(basicTab.view, "")
smallFilesThresholdSuffixLabel = Label(basicTab.view, "KB")
elif edition == 'me':
tagsToScanLabel = Label(basicTab.view, "Tags to scan:")
trackBox = Checkbox(basicTab.view, "Track")
artistBox = Checkbox(basicTab.view, "Artist")
albumBox = Checkbox(basicTab.view, "Album")
titleBox = Checkbox(basicTab.view, "Title")
genreBox = Checkbox(basicTab.view, "Genre")
yearBox = Checkbox(basicTab.view, "Year")
tagBoxes = [trackBox, artistBox, albumBox, titleBox, genreBox, yearBox]
regexpCheckbox = Checkbox(advancedTab.view, "Use regular expressions when filtering")
ignoreHardlinksBox = Checkbox(advancedTab.view, "Ignore duplicates hardlinking to the same file")
@ -39,8 +66,6 @@ wordWeightingBox.bind('value', defaults, 'values.wordWeighting')
matchSimilarWordsBox.bind('value', defaults, 'values.matchSimilarWords')
mixKindBox.bind('value', defaults, 'values.mixFileKind')
removeEmptyFoldersBox.bind('value', defaults, 'values.removeEmptyFolders')
ignoreSmallFilesBox.bind('value', defaults, 'values.ignoreSmallFiles')
smallFilesThresholdText.bind('value', defaults, 'values.smallFileThreshold')
checkForUpdatesBox.bind('value', defaults, 'values.SUEnableAutomaticChecks')
regexpCheckbox.bind('value', defaults, 'values.useRegexpFilter')
ignoreHardlinksBox.bind('value', defaults, 'values.ignoreHardlinkMatches')
@ -50,17 +75,34 @@ copyMovePopup.bind('selectedIndex', defaults, 'values.recreatePathType')
disableWhenContentScan = [thresholdSlider, wordWeightingBox, matchSimilarWordsBox]
for control in disableWhenContentScan:
control.bind('enabled', defaults, 'values.scanType', valueTransformer='vtScanTypeIsNotContent')
if edition == 'se':
ignoreSmallFilesBox.bind('value', defaults, 'values.ignoreSmallFiles')
smallFilesThresholdText.bind('value', defaults, 'values.smallFileThreshold')
elif edition == 'me':
for box in tagBoxes:
box.bind('enabled', defaults, 'values.scanType', valueTransformer='vtScanTypeIsTag')
trackBox.bind('value', defaults, 'values.scanTagTrack')
artistBox.bind('value', defaults, 'values.scanTagArtist')
albumBox.bind('value', defaults, 'values.scanTagAlbum')
titleBox.bind('value', defaults, 'values.scanTagTitle')
genreBox.bind('value', defaults, 'values.scanTagGenre')
yearBox.bind('value', defaults, 'values.scanTagYear')
result.canResize = False
result.canMinimize = False
allLabels = [scanTypeLabel, thresholdValuelabel, moreResultsLabel, fewerResultsLabel,
thresholdLabel, fontSizeLabel, smallFilesThresholdSuffixLabel, customCommandLabel,
copyMoveLabel]
thresholdLabel, fontSizeLabel, customCommandLabel, copyMoveLabel]
allCheckboxes = [wordWeightingBox, matchSimilarWordsBox, mixKindBox, removeEmptyFoldersBox,
checkForUpdatesBox, regexpCheckbox, ignoreHardlinksBox, debugModeCheckbox]
if edition == 'se':
allLabels += [smallFilesThresholdSuffixLabel]
allCheckboxes += [ignoreSmallFilesBox]
elif edition == 'me':
allLabels += [tagsToScanLabel]
allCheckboxes += tagBoxes
for label in allLabels:
label.controlSize = ControlSize.Small
fewerResultsLabel.alignment = TextAlignment.Right
allCheckboxes = [wordWeightingBox, matchSimilarWordsBox, mixKindBox, removeEmptyFoldersBox,
ignoreSmallFilesBox, checkForUpdatesBox, regexpCheckbox, ignoreHardlinksBox, debugModeCheckbox]
for checkbox in allCheckboxes:
checkbox.font = scanTypeLabel.font
resetToDefaultsButton.action = Action(defaults, 'revertToInitialValues:')
@ -69,8 +111,12 @@ scanTypeLabel.width = thresholdLabel.width = fontSizeLabel.width = 94
fontSizeCombo.width = 66
thresholdValuelabel.width = 25
resetToDefaultsButton.width = 136
smallFilesThresholdText.width = 60
smallFilesThresholdSuffixLabel.width = 40
if edition == 'se':
smallFilesThresholdText.width = 60
smallFilesThresholdSuffixLabel.width = 40
elif edition == 'me':
for box in tagBoxes:
box.width = 70
tabView.packToCorner(Pack.UpperLeft)
tabView.fill(Pack.Right)
@ -92,17 +138,37 @@ thresholdLabel.packRelativeTo(thresholdSlider, Pack.Left)
fontSizeCombo.packRelativeTo(moreResultsLabel, Pack.Below)
fontSizeLabel.packRelativeTo(fontSizeCombo, Pack.Left)
checkboxLayout = VLayout([wordWeightingBox, matchSimilarWordsBox, mixKindBox, removeEmptyFoldersBox,
ignoreSmallFilesBox])
checkboxLayout.packRelativeTo(fontSizeCombo, Pack.Below)
if edition == 'me':
tagsToScanLabel.packRelativeTo(fontSizeCombo, Pack.Below)
tagsToScanLabel.fill(Pack.Left)
tagsToScanLabel.fill(Pack.Right)
trackBox.packRelativeTo(tagsToScanLabel, Pack.Below)
trackBox.x += 10
artistBox.packRelativeTo(trackBox, Pack.Right)
albumBox.packRelativeTo(artistBox, Pack.Right)
titleBox.packRelativeTo(trackBox, Pack.Below)
genreBox.packRelativeTo(titleBox, Pack.Right)
yearBox.packRelativeTo(genreBox, Pack.Right)
viewToPackCheckboxesUnder = titleBox
else:
viewToPackCheckboxesUnder = fontSizeCombo
checkboxesToLayout = [wordWeightingBox, matchSimilarWordsBox, mixKindBox, removeEmptyFoldersBox]
if edition == 'se':
checkboxesToLayout.append(ignoreSmallFilesBox)
else:
checkboxesToLayout.append(checkForUpdatesBox)
checkboxLayout = VLayout(checkboxesToLayout)
checkboxLayout.packRelativeTo(viewToPackCheckboxesUnder, Pack.Below)
checkboxLayout.fill(Pack.Left)
checkboxLayout.fill(Pack.Right)
smallFilesThresholdText.packRelativeTo(ignoreSmallFilesBox, Pack.Below, margin=4)
checkForUpdatesBox.packRelativeTo(smallFilesThresholdText, Pack.Below, margin=4)
checkForUpdatesBox.fill(Pack.Right)
smallFilesThresholdText.x += 20
smallFilesThresholdSuffixLabel.packRelativeTo(smallFilesThresholdText, Pack.Right)
if edition == 'se':
smallFilesThresholdText.packRelativeTo(ignoreSmallFilesBox, Pack.Below, margin=4)
checkForUpdatesBox.packRelativeTo(smallFilesThresholdText, Pack.Below, margin=4)
checkForUpdatesBox.fill(Pack.Right)
smallFilesThresholdText.x += 20
smallFilesThresholdSuffixLabel.packRelativeTo(smallFilesThresholdText, Pack.Right)
advancedLayout = VLayout(advancedTab.view.subviews[:])
advancedLayout.packToCorner(Pack.UpperLeft)

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:dupeguru.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,105 +0,0 @@
/* Class = "NSWindow"; title = "dupeGuru ME Preferences"; ObjectID = "2"; */
"2.title" = "dupeGuru ME Preferences";
/* Class = "NSTextFieldCell"; title = "More results"; ObjectID = "29"; */
"29.title" = "More results";
/* Class = "NSTextFieldCell"; title = "Fewer results"; ObjectID = "30"; */
"30.title" = "Fewer results";
/* Class = "NSTextFieldCell"; title = "Filter hardness:"; ObjectID = "31"; */
"31.title" = "Filter hardness:";
/* Class = "NSTextFieldCell"; title = "Scan type:"; ObjectID = "32"; */
"32.title" = "Scan type:";
/* Class = "NSMenuItem"; title = "Content"; ObjectID = "35"; */
"35.title" = "Content";
/* Class = "NSMenuItem"; title = "Filename"; ObjectID = "36"; */
"36.title" = "Filename";
/* Class = "NSMenuItem"; title = "Filename - Fields"; ObjectID = "37"; */
"37.title" = "Filename - Fields";
/* Class = "NSMenuItem"; title = "Tags"; ObjectID = "38"; */
"38.title" = "Tags";
/* Class = "NSMenuItem"; title = "Audio Content"; ObjectID = "39"; */
"39.title" = "Audio Content";
/* Class = "NSMenuItem"; title = "Filename - Fields (No Order)"; ObjectID = "40"; */
"40.title" = "Filename - Fields (No Order)";
/* Class = "NSButtonCell"; title = "Word weighting"; ObjectID = "41"; */
"41.title" = "Word weighting";
/* Class = "NSButtonCell"; title = "Can mix file kind"; ObjectID = "42"; */
"42.title" = "Can mix file kind";
/* Class = "NSButtonCell"; title = "Reset to Defaults"; ObjectID = "45"; */
"45.title" = "Reset to Defaults";
/* Class = "NSButtonCell"; title = "Match similar words"; ObjectID = "46"; */
"46.title" = "Match similar words";
/* Class = "NSTextFieldCell"; title = "Copy and Move:"; ObjectID = "54"; */
"54.title" = "Copy and Move:";
/* Class = "NSMenuItem"; title = "Recreate relative path"; ObjectID = "57"; */
"57.title" = "Recreate relative path";
/* Class = "NSMenuItem"; title = "Recreate absolute path"; ObjectID = "58"; */
"58.title" = "Recreate absolute path";
/* Class = "NSMenuItem"; title = "Right in destination"; ObjectID = "59"; */
"59.title" = "Right in destination";
/* Class = "NSButtonCell"; title = "Automatically check for updates"; ObjectID = "60"; */
"60.title" = "Automatically check for updates";
/* Class = "NSButtonCell"; title = "Use regular expressions when filtering"; ObjectID = "61"; */
"61.title" = "Use regular expressions when filtering";
/* Class = "NSButtonCell"; title = "Remove empty folders after delete and move"; ObjectID = "62"; */
"62.title" = "Remove empty folders after delete and move";
/* Class = "NSTextFieldCell"; title = "Tags to scan:"; ObjectID = "63"; */
"63.title" = "Tags to scan:";
/* Class = "NSButtonCell"; title = "Track"; ObjectID = "64"; */
"64.title" = "Track";
/* Class = "NSButtonCell"; title = "Artist"; ObjectID = "65"; */
"65.title" = "Artist";
/* Class = "NSButtonCell"; title = "Album"; ObjectID = "66"; */
"66.title" = "Album";
/* Class = "NSButtonCell"; title = "Title"; ObjectID = "67"; */
"67.title" = "Title";
/* Class = "NSButtonCell"; title = "Genre"; ObjectID = "68"; */
"68.title" = "Genre";
/* Class = "NSButtonCell"; title = "Year"; ObjectID = "69"; */
"69.title" = "Year";
/* Class = "NSTabViewItem"; label = "Basic"; ObjectID = "116"; */
"116.label" = "Basic";
/* Class = "NSTabViewItem"; label = "Advanced"; ObjectID = "117"; */
"117.label" = "Advanced";
/* Class = "NSTextFieldCell"; title = "Custom Command (arguments: %d for dupe, %r for ref):"; ObjectID = "121"; */
"121.title" = "Custom Command (arguments: %d for dupe, %r for ref):";
/* Class = "NSButtonCell"; title = "Ignore duplicates hardlinking to the same file"; ObjectID = "126"; */
"126.title" = "Ignore duplicates hardlinking to the same file";
/* Class = "NSButtonCell"; title = "Debug mode (restart required)"; ObjectID = "130"; */
"130.title" = "Debug mode (restart required)";
/* Class = "NSTextFieldCell"; title = "Font size:"; ObjectID = "136"; */
"136.title" = "Font size:";

File diff suppressed because it is too large Load Diff