default template for PreviewFile
This commit is contained in:
parent
26f76f8d41
commit
fb444f646b
6 changed files with 23 additions and 0 deletions
|
@ -729,6 +729,10 @@ void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) {
|
||||||
window_->SetAspectRatio(aspect_ratio, extra_size);
|
window_->SetAspectRatio(aspect_ratio, extra_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::PreviewFile(const base::string16& filepath) {
|
||||||
|
window_->PreviewFile(filepath);
|
||||||
|
}
|
||||||
|
|
||||||
void Window::SetParentWindow(v8::Local<v8::Value> value,
|
void Window::SetParentWindow(v8::Local<v8::Value> value,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
if (IsModal()) {
|
if (IsModal()) {
|
||||||
|
@ -825,6 +829,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("setFullScreen", &Window::SetFullScreen)
|
.SetMethod("setFullScreen", &Window::SetFullScreen)
|
||||||
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
||||||
.SetMethod("setAspectRatio", &Window::SetAspectRatio)
|
.SetMethod("setAspectRatio", &Window::SetAspectRatio)
|
||||||
|
.SetMethod("previewFile", &Window::PreviewFile)
|
||||||
#if !defined(OS_WIN)
|
#if !defined(OS_WIN)
|
||||||
.SetMethod("setParentWindow", &Window::SetParentWindow)
|
.SetMethod("setParentWindow", &Window::SetParentWindow)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -170,6 +170,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void SetMenuBarVisibility(bool visible);
|
void SetMenuBarVisibility(bool visible);
|
||||||
bool IsMenuBarVisible();
|
bool IsMenuBarVisible();
|
||||||
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
|
void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
|
||||||
|
void PreviewFile(const base::string16& filepath);
|
||||||
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
|
void SetParentWindow(v8::Local<v8::Value> value, mate::Arguments* args);
|
||||||
v8::Local<v8::Value> GetParentWindow() const;
|
v8::Local<v8::Value> GetParentWindow() const;
|
||||||
std::vector<v8::Local<v8::Object>> GetChildWindows() const;
|
std::vector<v8::Local<v8::Object>> GetChildWindows() const;
|
||||||
|
|
|
@ -374,6 +374,9 @@ void NativeWindow::SetAspectRatio(double aspect_ratio,
|
||||||
aspect_ratio_extraSize_ = extra_size;
|
aspect_ratio_extraSize_ = extra_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::PreviewFile(const base::string16& filepath) {
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::RequestToClosePage() {
|
void NativeWindow::RequestToClosePage() {
|
||||||
bool prevent_default = false;
|
bool prevent_default = false;
|
||||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||||
|
|
|
@ -176,6 +176,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
double GetAspectRatio();
|
double GetAspectRatio();
|
||||||
gfx::Size GetAspectRatioExtraSize();
|
gfx::Size GetAspectRatioExtraSize();
|
||||||
virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
|
virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
|
||||||
|
virtual void PreviewFile(const base::string16& filepath);
|
||||||
|
|
||||||
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
||||||
return weak_factory_.GetWeakPtr();
|
return weak_factory_.GetWeakPtr();
|
||||||
|
|
|
@ -55,6 +55,7 @@ class NativeWindowMac : public NativeWindow,
|
||||||
void SetMovable(bool movable) override;
|
void SetMovable(bool movable) override;
|
||||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
||||||
override;
|
override;
|
||||||
|
void PreviewFile(const base::string16& filepath) override;
|
||||||
bool IsMovable() override;
|
bool IsMovable() override;
|
||||||
void SetMinimizable(bool minimizable) override;
|
void SetMinimizable(bool minimizable) override;
|
||||||
bool IsMinimizable() override;
|
bool IsMinimizable() override;
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "atom/common/color_util.h"
|
#include "atom/common/color_util.h"
|
||||||
#include "atom/common/draggable_region.h"
|
#include "atom/common/draggable_region.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
#include "base/mac/scoped_cftyperef.h"
|
#include "base/mac/scoped_cftyperef.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
|
@ -25,6 +27,7 @@
|
||||||
#include "third_party/skia/include/core/SkRegion.h"
|
#include "third_party/skia/include/core/SkRegion.h"
|
||||||
#include "ui/gfx/skia_util.h"
|
#include "ui/gfx/skia_util.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Prevents window from resizing during the scope.
|
// Prevents window from resizing during the scope.
|
||||||
|
@ -899,6 +902,15 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio,
|
||||||
[window_ setResizeIncrements:NSMakeSize(1.0, 1.0)];
|
[window_ setResizeIncrements:NSMakeSize(1.0, 1.0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::PreviewFile(const base::string16& filepath) {
|
||||||
|
std::string rtf = base::UTF16ToUTF8(filepath);
|
||||||
|
|
||||||
|
NSString *path = [NSString stringWithCString:rtf.c_str()
|
||||||
|
encoding:[NSString defaultCStringEncoding]];
|
||||||
|
NSAlert *alert = [NSAlert alertWithMessageText:path defaultButton:@"Close anyway" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@""];
|
||||||
|
[alert runModal];
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetMovable(bool movable) {
|
void NativeWindowMac::SetMovable(bool movable) {
|
||||||
[window_ setMovable:movable];
|
[window_ setMovable:movable];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue