From ce480b5fc34d208e6cf9b29198b8612991a1dd9e Mon Sep 17 00:00:00 2001 From: rhysd Date: Sat, 30 Jan 2016 02:07:30 +0900 Subject: [PATCH 1/2] github-electron: Fix type of 'dock' member of 'app' --- github-electron/github-electron-main-tests.ts | 3 + github-electron/github-electron.d.ts | 108 +++++++++--------- 2 files changed, 58 insertions(+), 53 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index e88926d58..d74d4904a 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -166,6 +166,9 @@ var dockMenu = Menu.buildFromTemplate([ }, ]); app.dock.setMenu(dockMenu); +app.dock.setBadge('foo'); +var id = app.dock.bounce('informational'); +app.dock.cancelBounce(id); app.setUserTasks([ { diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 4351b5aa1..97e0fb1e4 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1048,7 +1048,7 @@ declare module Electron { * Note: This API is only available on Windows. */ setUserTasks(tasks: Task[]): void; - dock: BrowserWindow; + dock: Dock; commandLine: CommandLine; /** * This method makes your application a Single Instance Application instead of allowing @@ -1075,6 +1075,58 @@ declare module Electron { appendArgument(value: any): void; } + interface Dock { + /** + * When critical is passed, the dock icon will bounce until either the + * application becomes active or the request is canceled. + * + * When informational is passed, the dock icon will bounce for one second. + * The request, though, remains active until either the application becomes + * active or the request is canceled. + * + * Note: This API is only available on Mac. + * @param type Can be critical or informational, the default is informational. + * @returns An ID representing the request + */ + bounce(type?: string): number; + /** + * Cancel the bounce of id. + * + * Note: This API is only available on Mac. + */ + cancelBounce(id: number): void; + /** + * Sets the string to be displayed in the dock’s badging area. + * + * Note: This API is only available on Mac. + */ + setBadge(text: string): void; + /** + * Returns the badge string of the dock. + * + * Note: This API is only available on Mac. + */ + getBadge(): string; + /** + * Hides the dock icon. + * + * Note: This API is only available on Mac. + */ + hide(): void; + /** + * Shows the dock icon. + * + * Note: This API is only available on Mac. + */ + show(): void; + /** + * Sets the application dock menu. + * + * Note: This API is only available on Mac. + */ + setMenu(menu: Menu): void; + } + interface Task { /** * Path of the program to execute, usually you should specify process.execPath @@ -1106,57 +1158,7 @@ declare module Electron { */ iconIndex?: number; commandLine?: CommandLine; - dock?: { - /** - * When critical is passed, the dock icon will bounce until either the - * application becomes active or the request is canceled. - * - * When informational is passed, the dock icon will bounce for one second. - * The request, though, remains active until either the application becomes - * active or the request is canceled. - * - * Note: This API is only available on Mac. - * @param type Can be critical or informational, the default is informational. - * @returns An ID representing the request - */ - bounce(type?: string): any; - /** - * Cancel the bounce of id. - * - * Note: This API is only available on Mac. - */ - cancelBounce(id: number): void; - /** - * Sets the string to be displayed in the dock’s badging area. - * - * Note: This API is only available on Mac. - */ - setBadge(text: string): void; - /** - * Returns the badge string of the dock. - * - * Note: This API is only available on Mac. - */ - getBadge(): string; - /** - * Hides the dock icon. - * - * Note: This API is only available on Mac. - */ - hide(): void; - /** - * Shows the dock icon. - * - * Note: This API is only available on Mac. - */ - show(): void; - /** - * Sets the application dock menu. - * - * Note: This API is only available on Mac. - */ - setMenu(menu: Menu): void; - }; + dock?: Dock; } class AutoUpdater implements NodeJS.EventEmitter { @@ -1225,7 +1227,7 @@ declare module Electron { filters?: { name: string; extensions: string[]; - }[] + }[]; } /** From e5fc6154826b24cc8421298d72d7007c54a9f999 Mon Sep 17 00:00:00 2001 From: rhysd Date: Sat, 30 Jan 2016 02:11:56 +0900 Subject: [PATCH 2/2] github-electron: Add app.dock.setIcon() API https://github.com/atom/electron/blob/master/docs/api/app.md#appdockseticonimage-os-x --- github-electron/github-electron-main-tests.ts | 1 + github-electron/github-electron.d.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index d74d4904a..5d3060e4b 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -169,6 +169,7 @@ app.dock.setMenu(dockMenu); app.dock.setBadge('foo'); var id = app.dock.bounce('informational'); app.dock.cancelBounce(id); +app.dock.setIcon('/path/to/icon.png'); app.setUserTasks([ { diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 97e0fb1e4..d5ca18690 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1125,6 +1125,12 @@ declare module Electron { * Note: This API is only available on Mac. */ setMenu(menu: Menu): void; + /** + * Sets the image associated with this dock icon. + * + * Note: This API is only available on Mac. + */ + setIcon(icon: NativeImage | string): void; } interface Task {