Skip to content

Commit

Permalink
Handle the OpenDocument event in GAPIC.
Browse files Browse the repository at this point in the history
This event is sent on OSX if the user requests GAPID to open a gfxtrace
file, for example via double-clicking on a gfxtrace file in the Finder.
This event is sent if the application is already running, or if it just
has been started in response to opening a file.
  • Loading branch information
pmuetschard committed Oct 30, 2017
1 parent 098d2f9 commit 399ad9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gapic/src/main/com/google/gapid/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ public void onCopyEnabled(boolean enabled) {
if (OS.isMac) {
MacApplication.init(shell.getDisplay(),
() -> showAbout(shell, widgets().theme),
() -> showSettingsDialog(shell, models().settings));
() -> showSettingsDialog(shell, models().settings),
file -> models().capture.loadCapture(new File(file)));
}
}

Expand Down
7 changes: 6 additions & 1 deletion gapic/src/main/com/google/gapid/util/MacApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

import java.util.function.Consumer;

/**
* Special handling for OSX application menus.
*/
Expand All @@ -30,7 +32,8 @@ private MacApplication() {
/**
* Initializes the OSX application menus.
*/
public static void init(Display display, Runnable onAbout, Runnable onSettings) {
public static void init(
Display display, Runnable onAbout, Runnable onSettings, Consumer<String> onOpen) {
Menu menu = display.getSystemMenu();
if (menu == null) {
return;
Expand All @@ -46,5 +49,7 @@ public static void init(Display display, Runnable onAbout, Runnable onSettings)
break;
}
}

display.addListener(SWT.OpenDocument, e -> onOpen.accept(e.text));
}
}

0 comments on commit 399ad9a

Please sign in to comment.