summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/utils.h2
-rw-r--r--libs/gtkmm2ext/utils.cc13
2 files changed, 15 insertions, 0 deletions
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<Gdk::Drawable> 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 ();
+ }
+ }
+}