From 46ad2f8459d453ea1589fd84aabca1aea3923865 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 15 Jul 2020 08:39:13 +0200 Subject: [PATCH] Added Go to Tab in Window menu --- CMakeLists.txt | 2 +- src/files.hpp | 1 + src/menu.cpp | 4 ++++ src/window.cpp | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3d29d9..a589b3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.8.8) project(juci) -set(JUCI_VERSION "1.6.0.2") +set(JUCI_VERSION "1.6.0.3") set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim ") diff --git a/src/files.hpp b/src/files.hpp index 63044b6..de2d5c5 100644 --- a/src/files.hpp +++ b/src/files.hpp @@ -161,6 +161,7 @@ const std::string default_config_file = R"RAW({ "window_previous_tab": "Left",)RAW" #endif R"RAW( + "window_goto_tab": "", "window_toggle_split": "", "window_split_source_buffer": "",)RAW" #ifdef __APPLE__ diff --git a/src/menu.cpp b/src/menu.cpp index 2769949..9e21dd2 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -497,6 +497,10 @@ const Glib::ustring menu_xml = R"RAW( _Previous _Tab app.window_previous_tab + + _Go _to _Tab + app.window_goto_tab +
diff --git a/src/window.cpp b/src/window.cpp index 0682642..c9d80a6 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1598,6 +1598,42 @@ void Window::set_menu_actions() { menu.add_action("window_previous_tab", []() { Notebook::get().previous(); }); + menu.add_action("window_goto_tab", []() { + auto directory_folder = Project::get_preferably_directory_folder(); + auto build = Project::Build::create(directory_folder); + if(!build->project_path.empty()) + directory_folder = build->project_path; + + auto current_view = Notebook::get().get_current_view(); + if(current_view) + SelectionDialog::create(current_view, true, true); + else + SelectionDialog::create(true, true); + + std::vector views; + for(auto view : Notebook::get().get_views()) { + views.emplace_back(view); + SelectionDialog::get()->add_row(filesystem::get_relative_path(view->file_path, directory_folder).string()); + if(view == current_view) + SelectionDialog::get()->set_cursor_at_last_row(); + } + + if(views.empty()) { + Info::get().print("No tabs open"); + return; + } + + SelectionDialog::get()->on_select = [views = std::move(views)](unsigned int index, const std::string &text, bool hide_window) { + if(Notebook::get().open(views[index])) { + auto view = Notebook::get().get_current_view(); + view->hide_tooltips(); + } + }; + + if(current_view) + current_view->hide_tooltips(); + SelectionDialog::get()->show(); + }); menu.add_action("window_toggle_split", [] { Notebook::get().toggle_split(); });