cocoawebview 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b9ceb3f514a6ed507c9db38001ff15bfc4725ee0bb1107e6a9a6872a4981afe
4
- data.tar.gz: 673ae12e518d228d40b808edf789ed07a19b54f82fd1a7b52f036c477c995005
3
+ metadata.gz: b434fa5361c35d5a60d14a7c817e353896e2748b7a5663f0220b6ca7481f01f1
4
+ data.tar.gz: 87ff99830e7533c2579f8525e042e9c0e19212b03babaeff3942a452cd022499
5
5
  SHA512:
6
- metadata.gz: 2d7972169c428d8cb5b7d80aa4038b34d8dbd1a7e11f961691d902ad09842fb77ca67668329c1a51cbed6afcd8283e2e2edc097a5d16defd6efa128ae360dd94
7
- data.tar.gz: cf24d3bcfea910ea0c4bce2b8317cf1e100e704ac9a1462399efd88e11739fa1c69252b3ad8f8afa5801e2563376e6931803c9828dc51d7300ed8b7d39ec2657
6
+ metadata.gz: b4a99f3ffebd8b527c0155f569dac8fdd4634241b042a69d74815fda262816267f85a8708df444e30a18ea49bc14206b44dfe98a24d31e9ded533d7f847df088
7
+ data.tar.gz: acc2363c86cf15816129176aaa863d89b6b810f1967a0aba5f3b2851168b432ed4649849cecd4dbfa06d9abc435c6c1d057778dfd33b66996c36fa018ea89cf7
@@ -10,7 +10,7 @@ NSApplication *application = nil;
10
10
  VALUE nsapp_initialize(VALUE self);
11
11
  VALUE nsapp_run(VALUE self);
12
12
 
13
- VALUE webview_initialize(VALUE self, VALUE debug);
13
+ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style);
14
14
  VALUE webview_show(VALUE self);
15
15
  VALUE webview_hide(VALUE self);
16
16
  VALUE webview_eval(VALUE self, VALUE code);
@@ -43,17 +43,14 @@ VALUE webview_set_title(VALUE self, VALUE title);
43
43
  BOOL showDevTool;
44
44
  }
45
45
  - (void)setDevTool:(BOOL)flag;
46
- - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag;
46
+ - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style;
47
47
  - (void)eval:(NSString*)code;
48
48
  - (void)setCocoaWebview:(VALUE)view;
49
49
  - (void)dragging;
50
50
  @end
51
51
 
52
52
  @implementation CocoaWebview
53
- - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag {
54
- int style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
55
- NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
56
- style &= ~NSWindowStyleMaskFullScreen;
53
+ - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style{
57
54
  self = [super initWithContentRect:frame
58
55
  styleMask:style
59
56
  backing:NSBackingStoreBuffered
@@ -175,7 +172,7 @@ Init_cocoawebview(void)
175
172
 
176
173
  /* CocoaWebview */
177
174
  rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
178
- rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 1);
175
+ rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 2);
179
176
  rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
180
177
  rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
181
178
  rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
@@ -200,7 +197,7 @@ VALUE nsapp_run(VALUE self) {
200
197
  [application run];
201
198
  }
202
199
 
203
- VALUE webview_initialize(VALUE self, VALUE debug) {
200
+ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style) {
204
201
  rb_iv_set(self, "@var", rb_hash_new());
205
202
  rb_iv_set(self, "@bindings", rb_hash_new());
206
203
  BOOL flag = NO;
@@ -209,7 +206,12 @@ VALUE webview_initialize(VALUE self, VALUE debug) {
209
206
  } else {
210
207
  flag = NO;
211
208
  }
212
- CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag];
209
+
210
+ //int c_style = NUM2INT(style);
211
+ int c_style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable |
212
+ NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
213
+ style &= ~NSWindowStyleMaskFullScreen;
214
+ CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style];
213
215
 
214
216
  [webview setReleasedWhenClosed:NO];
215
217
  [webview setCocoaWebview:self];
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/cocoawebview.rb CHANGED
@@ -5,6 +5,13 @@ require_relative "cocoawebview/version"
5
5
  require_relative "cocoawebview/cocoawebview"
6
6
 
7
7
  module CocoaWebview
8
+ NSWindowStyleMaskResizable = 8
9
+ NSWindowStyleMaskMiniaturizable = 4
10
+ NSWindowStyleMaskTitled = 1
11
+ NSWindowStyleMaskClosable = 2
12
+ NSWindowStyleMaskFullSizeContentView = (1 << 15)
13
+ NSWindowStyleMaskFullScreen = (1 << 14)
14
+
8
15
  class Error < StandardError; end
9
16
  # Your code goes here...
10
17
 
@@ -15,6 +22,22 @@ module CocoaWebview
15
22
  end
16
23
 
17
24
  class CocoaWebview
25
+ attr_accessor :callback
26
+
27
+ def self.create(debug: false, min: true, max: true, close: true, &block)
28
+ style = NSWindowStyleMaskTitled | NSWindowStyleMaskFullSizeContentView
29
+
30
+ style = style | NSWindowStyleMaskMiniaturizable if min
31
+ style = style | NSWindowStyleMaskResizable if max
32
+ style = style | NSWindowStyleMaskClosable if close
33
+
34
+ style &= ~NSWindowStyleMaskFullScreen
35
+
36
+ webview = new(debug, style)
37
+ webview.callback = block
38
+ webview
39
+ end
40
+
18
41
  def get_webview
19
42
  @webview
20
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoawebview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff