Revision: 28162
http://sourceforge.net/p/bibdesk/svn/28162
Author: hofman
Date: 2023-01-03 15:44:00 +0000 (Tue, 03 Jan 2023)
Log Message:
-----------
Use owr own format type popup in export accessory view. The working of the
systemn generated one is opaque and unreliable, and it is not available anymore
in 13.1.
Modified Paths:
--------------
trunk/bibdesk/BDSKSaveAccessoryViewController.h
trunk/bibdesk/BDSKSaveAccessoryViewController.m
trunk/bibdesk/Base.lproj/BDSKSaveAccessoryView.xib
trunk/bibdesk/BibDocument.m
Modified: trunk/bibdesk/BDSKSaveAccessoryViewController.h
===================================================================
--- trunk/bibdesk/BDSKSaveAccessoryViewController.h 2023-01-03 07:30:19 UTC
(rev 28161)
+++ trunk/bibdesk/BDSKSaveAccessoryViewController.h 2023-01-03 15:44:00 UTC
(rev 28162)
@@ -41,18 +41,22 @@
@class BDSKEncodingPopUpButton;
@interface BDSKSaveAccessoryViewController : NSViewController {
+ NSPopUpButton *formatTypePopupButton;
BDSKEncodingPopUpButton *saveTextEncodingPopupButton;
NSButton *exportSelectionCheckButton;
NSTextField *formatLabelField;
NSTextField *encodingLabelField;
- NSString *lastSelectedFileType;
+ NSSavePanel *savePanel;
}
+@property (nonatomic, assign) IBOutlet NSPopUpButton *formatTypePopupButton;
@property (nonatomic, assign) IBOutlet BDSKEncodingPopUpButton
*saveTextEncodingPopupButton;
@property (nonatomic, assign) IBOutlet NSButton *exportSelectionCheckButton;
@property (nonatomic, assign) IBOutlet NSTextField *formatLabelField;
@property (nonatomic, assign) IBOutlet NSTextField *encodingLabelField;
+@property (nonatomic, retain) NSSavePanel *savePanel;
+
@property (nonatomic, readonly) NSView *saveAccessoryView;
@property (nonatomic, readonly) NSView *exportAccessoryView;
@@ -62,6 +66,6 @@
@property (nonatomic) BOOL exportSelection;
@property (nonatomic, getter=isSaveTextEncodingPopupButtonEnabled) BOOL
saveTextEncodingPopupButtonEnabled;
@property (nonatomic, getter=isExportSelectionCheckButtonEnabled) BOOL
exportSelectionCheckButtonEnabled;
-@property (nonatomic, retain) NSString *lastSelectedFileType;
+@property (nonatomic, readonly) NSString *selectedFileType;
@end
Modified: trunk/bibdesk/BDSKSaveAccessoryViewController.m
===================================================================
--- trunk/bibdesk/BDSKSaveAccessoryViewController.m 2023-01-03 07:30:19 UTC
(rev 28161)
+++ trunk/bibdesk/BDSKSaveAccessoryViewController.m 2023-01-03 15:44:00 UTC
(rev 28162)
@@ -43,8 +43,8 @@
@implementation BDSKSaveAccessoryViewController
-@synthesize saveTextEncodingPopupButton, exportSelectionCheckButton,
formatLabelField, encodingLabelField, lastSelectedFileType;
-@dynamic saveAccessoryView, exportAccessoryView, saveTextEncoding,
exportSelection,saveTextEncodingPopupButtonEnabled,
exportSelectionCheckButtonEnabled;
+@synthesize formatTypePopupButton, saveTextEncodingPopupButton,
exportSelectionCheckButton, formatLabelField, encodingLabelField, savePanel;
+@dynamic saveAccessoryView, exportAccessoryView, selectedFileType,
saveTextEncoding, exportSelection,saveTextEncodingPopupButtonEnabled,
exportSelectionCheckButtonEnabled;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle
*)nibBundleOrNil {
self = [super initWithNibName:@"BDSKSaveAccessoryView" bundle:nil];
@@ -56,13 +56,15 @@
}
- (void)dealloc {
- BDSKDESTROY(lastSelectedFileType);
+ BDSKDESTROY(savePanel);
[super dealloc];
}
- (NSView *)saveAccessoryView {
+ [formatTypePopupButton removeFromSuperview];
[formatLabelField removeFromSuperview];
[exportSelectionCheckButton removeFromSuperview];
+ formatTypePopupButton = nil;
formatLabelField = nil;
exportSelectionCheckButton = nil;
[[self view] layoutSubtreeIfNeeded];
@@ -87,6 +89,10 @@
[[self view] addConstraints:constraints];
}
+- (NSString *)selectedFileType {
+ return [[[self formatTypePopupButton] selectedItem] representedObject];
+}
+
- (NSStringEncoding)saveTextEncoding {
return [saveTextEncodingPopupButton encoding];
}
Modified: trunk/bibdesk/Base.lproj/BDSKSaveAccessoryView.xib
===================================================================
--- trunk/bibdesk/Base.lproj/BDSKSaveAccessoryView.xib 2023-01-03 07:30:19 UTC
(rev 28161)
+++ trunk/bibdesk/Base.lproj/BDSKSaveAccessoryView.xib 2023-01-03 15:44:00 UTC
(rev 28162)
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0"
toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"
useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0"
toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"
useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
- <development version="8000" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin"
version="17701"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin"
version="19529"/>
<capability name="documents saved in the Xcode 8 format"
minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -12,6 +11,7 @@
<outlet property="encodingLabelField" destination="8"
id="y0n-9r-dQh"/>
<outlet property="exportSelectionCheckButton" destination="5"
id="19"/>
<outlet property="formatLabelField" destination="4"
id="LkC-bK-HOb"/>
+ <outlet property="formatTypePopupButton"
destination="j5x-qN-HPY" id="fGE-ep-Dd8"/>
<outlet property="saveTextEncodingPopupButton" destination="9"
id="18"/>
<outlet property="view" destination="hAe-OQ-cVU"
id="Jv3-a0-enC"/>
</connections>
@@ -63,6 +63,14 @@
<accessibilityConnection property="title"
destination="8" id="14"/>
</connections>
</popUpButton>
+ <popUpButton verticalHuggingPriority="750"
translatesAutoresizingMaskIntoConstraints="NO" id="j5x-qN-HPY">
+ <rect key="frame" x="107" y="62" width="39"
height="25"/>
+ <popUpButtonCell key="cell" type="push"
bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail"
borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2"
id="9kH-i8-WIj">
+ <behavior key="behavior"
lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="menu"/>
+ <menu key="menu" id="nxf-HF-rf1"/>
+ </popUpButtonCell>
+ </popUpButton>
</subviews>
<constraints>
<constraint firstItem="9" firstAttribute="leading"
secondItem="5" secondAttribute="leading" id="0sd-Av-nta"/>
@@ -78,10 +86,13 @@
<constraint firstItem="8" firstAttribute="baseline"
secondItem="9" secondAttribute="baseline" id="XXD-Bi-vnd"/>
<constraint firstItem="4" firstAttribute="leading"
relation="greaterThanOrEqual" secondItem="3" secondAttribute="leading"
constant="12" id="Y9p-3q-Q5j"/>
<constraint firstItem="9" firstAttribute="baseline"
secondItem="8" secondAttribute="firstBaseline" id="Ylt-gD-h9y"/>
+ <constraint firstItem="9" firstAttribute="leading"
secondItem="j5x-qN-HPY" secondAttribute="leading" id="bMi-Eq-uAP"/>
+ <constraint firstItem="9" firstAttribute="trailing"
secondItem="j5x-qN-HPY" secondAttribute="trailing" id="dHf-n6-cft"/>
<constraint firstItem="5" firstAttribute="top"
secondItem="9" secondAttribute="bottom" constant="8" symbolic="YES"
id="ej9-tL-12o"/>
<constraint firstItem="8" firstAttribute="centerY"
secondItem="9" secondAttribute="centerY" id="kW7-Jt-IcP"/>
<constraint firstAttribute="trailing"
relation="greaterThanOrEqual" secondItem="5" secondAttribute="trailing"
constant="12" id="pSX-Jm-CMH"/>
<constraint firstAttribute="bottom" secondItem="5"
secondAttribute="bottom" constant="12" id="tha-eZ-Hze"/>
+ <constraint firstItem="j5x-qN-HPY"
firstAttribute="centerY" secondItem="4" secondAttribute="centerY"
id="vR1-yn-FIf"/>
<constraint firstAttribute="trailing" secondItem="5"
secondAttribute="trailing" priority="249" constant="12" id="vnf-k0-mpV"/>
<constraint firstItem="4" firstAttribute="top"
secondItem="3" secondAttribute="top" constant="12" id="xL6-M2-9lM"/>
<constraint firstItem="9" firstAttribute="top"
relation="greaterThanOrEqual" secondItem="3" secondAttribute="top"
constant="12" id="yfz-Dn-RPO"/>
Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2023-01-03 07:30:19 UTC (rev 28161)
+++ trunk/bibdesk/BibDocument.m 2023-01-03 15:44:00 UTC (rev 28162)
@@ -180,11 +180,6 @@
return saveOperation == NSSaveToOperation;
}
-@interface NSDocument (BDSKPrivateExtensions)
-// declare a private NSDocument method so we can override it
-- (void)changeSaveType:(id)sender;
-@end
-
@interface BibDocument ()
@property (nonatomic, retain) NSString *basePath;
@end
@@ -1061,14 +1056,14 @@
return nil;
}
-- (void)fallbackChangeSaveType:(id)sender{
- NSString *type = [[sender selectedItem] representedObject];
- [(NSSavePanel *)[sender window] setAllowedFileTypes:[NSArray
arrayWithObjects:[self fileNameExtensionForType:type
saveOperation:NSSaveToOperation], nil]];
- [saveAccessoryController setLastSelectedFileType:type];
+- (void)changeExportType:(id)sender {
+ NSString *type = [saveAccessoryController selectedFileType];
+ [[saveAccessoryController savePanel] setAllowedFileTypes:[NSArray
arrayWithObjects:[self fileNameExtensionForType:type
saveOperation:NSSaveToOperation], nil]];
+ [saveAccessoryController setSaveTextEncodingPopupButtonEnabled:[self
needsEncodingForType:type]];
}
- (NSString *)fileTypeFromLastRunSavePanel {
- return [saveAccessoryController lastSelectedFileType] ?: [super
fileTypeFromLastRunSavePanel];
+ return [saveAccessoryController selectedFileType] ?: [super
fileTypeFromLastRunSavePanel];
}
// if the user is saving in one of our plain text formats, give them an
encoding option as well
@@ -1081,27 +1076,18 @@
saveAccessoryController = [[BDSKSaveAccessoryViewController alloc] init];
if(docFlags.isExporting){
- NSPopUpButton *saveFormatPopupButton = popUpButtonSubview([savePanel
accessoryView]);
- BOOL createPopup = saveFormatPopupButton == nil;
- if (createPopup) {
- saveFormatPopupButton = [[NSPopUpButton alloc] init];
- NSDocumentController *docController = [NSDocumentController
sharedDocumentController];
- for (NSString *type in [self
writableTypesForSaveOperation:NSSaveToOperation]) {
- [saveFormatPopupButton addItemWithTitle:[docController
displayNameForType:type]];
- [[saveFormatPopupButton lastItem] setRepresentedObject:type];
- }
- [saveFormatPopupButton selectItemAtIndex:0];
- [saveFormatPopupButton setAction:@selector(changeSaveType:)];
- [saveFormatPopupButton setTarget:self];
+ NSPopUpButton *saveFormatPopupButton = [saveAccessoryController
formatTypePopupButton];
+ NSDocumentController *docController = [NSDocumentController
sharedDocumentController];
+ for (NSString *type in [self
writableTypesForSaveOperation:NSSaveToOperation]) {
+ [saveFormatPopupButton addItemWithTitle:[docController
displayNameForType:type]];
+ [[saveFormatPopupButton lastItem] setRepresentedObject:type];
}
- [saveAccessoryController
addSaveFormatPopUpButton:saveFormatPopupButton];
+ [saveFormatPopupButton selectItemAtIndex:0];
+ [saveFormatPopupButton setAction:@selector(changeExportType:)];
+ [saveFormatPopupButton setTarget:self];
[savePanel setAccessoryView:[saveAccessoryController
exportAccessoryView]];
- if (createPopup) {
- if ([NSDocument
instancesRespondToSelector:@selector(changeSaveType:)])
- [super changeSaveType:saveFormatPopupButton];
- else
- [self fallbackChangeSaveType:saveFormatPopupButton];
- }
+ [saveAccessoryController setSavePanel:savePanel];
+ [self changeExportType:saveFormatPopupButton];
}else{
[savePanel setAccessoryView:[saveAccessoryController
saveAccessoryView]];
}
@@ -1121,15 +1107,6 @@
return [[NSSet setWithObjects:BDSKBibTeXDocumentType, BDSKRISDocumentType,
BDSKMinimalBibTeXDocumentType, BDSKLTBDocumentType, BDSKArchiveDocumentType,
nil] containsObject:typeName];
}
-// this is a private method, the action of the file format poup
-- (void)changeSaveType:(id)sender{
- if ([NSDocument instancesRespondToSelector:@selector(changeSaveType:)])
- [super changeSaveType:sender];
- else
- [self fallbackChangeSaveType:sender];
- [saveAccessoryController setSaveTextEncodingPopupButtonEnabled:[self
needsEncodingForType:[self fileTypeFromLastRunSavePanel]]];
-}
-
- (NSArray *)publicationsForSaving {
if (docFlags.isExporting == NO || [saveAccessoryController
exportSelection] == NO)
return publications;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit