Open the right part of the system preferences for global shortcuts on Mavericks.
This commit is contained in:
parent
bc3a80e1b7
commit
4ed6f94211
|
@ -1297,6 +1297,7 @@ if (APPLE)
|
||||||
/System/Library/Frameworks/DiskArbitration.framework
|
/System/Library/Frameworks/DiskArbitration.framework
|
||||||
/System/Library/Frameworks/Foundation.framework
|
/System/Library/Frameworks/Foundation.framework
|
||||||
/System/Library/Frameworks/IOKit.framework
|
/System/Library/Frameworks/IOKit.framework
|
||||||
|
/System/Library/Frameworks/ScriptingBridge.framework
|
||||||
)
|
)
|
||||||
target_link_libraries(clementine_lib ${SPMEDIAKEYTAP_LIBRARIES})
|
target_link_libraries(clementine_lib ${SPMEDIAKEYTAP_LIBRARIES})
|
||||||
if (HAVE_SPARKLE)
|
if (HAVE_SPARKLE)
|
||||||
|
|
|
@ -17,23 +17,27 @@
|
||||||
|
|
||||||
#include "macglobalshortcutbackend.h"
|
#include "macglobalshortcutbackend.h"
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "globalshortcuts.h"
|
|
||||||
#include "mac_startup.h"
|
|
||||||
#import "mac_utilities.h"
|
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
|
#include <AppKit/NSEvent.h>
|
||||||
|
#include <AppKit/NSWorkspace.h>
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <IOKit/hidsystem/ev_keymap.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include <AppKit/NSEvent.h>
|
#include "config.h"
|
||||||
#include <AppKit/NSWorkspace.h>
|
#include "core/globalshortcuts.h"
|
||||||
#include <Foundation/NSString.h>
|
#include "core/logging.h"
|
||||||
#include <IOKit/hidsystem/ev_keymap.h>
|
#include "core/mac_startup.h"
|
||||||
|
#include "core/utilities.h"
|
||||||
|
|
||||||
|
#import "core/mac_utilities.h"
|
||||||
|
#import "mac/SBSystemPreferences.h"
|
||||||
|
|
||||||
class MacGlobalShortcutBackendPrivate : boost::noncopyable {
|
class MacGlobalShortcutBackendPrivate : boost::noncopyable {
|
||||||
public:
|
public:
|
||||||
|
@ -134,10 +138,34 @@ void MacGlobalShortcutBackend::ShowAccessibilityDialog() {
|
||||||
NSArray* paths = NSSearchPathForDirectoriesInDomains(
|
NSArray* paths = NSSearchPathForDirectoriesInDomains(
|
||||||
NSPreferencePanesDirectory, NSSystemDomainMask, YES);
|
NSPreferencePanesDirectory, NSSystemDomainMask, YES);
|
||||||
if ([paths count] == 1) {
|
if ([paths count] == 1) {
|
||||||
NSURL* prefpane_url =
|
NSURL* prefpane_url = nil;
|
||||||
[NSURL fileURLWithPath:[[paths objectAtIndex:0]
|
if (Utilities::GetMacVersion() < 9) {
|
||||||
stringByAppendingPathComponent:
|
prefpane_url =
|
||||||
@"UniversalAccessPref.prefPane"]];
|
[NSURL fileURLWithPath:[[paths objectAtIndex:0]
|
||||||
[[NSWorkspace sharedWorkspace] openURL:prefpane_url];
|
stringByAppendingPathComponent:
|
||||||
|
@"UniversalAccessPref.prefPane"]];
|
||||||
|
[[NSWorkspace sharedWorkspace] openURL:prefpane_url];
|
||||||
|
} else {
|
||||||
|
SBSystemPreferencesApplication* system_prefs = [SBApplication
|
||||||
|
applicationWithBundleIdentifier:@"com.apple.systempreferences"];
|
||||||
|
[system_prefs activate];
|
||||||
|
|
||||||
|
SBElementArray* panes = [system_prefs panes];
|
||||||
|
SBSystemPreferencesPane* security_pane = nil;
|
||||||
|
for (SBSystemPreferencesPane* pane : panes) {
|
||||||
|
if ([[pane id] isEqualToString:@"com.apple.preference.security"]) {
|
||||||
|
security_pane = pane;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[system_prefs setCurrentPane:security_pane];
|
||||||
|
|
||||||
|
SBElementArray* anchors = [security_pane anchors];
|
||||||
|
for (SBSystemPreferencesAnchor* anchor : anchors) {
|
||||||
|
if ([[anchor name] isEqualToString:@"Privacy_Accessibility"]) {
|
||||||
|
[anchor reveal];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,171 @@
|
||||||
|
/*
|
||||||
|
* SBSystemPreferences.h
|
||||||
|
*
|
||||||
|
* Generated with:
|
||||||
|
* sdef "/Applications/System Preferences.app" | sdp -fh --basename
|
||||||
|
*SBSystemPreferences -o SBSystemPreferences.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <ScriptingBridge/ScriptingBridge.h>
|
||||||
|
|
||||||
|
@class SBSystemPreferencesApplication, SBSystemPreferencesDocument,
|
||||||
|
SBSystemPreferencesWindow, SBSystemPreferencesPane,
|
||||||
|
SBSystemPreferencesAnchor;
|
||||||
|
|
||||||
|
enum SBSystemPreferencesSaveOptions {
|
||||||
|
SBSystemPreferencesSaveOptionsYes = 'yes ' /* Save the file. */,
|
||||||
|
SBSystemPreferencesSaveOptionsNo = 'no ' /* Do not save the file. */,
|
||||||
|
SBSystemPreferencesSaveOptionsAsk =
|
||||||
|
'ask ' /* Ask the user whether or not to save the file. */
|
||||||
|
};
|
||||||
|
typedef enum SBSystemPreferencesSaveOptions SBSystemPreferencesSaveOptions;
|
||||||
|
|
||||||
|
enum SBSystemPreferencesPrintingErrorHandling {
|
||||||
|
SBSystemPreferencesPrintingErrorHandlingStandard =
|
||||||
|
'lwst' /* Standard PostScript error handling */,
|
||||||
|
SBSystemPreferencesPrintingErrorHandlingDetailed =
|
||||||
|
'lwdt' /* print a detailed report of PostScript errors */
|
||||||
|
};
|
||||||
|
typedef enum SBSystemPreferencesPrintingErrorHandling
|
||||||
|
SBSystemPreferencesPrintingErrorHandling;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Standard Suite
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The application's top-level scripting object.
|
||||||
|
@interface SBSystemPreferencesApplication : SBApplication
|
||||||
|
|
||||||
|
- (SBElementArray*)documents;
|
||||||
|
- (SBElementArray*)windows;
|
||||||
|
|
||||||
|
@property(copy, readonly) NSString* name; // The name of the application.
|
||||||
|
@property(readonly) BOOL frontmost; // Is this the active application?
|
||||||
|
@property(copy, readonly)
|
||||||
|
NSString* version; // The version number of the application.
|
||||||
|
|
||||||
|
- (id)open:(id)x; // Open a document.
|
||||||
|
- (void)print:(id)x
|
||||||
|
withProperties:(NSDictionary*)withProperties
|
||||||
|
printDialog:(BOOL)printDialog; // Print a document.
|
||||||
|
- (void)quitSaving:
|
||||||
|
(SBSystemPreferencesSaveOptions)saving; // Quit the application.
|
||||||
|
- (BOOL)exists:(id)x; // Verify that an object exists.
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
// A document.
|
||||||
|
@interface SBSystemPreferencesDocument : SBObject
|
||||||
|
|
||||||
|
@property(copy, readonly) NSString* name; // Its name.
|
||||||
|
@property(readonly) BOOL modified; // Has it been modified since the last save?
|
||||||
|
@property(copy, readonly) NSURL* file; // Its location on disk, if it has one.
|
||||||
|
|
||||||
|
- (void)closeSaving:(SBSystemPreferencesSaveOptions)saving
|
||||||
|
savingIn:(NSURL*)savingIn; // Close a document.
|
||||||
|
- (void)saveIn:(NSURL*)in_ as:(id)as; // Save a document.
|
||||||
|
- (void)printWithProperties:(NSDictionary*)withProperties
|
||||||
|
printDialog:(BOOL)printDialog; // Print a document.
|
||||||
|
- (void) delete; // Delete an object.
|
||||||
|
- (void)duplicateTo:(SBObject*)to
|
||||||
|
withProperties:(NSDictionary*)withProperties; // Copy an object.
|
||||||
|
- (void)moveTo:(SBObject*)to; // Move an object to a new location.
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
// A window.
|
||||||
|
@interface SBSystemPreferencesWindow : SBObject
|
||||||
|
|
||||||
|
@property(copy, readonly) NSString* name; // The title of the window.
|
||||||
|
- (NSInteger)id; // The unique identifier of the window.
|
||||||
|
@property NSInteger index; // The index of the window, ordered front to back.
|
||||||
|
@property NSRect bounds; // The bounding rectangle of the window.
|
||||||
|
@property(readonly) BOOL closeable; // Does the window have a close button?
|
||||||
|
@property(readonly)
|
||||||
|
BOOL miniaturizable; // Does the window have a minimize button?
|
||||||
|
@property BOOL miniaturized; // Is the window minimized right now?
|
||||||
|
@property(readonly) BOOL resizable; // Can the window be resized?
|
||||||
|
@property BOOL visible; // Is the window visible right now?
|
||||||
|
@property(readonly) BOOL zoomable; // Does the window have a zoom button?
|
||||||
|
@property BOOL zoomed; // Is the window zoomed right now?
|
||||||
|
@property(copy, readonly) SBSystemPreferencesDocument*
|
||||||
|
document; // The document whose contents are displayed in the window.
|
||||||
|
|
||||||
|
- (void)closeSaving:(SBSystemPreferencesSaveOptions)saving
|
||||||
|
savingIn:(NSURL*)savingIn; // Close a document.
|
||||||
|
- (void)saveIn:(NSURL*)in_ as:(id)as; // Save a document.
|
||||||
|
- (void)printWithProperties:(NSDictionary*)withProperties
|
||||||
|
printDialog:(BOOL)printDialog; // Print a document.
|
||||||
|
- (void) delete; // Delete an object.
|
||||||
|
- (void)duplicateTo:(SBObject*)to
|
||||||
|
withProperties:(NSDictionary*)withProperties; // Copy an object.
|
||||||
|
- (void)moveTo:(SBObject*)to; // Move an object to a new location.
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*
|
||||||
|
* System Preferences
|
||||||
|
*/
|
||||||
|
|
||||||
|
// System Preferences top level scripting object
|
||||||
|
@interface SBSystemPreferencesApplication (SystemPreferences)
|
||||||
|
|
||||||
|
- (SBElementArray*)panes;
|
||||||
|
|
||||||
|
@property(copy)
|
||||||
|
SBSystemPreferencesPane* currentPane; // the currently selected pane
|
||||||
|
@property(copy, readonly) SBSystemPreferencesWindow*
|
||||||
|
preferencesWindow; // the main preferences window
|
||||||
|
@property BOOL showAll; // Is SystemPrefs in show all view. (Setting to false
|
||||||
|
// will do nothing)
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
// a preference pane
|
||||||
|
@interface SBSystemPreferencesPane : SBObject
|
||||||
|
|
||||||
|
- (SBElementArray*)anchors;
|
||||||
|
|
||||||
|
- (NSString*)id; // locale independent name of the preference pane; can refer
|
||||||
|
// to a pane using the expression: pane id "<name>"
|
||||||
|
@property(copy, readonly)
|
||||||
|
NSString* localizedName; // localized name of the preference pane
|
||||||
|
@property(copy, readonly) NSString* name; // name of the preference pane as it
|
||||||
|
// appears in the title bar; can
|
||||||
|
// refer to a pane using the
|
||||||
|
// expression: pane "<name>"
|
||||||
|
|
||||||
|
- (void)closeSaving:(SBSystemPreferencesSaveOptions)saving
|
||||||
|
savingIn:(NSURL*)savingIn; // Close a document.
|
||||||
|
- (void)saveIn:(NSURL*)in_ as:(id)as; // Save a document.
|
||||||
|
- (void)printWithProperties:(NSDictionary*)withProperties
|
||||||
|
printDialog:(BOOL)printDialog; // Print a document.
|
||||||
|
- (void) delete; // Delete an object.
|
||||||
|
- (void)duplicateTo:(SBObject*)to
|
||||||
|
withProperties:(NSDictionary*)withProperties; // Copy an object.
|
||||||
|
- (void)moveTo:(SBObject*)to; // Move an object to a new location.
|
||||||
|
- (id)reveal; // Reveals an anchor within a preference pane or preference pane
|
||||||
|
// itself
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
// an anchor within a preference pane
|
||||||
|
@interface SBSystemPreferencesAnchor : SBObject
|
||||||
|
|
||||||
|
@property(copy, readonly)
|
||||||
|
NSString* name; // name of the anchor within a preference pane
|
||||||
|
|
||||||
|
- (void)closeSaving:(SBSystemPreferencesSaveOptions)saving
|
||||||
|
savingIn:(NSURL*)savingIn; // Close a document.
|
||||||
|
- (void)saveIn:(NSURL*)in_ as:(id)as; // Save a document.
|
||||||
|
- (void)printWithProperties:(NSDictionary*)withProperties
|
||||||
|
printDialog:(BOOL)printDialog; // Print a document.
|
||||||
|
- (void) delete; // Delete an object.
|
||||||
|
- (void)duplicateTo:(SBObject*)to
|
||||||
|
withProperties:(NSDictionary*)withProperties; // Copy an object.
|
||||||
|
- (void)moveTo:(SBObject*)to; // Move an object to a new location.
|
||||||
|
- (id)reveal; // Reveals an anchor within a preference pane or preference pane
|
||||||
|
// itself
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue