X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/587ce561e1deabbfacf0d619fdd6bb3899430720..0f90ec936573acad29a7050eb607e3b372953c7a:/src/gtk/notebook.cpp diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 3de79f8445..3bb33c9e2e 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -12,6 +12,9 @@ #endif #include "wx/notebook.h" + +#if wxUSE_NOTEBOOK + #include "wx/panel.h" #include "wx/utils.h" #include "wx/imaglist.h" @@ -184,6 +187,7 @@ void wxNotebook::Init() { m_imageList = (wxImageList *) NULL; m_pages.DeleteContents( TRUE ); + m_lastSelection = -1; } wxNotebook::wxNotebook() @@ -251,11 +255,9 @@ int wxNotebook::GetSelection() const GtkNotebook *notebook = GTK_NOTEBOOK(m_widget); - GtkNotebookPage *page = GTK_NOTEBOOK_PAGE( notebook->cur_page ); + if (notebook->cur_page == NULL) return m_lastSelection; - wxCHECK_MSG( page, -1, "no notebook page selected/current" ); - - return g_list_index( pages, (gpointer)page ); + return g_list_index( pages, (gpointer)(notebook->cur_page) ); } int wxNotebook::GetPageCount() const @@ -462,9 +464,14 @@ bool wxNotebook::DeletePage( int page ) wxNotebookPage* nb_page = GetNotebookPage(page); if (!nb_page) return FALSE; + /* GTK sets GtkNotebook.cur_page to NULL before sending + the switvh page event */ + m_lastSelection = GetSelection(); + nb_page->m_client->Destroy(); - m_pages.DeleteObject( nb_page ); + + m_lastSelection = -1; return TRUE; } @@ -619,3 +626,4 @@ bool wxNotebook::IsOwnGtkWindow( GdkWindow *window ) IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) +#endif \ No newline at end of file