tweak API of WindowProxy, and remove all unnecessary get() calls in functions where, if we have no window, there is nothing to do

This commit is contained in:
Paul Davis 2013-10-13 22:40:39 -04:00
parent 44b359b70a
commit 09c7c5fb95
2 changed files with 19 additions and 18 deletions

View file

@ -349,7 +349,7 @@ ProxyBase::setup ()
assert (_window); assert (_window);
vistracker = new Gtkmm2ext::VisibilityTracker (*_window); vistracker = new Gtkmm2ext::VisibilityTracker (*_window);
_window->signal_delete_event().connect (sigc::mem_fun (*this, &ProxyBase::handle_win_event)); _window->signal_delete_event().connect (sigc::mem_fun (*this, &ProxyBase::delete_event_handler));
if (_width != -1 || _height != -1 || _x_off != -1 || _y_off != -1) { if (_width != -1 || _height != -1 || _x_off != -1 || _y_off != -1) {
/* cancel any mouse-based positioning */ /* cancel any mouse-based positioning */
@ -369,8 +369,9 @@ ProxyBase::setup ()
void void
ProxyBase::show () ProxyBase::show ()
{ {
Gtk::Window* win = get (true); get (true);
win->show (); assert (_window);
_window->show ();
} }
void void
@ -384,17 +385,19 @@ ProxyBase::maybe_show ()
void void
ProxyBase::show_all () ProxyBase::show_all ()
{ {
Gtk::Window* win = get (true); get (true);
win->show_all (); assert (_window);
_window->show_all ();
} }
void void
ProxyBase::present () ProxyBase::present ()
{ {
Gtk::Window* win = get (true); get (true);
win->show_all (); assert (_window);
win->present ();
_window->show_all ();
_window->present ();
/* turn off any mouse-based positioning */ /* turn off any mouse-based positioning */
_window->set_position (Gtk::WIN_POS_NONE); _window->set_position (Gtk::WIN_POS_NONE);
@ -403,15 +406,14 @@ ProxyBase::present ()
void void
ProxyBase::hide () ProxyBase::hide ()
{ {
Gtk::Window* win = get (false); if (_window) {
if (win) {
save_pos_and_size(); save_pos_and_size();
win->hide (); _window->hide ();
} }
} }
bool bool
ProxyBase::handle_win_event (GdkEventAny* /*ev*/) ProxyBase::delete_event_handler (GdkEventAny* /*ev*/)
{ {
hide(); hide();
return true; return true;
@ -420,10 +422,9 @@ ProxyBase::handle_win_event (GdkEventAny* /*ev*/)
void void
ProxyBase::save_pos_and_size () ProxyBase::save_pos_and_size ()
{ {
Gtk::Window* win = get (false); if (_window) {
if (win) { _window->get_position (_x_off, _y_off);
win->get_position (_x_off, _y_off); _window->get_size (_width, _height);
win->get_size (_width, _height);
} }
} }
/*-----------------------*/ /*-----------------------*/

View file

@ -122,7 +122,7 @@ class ProxyBase : public ARDOUR::SessionHandlePtr, public sigc::trackable {
Gtkmm2ext::VisibilityTracker* vistracker; Gtkmm2ext::VisibilityTracker* vistracker;
void save_pos_and_size (); void save_pos_and_size ();
bool handle_win_event (GdkEventAny *ev); bool delete_event_handler (GdkEventAny *ev);
void setup (); void setup ();
}; };