ruber 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +21 -0
- data/data/share/apps/ruber/ruberui.rc +3 -1
- data/lib/ruber/application/application.rb +22 -23
- data/lib/ruber/application/plugin.yaml +7 -2
- data/lib/ruber/{projects → application}/project_files_list.rb +0 -0
- data/lib/ruber/{projects → application}/project_files_widget.rb +0 -0
- data/lib/ruber/application/ui/project_files_rule_chooser_widget.rb +74 -0
- data/lib/ruber/{projects → application}/ui/project_files_rule_chooser_widget.ui +0 -0
- data/lib/ruber/application/ui/project_files_widget.rb +117 -0
- data/lib/ruber/{projects → application}/ui/project_files_widget.ui +0 -0
- data/lib/ruber/component_manager.rb +14 -9
- data/lib/ruber/editor/document.rb +35 -5
- data/lib/ruber/kde_sugar.rb +16 -0
- data/lib/ruber/main_window/choose_plugins_dlg.rb +7 -4
- data/lib/ruber/main_window/main_window.rb +131 -193
- data/lib/ruber/main_window/main_window_actions.rb +157 -58
- data/lib/ruber/main_window/main_window_internal.rb +145 -54
- data/lib/ruber/main_window/open_file_in_project_dlg.rb +4 -4
- data/lib/ruber/main_window/plugin.yaml +3 -6
- data/lib/ruber/main_window/ui/workspace_settings_widget.rb +2 -2
- data/lib/ruber/main_window/workspace.rb +62 -32
- data/lib/ruber/output_widget.rb +20 -16
- data/lib/ruber/pane.rb +11 -5
- data/lib/ruber/project.rb +27 -12
- data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +2 -2
- data/lib/ruber/projects/ui/project_files_widget.rb +2 -2
- data/lib/ruber/utils.rb +37 -4
- data/lib/ruber/version.rb +1 -1
- data/lib/ruber/world/document_factory.rb +121 -0
- data/lib/ruber/world/document_list.rb +396 -0
- data/lib/ruber/world/environment.rb +470 -0
- data/lib/ruber/{main_window → world}/hint_solver.rb +1 -1
- data/lib/ruber/world/plugin.yaml +11 -0
- data/lib/ruber/world/project_factory.rb +131 -0
- data/lib/ruber/world/project_list.rb +265 -0
- data/lib/ruber/world/ui/workspace_settings_widget.rb +51 -0
- data/lib/ruber/{main_window → world}/ui/workspace_settings_widget.ui +0 -0
- data/lib/ruber/world/world.rb +307 -0
- data/plugins/auto_end/auto_end.rb +135 -9
- data/plugins/autosave/autosave.rb +4 -4
- data/plugins/find_in_files/find_in_files.rb +5 -5
- data/plugins/find_in_files/find_in_files_widgets.rb +1 -1
- data/plugins/project_browser/project_browser.rb +4 -4
- data/plugins/rake/rake.rb +4 -4
- data/plugins/rake/rake_extension.rb +1 -1
- data/plugins/rspec/rspec.rb +4 -4
- data/plugins/rspec/ruber_rspec_formatter.rb +2 -2
- data/plugins/ruby_development/ruby_development.rb +3 -3
- data/plugins/ruby_runner/ruby_runner.rb +2 -2
- data/plugins/state/plugin.yaml +6 -8
- data/plugins/state/state.rb +201 -391
- data/plugins/state/ui/config_widget.rb +5 -5
- data/plugins/state/ui/config_widget.ui +3 -3
- data/plugins/syntax_checker/syntax_checker.rb +4 -0
- data/spec/annotation_model_spec.rb +1 -1
- data/spec/auto_end_spec.rb +98 -47
- data/spec/component_manager_spec.rb +80 -21
- data/spec/document_factory_spec.rb +115 -0
- data/spec/document_list_spec.rb +560 -450
- data/spec/document_spec.rb +143 -55
- data/spec/editor_view_spec.rb +2 -2
- data/spec/environment_spec.rb +1900 -0
- data/spec/hint_solver_spec.rb +5 -5
- data/spec/kde_sugar_spec.rb +16 -0
- data/spec/output_widget_spec.rb +177 -51
- data/spec/pane_spec.rb +29 -5
- data/spec/plugin_spec.rb +1 -1
- data/spec/project_factory_spec.rb +104 -0
- data/spec/project_list_spec.rb +352 -447
- data/spec/project_spec.rb +34 -33
- data/spec/qt_sugar_spec.rb +2 -2
- data/spec/state_spec.rb +508 -811
- data/spec/utils_spec.rb +149 -98
- data/spec/workspace_spec.rb +120 -9
- data/spec/world_spec.rb +1219 -0
- metadata +23 -14
- data/lib/ruber/documents/document_list.rb +0 -412
- data/lib/ruber/documents/plugin.yaml +0 -4
- data/lib/ruber/main_window/view_manager.rb +0 -431
- data/lib/ruber/projects/plugin.yaml +0 -11
- data/lib/ruber/projects/project_list.rb +0 -314
@@ -47,7 +47,7 @@ It creates and activates a new, empty file
|
|
47
47
|
@return [EditorView] the editor used to display the new file
|
48
48
|
=end
|
49
49
|
def new_file
|
50
|
-
display_doc Ruber[:
|
50
|
+
display_doc Ruber[:world].new_document
|
51
51
|
end
|
52
52
|
|
53
53
|
=begin rdoc
|
@@ -64,11 +64,15 @@ user will become active
|
|
64
64
|
@return [Array<EditorView>] a list of the editors used for the files
|
65
65
|
=end
|
66
66
|
def open_file
|
67
|
-
dir = KDE::Url.from_path(
|
67
|
+
dir = KDE::Url.from_path(@active_environment.project.project_directory) rescue KDE::Url.new
|
68
68
|
filenames = KDE::FileDialog.get_open_urls(dir, OPEN_DLG_FILTERS.join("\n") , self)
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
# editors = []
|
70
|
+
# without_activating do
|
71
|
+
editors = filenames.map{|f| gui_open_file(f, false)}
|
72
|
+
# end
|
73
|
+
unless editors.empty?
|
74
|
+
@active_environment.activate_editor editors[0]
|
75
|
+
editors[-1].set_focus
|
72
76
|
end
|
73
77
|
editors
|
74
78
|
end
|
@@ -97,6 +101,11 @@ save it, discard changes or not close the view.
|
|
97
101
|
def close_current_editor
|
98
102
|
close_editor active_editor if active_editor
|
99
103
|
end
|
104
|
+
|
105
|
+
def close_current_tab
|
106
|
+
@active_environment.close_tab @active_environment.tab_widget.current_index
|
107
|
+
end
|
108
|
+
slots :close_current_tab
|
100
109
|
|
101
110
|
=begin rdoc
|
102
111
|
Slot connected to the Close Current Tab action
|
@@ -109,19 +118,19 @@ is asked what to do. If the user cancels the dialog, nothing is done.
|
|
109
118
|
@return [Boolean] *true* if the tab was closed successfully (or the tab widget was
|
110
119
|
empty) and *false* if the user canceled the save dialog
|
111
120
|
=end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
# def close_tab idx = nil
|
122
|
+
# tab = idx ? @tabs.widget(idx) : @tabs.current_widget
|
123
|
+
# return true unless tab
|
124
|
+
# docs = tab.map(&:document).select{|d| d.views.size == 1}.uniq
|
125
|
+
# return false unless save_documents docs
|
126
|
+
# views = tab.to_a
|
127
|
+
# without_activating do
|
128
|
+
# views.each{|v| close_editor v, false}
|
129
|
+
# end
|
130
|
+
# true
|
131
|
+
# end
|
132
|
+
# slots :close_tab
|
133
|
+
# slots 'close_tab(int)'
|
125
134
|
|
126
135
|
=begin rdoc
|
127
136
|
Slot connected to the 'Close All Other' action
|
@@ -135,15 +144,13 @@ don't close the views. In the latter case, nothing will be done
|
|
135
144
|
otherwise
|
136
145
|
=end
|
137
146
|
def close_other_views
|
138
|
-
to_close = @
|
147
|
+
to_close = @active_environment.tab_widget.inject([]) do |res, pn|
|
139
148
|
res += pn.each_view.to_a
|
140
149
|
res
|
141
150
|
end
|
142
151
|
to_close.delete active_editor
|
143
152
|
if save_documents to_close.map{|v| v.document}.uniq
|
144
|
-
|
145
|
-
to_close.each{|v| close_editor v, false}
|
146
|
-
end
|
153
|
+
to_close.each{|v| close_editor v, false}
|
147
154
|
true
|
148
155
|
else false
|
149
156
|
end
|
@@ -165,13 +172,11 @@ without asking the user.
|
|
165
172
|
otherwise
|
166
173
|
=end
|
167
174
|
def close_all_views ask = true
|
168
|
-
|
175
|
+
views = @active_environment.views
|
176
|
+
docs = views.map(&:document).uniq
|
169
177
|
return false if ask and !save_documents docs
|
170
|
-
|
171
|
-
|
172
|
-
w.to_a.each{|v| close_editor v, false}
|
173
|
-
end
|
174
|
-
end
|
178
|
+
@active_environment.activate_editor nil
|
179
|
+
views.to_a.each{|v| close_editor v, false}
|
175
180
|
true
|
176
181
|
end
|
177
182
|
|
@@ -187,6 +192,7 @@ given URL
|
|
187
192
|
def open_recent_project url
|
188
193
|
prj = safe_open_project url.path
|
189
194
|
return unless prj
|
195
|
+
Ruber[:world].active_project = prj
|
190
196
|
action_collection.action('project-open_recent').add_url url, url.file_name
|
191
197
|
prj
|
192
198
|
end
|
@@ -205,6 +211,8 @@ It opens the project chosen by the user using an open dialog
|
|
205
211
|
KDE::i18n('Open project')
|
206
212
|
return unless filename
|
207
213
|
prj = safe_open_project filename
|
214
|
+
return unless prj
|
215
|
+
Ruber[:world].active_project = prj
|
208
216
|
url = KDE::Url.new prj.project_file
|
209
217
|
action_collection.action('project-open_recent').add_url url, url.file_name
|
210
218
|
prj
|
@@ -218,7 +226,7 @@ project couldn't be saved
|
|
218
226
|
@return [nil]
|
219
227
|
=end
|
220
228
|
def close_current_project
|
221
|
-
unless
|
229
|
+
unless @active_environment.project.close
|
222
230
|
KDE::MessageBox.sorry self, "The project couldn't be saved"
|
223
231
|
end
|
224
232
|
nil
|
@@ -232,10 +240,11 @@ It opens the file chosen by the user in a quick open file dialog
|
|
232
240
|
@return [EditorView,nil] the editor where the document has been displayed
|
233
241
|
=end
|
234
242
|
def open_file_in_project
|
235
|
-
dlg = OpenFileInProjectDlg.new self
|
243
|
+
dlg = OpenFileInProjectDlg.new @active_environment.project, self
|
236
244
|
if dlg.exec == Qt::Dialog::Accepted
|
237
|
-
editor =
|
238
|
-
|
245
|
+
editor = @active_environment.display_document dlg.chosen_file
|
246
|
+
editor.set_focus
|
247
|
+
action_collection.action('file_open_recent').add_url( KDE::Url.new(dlg.chosen_file) )
|
239
248
|
editor
|
240
249
|
end
|
241
250
|
end
|
@@ -286,7 +295,7 @@ if there's no active project
|
|
286
295
|
@return [nil]
|
287
296
|
=end
|
288
297
|
def configure_project
|
289
|
-
prj =
|
298
|
+
prj = @active_environment.project
|
290
299
|
raise "No project is selected" unless prj
|
291
300
|
prj.dialog.exec
|
292
301
|
nil
|
@@ -306,12 +315,12 @@ it's closed
|
|
306
315
|
dlg = NewProjectDialog.new self
|
307
316
|
return if dlg.exec == Qt::Dialog::Rejected
|
308
317
|
dir = File.dirname dlg.project_file
|
309
|
-
FileUtils.mkdir dir
|
310
|
-
prj = Ruber[:
|
318
|
+
FileUtils.mkdir dir unless File.directory? dir
|
319
|
+
prj = Ruber[:world].new_project dlg.project_file, dlg.project_name
|
311
320
|
prj.save
|
312
321
|
action_collection.action('project-open_recent').add_url KDE::Url.new(dlg.project_file)
|
313
|
-
|
314
|
-
Ruber[:
|
322
|
+
# Ruber[:projects].close_current_project if Ruber[:projects].current
|
323
|
+
Ruber[:world].active_project = prj
|
315
324
|
nil
|
316
325
|
end
|
317
326
|
|
@@ -324,9 +333,10 @@ one, it returns to the first
|
|
324
333
|
@return [EditorView,nil] the active editor
|
325
334
|
=end
|
326
335
|
def next_document
|
327
|
-
|
328
|
-
|
329
|
-
|
336
|
+
tabs = @active_environment.tab_widget
|
337
|
+
idx = tabs.current_index
|
338
|
+
new_idx = idx + 1 < tabs.count ? idx + 1 : 0
|
339
|
+
tabs.current_index = new_idx
|
330
340
|
active_editor
|
331
341
|
end
|
332
342
|
|
@@ -339,9 +349,10 @@ one, it jumps to the last
|
|
339
349
|
@return [EditorView,nil] the active editor
|
340
350
|
=end
|
341
351
|
def previous_document
|
342
|
-
|
343
|
-
|
344
|
-
|
352
|
+
tabs = @active_environment.tab_widget
|
353
|
+
idx = tabs.current_index
|
354
|
+
new_idx = idx > 0 ? idx - 1 : tabs.count - 1
|
355
|
+
tabs.current_index = new_idx
|
345
356
|
nil
|
346
357
|
end
|
347
358
|
|
@@ -430,7 +441,7 @@ Displays the configuration dialog for the current document, if it exists
|
|
430
441
|
@return [nil]
|
431
442
|
=end
|
432
443
|
def configure_document
|
433
|
-
|
444
|
+
active_document.own_project.dialog.exec
|
434
445
|
nil
|
435
446
|
end
|
436
447
|
|
@@ -458,8 +469,10 @@ It splits the active view horizontally, so that a new copy of the view is create
|
|
458
469
|
@return [EditorView] the newly created editor
|
459
470
|
=end
|
460
471
|
def split_horizontally
|
461
|
-
ed = active_editor
|
462
|
-
display_document ed.document, :existing => :never,
|
472
|
+
ed = @active_environment.active_editor
|
473
|
+
@active_environment.display_document ed.document, :existing => :never,
|
474
|
+
:new => ed, :split => :horizontal
|
475
|
+
ed.set_focus
|
463
476
|
end
|
464
477
|
slots :split_horizontally
|
465
478
|
|
@@ -472,8 +485,10 @@ It splits the active view vertically, so that a new copy of the view is created.
|
|
472
485
|
@return [EditorView] the newly created editor
|
473
486
|
=end
|
474
487
|
def split_vertically
|
475
|
-
ed = active_editor
|
476
|
-
|
488
|
+
ed = @active_environment.active_editor
|
489
|
+
@active_environment.display_document ed.document, :existing => :never,
|
490
|
+
:new => ed, :split => :vertical
|
491
|
+
ed.set_focus
|
477
492
|
end
|
478
493
|
slots :split_vertically
|
479
494
|
|
@@ -488,8 +503,8 @@ associated to it and gives focus to it.
|
|
488
503
|
=end
|
489
504
|
def switch_to_new_document
|
490
505
|
old = active_editor
|
491
|
-
ed = replace_editor old, Ruber[:
|
492
|
-
|
506
|
+
ed = replace_editor old, Ruber[:world].new_document
|
507
|
+
ed.set_focus if ed
|
493
508
|
end
|
494
509
|
slots :switch_to_new_document
|
495
510
|
|
@@ -503,12 +518,13 @@ the active editor with a new one associated with the document and gives focus to
|
|
503
518
|
@return [EditorView] the newly created editor
|
504
519
|
=end
|
505
520
|
def switch_to_file
|
506
|
-
dir = KDE::Url.from_path(
|
521
|
+
dir = KDE::Url.from_path(@active_environment.project.project_directory) rescue KDE::Url.new
|
507
522
|
filename = KDE::FileDialog.get_open_url(dir, OPEN_DLG_FILTERS.join("\n") , self)
|
508
523
|
return unless filename.valid?
|
509
524
|
Ruber::Application.process_events
|
510
525
|
ed = replace_editor active_editor, filename
|
511
|
-
|
526
|
+
ed.set_focus if ed
|
527
|
+
ed
|
512
528
|
end
|
513
529
|
slots :switch_to_file
|
514
530
|
|
@@ -520,7 +536,7 @@ action list so that it contains an action for each of the open documents
|
|
520
536
|
=end
|
521
537
|
def update_switch_to_list
|
522
538
|
unplug_action_list "window-switch_to_open_document_list"
|
523
|
-
@switch_to_actions = Ruber[:
|
539
|
+
@switch_to_actions = Ruber[:world].documents.map do |doc|
|
524
540
|
a = action_collection.add_action "switch_to_#{doc.document_name}", self, SLOT(:switch_to_document)
|
525
541
|
a.text = KDE.i18n("Switch to %s") % [doc.document_name]
|
526
542
|
a.object_name = doc.document_name
|
@@ -531,6 +547,88 @@ action list so that it contains an action for each of the open documents
|
|
531
547
|
end
|
532
548
|
slots :update_switch_to_list
|
533
549
|
|
550
|
+
=begin rdoc
|
551
|
+
Updates the Active Project menu
|
552
|
+
|
553
|
+
@param [Project,nil] project if not *nil*, a project to exclude from the menu. This
|
554
|
+
is meant to be used when a project is closed, since the project list notifies
|
555
|
+
that a project is being closed _before_ removing it from the list
|
556
|
+
@return [nil]
|
557
|
+
=end
|
558
|
+
def update_active_project_menu project = nil
|
559
|
+
activate_action = action_collection.action 'project-active_project'
|
560
|
+
old_actions = activate_action.actions
|
561
|
+
activate_action.remove_all_actions
|
562
|
+
activate_action.add_action old_actions.delete_at(0)
|
563
|
+
old_actions.each{|a| a.delete_later}
|
564
|
+
Ruber[:world].projects.sort_by{|pr| pr.project_name}.each do |prj|
|
565
|
+
next if prj == project
|
566
|
+
name = "projects-activate_project-project_file_#{prj.project_file}"
|
567
|
+
a = activate_action.add_action prj.project_name
|
568
|
+
a.object_name = name
|
569
|
+
end
|
570
|
+
nil
|
571
|
+
end
|
572
|
+
slots :update_active_project_menu
|
573
|
+
slots 'update_active_project_menu(QObject*)'
|
574
|
+
|
575
|
+
=begin rdoc
|
576
|
+
Checks the entry in the Active Project action which corresponds to the current
|
577
|
+
project
|
578
|
+
|
579
|
+
If there's no current project, the action which deactivates all projects is selected.
|
580
|
+
|
581
|
+
If the action corresponding to the current project is already selected, nothing is
|
582
|
+
done.
|
583
|
+
@return [nil]
|
584
|
+
=end
|
585
|
+
def select_active_project_entry
|
586
|
+
active_project_action = action_collection.action 'project-active_project'
|
587
|
+
to_select = action_for_project Ruber[:world].active_project
|
588
|
+
unless to_select == active_project_action.current_action
|
589
|
+
active_project_action.current_action = to_select
|
590
|
+
end
|
591
|
+
nil
|
592
|
+
end
|
593
|
+
|
594
|
+
=begin rdoc
|
595
|
+
The action in the Active Project action list associated with a project
|
596
|
+
|
597
|
+
@param [Project,nil] prj the project. If *nil*, the action which deactivates
|
598
|
+
all projects is returned
|
599
|
+
@return [KDE::Action] the action associated with the given project
|
600
|
+
=end
|
601
|
+
def action_for_project prj
|
602
|
+
active_project_action = action_collection.action 'project-active_project'
|
603
|
+
if prj
|
604
|
+
file = prj.project_file
|
605
|
+
active_project_action.actions.find do |a|
|
606
|
+
a.object_name == "projects-activate_project-project_file_#{file}"
|
607
|
+
end
|
608
|
+
else active_project_action.action 0
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
=begin rdoc
|
613
|
+
Slot connected with the active project action
|
614
|
+
|
615
|
+
It makes the project corresponding to the selected action active. If the selected
|
616
|
+
action is the None action, then all projects will be deactivated.
|
617
|
+
|
618
|
+
If the project associated with the action is already the current project, nothing
|
619
|
+
will be done
|
620
|
+
@param [Qt::Action] act the selected action
|
621
|
+
@return [Project,nil] the new current project
|
622
|
+
=end
|
623
|
+
def change_active_project act
|
624
|
+
#object_name returns nil instead of an empty string if not set
|
625
|
+
match = (act.object_name || '').match(/projects-activate_project-project_file_(.*)$/)
|
626
|
+
prj = match ? Ruber[:world].projects[match[1]] : nil
|
627
|
+
Ruber[:world].active_project = prj
|
628
|
+
prj
|
629
|
+
end
|
630
|
+
slots 'change_active_project(QAction*)'
|
631
|
+
|
534
632
|
=begin rdoc
|
535
633
|
Slot associated with the actions in the Switch to Document submenu
|
536
634
|
|
@@ -543,9 +641,9 @@ editor with it, giving focus to it. The document to use is determined from the
|
|
543
641
|
@return [EditorView] the newly created editor
|
544
642
|
=end
|
545
643
|
def switch_to_document
|
546
|
-
doc = Ruber[:
|
644
|
+
doc = Ruber[:world].documents.document_with_name sender.object_name
|
547
645
|
ed = replace_editor active_editor, doc
|
548
|
-
|
646
|
+
ed.set_focus if ed
|
549
647
|
end
|
550
648
|
slots :switch_to_document
|
551
649
|
|
@@ -562,7 +660,7 @@ for it, replaces the active editor with it and gives focus to it.
|
|
562
660
|
=end
|
563
661
|
def switch_to_recent_file url
|
564
662
|
ed = replace_editor active_editor, url
|
565
|
-
|
663
|
+
ed.set_focus if ed
|
566
664
|
end
|
567
665
|
slots 'switch_to_recent_file(KUrl)'
|
568
666
|
|
@@ -582,8 +680,9 @@ one view, nothing is done.
|
|
582
680
|
direction = action_name.match('next') ? :next : :previous
|
583
681
|
orientation = action_name.match(/horizontal/) ? Qt::Horizontal : Qt::Vertical
|
584
682
|
pane = find_next_pane active_editor.parent, orientation, direction
|
585
|
-
|
586
|
-
|
683
|
+
tabs = @active_environment.tab_widget
|
684
|
+
view = pane ? pane.view : tabs.current_widget.views[direction == :next ? 0 : -1]
|
685
|
+
view.set_focus
|
587
686
|
end
|
588
687
|
slots :move_among_views
|
589
688
|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
You should have received a copy of the GNU General Public License
|
16
16
|
along with this program; if not, write to the
|
17
17
|
Free Software Foundation, Inc.,
|
18
|
-
59 Temple Place - Suite
|
18
|
+
59 Temple Place - Suite g, Boston, MA 02111-1307, USA.
|
19
19
|
=end
|
20
20
|
|
21
21
|
require 'facets/enumerable/sum'
|
@@ -23,7 +23,7 @@ require 'facets/enumerable/sum'
|
|
23
23
|
module Ruber
|
24
24
|
|
25
25
|
class MainWindow < KParts::MainWindow
|
26
|
-
|
26
|
+
|
27
27
|
=begin rdoc
|
28
28
|
A list of strings to be used to create the filter for open file dialogs
|
29
29
|
=end
|
@@ -43,13 +43,12 @@ A list of strings to be used to create the filter for open file dialogs
|
|
43
43
|
=begin rdoc
|
44
44
|
Override of @KParts::MainWindow#queryClose@
|
45
45
|
|
46
|
-
It calls
|
47
|
-
|
48
|
-
@return [Boolean] what the {ComponentManager#query_close query_close} method of
|
49
|
-
the component manager returns
|
46
|
+
It calls the {Application#ask_to_quit ask_to_quit} method of the application.
|
47
|
+
@return [Boolean] what {Application#ask_to_quit} returns
|
50
48
|
=end
|
51
49
|
def queryClose
|
52
|
-
Ruber[:
|
50
|
+
res = Ruber[:app].ask_to_quit
|
51
|
+
res
|
53
52
|
end
|
54
53
|
|
55
54
|
=begin rdoc
|
@@ -59,7 +58,25 @@ It calls the {Application#quit_ruber quit_ruber} method of the application
|
|
59
58
|
@return [TrueClass] *true*
|
60
59
|
=end
|
61
60
|
def queryExit
|
62
|
-
|
61
|
+
#There's a C++-side crash in any view is open after this method when closing
|
62
|
+
#a session. As I have no clue as why this happens, for the time being, as
|
63
|
+
#a workaround, we close all the documents.
|
64
|
+
|
65
|
+
#For some reason, this method is called twice when closing a session
|
66
|
+
#but only when Ruber is launched from the global installation (that is, typing
|
67
|
+
#ruber in the shell), and not when testing from xsm. This causes a number of
|
68
|
+
#problems, the most evident is the save_settings method being called twice,
|
69
|
+
#one of the times after all documents have been closed. This obviously breaks
|
70
|
+
#the state plugin. To avoid the issue, we use an instance variable to keep
|
71
|
+
#trace of whether the method has already been called or not. Ruber[:app].quit_ruber
|
72
|
+
#is only called the first time, while the documents are only closed the
|
73
|
+
#second time
|
74
|
+
if @query_exit_called
|
75
|
+
Ruber[:world].close_all :documents, :discard
|
76
|
+
else
|
77
|
+
Ruber[:app].quit_ruber
|
78
|
+
@query_exit_called = true
|
79
|
+
end
|
63
80
|
true
|
64
81
|
end
|
65
82
|
|
@@ -95,20 +112,28 @@ It adds the document to the part manager and makes several signal-slot connectio
|
|
95
112
|
@return [nil]
|
96
113
|
=end
|
97
114
|
def document_created doc
|
98
|
-
@view_manager.part_manager.add_part doc.send(:internal)
|
99
115
|
connect doc, SIGNAL('modified_changed(bool, QObject*)'), self, SLOT('document_modified_changed(bool)')
|
100
|
-
connect doc, SIGNAL('modified_on_disk(QObject*, bool, KTextEditor::ModificationInterface::ModifiedOnDiskReason)'), self, SLOT('update_document_icon(QObject*)')
|
101
116
|
connect doc, SIGNAL('document_url_changed(QObject*)'), self, SLOT(:document_url_changed)
|
102
117
|
connect doc, SIGNAL(:completed), self, SLOT(:document_url_changed)
|
103
|
-
connect doc, SIGNAL('closing(QObject*)'), self, SLOT('remove_document_from_part_manager(QObject*)')
|
104
118
|
update_switch_to_list
|
105
119
|
end
|
106
120
|
slots 'document_created(QObject*)'
|
107
121
|
|
108
|
-
def
|
109
|
-
|
122
|
+
def slot_active_environment_changed(new, old)
|
123
|
+
if old
|
124
|
+
old.disconnect SIGNAL('active_editor_changed(QWidget*)'), self, SLOT('slot_active_editor_changed(QWidget*)')
|
125
|
+
end
|
126
|
+
@active_environment = new
|
127
|
+
if new
|
128
|
+
connect new, SIGNAL('active_editor_changed(QWidget*)'), self, SLOT('slot_active_editor_changed(QWidget*)')
|
129
|
+
@workspace.main_widget = new.tab_widget
|
130
|
+
change_state 'active_project_exists', !new.project.nil?
|
131
|
+
select_active_project_entry
|
132
|
+
change_title
|
133
|
+
else Ruber[:world].active_environment = Ruber[:world].default_environment
|
134
|
+
end
|
110
135
|
end
|
111
|
-
slots '
|
136
|
+
slots 'slot_active_environment_changed(QObject*, QObject*)'
|
112
137
|
|
113
138
|
=begin rdoc
|
114
139
|
Slot called whenever the active editor changes
|
@@ -128,6 +153,19 @@ and updates the title and the statusbar
|
|
128
153
|
nil
|
129
154
|
end
|
130
155
|
slots 'slot_active_editor_changed(QWidget*)'
|
156
|
+
|
157
|
+
def slot_project_created prj
|
158
|
+
@workspace.add_widget prj.environment.tab_widget
|
159
|
+
update_active_project_menu
|
160
|
+
end
|
161
|
+
slots 'slot_project_created(QObject*)'
|
162
|
+
|
163
|
+
def slot_project_closing prj
|
164
|
+
@workspace.remove_widget prj.environment.tab_widget
|
165
|
+
update_active_project_menu prj
|
166
|
+
end
|
167
|
+
slots 'slot_project_closing(QObject*)'
|
168
|
+
|
131
169
|
|
132
170
|
=begin rdoc
|
133
171
|
Changes the icon in the tab corresponding to a document so that it reflects its
|
@@ -136,18 +174,19 @@ current status
|
|
136
174
|
@param [Document] doc the document to update the icon for
|
137
175
|
@return [nil]
|
138
176
|
=end
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
177
|
+
# def update_document_icon doc
|
178
|
+
# views = doc.views
|
179
|
+
# views.each do |v|
|
180
|
+
# tab = @active_environment.tab v
|
181
|
+
# next unless tab
|
182
|
+
# tab_widget = @active_environment.tab_widget
|
183
|
+
# if v.is_ancestor_of tab.focus_widget
|
184
|
+
# idx = tab_widget.index_of tab
|
185
|
+
# @tab_widget.set_tab_icon idx, doc.icon
|
186
|
+
# end
|
187
|
+
# end
|
188
|
+
# nil
|
189
|
+
# end
|
151
190
|
|
152
191
|
=begin rdoc
|
153
192
|
Opens a file in an editor, gives focus to it and adds it to the list of recent
|
@@ -163,10 +202,10 @@ See {#editor_for!} for the values which can be included in _hints_
|
|
163
202
|
@return [EditorView,nil] the editor displaying the file or *nil* if the file
|
164
203
|
couldn't be opened
|
165
204
|
=end
|
166
|
-
def gui_open_file file, hints = DEFAULT_HINTS
|
167
|
-
editor = editor_for! file, hints
|
205
|
+
def gui_open_file file, give_focus = true, hints = DEFAULT_HINTS
|
206
|
+
editor = @active_environment.editor_for! file, hints
|
168
207
|
return unless editor
|
169
|
-
|
208
|
+
editor.set_focus if give_focus
|
170
209
|
url = KDE::Url.new file
|
171
210
|
action_collection.action('file_open_recent').add_url url, url.file_name
|
172
211
|
action_collection.action('window-switch_to_recent_file').add_url url, url.file_name
|
@@ -183,12 +222,12 @@ modified status
|
|
183
222
|
=end
|
184
223
|
def change_title
|
185
224
|
title = ''
|
186
|
-
prj =
|
225
|
+
prj = @active_environment.project
|
187
226
|
if prj
|
188
227
|
title << (prj.project_name ? prj.project_name :
|
189
228
|
File.basename(prj.project_file, '.ruprj'))
|
190
229
|
end
|
191
|
-
doc =
|
230
|
+
doc = active_document
|
192
231
|
if doc and doc.path.empty?
|
193
232
|
title << ' - ' << doc.document_name
|
194
233
|
elsif doc
|
@@ -214,7 +253,7 @@ Nothing is done if the document isn't associated with a view
|
|
214
253
|
def document_modified_changed mod
|
215
254
|
doc = self.sender
|
216
255
|
change_title
|
217
|
-
|
256
|
+
# update_document_icon doc
|
218
257
|
nil
|
219
258
|
end
|
220
259
|
|
@@ -230,17 +269,17 @@ Nothing is done if the document isn't associated with a view
|
|
230
269
|
=end
|
231
270
|
def document_url_changed
|
232
271
|
doc = self.sender
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
272
|
+
# return unless doc.has_view?
|
273
|
+
# change_title
|
274
|
+
# doc.views.each do |v|
|
275
|
+
# v.parent.label = @view_manager.label_for_editor v
|
276
|
+
# tab = @view_manager.tab v
|
277
|
+
# if @view_manager.focus_editor? v, tab
|
278
|
+
# idx = @tabs.index_of tab
|
279
|
+
# @tabs.set_tab_text idx, doc.document_name
|
280
|
+
# end
|
281
|
+
# end
|
282
|
+
# update_document_icon doc
|
244
283
|
unless doc.path.empty?
|
245
284
|
action_collection.action('file_open_recent').add_url KDE::Url.new(doc.path)
|
246
285
|
end
|
@@ -273,20 +312,72 @@ Gives the UI states their initial values
|
|
273
312
|
end
|
274
313
|
|
275
314
|
=begin rdoc
|
276
|
-
Closes the
|
315
|
+
Closes the views associated with the given project
|
277
316
|
|
278
|
-
If any
|
279
|
-
|
317
|
+
If any of the views is the only one associated with its document, the document
|
318
|
+
itself will be closed. In this case, if the document is modified, the user has
|
319
|
+
the possiblity of choosing whether to save them, discard the changes or not to
|
320
|
+
close the documents.
|
280
321
|
@param [Project] prj the project whose documents should be closed
|
281
|
-
@return [Boolean] *true* if the documents were
|
322
|
+
@return [Boolean] *true* if the documents were closed and *false* if the user chose
|
323
|
+
to abort
|
282
324
|
=end
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
325
|
+
# def close_project_files prj
|
326
|
+
# views_to_close = prj.extension(:environment).views
|
327
|
+
# to_save = views_to_close.map do |v|
|
328
|
+
# v.document.views(:all).count == 1 ? v.document : nil
|
329
|
+
# end
|
330
|
+
# return false unless save_documents to_save.compact
|
331
|
+
# without_activating{views_to_close.each{|v| close_editor v, false}}
|
332
|
+
# end
|
333
|
+
|
334
|
+
=begin rdoc
|
335
|
+
Creates a new view manager
|
336
|
+
|
337
|
+
A new tab widget for the view manager is created if none is given.
|
338
|
+
|
339
|
+
After creating the view manager, it makes all the necessary signal-slot connections
|
340
|
+
with it and with the associated tab widget, if a new one is created.
|
341
|
+
@param [KDE::TabWidget,nil] tabs the tab widget to use for the view manager. If
|
342
|
+
*nil*, a new widget will be created
|
343
|
+
@return [ViewManager] the new view manager
|
344
|
+
=end
|
345
|
+
# def create_view_manager tabs = nil
|
346
|
+
# mw = self
|
347
|
+
# tabs ||= KDE::TabWidget.new do
|
348
|
+
# self.document_mode = true
|
349
|
+
# self.tabs_closable = Ruber[:config][:workspace, :close_buttons]
|
350
|
+
# connect self, SIGNAL('tabCloseRequested(int)'), mw, SLOT('close_tab(int)')
|
351
|
+
# end
|
352
|
+
# manager = ViewManager.new tabs, self
|
353
|
+
# connect manager, SIGNAL('active_editor_changed(QWidget*)'), self, SLOT('slot_active_editor_changed(QWidget*)')
|
354
|
+
# manager
|
355
|
+
# end
|
356
|
+
|
357
|
+
=begin rdoc
|
358
|
+
Activates a view manager
|
359
|
+
|
360
|
+
Activating a view manager means, besides other things, that its tab widget becomes
|
361
|
+
the main widget of the workspace (becoming visible if it was hidden) and that the
|
362
|
+
tab widget of the previously active view manager is hidden
|
363
|
+
@param [ViewManager] the view manager to activate
|
364
|
+
@return [ViewManager,nil] the previously active view manager, or *nil* if there
|
365
|
+
wasn't a view manager active
|
366
|
+
=end
|
367
|
+
# def switch_to_view_manager manager
|
368
|
+
# old = @view_manager
|
369
|
+
# if old
|
370
|
+
# old.deactivate
|
371
|
+
# old.tabs.hide
|
372
|
+
# end
|
373
|
+
# @view_manager = manager
|
374
|
+
# @tabs = manager.tabs
|
375
|
+
# @workspace.main_widget = @tabs
|
376
|
+
# @tabs.show
|
377
|
+
# @view_manager.activate
|
378
|
+
# active_editor.set_focus if active_editor
|
379
|
+
# old
|
380
|
+
# end
|
290
381
|
|
291
382
|
end
|
292
383
|
|