Remove hidden SETM Editor in METM to save memory and handles, fixes #3944

This commit is contained in:
heckflosse
2017-06-29 19:52:09 +02:00
parent 5f97800e69
commit 3281332b8e
3 changed files with 49 additions and 37 deletions

View File

@@ -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);
}