Ejemplo n.º 1
0
static void close_page(MainWindow *main_window, Document *document)
{
  gphpedit_debug(DEBUG_MAIN_WINDOW);
  gint page_num;
  gint page_num_closing;
  gint current_active_tab;
  GtkWidget *document_widget;

  g_object_get(document, "editor_widget", &document_widget, NULL);
  page_num_closing = gtk_notebook_page_num(GTK_NOTEBOOK(main_window->notebook_editor), document_widget);
  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;
    }  
  }

  if(document_manager_set_current_document_from_position(main_window->docmg, page_num)) {
    gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window->notebook_editor), page_num);
  }
  gtk_notebook_remove_page(GTK_NOTEBOOK(main_window->notebook_editor), page_num_closing);
}
Ejemplo n.º 2
0
void set_active_tab(page_num)
{
    gphpedit_debug(DEBUG_MAIN_WINDOW);
    if(document_manager_set_current_document_from_position(main_window.docmg, page_num)) {
        gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window.notebook_editor), page_num);
    }
    update_app_title(document_manager_get_current_document(main_window.docmg));
}