--- gnome-terminal-backup/src/terminal-window.c	2006-05-25 12:15:15.000000000 -0500
+++ -	2006-05-25 22:45:55.513202000 -0500
@@ -67,6 +67,7 @@
   GList *tab_menuitems;
   GList *terms;
   TerminalScreen *active_term;
+  GtkRequisition vbox_requisition;
   GdkPixbuf *icon;
   GtkClipboard *clipboard;
   int old_char_width;
@@ -154,6 +155,9 @@
                                            const char      *dir);
 static void new_window_callback           (GtkWidget      *menuitem,
                                            TerminalWindow *window);
+static void size_request_callback         (GtkWidget *widget,
+                                           GtkRequisition *requisition,
+                                           TerminalWindow *window);
 static void new_tab_callback              (GtkWidget      *menuitem,
                                            TerminalWindow *window);
 static gboolean key_press_callback	  (GtkWidget      *widget,
@@ -234,6 +238,8 @@
 
 static void terminal_window_show (GtkWidget *widget);
 
+static void update_geometry  (TerminalWindow *window);
+
 static gboolean confirm_close_window (TerminalWindow *window);
 
 static gpointer parent_class;
@@ -839,6 +845,12 @@
   gtk_box_pack_end (GTK_BOX (window->priv->main_vbox),
                     window->priv->notebook,
                     TRUE, TRUE, 0);  
+
+  gtk_widget_size_request(window->priv->main_vbox, &window->priv->vbox_requisition);
+  g_signal_connect_after (G_OBJECT (window->priv->main_vbox),
+                          "size_request",
+                          G_CALLBACK (size_request_callback),
+                          window);
   
   mi = append_menuitem (window->priv->menubar,
                         "", NULL,
@@ -1477,14 +1489,6 @@
       gtk_widget_hide (window->priv->menubar);
     }
   reset_menubar_labels (window);
-
-  if (window->priv->active_term)
-    {
-#ifdef DEBUG_GEOMETRY
-      g_fprintf (stderr,"setting size after toggling menubar visibility\n");
-#endif
-      terminal_window_set_size (window, window->priv->active_term, TRUE);
-    }
 }
 
 gboolean
@@ -1502,79 +1506,6 @@
 }
 
 void
-terminal_window_set_size (TerminalWindow *window,
-                          TerminalScreen *screen,
-                          gboolean        even_if_mapped)
-{
-  terminal_window_set_size_force_grid (window, screen, even_if_mapped, -1, -1);
-}
-
-void
-terminal_window_set_size_force_grid (TerminalWindow *window,
-                                     TerminalScreen *screen,
-                                     gboolean        even_if_mapped,
-                                     int             force_grid_width,
-                                     int             force_grid_height)
-{
-  /* Owen's hack from gnome-terminal */
-  GtkWidget *widget;
-  GtkWidget *app;
-  GtkRequisition toplevel_request;
-  GtkRequisition widget_request;
-  int w, h;
-  int char_width;
-  int char_height;
-  int grid_width;
-  int grid_height;
-  int xpad;
-  int ypad;
-
-  /* be sure our geometry is up-to-date */
-  terminal_window_update_geometry (window);
-  widget = terminal_screen_get_widget (screen);
-  
-  app = gtk_widget_get_toplevel (widget);
-  g_assert (app != NULL);
-
-  gtk_widget_size_request (app, &toplevel_request);
-  gtk_widget_size_request (widget, &widget_request);
-
-#ifdef DEBUG_GEOMETRY
-  g_fprintf (stderr,"set size: toplevel %dx%d widget %dx%d\n",
-           toplevel_request.width, toplevel_request.height,
-           widget_request.width, widget_request.height);
-#endif
-  
-  w = toplevel_request.width - widget_request.width;
-  h = toplevel_request.height - widget_request.height;
-
-  terminal_widget_get_cell_size (widget, &char_width, &char_height);
-  terminal_widget_get_size (widget, &grid_width, &grid_height);
-
-  if (force_grid_width >= 0)
-    grid_width = force_grid_width;
-  if (force_grid_height >= 0)
-    grid_height = force_grid_height;
-  
-  terminal_widget_get_padding (widget, &xpad, &ypad);
-  
-  w += xpad + char_width * grid_width;
-  h += ypad + char_height * grid_height;
-
-#ifdef DEBUG_GEOMETRY
-  g_fprintf (stderr,"set size: grid %dx%d force %dx%d setting %dx%d pixels\n",
-           grid_width, grid_height, force_grid_width, force_grid_height, w, h);
-#endif
-
-  if (even_if_mapped && GTK_WIDGET_MAPPED (app)) {
-    gtk_window_resize (GTK_WINDOW (app), w, h);
-  }
-  else {
-    gtk_window_set_default_size (GTK_WINDOW (app), w, h);
-  }
-}
-
-void
 terminal_window_set_active (TerminalWindow *window,
                             TerminalScreen *screen)
 {
@@ -1584,8 +1515,22 @@
   if (window->priv->active_term == screen)
     return;
   
+  /* Workaround to remove gtknotebook's feature of computing its size based on
+   * all pages. When the widget is hidden, its size will not be taken into
+   * account.
+   */
+  if (window->priv->active_term)
+  {
+    GtkWidget *old_widget;
+    old_widget = terminal_screen_get_widget (window->priv->active_term);
+    gtk_widget_hide (old_widget);
+  }
+  
   widget = terminal_screen_get_widget (screen);
   
+  /* Make sure that the widget is no longer hidden due to the workaround */
+  gtk_widget_show (widget);
+
   profile = terminal_screen_get_profile (screen);
 
   if (!GTK_WIDGET_REALIZED (widget))
@@ -1593,7 +1538,6 @@
 
   window->priv->active_term = screen;
 
-  terminal_window_update_geometry (window);
   terminal_window_update_icon (window);
   
   /* Override menubar setting if it wasn't restored from session */
@@ -1611,12 +1555,6 @@
   gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
                                  gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
                                                         GTK_WIDGET (screen)));
