diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index bd5929289..d211add4f 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -2333,17 +2333,7 @@ void Preferences::workflowUpdate () { if(moptions.tabbedUI != options.tabbedUI) { - parent->MoveFileBrowserToMain(); - parent->CloseOpenEditors(); - parent->SetMainCurrent(); - - if(moptions.tabbedUI) { - parent->epanel->hide(); - parent->set_title_decorated(""); - } else { - parent->epanel->show_all(); - parent->set_title_decorated(parent->epanel->getFileName()); - } + parent->setEditorMode(moptions.tabbedUI); } if(moptions.hideTPVScrollbar != options.hideTPVScrollbar) { diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index e40d95f15..3324600bb 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -165,7 +165,6 @@ RTWindow::RTWindow () mainNB->set_scrollable (true); mainNB->signal_switch_page().connect_notify( sigc::mem_fun(*this, &RTWindow::on_mainNB_switch_page) ); - // Editor panel fpanel = new FilePanel () ; fpanel->setParent (this); @@ -203,29 +202,10 @@ RTWindow::RTWindow () mainNB->append_page (*bpanel, *lbq); - // Editor panel, single-tab mode only - epanel = Gtk::manage ( new EditorPanel (fpanel) ); - epanel->setParent (this); - - // decorate tab - Gtk::Grid* editorLabelGrid = Gtk::manage (new Gtk::Grid ()); - setExpandAlignProperties(editorLabelGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - Gtk::Label* el = Gtk::manage (new Gtk::Label( Glib::ustring(" ") + M("MAIN_FRAME_EDITOR") )); - - if (options.mainNBVertical) { - el->set_angle (90); - editorLabelGrid->attach_next_to(*Gtk::manage (new RTImage ("rt-logo-small.png")), Gtk::POS_TOP, 1, 1); - editorLabelGrid->attach_next_to(*el, Gtk::POS_TOP, 1, 1); - } else { - editorLabelGrid->attach_next_to(*Gtk::manage (new RTImage ("rt-logo-small.png")), Gtk::POS_RIGHT, 1, 1); - editorLabelGrid->attach_next_to(*el, Gtk::POS_RIGHT, 1, 1); + if(isSingleTabMode()) { + createSetmEditor(); } - editorLabelGrid->set_tooltip_markup (M("MAIN_FRAME_EDITOR_TOOLTIP")); - editorLabelGrid->show_all (); - epanel->tbTopPanel_1_visible(true); //show the toggle Top Panel button - mainNB->append_page (*epanel, *editorLabelGrid); - mainNB->set_current_page (mainNB->page_num (*fpanel)); //Gtk::VBox* mainBox = Gtk::manage (new Gtk::VBox ()); @@ -291,10 +271,6 @@ RTWindow::RTWindow () } } } - - if (!isSingleTabMode() && !simpleEditor) { - epanel->hide(); - } } RTWindow::~RTWindow() @@ -862,3 +838,47 @@ bool RTWindow::isEditorPanel(guint pageNum) { return isEditorPanel(mainNB->get_nth_page(pageNum)); } + +void RTWindow::setEditorMode(bool tabbedUI) +{ + MoveFileBrowserToMain(); + CloseOpenEditors(); + SetMainCurrent(); + + if(tabbedUI) { + mainNB->remove_page(*epanel); + epanel = nullptr; + set_title_decorated(""); + } else { + createSetmEditor(); + epanel->show_all(); + set_title_decorated(""); + } +} + +void RTWindow::createSetmEditor() +{ + // Editor panel, single-tab mode only + epanel = Gtk::manage ( new EditorPanel (fpanel) ); + epanel->setParent (this); + + // decorate tab + Gtk::Grid* const editorLabelGrid = Gtk::manage (new Gtk::Grid ()); + setExpandAlignProperties(editorLabelGrid, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); + Gtk::Label* const el = Gtk::manage (new Gtk::Label( Glib::ustring(" ") + M("MAIN_FRAME_EDITOR") )); + + const auto pos = options.mainNBVertical ? Gtk::POS_TOP : Gtk::POS_RIGHT; + + if (options.mainNBVertical) { + el->set_angle(90); + } + + editorLabelGrid->attach_next_to(*Gtk::manage (new RTImage ("rt-logo-small.png")), pos, 1, 1); + editorLabelGrid->attach_next_to(*el, pos, 1, 1); + + editorLabelGrid->set_tooltip_markup (M("MAIN_FRAME_EDITOR_TOOLTIP")); + editorLabelGrid->show_all (); + epanel->tbTopPanel_1_visible(true); //show the toggle Top Panel button + mainNB->append_page (*epanel, *editorLabelGrid); + +} diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index f3d6c5aa2..a57f7b4a3 100644 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -116,6 +116,8 @@ public: } void set_title_decorated(Glib::ustring fname); void CloseOpenEditors(); + void setEditorMode(bool tabbedUI); + void createSetmEditor(); }; #endif