From 8f1c6a5a4dcb58a2b28bad0a5f08715fc733ccce Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 9 Jan 2010 14:21:12 +0000 Subject: [PATCH] add Gtkmm2ext::detach_menu() that was needed by my previous commit git-svn-id: svn://localhost/ardour2/branches/3.0@6471 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/gtkmm2ext/gtkmm2ext/utils.h | 2 ++ libs/gtkmm2ext/utils.cc | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h index 7f986e738c..d6d5a9498c 100644 --- a/libs/gtkmm2ext/gtkmm2ext/utils.h +++ b/libs/gtkmm2ext/gtkmm2ext/utils.h @@ -31,6 +31,7 @@ namespace Gtk { class Widget; class Window; class Paned; + class Menu; } namespace Gtkmm2ext { @@ -69,6 +70,7 @@ namespace Gtkmm2ext { void set_decoration (Gtk::Window* win, Gdk::WMDecoration decor); void set_treeview_header_as_default_label(Gtk::TreeViewColumn *c); Glib::RefPtr get_bogus_drawable(); + void detach_menu (Gtk::Menu&); }; #endif /* __gtkmm2ext_utils_h__ */ diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index 3a021bbe7b..400899cb67 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -135,3 +135,16 @@ void Gtkmm2ext::set_treeview_header_as_default_label(Gtk::TreeViewColumn* c) gtk_tree_view_column_set_widget( c->gobj(), GTK_WIDGET(0) ); } +void +Gtkmm2ext::detach_menu (Gtk::Menu& menu) +{ + /* its possible for a Gtk::Menu to have no gobj() because it has + not yet been instantiated. Catch this and provide a safe + detach method. + */ + if (menu.gobj()) { + if (menu.get_attach_widget()) { + menu.detach (); + } + } +}