Index: terminal-window.c
===================================================================
RCS file: /cvs/gnome/profterm/src/terminal-window.c,v
retrieving revision 1.53
diff -u -r1.53 terminal-window.c
--- terminal-window.c	7 May 2002 12:33:01 -0000	1.53
+++ terminal-window.c	25 May 2002 09:10:38 -0000
@@ -874,6 +874,40 @@
   update_copy_sensitivity (window);
 }
 
+static void
+tab_close_clicked_cb (GtkWidget *button,
+                      TerminalScreen *screen)
+{
+  TerminalWindow * window;
+  window = terminal_screen_get_window (screen);
+  terminal_window_remove_screen (window, screen);
+}
+
+static void
+tab_add_close_button(GtkWidget * notebook_hbox, TerminalScreen * screen)
+{
+  GtkWidget *button;
+  GtkWidget *image;
+
+  image = gtk_image_new_from_file (TERM_DATADIR "/pixmaps/small-close.xpm");
+
+  /* create the button */
+  button = gtk_button_new ();
+  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+  gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
+
+  /* put the image on the button */
+  gtk_container_add (GTK_CONTAINER (button), image);
+
+  /* pack button into tab */
+  gtk_box_pack_start (GTK_BOX (notebook_hbox), button, FALSE, FALSE, 0);
+  g_object_set_data (G_OBJECT (screen), "close_button", button);
+  gtk_widget_show_all (button);
+
+  g_signal_connect (G_OBJECT (button), "clicked",
+      G_CALLBACK (tab_close_clicked_cb), screen);
+}
+
 void
 terminal_window_add_screen (TerminalWindow *window,
                             TerminalScreen *screen)
@@ -883,6 +917,7 @@
   GtkWidget *hbox;
   GtkWidget *scrollbar;
   GtkWidget *label;  
+  GtkWidget *notebook_hbox;
   
   old = terminal_screen_get_window (screen);
 
@@ -903,6 +938,7 @@
   terminal_screen_set_window (screen, window);
 
   hbox = gtk_hbox_new (FALSE, 0);
+  notebook_hbox = gtk_hbox_new (FALSE, 0);
   scrollbar = gtk_vscrollbar_new (NULL);
   label = eel_ellipsizing_label_new (terminal_screen_get_title (screen));
   gtk_widget_show (label);
@@ -931,7 +967,10 @@
 
   gtk_box_pack_start (GTK_BOX (hbox),
                       GTK_WIDGET (term), TRUE, TRUE, 0);
-  
+
+  gtk_box_pack_start (GTK_BOX (notebook_hbox),
+                      GTK_WIDGET (label), TRUE, TRUE, 0);
+ 
   gtk_range_set_adjustment (GTK_RANGE (scrollbar),
                             terminal_widget_get_scroll_adjustment (term));
 
@@ -942,7 +981,9 @@
   
   gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->notebook),
                             hbox,
-                            label);
+                            notebook_hbox);
+
+  tab_add_close_button (notebook_hbox, screen);
 
   reset_tab_menuitems (window);
   update_tab_sensitivity (window);
@@ -1333,13 +1374,37 @@
   GtkWidget* page_widget;
   TerminalScreen *screen;
   GtkWidget *menu_item;
+  GtkWidget *close_button;
   int old_grid_width, old_grid_height;
   GtkWidget *old_widget;
+  GList * screens, * item;
   
   old_widget = NULL;
   old_grid_width = -1;
   old_grid_height = -1;
 
+  /* 
+   * FIXME: in order to make sure non-selected tabs have desensitized
+   * close buttons, we simply desensitize all of them here each time
+   * the page is switched.  this is obviously not the most efficient
+   * way to do it, but the rationale for now is that it's simple, works,
+   * and required the least amount of work with little room for problems.
+   * unfortunately, you can't easily just desensitize the last active
+   * screen here because active_term of the window is not always the
+   * last selected screen here (e.g, when creating new tabs, it points
+   * to the new screen already)
+   */
+   
+  /* Desensitize all tab close buttons */
+  screens = terminal_window_list_screens(window);
+  for (item = screens; item != NULL; item= g_list_next(item))
+    {
+      close_button = g_object_get_data(G_OBJECT(item->data), "close_button");
+      if (close_button)
+        gtk_widget_set_sensitive(close_button, FALSE);
+    }
+  g_list_free (screens);
+  
   if (window->priv->active_term)
     {
       old_widget = terminal_screen_get_widget (window->priv->active_term);
@@ -1352,6 +1417,9 @@
   g_assert (page_widget);
 
   screen = find_screen_by_hbox (window, page_widget);
+  close_button = g_object_get_data (G_OBJECT (screen), "close_button");
+  if (close_button)
+    gtk_widget_set_sensitive(close_button, TRUE);
 
   g_assert (screen);
 
