From: Cheng Zhao Date: Tue, 27 May 2014 06:15:34 +0000 (+0800) Subject: mac: Add APIs on setting icon in titlebar. X-Git-Tag: v0.12.7~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a7b730654cad1ac78871eb86ee4d424d987f437a;p=electron.git mac: Add APIs on setting icon in titlebar. --- diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index c30e299f..7f433321 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -314,6 +314,14 @@ void Window::CapturePage(mate::Arguments* args) { window_->CapturePage(rect, base::Bind(&OnCapturePageDone, callback)); } +void Window::SetRepresentedFilename(const std::string& filename) { + window_->SetRepresentedFilename(filename); +} + +void Window::SetDocumentEdited(bool edited) { + window_->SetDocumentEdited(edited); +} + mate::Handle Window::GetWebContents(v8::Isolate* isolate) const { return WebContents::Create(isolate, window_->GetWebContents()); } @@ -360,6 +368,8 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("flashFrame", &Window::FlashFrame) .SetMethod("setKiosk", &Window::SetKiosk) .SetMethod("isKiosk", &Window::IsKiosk) + .SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename) + .SetMethod("setDocumentEdited", &Window::SetDocumentEdited) .SetMethod("_openDevTools", &Window::OpenDevTools) .SetMethod("closeDevTools", &Window::CloseDevTools) .SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index be74f14b..1aa9cee9 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -101,6 +101,8 @@ class Window : public mate::EventEmitter, void BlurWebView(); bool IsWebViewFocused(); void CapturePage(mate::Arguments* args); + void SetRepresentedFilename(const std::string& filename); + void SetDocumentEdited(bool edited); // APIs for WebContents. mate::Handle GetWebContents(v8::Isolate* isolate) const; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index b4214a1f..949dff1c 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -191,6 +191,12 @@ void NativeWindow::InitFromOptions(base::DictionaryValue* options) { Show(); } +void NativeWindow::SetRepresentedFilename(const std::string& filename) { +} + +void NativeWindow::SetDocumentEdited(bool edited) { +} + bool NativeWindow::HasModalDialog() { return has_dialog_attached_; } diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index f9c490e5..a29b8285 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -129,6 +129,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, virtual void FlashFrame(bool flash) = 0; virtual void SetKiosk(bool kiosk) = 0; virtual bool IsKiosk() = 0; + virtual void SetRepresentedFilename(const std::string& filename); + virtual void SetDocumentEdited(bool edited); virtual bool HasModalDialog(); virtual gfx::NativeWindow GetNativeWindow() = 0; diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index d60da8df..5dc8aa6b 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -56,6 +56,8 @@ class NativeWindowMac : public NativeWindow { virtual void FlashFrame(bool flash) OVERRIDE; virtual void SetKiosk(bool kiosk) OVERRIDE; virtual bool IsKiosk() OVERRIDE; + virtual void SetRepresentedFilename(const std::string& filename) OVERRIDE; + virtual void SetDocumentEdited(bool edited) OVERRIDE; virtual bool HasModalDialog() OVERRIDE; virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index a34ec9c7..634b052c 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -432,6 +432,14 @@ bool NativeWindowMac::IsKiosk() { return is_kiosk_; } +void NativeWindowMac::SetRepresentedFilename(const std::string& filename) { + [window_ setRepresentedFilename:base::SysUTF8ToNSString(filename)]; +} + +void NativeWindowMac::SetDocumentEdited(bool edited) { + [window_ setDocumentEdited:edited]; +} + bool NativeWindowMac::HasModalDialog() { return [window_ attachedSheet] != nil; } diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index c25d3bf8..ae0c8fe7 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -362,6 +362,20 @@ Enters or leaves the kiosk mode. Returns whether the window is in kiosk mode. +### BrowserWindow.setRepresentedFilename(filename) + +* `filename` String + +__OS X Only__ Sets the pathname of the file the window represents, and the icon +of the file will show in window's title bar. + +### BrowserWindow.setDocumentEdited(edited) + +* `edited` Boolean + +__OS X Only__ Specifies whether the window’s document has been edited, and the +icon in titlebar will become grey when set to `true`. + ### BrowserWindow.openDevTools() Opens the developer tools.