mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
* 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.format.ExpressionFormat;
|
||||
import net.filebot.gio.GVFS;
|
||||
import net.filebot.mac.MacAppHelper;
|
||||
import net.filebot.ui.MainFrame;
|
||||
import net.filebot.ui.PanelBuilder;
|
||||
import net.filebot.ui.SinglePanelFrame;
|
||||
@ -266,7 +267,6 @@ public class Main {
|
||||
// don't care, doesn't make a difference
|
||||
}
|
||||
|
||||
frame.setLocationByPlatform(true);
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
|
||||
@Override
|
||||
@ -282,6 +282,12 @@ public class Main {
|
||||
}
|
||||
});
|
||||
|
||||
// window settings
|
||||
if (Settings.isMacSandbox()) {
|
||||
MacAppHelper.setWindowCanFullScreen(frame);
|
||||
}
|
||||
frame.setLocationByPlatform(true);
|
||||
|
||||
// start application
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public final class Settings {
|
||||
return !("mas".equals(getApplicationDeployment()) || "usc".equals(getApplicationDeployment()));
|
||||
}
|
||||
|
||||
public static boolean isSandboxed() {
|
||||
public static boolean isMacSandbox() {
|
||||
return "mas".equals(getApplicationDeployment());
|
||||
}
|
||||
|
||||
|
54
source/net/filebot/mac/MacAppHelper.java
Normal file
54
source/net/filebot/mac/MacAppHelper.java
Normal file
@ -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.Settings;
|
||||
import net.filebot.cli.GroovyPad;
|
||||
import net.filebot.mac.MacAppHelper;
|
||||
import net.filebot.ui.analyze.AnalyzePanelBuilder;
|
||||
import net.filebot.ui.episodelist.EpisodeListPanelBuilder;
|
||||
import net.filebot.ui.list.ListPanelBuilder;
|
||||
@ -230,7 +231,11 @@ public class MainFrame extends JFrame {
|
||||
selectEnabled = true;
|
||||
|
||||
// bring window to front when on dnd
|
||||
SwingUtilities.getWindowAncestor(((DropTarget) dtde.getSource()).getComponent()).toFront();
|
||||
if (Settings.isMacSandbox()) {
|
||||
MacAppHelper.requestForeground();
|
||||
} else {
|
||||
SwingUtilities.getWindowAncestor(((DropTarget) dtde.getSource()).getComponent()).toFront();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ class SubtitleDownloadComponent extends JComponent {
|
||||
Charset selectedEncoding = Charset.forName("UTF-8");
|
||||
|
||||
// just use default values when we can't use a JFC with accessory component
|
||||
if (Settings.isSandboxed()) {
|
||||
if (Settings.isMacSandbox()) {
|
||||
// AWT
|
||||
selectedOutputFolder = showOpenDialogSelectFolder(null, "Export Subtitles", this);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user