+
+#include "wx/listimpl.cpp"
+WX_DEFINE_LIST(wxGtkNotebookPagesList)
+
+extern "C" {
+static void event_after(GtkNotebook*, GdkEvent*, wxNotebook*);
+}
+
+//-----------------------------------------------------------------------------
+// "switch_page"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void
+switch_page_after(GtkNotebook* widget, GtkNotebookPage*, guint, wxNotebook* win)
+{
+ g_signal_handlers_block_by_func(widget, (void*)switch_page_after, win);
+
+ win->GTKOnPageChanged();
+}
+}
+
+extern "C" {
+static void
+switch_page(GtkNotebook* widget, GtkNotebookPage*, int page, wxNotebook* win)
+{
+ win->m_oldSelection = gtk_notebook_get_current_page(widget);
+
+ if (win->SendPageChangingEvent(page))
+ // allow change, unblock handler for changed event
+ g_signal_handlers_unblock_by_func(widget, (void*)switch_page_after, win);
+ else
+ // change vetoed, unblock handler to set selection back
+ g_signal_handlers_unblock_by_func(widget, (void*)event_after, win);
+}
+}
+
+//-----------------------------------------------------------------------------
+// "event_after" from m_widget
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void event_after(GtkNotebook* widget, GdkEvent*, wxNotebook* win)
+{
+ g_signal_handlers_block_by_func(widget, (void*)event_after, win);
+ g_signal_handlers_block_by_func(widget, (void*)switch_page, win);
+
+ // restore previous selection
+ gtk_notebook_set_current_page(widget, win->m_oldSelection);
+
+ g_signal_handlers_unblock_by_func(widget, (void*)switch_page, win);
+}
+}
+
+//-----------------------------------------------------------------------------
+// InsertChild callback for wxNotebook
+//-----------------------------------------------------------------------------
+
+void wxNotebook::AddChildGTK(wxWindowGTK* child)
+{
+ // Hack Alert! (Part I): This sets the notebook as the parent of the child
+ // widget, and takes care of some details such as updating the state and
+ // style of the child to reflect its new location. We do this early
+ // because without it GetBestSize (which is used to set the initial size
+ // of controls if an explicit size is not given) will often report
+ // incorrect sizes since the widget's style context is not fully known.
+ // See bug #901694 for details
+ // (http://sourceforge.net/tracker/?func=detail&aid=901694&group_id=9863&atid=109863)
+ gtk_widget_set_parent(child->m_widget, m_widget);
+
+ // NOTE: This should be considered a temporary workaround until we can
+ // work out the details and implement delaying the setting of the initial
+ // size of widgets until the size is really needed.
+}
+