Class: Redcar::Window
- Inherits:
-
Object
show all
- Includes:
- Model, Observable
- Defined in:
- plugins/application/lib/application/window.rb
Constant Summary
- DEFAULT_TITLE =
"Redcar"
Constants included
from Observable
Observable::ASPECTS
Instance Attribute Summary (collapse)
Attributes included from Model
#controller
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Methods included from Observable
#add_listener, #notify_listeners, #remove_listener
#ignore, #ignore_changes
Constructor Details
- (Window) initialize
18
19
20
21
22
23
24
25
26
27
|
# File 'plugins/application/lib/application/window.rb', line 18
def initialize
Window.all << self
@visible = false
@notebooks = []
@notebook_orientation = :horizontal
create_notebook
@treebook = Treebook.new
@speedbar = nil
self.title = DEFAULT_TITLE
end
|
Instance Attribute Details
Returns the value of attribute keymap
214
215
216
|
# File 'plugins/application/lib/application/window.rb', line 214
def keymap
@keymap
end
|
Returns the value of attribute menu
214
215
216
|
# File 'plugins/application/lib/application/window.rb', line 214
def
@menu
end
|
- (Object) notebook_orientation
Returns the value of attribute notebook_orientation
14
15
16
|
# File 'plugins/application/lib/application/window.rb', line 14
def notebook_orientation
@notebook_orientation
end
|
- (Object) notebooks
Returns the value of attribute notebooks
14
15
16
|
# File 'plugins/application/lib/application/window.rb', line 14
def notebooks
@notebooks
end
|
- (Object) speedbar
Returns the value of attribute speedbar
16
17
18
|
# File 'plugins/application/lib/application/window.rb', line 16
def speedbar
@speedbar
end
|
Returns the value of attribute toolbar
214
215
216
|
# File 'plugins/application/lib/application/window.rb', line 214
def toolbar
@toolbar
end
|
- (Object) treebook
Returns the value of attribute treebook
15
16
17
|
# File 'plugins/application/lib/application/window.rb', line 15
def treebook
@treebook
end
|
Class Method Details
10
11
12
|
# File 'plugins/application/lib/application/window.rb', line 10
def self.all
@all ||= []
end
|
Instance Method Details
- (Object) all_tabs
295
296
297
|
# File 'plugins/application/lib/application/window.rb', line 295
def all_tabs
notebooks.map {|nb| nb.tabs }.flatten
end
|
- (Object) attach_notebook_listeners(notebook)
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'plugins/application/lib/application/window.rb', line 122
def attach_notebook_listeners(notebook)
notebook.add_listener(:tab_focussed) do |tab|
notify_listeners(:tab_focussed, tab)
if tab
self.focussed_notebook = tab.notebook
else
new_notebook = self.notebooks.sort_by {|nb| nb.tabs.length}.last
if new_tab = new_notebook.focussed_tab
new_notebook.focussed_tab.focus
end
end
if speedbar and speedbar.respond_to?(:tab_changed)
speedbar.tab_changed(tab)
end
end
notebook.add_listener(:tab_closed) do
notify_listeners(:tab_closed)
end
notebook.add_listener(:focussed_tab_changed) do |tab|
if notebook == focussed_notebook
notify_listeners(:focussed_tab_changed, tab)
end
end
notebook.add_listener(:focussed_tab_selection_changed) do |tab|
if notebook == focussed_notebook
notify_listeners(:focussed_tab_selection_changed, tab)
end
end
end
|
Get dimensions and location of this window
Returns: [x, y, width, height]
103
104
105
106
107
|
# File 'plugins/application/lib/application/window.rb', line 103
def bounds
if controller
controller.bounds
end
end
|
- (Object) bounds=(new_bounds)
Set bounds of this window
112
113
114
115
116
|
# File 'plugins/application/lib/application/window.rb', line 112
def bounds=(new_bounds)
if controller
controller.set_bounds(new_bounds)
end
end
|
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'plugins/application/lib/application/window.rb', line 261
def close
Redcar.app.events.ignore(:window_close, self) do
notify_listeners(:about_to_close, self)
notebooks.each do |notebook|
notebook.tabs.each {|tab| tab.close }
end
if notebooks.length > 1
close_notebook
end
notify_listeners(:closed, self)
end
end
|
- (Object) close_notebook
152
153
154
155
156
157
158
159
160
161
|
# File 'plugins/application/lib/application/window.rb', line 152
def close_notebook
return if @notebooks.length == 1
first_notebook, second_notebook = *@notebooks
second_notebook.tabs.each do |tab|
first_notebook.grab_tab_from(second_notebook, tab)
end
@notebooks.delete(second_notebook)
self.focussed_notebook = first_notebook
notify_listeners(:notebook_removed, second_notebook)
end
|
- (Object) close_speedbar
286
287
288
289
290
291
292
293
|
# File 'plugins/application/lib/application/window.rb', line 286
def close_speedbar
notify_listeners(:speedbar_closed, @speedbar)
@speedbar.close if @speedbar.respond_to?(:close)
@speedbar = nil
if tab = focussed_notebook.focussed_tab
tab.focus
end
end
|
- (Object) create_notebook
Create a new notebook in this window.
70
71
72
73
74
75
76
77
78
79
|
# File 'plugins/application/lib/application/window.rb', line 70
def create_notebook
notebook = Redcar::Notebook.new(self)
@notebooks << notebook
if @notebooks.length == 1
self.focussed_notebook = notebook
end
attach_notebook_listeners(notebook)
notify_listeners(:new_notebook, notebook)
end
|
- (Object) enlarge_notebook(index)
81
82
83
|
# File 'plugins/application/lib/application/window.rb', line 81
def enlarge_notebook(index)
notify_listeners(:enlarge_notebook,index)
end
|
245
246
247
248
249
250
|
# File 'plugins/application/lib/application/window.rb', line 245
def focus
Redcar.app.events.ignore(:window_focus, self) do
notify_listeners(:focussed, self)
refresh_tabs
end
end
|
- (Object) focussed_notebook
163
164
165
|
# File 'plugins/application/lib/application/window.rb', line 163
def focussed_notebook
@focussed_notebook
end
|
- (Object) focussed_notebook=(notebook)
175
176
177
178
179
180
|
# File 'plugins/application/lib/application/window.rb', line 175
def focussed_notebook=(notebook)
if notebook != @focussed_notebook
set_focussed_notebook(notebook)
notify_listeners(:notebook_focussed, notebook)
end
end
|
- (Object) focussed_notebook_tab
167
168
169
|
# File 'plugins/application/lib/application/window.rb', line 167
def focussed_notebook_tab
@focussed_notebook.focussed_tab
end
|
- (Object) focussed_notebook_tab_document
171
172
173
|
# File 'plugins/application/lib/application/window.rb', line 171
def focussed_notebook_tab_document
focussed_notebook_tab.document if focussed_notebook_tab
end
|
- (Object) fullscreen
59
60
61
|
# File 'plugins/application/lib/application/window.rb', line 59
def fullscreen
controller.fullscreen
end
|
- (Object) fullscreen=(value)
63
64
65
|
# File 'plugins/application/lib/application/window.rb', line 63
def fullscreen=(value)
controller.fullscreen = value
end
|
274
275
276
|
# File 'plugins/application/lib/application/window.rb', line 274
def inspect
"#<Redcar::Window \"#{title}\">"
end
|
- (Object) new_tab(*args, &block)
Delegates to the new_tab method in the Window's active Notebook.
210
211
212
|
# File 'plugins/application/lib/application/window.rb', line 210
def new_tab(*args, &block)
focussed_notebook.new_tab(*args, &block)
end
|
- (Object) nonfocussed_notebook
186
187
188
189
190
|
# File 'plugins/application/lib/application/window.rb', line 186
def nonfocussed_notebook
i = @notebooks.index @focussed_notebook
@notebooks[(i + 1) % @notebooks.length]
end
|
- (Object) open_speedbar(speedbar)
278
279
280
281
282
283
284
|
# File 'plugins/application/lib/application/window.rb', line 278
def open_speedbar(speedbar)
if @speedbar
close_speedbar
end
@speedbar = speedbar
notify_listeners(:speedbar_opened, speedbar)
end
|
228
229
230
|
# File 'plugins/application/lib/application/window.rb', line 228
def ()
notify_listeners(:popup_menu, )
end
|
232
233
234
|
# File 'plugins/application/lib/application/window.rb', line 232
def ()
notify_listeners(:popup_menu_with_numbers, )
end
|
236
237
238
|
# File 'plugins/application/lib/application/window.rb', line 236
def
notify_listeners(:refresh_menu)
end
|
- (Object) refresh_tabs
Check all tabs for underlying files; mark if missing
253
254
255
256
257
258
259
|
# File 'plugins/application/lib/application/window.rb', line 253
def refresh_tabs
all_tabs.each do |tab|
if tab.is_a?(Redcar::EditTab)
tab.update_for_file_changes
end
end
end
|
240
241
242
|
# File 'plugins/application/lib/application/window.rb', line 240
def refresh_toolbar
notify_listeners(:refresh_toolbar)
end
|
- (Object) reset_notebook_widths
118
119
120
|
# File 'plugins/application/lib/application/window.rb', line 118
def reset_notebook_widths
notify_listeners(:reset_notebook_widths)
end
|
- (Object) rotate_notebooks
Sets the orientation of the notebooks to whatever it is not currently.
201
202
203
204
205
206
207
|
# File 'plugins/application/lib/application/window.rb', line 201
def rotate_notebooks
if notebook_orientation == :horizontal
self.notebook_orientation = :vertical
else
self.notebook_orientation = :horizontal
end
end
|
- (Object) set_focussed_notebook(notebook)
182
183
184
|
# File 'plugins/application/lib/application/window.rb', line 182
def set_focussed_notebook(notebook)
@focussed_notebook = notebook
end
|
- (Object) set_trees_visible(value)
29
30
31
32
33
34
35
|
# File 'plugins/application/lib/application/window.rb', line 29
def set_trees_visible(value)
if value
notify_listeners(:toggle_trees_visible) unless trees_visible?
else
notify_listeners(:toggle_trees_visible) if trees_visible?
end
end
|
50
51
52
53
|
# File 'plugins/application/lib/application/window.rb', line 50
def show
@visible = true
notify_listeners(:show)
end
|
41
42
43
|
# File 'plugins/application/lib/application/window.rb', line 41
def title
@title
end
|
- (Object) title=(value)
45
46
47
48
|
# File 'plugins/application/lib/application/window.rb', line 45
def title=(value)
@title = value
notify_listeners(:title_changed, @title)
end
|
- (Object) treebook_width
The width of a treebook in this window. (Even if there is none this is the
width it would be.)
87
88
89
90
91
|
# File 'plugins/application/lib/application/window.rb', line 87
def treebook_width
if controller
controller.treebook_open_width
end
end
|
- (Object) treebook_width=(size)
Set treebook width (does not reopen a hidden tree)
94
95
96
97
98
|
# File 'plugins/application/lib/application/window.rb', line 94
def treebook_width=(size)
if controller
controller.set_treebook_open_width(size)
end
end
|
- (Boolean) trees_visible?
37
38
39
|
# File 'plugins/application/lib/application/window.rb', line 37
def trees_visible?
not controller.treebook_hidden?
end
|
- (Boolean) visible?
55
56
57
|
# File 'plugins/application/lib/application/window.rb', line 55
def visible?
@visible
end
|