summaryrefslogtreecommitdiff
path: root/tools/editor/plugins
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-09-10 12:07:39 -0300
committerGitHub <noreply@github.com>2016-09-10 12:07:39 -0300
commit3c30a3b1aadfdf0c79162d8c6e8f8c12b4ad08a1 (patch)
tree7b3dc2e3978e38d59f39c856c6bf4b5181b07cd6 /tools/editor/plugins
parentc5b738511029ab27746b1ae34cfaaf056dc5902b (diff)
parent3d84849e033f8046389006ed19f7fd8c9875f052 (diff)
Merge pull request #6137 from supaiku-o/master
Add a Close All files option to script editor
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp38
-rw-r--r--tools/editor/plugins/script_editor_plugin.h4
2 files changed, 40 insertions, 2 deletions
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 1f931fb492..7f41949613 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -480,6 +480,33 @@ void ScriptEditor::_close_docs_tab() {
}
+void ScriptEditor::_close_all_tabs() {
+
+ int child_count = tab_container->get_child_count();
+ for (int i = child_count-1; i>=0; i--) {
+
+ tab_container->set_current_tab(i);
+ ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
+
+ if (se) {
+
+ // Maybe there are unsaved changes
+ if (se->is_unsaved()) {
+ _ask_close_current_unsaved_tab(se);
+ continue;
+ }
+
+ }
+
+ _close_current_tab();
+ }
+
+}
+
+void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) {
+ erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\"");
+ erase_tab_confirm->popup_centered_minsize();
+}
void ScriptEditor::_resave_scripts(const String& p_str) {
@@ -831,8 +858,7 @@ void ScriptEditor::_menu_option(int p_option) {
case FILE_CLOSE: {
if (current->is_unsaved()) {
- erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\"");
- erase_tab_confirm->popup_centered_minsize();
+ _ask_close_current_unsaved_tab(current);
} else {
_close_current_tab();
}
@@ -840,6 +866,9 @@ void ScriptEditor::_menu_option(int p_option) {
case CLOSE_DOCS: {
_close_docs_tab();
} break;
+ case CLOSE_ALL: {
+ _close_all_tabs();
+ } break;
case DEBUG_NEXT: {
if (debugger)
@@ -913,6 +942,9 @@ void ScriptEditor::_menu_option(int p_option) {
case CLOSE_DOCS: {
_close_docs_tab();
} break;
+ case CLOSE_ALL: {
+ _close_all_tabs();
+ } break;
}
@@ -1977,6 +2009,7 @@ void ScriptEditor::_bind_methods() {
ObjectTypeDB::bind_method("_menu_option",&ScriptEditor::_menu_option);
ObjectTypeDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab);
ObjectTypeDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab);
+ ObjectTypeDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs);
ObjectTypeDB::bind_method("_editor_play",&ScriptEditor::_editor_play);
ObjectTypeDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause);
ObjectTypeDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop);
@@ -2067,6 +2100,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL);
file_menu->get_popup()->connect("item_pressed", this,"_menu_option");
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 1a23ffed72..907240a352 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -133,6 +133,7 @@ class ScriptEditor : public VBoxContainer {
FILE_SAVE_THEME_AS,
FILE_CLOSE,
CLOSE_DOCS,
+ CLOSE_ALL,
FILE_TOOL_RELOAD,
FILE_TOOL_RELOAD_SOFT,
DEBUG_NEXT,
@@ -221,6 +222,9 @@ class ScriptEditor : public VBoxContainer {
void _close_current_tab();
void _close_docs_tab();
+ void _close_all_tabs();
+
+ void _ask_close_current_unsaved_tab(ScriptEditorBase *current);
bool grab_focus_block;