Beispiel #1
0
void TabWidget::remove_tab(int index) {
    assert(m_content->child_count() < index);
    m_header->remove_tab(index);
    m_content->remove_child(index);
    if (active_tab() == index)
        set_active_tab(index == (index - 1) ? index - 1 : 0);
}
void close_page(Document *document)
{
    gphpedit_debug(DEBUG_MAIN_WINDOW);
    gint page_num;
    gint page_num_closing;
    gint current_active_tab;

    page_num_closing = gtk_notebook_page_num(GTK_NOTEBOOK(main_window.notebook_editor), document_get_editor_widget(document));
    current_active_tab = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_window.notebook_editor));

    if (page_num_closing != current_active_tab) {
        page_num = current_active_tab;
    }
    else {
        // If there is a tab before the current one then set it as the active tab.
        page_num = page_num_closing - 1;
        // If the current tab is the 0th tab then set the current tab as 0 itself.
        // If there are are subsequent tabs, then this will set the next tab as active.
        if (page_num < 0) {
            page_num = 0;
        }
    }
    set_active_tab(page_num);
    gtk_notebook_remove_page(GTK_NOTEBOOK(main_window.notebook_editor), page_num_closing);
}