2015-07-03 15:06:29 -04:00
|
|
|
/*
|
2019-08-02 22:40:09 -04:00
|
|
|
* Copyright (C) 2015 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2015-07-03 15:06:29 -04:00
|
|
|
|
|
|
|
#include <gtkmm/action.h>
|
2024-11-02 16:35:31 -04:00
|
|
|
#include <gtkmm/frame.h>
|
2015-07-03 15:06:29 -04:00
|
|
|
#include <gtkmm/notebook.h>
|
|
|
|
#include <gtkmm/window.h>
|
2015-07-21 21:10:46 -04:00
|
|
|
#include <gtkmm/stock.h>
|
2015-07-03 15:06:29 -04:00
|
|
|
|
2024-11-02 16:35:31 -04:00
|
|
|
#include "gtkmm2ext/actions.h"
|
2015-07-09 13:27:39 -04:00
|
|
|
#include "gtkmm2ext/gtk_ui.h"
|
2015-07-21 22:37:39 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
2015-07-03 15:06:29 -04:00
|
|
|
#include "gtkmm2ext/visibility_tracker.h"
|
|
|
|
|
2017-07-16 22:55:52 -04:00
|
|
|
#include "widgets/tabbable.h"
|
2015-11-18 22:25:18 -05:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2015-07-09 12:40:51 -04:00
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
using std::string;
|
2017-07-16 22:55:52 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace ArdourWidgets;
|
2015-07-03 15:06:29 -04:00
|
|
|
|
2024-11-05 19:28:48 -05:00
|
|
|
Tabbable::Tabbable (const string& visible_name, string const & nontranslatable_name, Widget* w, bool tabbed_by_default)
|
2020-05-01 16:28:05 -04:00
|
|
|
: WindowProxy (visible_name, nontranslatable_name)
|
2015-11-18 22:25:18 -05:00
|
|
|
, _parent_notebook (0)
|
2017-02-20 16:55:31 -05:00
|
|
|
, tab_requested_by_state (tabbed_by_default)
|
2015-07-03 15:06:29 -04:00
|
|
|
{
|
2024-11-05 19:28:48 -05:00
|
|
|
if (w) {
|
|
|
|
_contents = w;
|
|
|
|
} else {
|
|
|
|
_contents = &_content_vbox;
|
|
|
|
default_layout ();
|
|
|
|
}
|
2015-07-03 15:06:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Tabbable::~Tabbable ()
|
|
|
|
{
|
|
|
|
if (_window) {
|
|
|
|
delete _window;
|
|
|
|
_window = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-02 16:35:31 -04:00
|
|
|
void
|
|
|
|
Tabbable::default_layout ()
|
|
|
|
{
|
2024-11-12 23:28:22 -05:00
|
|
|
#ifndef LIVETRAX
|
2024-11-02 16:35:31 -04:00
|
|
|
left_attachment_button.set_text (_("Left"));
|
|
|
|
right_attachment_button.set_text (_("Right"));
|
|
|
|
bottom_attachment_button.set_text (_("Btm"));
|
|
|
|
|
2024-11-08 19:09:13 -05:00
|
|
|
left_attachment_button.set_icon (ArdourIcon::AttachmentLeft);
|
|
|
|
right_attachment_button.set_icon (ArdourIcon::AttachmentRight);
|
|
|
|
bottom_attachment_button.set_icon (ArdourIcon::AttachmentBottom);
|
|
|
|
|
|
|
|
left_attachment_button.set_name ("lock button"); // XXX re-use netural "fill active" bg style of "lock"
|
|
|
|
right_attachment_button.set_name ("lock button"); // TODO create dedicate button style
|
|
|
|
bottom_attachment_button.set_name ("lock button");
|
|
|
|
|
|
|
|
left_attachment_button.set_tweaks (ArdourButton::ExpandtoSquare);
|
|
|
|
right_attachment_button.set_tweaks (ArdourButton::ExpandtoSquare);
|
|
|
|
bottom_attachment_button.set_tweaks (ArdourButton::ExpandtoSquare);
|
|
|
|
|
2024-11-02 16:35:31 -04:00
|
|
|
content_attachment_hbox.set_border_width(3);
|
|
|
|
content_attachment_hbox.set_spacing(3);
|
|
|
|
content_attachment_hbox.pack_end (right_attachment_button, false, false);
|
|
|
|
content_attachment_hbox.pack_end (bottom_attachment_button, false, false);
|
|
|
|
content_attachment_hbox.pack_end (left_attachment_button, false, false);
|
|
|
|
content_attachments.add (content_attachment_hbox);
|
2024-11-12 23:28:22 -05:00
|
|
|
#endif
|
2024-11-02 16:35:31 -04:00
|
|
|
|
|
|
|
content_header_hbox.pack_start (content_app_bar, true, true);
|
|
|
|
content_header_hbox.pack_start (content_attachments, false, false);
|
|
|
|
content_header_hbox.pack_start (content_tabbables, false, false);
|
|
|
|
|
2024-11-12 23:28:22 -05:00
|
|
|
#ifndef LIVETRAX
|
2024-11-02 16:35:31 -04:00
|
|
|
//wrap the header eboxen in a themeable frame
|
|
|
|
Gtk::Frame *toolbar_frame = manage(new Gtk::Frame);
|
|
|
|
toolbar_frame->set_name ("TransportFrame");
|
|
|
|
toolbar_frame->set_shadow_type (Gtk::SHADOW_NONE);
|
|
|
|
toolbar_frame->add (content_header_hbox);
|
|
|
|
|
|
|
|
_content_vbox.pack_start (*toolbar_frame, false, false);
|
2024-11-12 23:28:22 -05:00
|
|
|
#endif
|
2024-11-02 16:35:31 -04:00
|
|
|
_content_vbox.pack_start (content_hbox, true, true);
|
|
|
|
|
|
|
|
content_hbox.pack_start (content_att_left, false, false);
|
|
|
|
content_hbox.pack_start (content_midlevel_vbox, true, true);
|
|
|
|
|
|
|
|
content_midlevel_vbox.pack_start (content_right_pane, true, true);
|
|
|
|
content_midlevel_vbox.pack_start (content_att_bottom, false, false);
|
|
|
|
|
|
|
|
content_right_pane.add (content_inner_vbox);
|
|
|
|
content_right_pane.add (content_right_vbox);
|
|
|
|
|
|
|
|
//TODO: menu switcher here?
|
|
|
|
content_right_vbox.pack_start (content_att_right, true, true);
|
|
|
|
|
|
|
|
content_inner_vbox.pack_start (content_toolbar, false, false);
|
|
|
|
content_inner_vbox.pack_start (content_innermost_hbox, true, true);
|
|
|
|
|
|
|
|
content_right_pane.set_child_minsize (content_att_right, 160); /* rough guess at width of notebook tabs */
|
|
|
|
content_right_pane.set_check_divider_position (true);
|
|
|
|
content_right_pane.set_divider (0, 0.85);
|
|
|
|
|
|
|
|
_content_vbox.show_all();
|
|
|
|
}
|
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
void
|
2021-02-23 11:24:42 -05:00
|
|
|
Tabbable::add_to_notebook (Notebook& notebook)
|
2015-07-03 15:06:29 -04:00
|
|
|
{
|
2015-07-22 17:49:03 -04:00
|
|
|
_parent_notebook = ¬ebook;
|
2015-07-21 22:37:39 -04:00
|
|
|
|
2015-07-22 17:49:03 -04:00
|
|
|
if (tab_requested_by_state) {
|
|
|
|
attach ();
|
|
|
|
}
|
2015-07-03 15:06:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Window*
|
2015-07-09 12:40:51 -04:00
|
|
|
Tabbable::use_own_window (bool and_pack_it)
|
2015-07-03 15:06:29 -04:00
|
|
|
{
|
2015-07-09 12:40:51 -04:00
|
|
|
Gtk::Window* win = get (true);
|
|
|
|
|
|
|
|
if (and_pack_it) {
|
2024-11-05 19:28:48 -05:00
|
|
|
Gtk::Container* parent = _contents->get_parent();
|
2015-07-09 12:40:51 -04:00
|
|
|
if (parent) {
|
2024-11-05 19:28:48 -05:00
|
|
|
_contents->hide ();
|
|
|
|
parent->remove (*_contents);
|
2015-07-09 12:40:51 -04:00
|
|
|
}
|
2024-11-05 19:28:48 -05:00
|
|
|
_own_notebook.append_page (*_contents);
|
|
|
|
_contents->show ();
|
2015-07-09 12:40:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return win;
|
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-07-25 09:18:32 -04:00
|
|
|
Tabbable::window_visible () const
|
2015-07-03 15:06:29 -04:00
|
|
|
{
|
2015-07-25 09:18:32 -04:00
|
|
|
if (!_window) {
|
2015-07-03 15:06:29 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-01-26 15:21:06 -05:00
|
|
|
return _window->get_visible();
|
2015-07-03 15:06:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Window*
|
|
|
|
Tabbable::get (bool create)
|
|
|
|
{
|
|
|
|
if (_window) {
|
|
|
|
return _window;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!create) {
|
|
|
|
return 0;
|
|
|
|
}
|
2015-07-07 22:12:21 -04:00
|
|
|
|
2015-10-26 14:35:06 -04:00
|
|
|
/* From here on, we're creating the window
|
2015-07-07 22:12:21 -04:00
|
|
|
*/
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
if ((_window = new Window (WINDOW_TOPLEVEL)) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
_window->add (_own_notebook);
|
|
|
|
_own_notebook.show ();
|
|
|
|
_own_notebook.set_show_tabs (false);
|
|
|
|
|
2015-07-23 08:35:24 -04:00
|
|
|
_window->signal_map().connect (sigc::mem_fun (*this, &Tabbable::window_mapped));
|
|
|
|
_window->signal_unmap().connect (sigc::mem_fun (*this, &Tabbable::window_unmapped));
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
/* do other window-related setup */
|
|
|
|
|
|
|
|
setup ();
|
2015-07-03 15:06:29 -04:00
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
/* window should be ready for derived classes to do something with it */
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
return _window;
|
|
|
|
}
|
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
void
|
|
|
|
Tabbable::show_own_window (bool and_pack_it)
|
2015-07-07 22:12:21 -04:00
|
|
|
{
|
2024-11-05 19:28:48 -05:00
|
|
|
Gtk::Widget* parent = _contents->get_parent();
|
2015-07-08 13:13:47 -04:00
|
|
|
Gtk::Allocation alloc;
|
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
if (parent) {
|
|
|
|
alloc = parent->get_allocation();
|
|
|
|
}
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
(void) use_own_window (and_pack_it);
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
if (parent) {
|
|
|
|
_window->set_default_size (alloc.get_width(), alloc.get_height());
|
|
|
|
}
|
|
|
|
|
2015-07-25 09:18:32 -04:00
|
|
|
tab_requested_by_state = false;
|
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
_window->present ();
|
|
|
|
}
|
|
|
|
|
|
|
|
Gtk::Notebook*
|
|
|
|
Tabbable::tab_root_drop ()
|
|
|
|
{
|
2015-07-07 22:12:21 -04:00
|
|
|
/* This is called after a drop of a tab onto the root window. Its
|
2021-02-04 13:12:22 -05:00
|
|
|
* responsibility is to return the notebook that this Tabbable's
|
2015-07-07 22:12:21 -04:00
|
|
|
* contents should be packed into before the drop handling is
|
|
|
|
* completed. It is not responsible for actually taking care of this
|
|
|
|
* packing.
|
|
|
|
*/
|
2015-07-08 13:13:47 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
show_own_window (false);
|
2015-07-07 22:12:21 -04:00
|
|
|
return &_own_notebook;
|
|
|
|
}
|
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
void
|
|
|
|
Tabbable::show_window ()
|
|
|
|
{
|
2015-07-21 21:10:46 -04:00
|
|
|
make_visible ();
|
2015-07-03 15:06:29 -04:00
|
|
|
|
2015-07-21 21:10:46 -04:00
|
|
|
if (_window && (current_toplevel() == _window)) {
|
|
|
|
if (!_visible) { /* was hidden, update status */
|
|
|
|
set_pos_and_size ();
|
2015-07-03 15:06:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-20 09:27:41 -05:00
|
|
|
/** If this Tabbable is currently parented by a tab, ensure that the tab is the
|
|
|
|
* current one. If it is parented by a window, then toggle the visibility of
|
|
|
|
* that window.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Tabbable::change_visibility ()
|
|
|
|
{
|
|
|
|
if (tabbed()) {
|
2024-11-05 19:28:48 -05:00
|
|
|
_parent_notebook->set_current_page (_parent_notebook->page_num (*_contents));
|
2015-11-20 09:27:41 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tab_requested_by_state) {
|
|
|
|
/* should be tabbed, but currently isn't parented by a notebook */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_window && (current_toplevel() == _window)) {
|
2015-11-20 14:19:22 -05:00
|
|
|
/* Use WindowProxy method which will rotate then hide */
|
|
|
|
toggle();
|
2015-11-20 09:27:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
void
|
|
|
|
Tabbable::make_visible ()
|
|
|
|
{
|
|
|
|
if (_window && (current_toplevel() == _window)) {
|
2016-02-26 18:51:23 -05:00
|
|
|
set_pos ();
|
2015-07-22 15:22:23 -04:00
|
|
|
_window->present ();
|
|
|
|
} else {
|
2015-07-22 17:49:03 -04:00
|
|
|
|
|
|
|
if (!tab_requested_by_state) {
|
|
|
|
show_own_window (true);
|
|
|
|
} else {
|
|
|
|
show_tab ();
|
|
|
|
}
|
2015-07-22 15:22:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::make_invisible ()
|
|
|
|
{
|
|
|
|
if (_window && (current_toplevel() == _window)) {
|
|
|
|
_window->hide ();
|
|
|
|
} else {
|
|
|
|
hide_tab ();
|
|
|
|
}
|
|
|
|
}
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
void
|
|
|
|
Tabbable::detach ()
|
|
|
|
{
|
|
|
|
show_own_window (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::attach ()
|
2015-07-03 15:06:29 -04:00
|
|
|
{
|
2015-07-22 15:22:23 -04:00
|
|
|
if (!_parent_notebook) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-22 17:49:03 -04:00
|
|
|
if (tabbed()) {
|
2015-07-22 15:22:23 -04:00
|
|
|
/* already tabbed */
|
|
|
|
return;
|
|
|
|
}
|
2015-07-03 15:06:29 -04:00
|
|
|
|
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
if (_window && current_toplevel() == _window) {
|
2015-07-03 15:06:29 -04:00
|
|
|
/* unpack Tabbable from parent, put it back in the main tabbed
|
|
|
|
* notebook
|
|
|
|
*/
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
save_pos_and_size ();
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2024-11-05 19:28:48 -05:00
|
|
|
_contents->hide ();
|
|
|
|
_contents->get_parent()->remove (*_contents);
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
/* leave the window around */
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
_window->hide ();
|
|
|
|
}
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2024-11-05 19:28:48 -05:00
|
|
|
_parent_notebook->append_page (*_contents);
|
|
|
|
_parent_notebook->set_tab_detachable (*_contents);
|
|
|
|
_parent_notebook->set_tab_reorderable (*_contents);
|
|
|
|
_parent_notebook->set_current_page (_parent_notebook->page_num (*_contents));
|
2021-02-04 13:12:22 -05:00
|
|
|
|
2024-11-05 19:28:48 -05:00
|
|
|
_contents->show ();
|
2015-07-22 17:49:03 -04:00
|
|
|
|
|
|
|
/* have to force this on, which is semantically correct, since
|
|
|
|
* the user has effectively asked for it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tab_requested_by_state = true;
|
2015-07-22 21:13:33 -04:00
|
|
|
StateChange (*this);
|
2015-07-22 15:22:23 -04:00
|
|
|
}
|
2015-07-03 15:06:29 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
bool
|
|
|
|
Tabbable::delete_event_handler (GdkEventAny *ev)
|
|
|
|
{
|
|
|
|
_window->hide();
|
2015-07-03 15:06:29 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
return true;
|
2015-07-03 15:06:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-07-25 09:18:32 -04:00
|
|
|
Tabbable::tabbed () const
|
2015-07-03 15:06:29 -04:00
|
|
|
{
|
2015-07-25 09:18:32 -04:00
|
|
|
if (_window && (current_toplevel() == _window)) {
|
2015-07-03 15:06:29 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-11-05 19:28:48 -05:00
|
|
|
if (_parent_notebook && (_parent_notebook->page_num (*_contents) >= 0)) {
|
2015-07-03 15:06:29 -04:00
|
|
|
return true;
|
|
|
|
}
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-03 15:06:29 -04:00
|
|
|
return false;
|
|
|
|
}
|
2015-07-07 22:12:21 -04:00
|
|
|
|
2015-07-22 15:22:23 -04:00
|
|
|
void
|
|
|
|
Tabbable::hide_tab ()
|
|
|
|
{
|
2015-07-22 17:49:03 -04:00
|
|
|
if (tabbed()) {
|
2024-11-05 19:28:48 -05:00
|
|
|
_contents->hide();
|
|
|
|
_parent_notebook->remove_page (*_contents);
|
2015-07-22 21:13:33 -04:00
|
|
|
StateChange (*this);
|
2015-07-22 15:22:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 22:12:21 -04:00
|
|
|
void
|
|
|
|
Tabbable::show_tab ()
|
|
|
|
{
|
|
|
|
if (!window_visible() && _parent_notebook) {
|
2024-11-05 19:28:48 -05:00
|
|
|
if (_contents->get_parent() == 0) {
|
2015-07-23 08:35:24 -04:00
|
|
|
tab_requested_by_state = true;
|
2021-02-23 11:24:42 -05:00
|
|
|
add_to_notebook (*_parent_notebook);
|
2015-07-21 21:10:46 -04:00
|
|
|
}
|
2024-11-05 19:28:48 -05:00
|
|
|
_parent_notebook->set_current_page (_parent_notebook->page_num (*_contents));
|
|
|
|
_contents->show ();
|
2016-06-07 18:29:03 -04:00
|
|
|
current_toplevel()->present ();
|
2015-07-07 22:12:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Gtk::Window*
|
|
|
|
Tabbable::current_toplevel () const
|
|
|
|
{
|
|
|
|
return dynamic_cast<Gtk::Window*> (contents().get_toplevel());
|
|
|
|
}
|
2015-07-09 12:40:51 -04:00
|
|
|
|
|
|
|
string
|
|
|
|
Tabbable::xml_node_name()
|
|
|
|
{
|
|
|
|
return WindowProxy::xml_node_name();
|
|
|
|
}
|
|
|
|
|
2015-07-22 17:49:03 -04:00
|
|
|
bool
|
2015-07-25 09:18:32 -04:00
|
|
|
Tabbable::tabbed_by_default() const
|
2015-07-22 17:49:03 -04:00
|
|
|
{
|
2015-07-25 09:18:32 -04:00
|
|
|
return tab_requested_by_state;
|
2015-07-22 17:49:03 -04:00
|
|
|
}
|
|
|
|
|
2015-07-09 12:40:51 -04:00
|
|
|
XMLNode&
|
2022-04-06 23:56:32 -04:00
|
|
|
Tabbable::get_state() const
|
2015-07-09 12:40:51 -04:00
|
|
|
{
|
|
|
|
XMLNode& node (WindowProxy::get_state());
|
|
|
|
|
2016-08-28 09:33:46 -04:00
|
|
|
node.set_property (X_("tabbed"), tabbed());
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2024-11-02 16:35:31 -04:00
|
|
|
node.set_property (string_compose("%1%2", _menu_name, X_("-listpane-pos")).c_str(), content_right_pane.get_divider ());
|
|
|
|
|
2015-07-09 12:40:51 -04:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Tabbable::set_state (const XMLNode& node, int version)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2015-07-23 17:22:05 -04:00
|
|
|
if ((ret = WindowProxy::set_state (node, version)) != 0) {
|
|
|
|
return ret;
|
2015-07-09 12:40:51 -04:00
|
|
|
}
|
|
|
|
|
2015-07-23 17:22:05 -04:00
|
|
|
if (_visible) {
|
|
|
|
show_own_window (true);
|
2015-10-26 14:35:06 -04:00
|
|
|
}
|
2015-07-23 17:22:05 -04:00
|
|
|
|
2015-07-22 17:49:03 -04:00
|
|
|
XMLNodeList children = node.children ();
|
|
|
|
XMLNode* window_node = node.child ("Window");
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-22 17:49:03 -04:00
|
|
|
if (window_node) {
|
2016-08-28 09:33:46 -04:00
|
|
|
window_node->get_property (X_("tabbed"), tab_requested_by_state);
|
2024-11-02 16:35:31 -04:00
|
|
|
float fract;
|
|
|
|
if ( window_node->get_property (string_compose("%1%2", _menu_name, X_("-listpane-pos")).c_str(), fract) ) {
|
|
|
|
fract = std::max (.05f, std::min (.95f, fract));
|
|
|
|
content_right_pane.set_divider (0, fract);
|
|
|
|
}
|
2015-07-22 17:49:03 -04:00
|
|
|
}
|
|
|
|
|
2024-11-02 16:35:31 -04:00
|
|
|
|
2015-07-23 17:22:05 -04:00
|
|
|
if (!_visible) {
|
|
|
|
if (tab_requested_by_state) {
|
|
|
|
attach ();
|
|
|
|
} else {
|
|
|
|
/* this does nothing if not tabbed */
|
|
|
|
hide_tab ();
|
2015-07-23 08:35:24 -04:00
|
|
|
}
|
2015-07-22 17:49:03 -04:00
|
|
|
}
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-07-09 12:40:51 -04:00
|
|
|
return ret;
|
|
|
|
}
|
2015-07-15 16:23:11 -04:00
|
|
|
|
2015-07-23 08:35:24 -04:00
|
|
|
void
|
|
|
|
Tabbable::window_mapped ()
|
|
|
|
{
|
|
|
|
StateChange (*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::window_unmapped ()
|
|
|
|
{
|
|
|
|
StateChange (*this);
|
|
|
|
}
|
2024-11-02 16:35:31 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::showhide_att_right (bool yn)
|
|
|
|
{
|
|
|
|
if (yn) {
|
|
|
|
content_right_vbox.show ();
|
|
|
|
} else {
|
|
|
|
content_right_vbox.hide ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::att_right_button_toggled ()
|
|
|
|
{
|
|
|
|
Glib::RefPtr<Gtk::Action> act = right_attachment_button.get_related_action();
|
|
|
|
if (act) {
|
|
|
|
Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
|
|
|
|
if (tact) {
|
|
|
|
showhide_att_right (tact->get_active());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showhide_att_right (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::showhide_att_left (bool yn)
|
|
|
|
{
|
|
|
|
if (yn) {
|
|
|
|
content_att_left.show ();
|
|
|
|
} else {
|
|
|
|
content_att_left.hide ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::att_left_button_toggled ()
|
|
|
|
{
|
|
|
|
Glib::RefPtr<Gtk::Action> act = left_attachment_button.get_related_action();
|
|
|
|
if (act) {
|
|
|
|
Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
|
|
|
|
if (tact) {
|
|
|
|
showhide_att_left (tact->get_active());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showhide_att_left (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::showhide_att_bottom (bool yn)
|
|
|
|
{
|
|
|
|
if (yn) {
|
|
|
|
content_att_bottom.show ();
|
|
|
|
} else {
|
|
|
|
content_att_bottom.hide ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Tabbable::att_bottom_button_toggled ()
|
|
|
|
{
|
|
|
|
Glib::RefPtr<Gtk::Action> act = bottom_attachment_button.get_related_action();
|
|
|
|
if (act) {
|
|
|
|
Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
|
|
|
|
if (tact) {
|
|
|
|
showhide_att_bottom (tact->get_active());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showhide_att_bottom (false);
|
|
|
|
}
|
|
|
|
}
|