bowline 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.txt +62 -62
- data/Rakefile +10 -0
- data/TODO +3 -1
- data/VERSION +1 -1
- data/assets/bowline.js +118 -3
- data/bowline.gemspec +6 -6
- data/examples/example.js +2 -15
- data/examples/tweet.rb +35 -0
- data/examples/tweets_binder.rb +6 -0
- data/examples/twitter.html +6 -8
- data/examples/users.rb +8 -14
- data/lib/bowline/binders.rb +130 -42
- data/lib/bowline/dependencies/lib/dependencies.rb +2 -1
- data/lib/bowline/dependencies/lib/ext/rubygems.rb +4 -4
- data/lib/bowline/desktop.rb +11 -2
- data/lib/bowline/desktop/app.rb +7 -3
- data/lib/bowline/desktop/bridge.rb +8 -9
- data/lib/bowline/desktop/clipboard.rb +11 -2
- data/lib/bowline/desktop/dialog.rb +19 -0
- data/lib/bowline/desktop/dock.rb +14 -3
- data/lib/bowline/desktop/host.rb +13 -4
- data/lib/bowline/desktop/js.rb +2 -2
- data/lib/bowline/desktop/misc.rb +7 -3
- data/lib/bowline/desktop/network.rb +1 -1
- data/lib/bowline/desktop/proxy.rb +28 -30
- data/lib/bowline/desktop/sound.rb +3 -2
- data/lib/bowline/desktop/window.rb +147 -21
- data/lib/bowline/desktop/window_manager.rb +53 -5
- data/lib/bowline/desktop/window_methods.rb +2 -2
- data/lib/bowline/ext/object.rb +1 -1
- data/lib/bowline/generators.rb +1 -1
- data/lib/bowline/generators/binder.rb +1 -1
- data/lib/bowline/helpers.rb +1 -1
- data/lib/bowline/initializer.rb +37 -4
- data/lib/bowline/library.rb +11 -0
- data/lib/bowline/local_model.rb +45 -19
- data/lib/bowline/logging.rb +1 -1
- data/lib/bowline/platform.rb +8 -6
- data/lib/bowline/tasks/app.rake +4 -3
- data/lib/bowline/version.rb +1 -1
- data/lib/bowline/watcher.rb +18 -8
- data/templates/binder.rb +1 -1
- data/vendor/pathname.rb +0 -4
- metadata +6 -6
- data/examples/account.rb +0 -31
- data/examples/tweets.rb +0 -28
data/lib/bowline/desktop/app.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
3
|
module App
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
4
|
+
##
|
5
|
+
# :singleton-method: busy(bool = true)
|
6
|
+
# Shows a busy cursor (hourglass) on all windows.
|
7
|
+
|
8
|
+
##
|
9
|
+
# :singleton-method: exit
|
10
|
+
# Exits the application.
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
@@ -2,12 +2,11 @@ module Bowline
|
|
2
2
|
module Desktop
|
3
3
|
module Bridge
|
4
4
|
module ClassMethods
|
5
|
-
|
6
|
-
# module, and then call js_expose
|
7
|
-
# to expose your classes' class
|
8
|
-
# variables to JavaScript.
|
5
|
+
##
|
6
|
+
# Extend you own classes with this module, and then call js_expose
|
7
|
+
# to expose your classes' class variables to JavaScript.
|
9
8
|
#
|
10
|
-
#
|
9
|
+
# Example:
|
11
10
|
# class FooClass
|
12
11
|
# extend Bowline::Desktop::Bridge::ClassMethods
|
13
12
|
# js_expose
|
@@ -17,7 +16,7 @@ module Bowline
|
|
17
16
|
# end
|
18
17
|
# end
|
19
18
|
#
|
20
|
-
# JavaScript:
|
19
|
+
# JavaScript Example:
|
21
20
|
# Bowline.invoke("FooClass", "foo", function(res){
|
22
21
|
# console.log(res);
|
23
22
|
# })
|
@@ -36,7 +35,7 @@ module Bowline
|
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
|
-
class Message
|
38
|
+
class Message #:nodoc:
|
40
39
|
include Bowline::Logging
|
41
40
|
|
42
41
|
def self.from_array(window, arr)
|
@@ -75,12 +74,12 @@ module Bowline
|
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
78
|
-
def setup
|
77
|
+
def setup #:nodoc:
|
79
78
|
Desktop.on_tick(method(:poll))
|
80
79
|
end
|
81
80
|
module_function :setup
|
82
81
|
|
83
|
-
def poll
|
82
|
+
def poll #:nodoc:
|
84
83
|
WindowManager.allocated_windows.each do |window|
|
85
84
|
result = window.run_script("try {Bowline.pollJS()} catch(e) {false}")
|
86
85
|
next if result.blank? || result == "false"
|
@@ -1,8 +1,17 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
|
+
# The Clipboard module gives you cross-platform access to
|
4
|
+
# the systems native clipboard. At the moment, you can only
|
5
|
+
# read/write strings. We're planning to extend this to images.
|
3
6
|
module Clipboard
|
4
|
-
|
5
|
-
#
|
7
|
+
##
|
8
|
+
# :singleton-method: write(str)
|
9
|
+
# Write a string to the Clipboard.
|
10
|
+
# write("some text")
|
11
|
+
|
12
|
+
##
|
13
|
+
# :singleton-method: write(str)
|
14
|
+
# Read a string from the Clipboard.
|
6
15
|
# read #=> str
|
7
16
|
end
|
8
17
|
end
|
@@ -1,6 +1,25 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
3
|
module Dialog
|
4
|
+
# Display a dialog box from the main window.
|
5
|
+
# You can ask for a confirmation, or just display some information.
|
6
|
+
#
|
7
|
+
# Supported options are:
|
8
|
+
# :yes_no - Puts Yes and No buttons on the message box *
|
9
|
+
# :ok - Puts an Ok button on the message box *
|
10
|
+
# :cancel - Puts a Cancel button on the message box
|
11
|
+
# :icon_exclamation - Displays an exclamation mark symbol
|
12
|
+
# :icon_error - Displays an error symbol
|
13
|
+
# :question - Displays a question mark symbol
|
14
|
+
# :information - Displays an information symbol
|
15
|
+
# :caption - Title for the message box
|
16
|
+
# * may be combined with :cancel
|
17
|
+
#
|
18
|
+
# Return values are:
|
19
|
+
# :yes - User clicked yes
|
20
|
+
# :no - User clicked no
|
21
|
+
# :ok - User clicked ok
|
22
|
+
# :cancel - User clicked cancel, or closed the box
|
4
23
|
def message(msg, options = {})
|
5
24
|
style = 0
|
6
25
|
style |= YES_NO if options[:yes_no]
|
data/lib/bowline/desktop/dock.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
|
+
# The Dock module gives you a few methods to control
|
4
|
+
# the Mac OSX dock. It's platform specific, and on platforms
|
5
|
+
# other than OSX calling the methods won't do anything.
|
3
6
|
module Dock
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
+
# Set the badge number. This is the little numbered red star above
|
8
|
+
# the App's Dock icon. A good example of this is Mail.app incrementing
|
9
|
+
# its icon's star whenever a new mail is received.
|
10
|
+
def badge=(number)
|
11
|
+
self._badge = number.to_s
|
12
|
+
end
|
13
|
+
module_function :badge=
|
14
|
+
|
15
|
+
##
|
16
|
+
# :singleton-method: clear_badge
|
17
|
+
# Clear the Icon's badge number
|
7
18
|
end
|
8
19
|
end
|
9
20
|
end
|
data/lib/bowline/desktop/host.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
3
|
module Host
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
7
|
-
|
4
|
+
##
|
5
|
+
# :singleton-method: ip
|
6
|
+
# Returns the computer's local IP address
|
7
|
+
|
8
|
+
##
|
9
|
+
# :singleton-method: public_ip
|
10
|
+
# Returns the computer's network IP address.
|
11
|
+
# This method doesn't return the computer's Internet IP,
|
12
|
+
# for that you need a remote server.
|
13
|
+
|
14
|
+
##
|
15
|
+
# :singleton-method: host_name
|
16
|
+
# Returns the computer's host name
|
8
17
|
end
|
9
18
|
end
|
10
19
|
end
|
data/lib/bowline/desktop/js.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
|
-
module JS
|
3
|
+
module JS #:nodoc:
|
4
4
|
class Script
|
5
5
|
include Bowline::Logging
|
6
6
|
|
@@ -31,7 +31,7 @@ module Bowline
|
|
31
31
|
result
|
32
32
|
else
|
33
33
|
trace "Pseudo JS eval on #{window}: #{script}"
|
34
|
-
prok.call(nil)
|
34
|
+
prok.call(nil) if prok
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
data/lib/bowline/desktop/misc.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
3
|
module Misc
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
4
|
+
##
|
5
|
+
# :singleton-method: launch_browser(url)
|
6
|
+
# Launch the computer's default browser
|
7
|
+
|
8
|
+
##
|
9
|
+
# :singleton-method: bell
|
10
|
+
# Call the system bell
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
@@ -1,35 +1,33 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# * We don't know if it's a method call, or a variable
|
32
|
-
|
3
|
+
# Use to call out to JavaScript.
|
4
|
+
#
|
5
|
+
# Use the method 'call' if you want to call a function,
|
6
|
+
# or the method 'res' if you want the result of a variable evaluation.
|
7
|
+
#
|
8
|
+
# You can pass a block as the last argument which will
|
9
|
+
# be called with the result of the evaluation.
|
10
|
+
#
|
11
|
+
# All arguments are serialized by JSON, so you can only pass
|
12
|
+
# the following objects:
|
13
|
+
# * Hash
|
14
|
+
# * Array
|
15
|
+
# * String
|
16
|
+
# * Integer
|
17
|
+
#
|
18
|
+
# Examples:
|
19
|
+
# proxy.FooObject.messages = [1,2,3] #=> "FooObject.messages = [1,2,3]"
|
20
|
+
# proxy.FooObject.hi.call #=> "FooObject.hi()"
|
21
|
+
# proxy.FooObject.hi(1,2,3).bye.call #=> "FooObject.hi(1,2,3).bye()"
|
22
|
+
# proxy.FooObject.messages.res #=> "FooObject.messages"
|
23
|
+
# proxy.FooObject.messages.res {|result|
|
24
|
+
# puts "Messages are: #{result}"
|
25
|
+
# }
|
26
|
+
#
|
27
|
+
# Reasoning behind this class's call/res API:
|
28
|
+
# * JavaScript needs to be called all at once
|
29
|
+
# * We don't know if it's a method call, or a variable
|
30
|
+
class Proxy
|
33
31
|
def initialize(win)
|
34
32
|
@window = win
|
35
33
|
@crumbs = []
|
@@ -1,30 +1,156 @@
|
|
1
1
|
module Bowline
|
2
2
|
module Desktop
|
3
|
+
# Use the Window class to create new windows that your
|
4
|
+
# users can interact with.
|
5
|
+
#
|
6
|
+
# Usually, this class isn't instantiated directly, but rather
|
7
|
+
# used in conjunction with the WindowManager class.
|
8
|
+
# We recommend this approach, otherwise your window won't be
|
9
|
+
# able to call out to Ruby, or use Bowline's binding API.
|
10
|
+
#
|
11
|
+
# At the moment, these methods need to be called in the main thread.
|
12
|
+
# This is a restriction we're hoping to remove soon.
|
3
13
|
class Window
|
4
14
|
include WindowMethods
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
#
|
15
|
+
##
|
16
|
+
# :singleton-method: center(direction = :both)
|
17
|
+
# Center the window in a given direction.
|
18
|
+
# Supports the following directions:
|
19
|
+
# :both - both horizontal and vertical to the app
|
20
|
+
# :horizontal - horizontal to the app
|
21
|
+
# :vertical - vertical to the app
|
22
|
+
# :center - center of the screen
|
23
|
+
#
|
24
|
+
# :call-seq:
|
25
|
+
# my_method(Range)
|
26
|
+
# my_method(offset, length)
|
27
|
+
|
28
|
+
##
|
29
|
+
# :singleton-method: close
|
30
|
+
# Close the window.
|
31
|
+
|
32
|
+
##
|
33
|
+
# :singleton-method: disable
|
34
|
+
# Disable user input to the window.
|
35
|
+
|
36
|
+
##
|
37
|
+
# :singleton-method: enable
|
38
|
+
# Enable user input to the window.
|
39
|
+
|
40
|
+
##
|
41
|
+
# :singleton-method: chome=(bool)
|
42
|
+
# Enable/disable window's chrome,
|
43
|
+
# i.e. the buttons & frame
|
44
|
+
|
45
|
+
##
|
46
|
+
# :singleton-method: file=(path)
|
47
|
+
# Load HTML file. You can pass an absolute path, a path
|
48
|
+
# relative to the apps root, or a symbol, like so:
|
49
|
+
# window.file = :about
|
50
|
+
# Passing a symbol will load the corrosponding HTML file
|
51
|
+
# in the public directory. In this case, it'll load about.html
|
52
|
+
|
53
|
+
##
|
54
|
+
# :singleton-method: id
|
55
|
+
# Internal ID for the window.
|
56
|
+
|
57
|
+
##
|
58
|
+
# :singleton-method: dealocated?
|
59
|
+
# Returns true if the window has been dealocated.
|
60
|
+
# Calling methods on dealocated windows has no effect.
|
61
|
+
# Instead, you'll need to create a new instance.
|
62
|
+
|
63
|
+
##
|
64
|
+
# :singleton-method: modal(flag = true)
|
65
|
+
# Disable/Enable user interaction with other windows.
|
66
|
+
|
67
|
+
##
|
68
|
+
# :singleton-method: name=(str)
|
69
|
+
# Set windows name (shown in the window's title bar)
|
70
|
+
|
71
|
+
##
|
72
|
+
# :singleton-method: run_script(str)
|
73
|
+
# Run JavaScript in this window.
|
74
|
+
#
|
75
|
+
# The return result types are very limited,
|
76
|
+
# only the following are supported:
|
77
|
+
# - Booleans
|
78
|
+
# - Integers
|
79
|
+
# - Strings
|
80
|
+
# These all then get converted into strings.
|
81
|
+
#
|
82
|
+
# This API is very low level. We recommend you use the abstractions
|
83
|
+
# provided by the WindowManager class, such as the 'page' method.
|
84
|
+
|
85
|
+
##
|
86
|
+
# :singleton-method: raise
|
87
|
+
# Raise this window above all other ones.
|
88
|
+
|
89
|
+
##
|
90
|
+
# :singleton-method: show
|
91
|
+
# Show this window. By default, windows are hidden.
|
92
|
+
|
93
|
+
##
|
94
|
+
# :singleton-method: hide
|
95
|
+
# Hide this window.
|
96
|
+
|
97
|
+
##
|
98
|
+
# :singleton-method: close
|
99
|
+
# Close this window. Once a window is closed, either by a user or
|
100
|
+
# by calling this method, it has been deallocated and may not be opened again.
|
101
|
+
#
|
102
|
+
# You'll need to create a new instance of this class for a new window.
|
103
|
+
# Calling any methods on a dealocated window won't have any effect.
|
104
|
+
|
105
|
+
##
|
106
|
+
# :singleton-method: set_size(width, weight)
|
107
|
+
# Set the window's width & height in pixels.
|
108
|
+
|
109
|
+
##
|
110
|
+
# :singleton-method: height=(int)
|
111
|
+
# Helper to set the window's height.
|
112
|
+
|
113
|
+
##
|
114
|
+
# :singleton-method: width=(int)
|
115
|
+
# Helper to set the window's width.
|
116
|
+
|
117
|
+
##
|
118
|
+
# :singleton-method: set_position(x, y)
|
119
|
+
# Set the window's position on the screen.
|
120
|
+
|
121
|
+
##
|
122
|
+
# :singleton-method: select_dir(options = {})
|
123
|
+
# Prompt the user to select a folder.
|
124
|
+
#
|
125
|
+
# Supported options are:
|
126
|
+
# :message
|
127
|
+
# :default_path
|
128
|
+
|
129
|
+
##
|
130
|
+
# :singleton-method: select_file(options = {})
|
131
|
+
# Prompt the user to select a file.
|
132
|
+
#
|
133
|
+
# Supported options are:
|
134
|
+
# :message
|
135
|
+
# :default_path
|
136
|
+
# :default_filename
|
137
|
+
# :default_extension
|
138
|
+
# :wildcard - defaults to *.*
|
139
|
+
# :open - show open button
|
140
|
+
# :save - show save button
|
141
|
+
# :overwrite_prompt - prompt if file already exists
|
142
|
+
# :file_must_exist
|
143
|
+
#
|
144
|
+
# The :wildcard options may be a specification for multiple
|
145
|
+
# types of file with a description for each, such as:
|
146
|
+
# "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
|
147
|
+
|
148
|
+
##
|
149
|
+
# :singleton-method: shown?
|
150
|
+
# Is this window currently shown?
|
25
151
|
end
|
26
152
|
|
27
|
-
class MainWindow
|
153
|
+
class MainWindow #:nodoc:
|
28
154
|
include WindowMethods
|
29
155
|
end
|
30
156
|
end
|