+
+#include "wx/listimpl.cpp"
+WX_DEFINE_LIST(wxGtkNotebookPagesList)
+
+
+//-----------------------------------------------------------------------------
+// "switch_page"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void gtk_notebook_page_changing_callback( GtkNotebook *widget,
+ GtkNotebookPage *WXUNUSED(gpage),
+ guint page,
+ wxNotebook *notebook )
+{
+ int old = gtk_notebook_get_current_page( widget );
+
+ if ( !notebook->SendPageChangingEvent(page) )
+ {
+ // program doesn't allow the page change
+ g_signal_stop_emission_by_name(notebook->m_widget, "switch_page");
+ }
+ else
+ {
+ // the page change event also reports the old page
+ notebook->m_oldSelection = old;
+ }
+}
+}
+
+extern "C" {
+static void gtk_notebook_page_changed_callback( GtkNotebook *widget,
+ GtkNotebookPage *WXUNUSED(gpage),
+ guint page,
+ wxNotebook *notebook )
+{
+ int old = notebook->m_oldSelection;
+ notebook->SendPageChangedEvent( old );
+}
+}
+
+//-----------------------------------------------------------------------------
+// "size_allocate"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
+{
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+
+ if ((win->m_x == alloc->x) &&
+ (win->m_y == alloc->y) &&
+ (win->m_width == alloc->width) &&
+ (win->m_height == alloc->height))
+ {
+ return;
+ }
+
+ win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
+
+ /* GTK 1.2 up to version 1.2.5 is broken so that we have to call allocate
+ here in order to make repositioning after resizing to take effect. */
+ if ((gtk_major_version == 1) &&
+ (gtk_minor_version == 2) &&
+ (gtk_micro_version < 6) &&
+ (win->m_wxwindow) &&
+ (GTK_WIDGET_REALIZED(win->m_wxwindow)))
+ {
+ gtk_widget_size_allocate( win->m_wxwindow, alloc );
+ }
+}
+}
+
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void
+gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
+{
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+
+ /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize
+ here in order to make repositioning before showing to take effect. */
+ gtk_widget_queue_resize( win->m_widget );
+}
+}
+
+//-----------------------------------------------------------------------------
+// InsertChild callback for wxNotebook
+//-----------------------------------------------------------------------------
+
+static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* 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, parent->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.
+}
+