+    return client;
+}
+
+bool wxNotebook::InsertPage( size_t position,
+                             wxNotebookPage* win,
+                             const wxString& text,
+                             bool select,
+                             int imageId )
+{
+    wxCHECK_MSG( m_widget != NULL, false, wxT("invalid notebook") );
+
+    wxCHECK_MSG( win->GetParent() == this, false,
+               wxT("Can't add a page whose parent is not the notebook!") );
+
+    wxCHECK_MSG( position <= GetPageCount(), false,
+                 _T("invalid page index in wxNotebookPage::InsertPage()") );
+
+    // Hack Alert! (Part II): See above in wxNotebook::AddChildGTK
+    // why this has to be done.
+    gtk_widget_unparent(win->m_widget);
+
+    if (m_themeEnabled)
+        win->SetThemeEnabled(true);
+
+    GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
+
+    wxGtkNotebookPage* pageData = new wxGtkNotebookPage;
+
+    m_pages.Insert(win, position);
+    m_pagesData.Insert(position, pageData);
+
+    // set the label image and text
+    // this must be done before adding the page, as GetPageText
+    // and GetPageImage will otherwise return wrong values in
+    // the page-changed event that results from inserting the
+    // first page.
+    pageData->m_imageIndex = imageId;
+
+    pageData->m_box = gtk_hbox_new(false, 1);
+    gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2);
+
+    pageData->m_image = NULL;
+    if (imageId != -1)
+    {
+        if (m_imageList)
+        {
+            const wxBitmap* bitmap = m_imageList->GetBitmapPtr(imageId);
+            pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf());
+            gtk_box_pack_start(GTK_BOX(pageData->m_box),
+                pageData->m_image, false, false, m_padding);
+        }
+        else
+            wxFAIL_MSG("invalid notebook imagelist");
+    }
+
+    /* set the label text */
+    pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text)));
+    gtk_box_pack_end(GTK_BOX(pageData->m_box),
+        pageData->m_label, false, false, m_padding);
+
+    gtk_widget_show_all(pageData->m_box);
+    gtk_notebook_insert_page(notebook, win->m_widget, pageData->m_box, position);
+
+    /* apply current style */
+    GtkRcStyle *style = CreateWidgetStyle();
+    if ( style )
+    {
+        gtk_widget_modify_style(pageData->m_label, style);
+        gtk_rc_style_unref(style);
+    }
+
+    if (select && GetPageCount() > 1)
+    {
+        SetSelection( position );
+    }
+
+    InvalidateBestSize();
+    return true;
+}
+
+// helper for HitTest(): check if the point lies inside the given widget which
+// is the child of the notebook whose position and border size are passed as
+// parameters
+static bool
+IsPointInsideWidget(const wxPoint& pt, GtkWidget *w,
+                    gint x, gint y, gint border = 0)
+{
+    return
+        (pt.x >= w->allocation.x - x - border) &&
+        (pt.x <= w->allocation.x - x + border + w->allocation.width) &&
+        (pt.y >= w->allocation.y - y - border) &&
+        (pt.y <= w->allocation.y - y + border + w->allocation.height);
+}
+
+int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
+{
+    const gint x = m_widget->allocation.x;
+    const gint y = m_widget->allocation.y;
+
+    const size_t count = GetPageCount();
+    size_t i = 0;
+
+    GtkNotebook * notebook = GTK_NOTEBOOK(m_widget);
+    if (gtk_notebook_get_scrollable(notebook))
+        i = g_list_position( notebook->children, notebook->first_tab );
+
+    for ( ; i < count; i++ )
+    {
+        wxGtkNotebookPage* pageData = GetNotebookPage(i);
+        GtkWidget* box = pageData->m_box;
+
+        const gint border = gtk_container_get_border_width(GTK_CONTAINER(box));
+
+        if ( IsPointInsideWidget(pt, box, x, y, border) )
+        {
+            // ok, we're inside this tab -- now find out where, if needed
+            if ( flags )
+            {
+                if (pageData->m_image && IsPointInsideWidget(pt, pageData->m_image, x, y))
+                {
+                    *flags = wxBK_HITTEST_ONICON;
+                }
+                else if (IsPointInsideWidget(pt, pageData->m_label, x, y))
+                {
+                    *flags = wxBK_HITTEST_ONLABEL;
+                }
+                else
+                {
+                    *flags = wxBK_HITTEST_ONITEM;
+                }
+            }
+
+            return i;
+        }
+    }
+
+    if ( flags )
+    {
+        *flags = wxBK_HITTEST_NOWHERE;
+        wxWindowBase * page = GetCurrentPage();
+        if ( page )
+        {
+            // rect origin is in notebook's parent coordinates
+            wxRect rect = page->GetRect();
+
+            // adjust it to the notebook's coordinates
+            wxPoint pos = GetPosition();
+            rect.x -= pos.x;
+            rect.y -= pos.y;
+            if ( rect.Contains( pt ) )
+                *flags |= wxBK_HITTEST_ONPAGE;
+        }
+    }
+
+    return wxNOT_FOUND;
+}
+
+void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
+{
+    if (event.IsWindowChange())
+        AdvanceSelection( event.GetDirection() );
+    else
+        event.Skip();
+}