update the selection properly after deleting the page
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24180 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -262,10 +262,6 @@ wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxNotebook::~wxNotebook()
|
wxNotebook::~wxNotebook()
|
||||||
{
|
{
|
||||||
/* don't generate change page events any more */
|
|
||||||
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
|
|
||||||
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
|
|
||||||
|
|
||||||
DeleteAllPages();
|
DeleteAllPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,16 +537,10 @@ bool wxNotebook::DeleteAllPages()
|
|||||||
|
|
||||||
bool wxNotebook::DeletePage( size_t page )
|
bool wxNotebook::DeletePage( size_t page )
|
||||||
{
|
{
|
||||||
// GTK sets GtkNotebook.cur_page to NULL before sending the switch page
|
if ( m_selection == (int)m_pagesData.GetCount() - 1 )
|
||||||
// event so we have to store the selection internally
|
|
||||||
if ( m_selection == -1 )
|
|
||||||
{
|
{
|
||||||
m_selection = GetSelection();
|
// the index will become invalid after the page is deleted
|
||||||
if ( m_selection == (int)m_pagesData.GetCount() - 1 )
|
m_selection = -1;
|
||||||
{
|
|
||||||
// the index will become invalid after the page is deleted
|
|
||||||
m_selection = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// it will call our DoRemovePage() to do the real work
|
// it will call our DoRemovePage() to do the real work
|
||||||
@@ -567,8 +557,17 @@ wxNotebookPage *wxNotebook::DoRemovePage( size_t page )
|
|||||||
gtk_widget_unrealize( client->m_widget );
|
gtk_widget_unrealize( client->m_widget );
|
||||||
gtk_widget_unparent( client->m_widget );
|
gtk_widget_unparent( client->m_widget );
|
||||||
|
|
||||||
|
// gtk_notebook_remove_page() sends "switch_page" signal with some strange
|
||||||
|
// new page index (when deleting selected page 0, new page is 1 although,
|
||||||
|
// clearly, the selection should stay 0), so suppress this
|
||||||
|
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
|
||||||
|
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
|
||||||
|
|
||||||
gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
|
gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
|
||||||
|
|
||||||
wxGtkNotebookPage* p = GetNotebookPage(page);
|
wxGtkNotebookPage* p = GetNotebookPage(page);
|
||||||
m_pagesData.DeleteObject(p);
|
m_pagesData.DeleteObject(p);
|
||||||
delete p;
|
delete p;
|
||||||
|
@@ -262,10 +262,6 @@ wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxNotebook::~wxNotebook()
|
wxNotebook::~wxNotebook()
|
||||||
{
|
{
|
||||||
/* don't generate change page events any more */
|
|
||||||
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
|
|
||||||
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
|
|
||||||
|
|
||||||
DeleteAllPages();
|
DeleteAllPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,16 +537,10 @@ bool wxNotebook::DeleteAllPages()
|
|||||||
|
|
||||||
bool wxNotebook::DeletePage( size_t page )
|
bool wxNotebook::DeletePage( size_t page )
|
||||||
{
|
{
|
||||||
// GTK sets GtkNotebook.cur_page to NULL before sending the switch page
|
if ( m_selection == (int)m_pagesData.GetCount() - 1 )
|
||||||
// event so we have to store the selection internally
|
|
||||||
if ( m_selection == -1 )
|
|
||||||
{
|
{
|
||||||
m_selection = GetSelection();
|
// the index will become invalid after the page is deleted
|
||||||
if ( m_selection == (int)m_pagesData.GetCount() - 1 )
|
m_selection = -1;
|
||||||
{
|
|
||||||
// the index will become invalid after the page is deleted
|
|
||||||
m_selection = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// it will call our DoRemovePage() to do the real work
|
// it will call our DoRemovePage() to do the real work
|
||||||
@@ -567,8 +557,17 @@ wxNotebookPage *wxNotebook::DoRemovePage( size_t page )
|
|||||||
gtk_widget_unrealize( client->m_widget );
|
gtk_widget_unrealize( client->m_widget );
|
||||||
gtk_widget_unparent( client->m_widget );
|
gtk_widget_unparent( client->m_widget );
|
||||||
|
|
||||||
|
// gtk_notebook_remove_page() sends "switch_page" signal with some strange
|
||||||
|
// new page index (when deleting selected page 0, new page is 1 although,
|
||||||
|
// clearly, the selection should stay 0), so suppress this
|
||||||
|
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
|
||||||
|
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );
|
||||||
|
|
||||||
gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
|
gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );
|
||||||
|
|
||||||
wxGtkNotebookPage* p = GetNotebookPage(page);
|
wxGtkNotebookPage* p = GetNotebookPage(page);
|
||||||
m_pagesData.DeleteObject(p);
|
m_pagesData.DeleteObject(p);
|
||||||
delete p;
|
delete p;
|
||||||
|
Reference in New Issue
Block a user