-// page change callback
-static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
- GtkNotebookPage *WXUNUSED(page),
- gint nPage,
- gpointer data)
-{
- wxNotebook *notebook = (wxNotebook *)data;
-
- int nOld = notebook->GetSelection();
-
- // TODO: emulate PAGE_CHANGING event
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
- notebook->GetId(),
- nPage,
- nOld);
- event.SetEventObject(notebook);
- notebook->ProcessEvent(event);
-}
-
-static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
-{
- if ((win->m_x == alloc->x) &&
- (win->m_y == alloc->y) &&
- (win->m_width == alloc->width) &&
- (win->m_height == alloc->height))
- {
- return;
- };
-
-/*
- printf( "OnResize from " );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- printf( win->GetClassInfo()->GetClassName() );
- printf( " .\n" );
-
- printf( " Old: X: %d Y: %d ", win->m_x, win->m_y );
- printf( " W: %d H: %d ", win->m_width, win->m_height );
- printf( " .\n" );
-
- printf( " New: X: %d Y: %d ", alloc->x, alloc->y );
- printf( " W: %d H: %d ", alloc->width, alloc->height );
- printf( " .\n" );
-*/
-
- win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
-
-/*
- printf( " Res: X: %d Y: %d ", win->m_x, win->m_y );
- printf( " W: %d H: %d ", win->m_width, win->m_height );
- printf( " .\n" );
-*/
-};
-
+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.
+}
+