-
-  /* set size of window to current grid size */
-#ifdef DEBUG_GEOMETRY
-  g_fprintf (stderr,"setting size after flipping notebook pages\n");
-#endif
-  terminal_window_set_size (window, screen, TRUE);
   
   update_copy_sensitivity (window);
   
@@ -1676,11 +1614,7 @@
   TerminalScreen *screen;
   GtkWidget *menu_item;
   int old_grid_width, old_grid_height;
-  GtkWidget *old_widget;
-  
-  old_widget = NULL;
-  old_grid_width = -1;
-  old_grid_height = -1;
+  GtkWidget *old_widget, *new_widget;
 
   if (window->priv->active_term == NULL)
     return;
@@ -1696,17 +1630,13 @@
   screen = TERMINAL_SCREEN (page_widget);
 
   g_assert (screen);
+  
+  /* This is so that we maintain the same grid */
+  new_widget = terminal_screen_get_widget (screen);
+  terminal_widget_set_size (new_widget, old_grid_width, old_grid_height);
 
   terminal_window_set_active (window, screen);
 
-  /* This is so we maintain the same grid moving among tabs with
-   * different fonts.
-   */
-#ifdef DEBUG_GEOMETRY
-  g_fprintf (stderr,"setting size in switch_page handler\n");
-#endif
-  terminal_window_set_size_force_grid (window, screen, TRUE, old_grid_width, old_grid_height);
-  
   update_tab_sensitivity (window);
   
   menu_item = screen_get_menuitem (screen);
@@ -1886,7 +1816,7 @@
 }
 
 void
-terminal_window_update_geometry (TerminalWindow *window)
+update_geometry (TerminalWindow *window)
 {
   GdkGeometry hints;
   GtkWidget *widget;  
@@ -2213,6 +2143,34 @@
                              NULL, name, -1);
 }
 
+void
+size_request_callback (GtkWidget *widget,
+               GtkRequisition *requisition,
+               TerminalWindow *window)
+{
+  if (window->priv->vbox_requisition.height == requisition->height &&
+      window->priv->vbox_requisition.width == requisition->width)
+    return;
+  if (!window->priv->active_term)
+    return;
+
+  window->priv->vbox_requisition.height = requisition->height;
+  window->priv->vbox_requisition.width = requisition->width;
+
+#ifdef DEBUG_GEOMETRY
+  g_fprintf (stderr, "vbox size-request callback with size %dx%d\n",
+             requisition->width, requisition->height);
+#endif
+
+  if (GTK_WIDGET_MAPPED (window)) {
+    gtk_window_resize (GTK_WINDOW (window), requisition->width, requisition->height);
+  }
+  else {
+    gtk_window_set_default_size (GTK_WINDOW (window), requisition->width, requisition->height);
+  }
+  update_geometry (window);
+}
+
 static void
 new_tab_callback (GtkWidget      *menuitem,
                   TerminalWindow *window)
--- gnome-terminal-backup/src/terminal-screen.c	2006-05-25 12:15:15.000000000 -0500
+++ -	2006-05-25 22:13:32.189750000 -0500
@@ -545,7 +545,6 @@
        */
       terminal_screen_update_scrollbar (screen);
       terminal_window_update_icon (screen->priv->window);
-      terminal_window_update_geometry (screen->priv->window);
     }
   
   if (GTK_WIDGET_REALIZED (screen->priv->term))
@@ -877,8 +876,6 @@
   
   terminal_widget_set_allow_bold (term,
                                   terminal_profile_get_allow_bold (profile));
-
-  terminal_window_set_size (screen->priv->window, screen, TRUE);
 }
 
 static void
--- gnome-terminal-backup/src/terminal-window.h	2006-05-25 12:15:15.000000000 -0500
+++ -	2006-05-25 21:18:59.805094000 -0500
@@ -77,15 +77,6 @@
 int    terminal_window_get_screen_count (TerminalWindow *window);
 
 void terminal_window_update_icon      (TerminalWindow *window);
-void terminal_window_update_geometry  (TerminalWindow *window);
-void terminal_window_set_size         (TerminalWindow *window,
-                                       TerminalScreen *screen,
-                                       gboolean        even_if_mapped);
-void terminal_window_set_size_force_grid (TerminalWindow *window,
-                                          TerminalScreen *screen,
-                                          gboolean        even_if_mapped,
-                                          int             force_grid_width,
-                                          int             force_grid_height);
 
 void     terminal_window_set_fullscreen (TerminalWindow *window,
                                          gboolean        setting);
