* looking for tsui.tony@gmail.com--projects/gnome-terminal--tab-fixes--0.0.2--base-0 to compare with
* comparing to tsui.tony@gmail.com--projects/gnome-terminal--tab-fixes--0.0.2--base-0: .... done.

* modified files

--- orig/ChangeLog
+++ mod/ChangeLog
@@ -1,3 +1,8 @@
+2006-02-20  Tony Tsui  <tsuil.tony@gmail.com>
+
+	* src/terminal-window.c: Resize the terminal window after a tab is
+	  removed. Closes bug #324426.
+
 2006-01-30  Guilherme de S. Pastore  <gpastore@gnome.org>
 
 	* NEWS: updated.
--- orig/src/terminal-notebook.c
+++ mod/src/terminal-notebook.c
@@ -120,6 +120,16 @@ terminal_notebook_class_init (TerminalNo
                   G_TYPE_NONE,
                   1,
                   TERMINAL_TYPE_SCREEN);
+  signals[TAB_DELETE] =
+    g_signal_new ("tab_delete",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (TerminalNotebookClass, tab_delete),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__OBJECT,
+                  G_TYPE_NONE,
+                  1,
+                  TERMINAL_TYPE_SCREEN);
   signals[TAB_REMOVED] =
     g_signal_new ("tab_removed",
                   G_OBJECT_CLASS_TYPE (object_class),
@@ -837,6 +847,8 @@ terminal_notebook_remove_tab (TerminalNo
    */
   g_object_ref (screen);
 
+  g_signal_emit (G_OBJECT (nb), signals[TAB_DELETE], 0, screen);
+
   gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
 
   update_tabs_visibility (nb, FALSE);
--- orig/src/terminal-window.c
+++ mod/src/terminal-window.c
@@ -71,6 +71,8 @@ struct _TerminalWindowPrivate
   GtkClipboard *clipboard;
   int old_char_width;
   int old_char_height;
+  int old_grid_width;
+  int old_grid_height;
   void *old_geometry_widget; /* only used for pointer value as it may be freed */
   GConfClient *conf;
   guint notify_id;
@@ -124,6 +126,10 @@ static void notebook_tab_detached_callba
                                              TerminalScreen  *screen,
                                              TerminalWindow  *window);
 
+static void notebook_tab_delete_callback   (GtkWidget       *notebook,
+                                            TerminalScreen  *screen,
+                                            TerminalWindow  *window);
+
 static void notebook_tab_removed_callback   (GtkWidget       *notebook,
                                              TerminalScreen  *screen,
                                              TerminalWindow  *window);
@@ -820,6 +826,11 @@ terminal_window_init (TerminalWindow *wi
                           window);
 
   g_signal_connect_after (G_OBJECT (window->priv->notebook),
+                          "tab_delete",
+                          G_CALLBACK (notebook_tab_delete_callback),
+                          window);
+  
+  g_signal_connect_after (G_OBJECT (window->priv->notebook),
                           "tab_removed",
                           G_CALLBACK (notebook_tab_removed_callback),
                           window);
@@ -1433,10 +1444,6 @@ terminal_window_remove_screen (TerminalW
 {
   g_return_if_fail (terminal_screen_get_window (screen) == window);
 
-  window->priv->terms = g_list_remove (window->priv->terms, screen);
-  
-  terminal_screen_set_window (screen, NULL);
-  
   terminal_notebook_remove_tab (TERMINAL_NOTEBOOK (window->priv->notebook),
                                 screen);
 }
@@ -1813,17 +1820,40 @@ notebook_tab_detached_callback (GtkWidge
 }
 
 static void
+notebook_tab_delete_callback (GtkWidget       *notebook,
+                               TerminalScreen  *screen,
+                               TerminalWindow  *window)
+{  
+  /* If we are going to delete the active tab we need to record its grid width
+   * and height so the terminal window will be resized correctly after the tab
+   * has been removed. The cases when this is important is when the window
+   * size will change because:
+   *  - tabs will be hidden because only one terminal remain
+   *  - the tab being deleted has been zoomed in/out
+   */
+  if (window->priv->active_term == screen)
+    {
+      GtkWidget *old_active_widget;
+      
+      old_active_widget = terminal_screen_get_widget (screen);
+      terminal_widget_get_size (old_active_widget,
+                                &window->priv->old_grid_width,
+                                &window->priv->old_grid_height);
+    }
+  else
+    {
+      window->priv->old_grid_width = -1;
+      window->priv->old_grid_width = -1;
+    }
+}
+
+static void
 notebook_tab_removed_callback (GtkWidget       *notebook,
                                TerminalScreen  *screen,
                                TerminalWindow  *window)
 {  
-  /* Called from terminal_notebook_move_tab() */
-  if (find_screen (window, screen) != NULL) {
-    g_assert (terminal_screen_get_window (screen) == window);
-  
-    window->priv->terms = g_list_remove (window->priv->terms, screen);
-    terminal_screen_set_window (screen, NULL);
-  }
+  window->priv->terms = g_list_remove (window->priv->terms, screen);
+  terminal_screen_set_window (screen, NULL);
   
   g_signal_handlers_disconnect_by_func (G_OBJECT (screen),
                                         G_CALLBACK (profile_set_callback),
@@ -1850,7 +1880,17 @@ notebook_tab_removed_callback (GtkWidget
 
   /* Close window if no more terminals */
   if (window->priv->terms == NULL)
-    gtk_widget_destroy (GTK_WIDGET (window));
+    {
+      gtk_widget_destroy (GTK_WIDGET (window));
+      return;
+    }    
+
+#ifdef DEBUG_GEOMETRY
+    g_print ("setting size with forced grid after removing a terminal\n");
+#endif
+    terminal_window_set_size_force_grid (window, window->priv->active_term,
+                                         TRUE, window->priv->old_grid_width,
+                                         window->priv->old_grid_height);
 }
 
 static void

* added files

