]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Add BrowserWindow.isDoucumentEdited API, fixes #459.
authorHaojian Wu <hokein.wu@gmail.com>
Thu, 24 Jul 2014 07:48:33 +0000 (15:48 +0800)
committerHaojian Wu <hokein.wu@gmail.com>
Thu, 24 Jul 2014 08:01:04 +0000 (16:01 +0800)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_mac.h
atom/browser/native_window_mac.mm
docs/api/browser-window.md

index 668aa1a55c2cd49d06adfdf48e19b31136583049..0fabdd1a5bf2a65ad6691967cac33ae664e8ba7d 100644 (file)
@@ -328,6 +328,10 @@ void Window::SetDocumentEdited(bool edited) {
   window_->SetDocumentEdited(edited);
 }
 
+bool Window::IsDocumentEdited() {
+  return window_->IsDocumentEdited();
+}
+
 mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
   return WebContents::Create(isolate, window_->GetWebContents());
 }
@@ -379,6 +383,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
       .SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
       .SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename)
       .SetMethod("setDocumentEdited", &Window::SetDocumentEdited)
+      .SetMethod("IsDocumentEdited", &Window::IsDocumentEdited)
       .SetMethod("_openDevTools", &Window::OpenDevTools)
       .SetMethod("closeDevTools", &Window::CloseDevTools)
       .SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
index d47a66f1dfae079f26dd29a84e2c192320bcddb8..62e7d7f0874e6497a42e6cf0bbe6fb2b52a213cb 100644 (file)
@@ -100,6 +100,7 @@ class Window : public mate::EventEmitter,
   void SetRepresentedFilename(const std::string& filename);
   std::string GetRepresentedFilename();
   void SetDocumentEdited(bool edited);
+  bool IsDocumentEdited();
 
   // APIs for WebContents.
   mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
index 5027114915ffa1bbb091533f6a6a40e3b012a57f..bf055570bdbddce9b2c6f556747a0ff50fbb39fe 100644 (file)
@@ -202,6 +202,10 @@ void NativeWindow::SetDocumentEdited(bool edited) {
 void NativeWindow::SetMenu(ui::MenuModel* menu) {
 }
 
+bool NativeWindow::IsDocumentEdited() {
+  return false;
+}
+
 bool NativeWindow::HasModalDialog() {
   return has_dialog_attached_;
 }
index 896e0dbc10e090b3abaa29bfd0ed6f88a670bdbc..537f485ef5a9277068273c2421b36fafba793858 100644 (file)
@@ -138,6 +138,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
   virtual std::string GetRepresentedFilename();
   virtual void SetDocumentEdited(bool edited);
   virtual void SetMenu(ui::MenuModel* menu);
+  virtual bool IsDocumentEdited();
   virtual bool HasModalDialog();
   virtual gfx::NativeWindow GetNativeWindow() = 0;
 
index 5df01f91a1d2cccfe35340970f0b6bccbecdee90..4b29c5d6a68205ed2b4cac3447d5511d5710d070 100644 (file)
@@ -61,6 +61,7 @@ class NativeWindowMac : public NativeWindow {
   virtual void SetRepresentedFilename(const std::string& filename) OVERRIDE;
   virtual std::string GetRepresentedFilename() OVERRIDE;
   virtual void SetDocumentEdited(bool edited) OVERRIDE;
+  virtual bool IsDocumentEdited() OVERRIDE;
   virtual bool HasModalDialog() OVERRIDE;
   virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
 
index b524a8acf46e27f0b6cf5ff99e658f19cd760a43..07047a3b9e87208afcdb1a452c3225ba282f184d 100644 (file)
@@ -460,6 +460,10 @@ void NativeWindowMac::SetDocumentEdited(bool edited) {
   [window_ setDocumentEdited:edited];
 }
 
+bool NativeWindowMac::IsDocumentEdited() {
+  return [window_ isDocumentEdited];
+}
+
 bool NativeWindowMac::HasModalDialog() {
   return [window_ attachedSheet] != nil;
 }
index 8facd14f0f30d2edd513cf0e42e587c98f2550fd..cb90af403494ac8bfee872fec7ae56cb4d3f6717 100644 (file)
@@ -394,6 +394,10 @@ __OS X Only:__ Returns the pathname of the file the window represents.
 __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.IsDocumentEdited()
+
+__OS X Only:__ Whether the window's document has been edited.
+
 ### BrowserWindow.openDevTools()
 
 Opens the developer tools.