13
0

clean up tabbable state maintainance; drop Gtk::Button unintentionally used for close cross image

This commit is contained in:
Paul Davis 2015-07-23 17:22:05 -04:00
parent d6f3a006d2
commit b6c4ae46d0
2 changed files with 20 additions and 24 deletions

View File

@ -87,13 +87,12 @@ class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
std::string _tab_title; std::string _tab_title;
Gtk::HBox _tab_box; Gtk::HBox _tab_box;
Gtk::Label _tab_label; Gtk::Label _tab_label;
Gtk::Button _tab_close_button;
CairoIcon tab_close_image; CairoIcon tab_close_image;
bool tab_requested_by_state; bool tab_requested_by_state;
void show_tab (); void show_tab ();
void hide_tab (); void hide_tab ();
void tab_close_clicked (); bool tab_close_clicked (GdkEventButton*);
void show_own_window (bool and_pack_it); void show_own_window (bool and_pack_it);
void window_mapped (); void window_mapped ();
void window_unmapped (); void window_unmapped ();

View File

@ -39,14 +39,14 @@ Tabbable::Tabbable (Widget& w, const string& name)
, tab_close_image (ArdourIcon::CloseCross, 0xffffffff) , tab_close_image (ArdourIcon::CloseCross, 0xffffffff)
, tab_requested_by_state (true) , tab_requested_by_state (true)
{ {
/* sizes will be scaled during rendering */
tab_close_image.set_size_request (15,15); tab_close_image.set_size_request (15,15);
_tab_box.set_spacing (2); _tab_box.set_spacing (2);
_tab_box.pack_start (_tab_label, true, true); _tab_box.pack_start (_tab_label, true, true);
_tab_box.pack_start (_tab_close_button, false, false); _tab_box.pack_start (tab_close_image, false, false);
_tab_close_button.add (tab_close_image);
_tab_close_button.signal_clicked().connect (sigc::mem_fun (*this, &Tabbable::tab_close_clicked)); tab_close_image.signal_button_release_event().connect (sigc::mem_fun (*this, &Tabbable::tab_close_clicked));
} }
Tabbable::~Tabbable () Tabbable::~Tabbable ()
@ -57,10 +57,11 @@ Tabbable::~Tabbable ()
} }
} }
void bool
Tabbable::tab_close_clicked () Tabbable::tab_close_clicked (GdkEventButton*)
{ {
hide_tab (); hide_tab ();
return true;
} }
void void
@ -337,17 +338,17 @@ Tabbable::set_state (const XMLNode& node, int version)
{ {
int ret; int ret;
if ((ret = WindowProxy::set_state (node, version)) == 0) { if ((ret = WindowProxy::set_state (node, version)) != 0) {
if (_visible) { return ret;
if (use_own_window (true) == 0) {
ret = -1;
}
}
} }
if (_visible) {
show_own_window (true);
}
XMLNodeList children = node.children (); XMLNodeList children = node.children ();
XMLNode* window_node = node.child ("Window"); XMLNode* window_node = node.child ("Window");
if (window_node) { if (window_node) {
const XMLProperty* prop = window_node->property (X_("tabbed")); const XMLProperty* prop = window_node->property (X_("tabbed"));
if (prop) { if (prop) {
@ -355,17 +356,13 @@ Tabbable::set_state (const XMLNode& node, int version)
} }
} }
if (tab_requested_by_state) { if (!_visible) {
if (tab_requested_by_state) {
std::cerr << name() << " pn " << _parent_notebook << std::endl; attach ();
if (_parent_notebook) { } else {
std::cerr << "\t page " << _parent_notebook->page_num (_contents) << std::endl; /* this does nothing if not tabbed */
hide_tab ();
} }
attach ();
} else {
/* this does nothing if not tabbed */
hide_tab ();
} }
return ret; return ret;