* support OSX Lion Full Screen Mode
* fix "To Front on Drag" feature that wasn't working on OSX
This commit is contained in:
parent
d67e112c3b
commit
f7848f52f3
|
@ -53,6 +53,7 @@ import net.filebot.cli.ArgumentProcessor;
|
||||||
import net.filebot.cli.CmdlineOperations;
|
import net.filebot.cli.CmdlineOperations;
|
||||||
import net.filebot.format.ExpressionFormat;
|
import net.filebot.format.ExpressionFormat;
|
||||||
import net.filebot.gio.GVFS;
|
import net.filebot.gio.GVFS;
|
||||||
|
import net.filebot.mac.MacAppHelper;
|
||||||
import net.filebot.ui.MainFrame;
|
import net.filebot.ui.MainFrame;
|
||||||
import net.filebot.ui.PanelBuilder;
|
import net.filebot.ui.PanelBuilder;
|
||||||
import net.filebot.ui.SinglePanelFrame;
|
import net.filebot.ui.SinglePanelFrame;
|
||||||
|
@ -266,7 +267,6 @@ public class Main {
|
||||||
// don't care, doesn't make a difference
|
// don't care, doesn't make a difference
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.setLocationByPlatform(true);
|
|
||||||
frame.addWindowListener(new WindowAdapter() {
|
frame.addWindowListener(new WindowAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -282,6 +282,12 @@ public class Main {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// window settings
|
||||||
|
if (Settings.isMacSandbox()) {
|
||||||
|
MacAppHelper.setWindowCanFullScreen(frame);
|
||||||
|
}
|
||||||
|
frame.setLocationByPlatform(true);
|
||||||
|
|
||||||
// start application
|
// start application
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public final class Settings {
|
||||||
return !("mas".equals(getApplicationDeployment()) || "usc".equals(getApplicationDeployment()));
|
return !("mas".equals(getApplicationDeployment()) || "usc".equals(getApplicationDeployment()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSandboxed() {
|
public static boolean isMacSandbox() {
|
||||||
return "mas".equals(getApplicationDeployment());
|
return "mas".equals(getApplicationDeployment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package net.filebot.mac;
|
||||||
|
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.filebot.Main;
|
||||||
|
import ca.weblite.objc.Client;
|
||||||
|
|
||||||
|
public class MacAppHelper {
|
||||||
|
|
||||||
|
private static Client _objc;
|
||||||
|
|
||||||
|
public static Client objc() {
|
||||||
|
if (_objc == null) {
|
||||||
|
_objc = new Client();
|
||||||
|
}
|
||||||
|
return _objc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object NSData_initWithBase64Encoding(String text) {
|
||||||
|
return objc().sendProxy("NSData", "data").send("initWithBase64Encoding:", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object NSURL_bookmarkDataWithOptions(String path) {
|
||||||
|
return objc().sendProxy("NSURL", "fileURLWithPath:", path).sendProxy("bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error:", 2048, null, null, null).sendString("base64Encoding");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object NSURL_URLByResolvingBookmarkData_startAccessingSecurityScopedResource(String text) {
|
||||||
|
return objc().sendProxy("NSURL", "URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:", NSData_initWithBase64Encoding(text), 1024, null, false, null).send("startAccessingSecurityScopedResource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWindowCanFullScreen(Window window) {
|
||||||
|
try {
|
||||||
|
Class<?> fullScreenUtilities = Class.forName("com.apple.eawt.FullScreenUtilities");
|
||||||
|
Method setWindowCanFullScreen = fullScreenUtilities.getMethod("setWindowCanFullScreen", new Class<?>[] { Window.class, boolean.class });
|
||||||
|
setWindowCanFullScreen.invoke(null, window, true);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Logger.getLogger(Main.class.getName()).log(Level.WARNING, "setWindowCanFullScreen not supported: " + t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void requestForeground() {
|
||||||
|
try {
|
||||||
|
Class<?> application = Class.forName("com.apple.eawt.Application");
|
||||||
|
Object instance = application.getMethod("getApplication").invoke(null);
|
||||||
|
Method requestForeground = application.getMethod("requestForeground", new Class<?>[] { boolean.class });
|
||||||
|
requestForeground.invoke(instance, true);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Logger.getLogger(Main.class.getName()).log(Level.WARNING, "requestForeground not supported: " + t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package net.filebot.mac.sandbox;
|
|
||||||
|
|
||||||
import ca.weblite.objc.Client;
|
|
||||||
|
|
||||||
public class SandBoxUtil {
|
|
||||||
|
|
||||||
private static final Client objc = new Client();
|
|
||||||
|
|
||||||
public static Object NSData_initWithBase64Encoding(String text) {
|
|
||||||
return objc.sendProxy("NSData", "data").send("initWithBase64Encoding:", text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object NSURL_bookmarkDataWithOptions(String path) {
|
|
||||||
return objc.sendProxy("NSURL", "fileURLWithPath:", path).sendProxy("bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error:", 2048, null, null, null).sendString("base64Encoding");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object NSURL_URLByResolvingBookmarkData_startAccessingSecurityScopedResource(String text) {
|
|
||||||
return objc.sendProxy("NSURL", "URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:", NSData_initWithBase64Encoding(text), 1024, null, false, null).send("startAccessingSecurityScopedResource");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -43,6 +43,7 @@ import net.filebot.Analytics;
|
||||||
import net.filebot.ResourceManager;
|
import net.filebot.ResourceManager;
|
||||||
import net.filebot.Settings;
|
import net.filebot.Settings;
|
||||||
import net.filebot.cli.GroovyPad;
|
import net.filebot.cli.GroovyPad;
|
||||||
|
import net.filebot.mac.MacAppHelper;
|
||||||
import net.filebot.ui.analyze.AnalyzePanelBuilder;
|
import net.filebot.ui.analyze.AnalyzePanelBuilder;
|
||||||
import net.filebot.ui.episodelist.EpisodeListPanelBuilder;
|
import net.filebot.ui.episodelist.EpisodeListPanelBuilder;
|
||||||
import net.filebot.ui.list.ListPanelBuilder;
|
import net.filebot.ui.list.ListPanelBuilder;
|
||||||
|
@ -230,8 +231,12 @@ public class MainFrame extends JFrame {
|
||||||
selectEnabled = true;
|
selectEnabled = true;
|
||||||
|
|
||||||
// bring window to front when on dnd
|
// bring window to front when on dnd
|
||||||
|
if (Settings.isMacSandbox()) {
|
||||||
|
MacAppHelper.requestForeground();
|
||||||
|
} else {
|
||||||
SwingUtilities.getWindowAncestor(((DropTarget) dtde.getSource()).getComponent()).toFront();
|
SwingUtilities.getWindowAncestor(((DropTarget) dtde.getSource()).getComponent()).toFront();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ class SubtitleDownloadComponent extends JComponent {
|
||||||
Charset selectedEncoding = Charset.forName("UTF-8");
|
Charset selectedEncoding = Charset.forName("UTF-8");
|
||||||
|
|
||||||
// just use default values when we can't use a JFC with accessory component
|
// just use default values when we can't use a JFC with accessory component
|
||||||
if (Settings.isSandboxed()) {
|
if (Settings.isMacSandbox()) {
|
||||||
// AWT
|
// AWT
|
||||||
selectedOutputFolder = showOpenDialogSelectFolder(null, "Export Subtitles", this);
|
selectedOutputFolder = showOpenDialogSelectFolder(null, "Export Subtitles", this);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue