Index: terminal-debug.c
===================================================================
--- terminal-debug.c	(revision 3436)
+++ terminal-debug.c	(working copy)
@@ -33,7 +33,8 @@
     { "encodings", TERMINAL_DEBUG_ENCODINGS },
     { "factory",   TERMINAL_DEBUG_FACTORY   },
     { "geometry",  TERMINAL_DEBUG_GEOMETRY  },
-    { "profile",   TERMINAL_DEBUG_PROFILE   }
+    { "profile",   TERMINAL_DEBUG_PROFILE   },
+    { "bell",      TERMINAL_DEBUG_BELL      }
   };
 
   _terminal_debug_flags = g_parse_debug_string (g_getenv ("GNOME_TERMINAL_DEBUG"),
Index: terminal-debug.h
===================================================================
--- terminal-debug.h	(revision 3436)
+++ terminal-debug.h	(working copy)
@@ -31,6 +31,7 @@
   TERMINAL_DEBUG_FACTORY    = 1 << 2,
   TERMINAL_DEBUG_GEOMETRY   = 1 << 3,
   TERMINAL_DEBUG_PROFILE    = 1 << 4,
+  TERMINAL_DEBUG_BELL       = 1 << 5,
 } TerminalDebugFlags;
 
 void _terminal_debug_init(void);
Index: terminal-screen.c
===================================================================
--- terminal-screen.c	(revision 3436)
+++ terminal-screen.c	(working copy)
@@ -73,6 +73,7 @@
   double font_scale;
   gboolean user_title; /* title was manually set */
   GSList *match_tags;
+  gboolean bell_raised;
 };
 
 enum
@@ -91,7 +92,8 @@
   PROP_ICON_TITLE_SET,
   PROP_OVERRIDE_COMMAND,
   PROP_TITLE,
-  PROP_INITIAL_ENVIRONMENT
+  PROP_INITIAL_ENVIRONMENT,
+  PROP_BELL_RAISED
 };
 
 enum
@@ -129,6 +131,11 @@
 static void terminal_screen_icon_title_changed        (VteTerminal *vte_terminal,
                                                        TerminalScreen *screen);
 
+static void terminal_screen_beep_cb (TerminalScreen *screen);
+static gboolean terminal_screen_focus_cb (TerminalScreen *screen);
+static gboolean terminal_screen_focus_in_event_cb (TerminalScreen *screen);
+static gboolean terminal_screen_key_press_event_cb (TerminalScreen *screen);
+
 static void update_color_scheme                      (TerminalScreen *screen);
 
 static gboolean terminal_screen_format_title (TerminalScreen *screen, const char *raw_title, char **old_cooked_title);
@@ -394,6 +401,19 @@
 
   g_signal_connect (screen, "parent-set", G_CALLBACK (parent_set_callback), NULL);
 
+  g_signal_connect (screen, "beep",
+                    G_CALLBACK (terminal_screen_beep_cb),
+                    NULL);
+  g_signal_connect (VTE_TERMINAL (screen), "focus",
+                    G_CALLBACK (terminal_screen_focus_cb),
+                    NULL);
+  g_signal_connect (VTE_TERMINAL (screen), "focus-in-event",
+                    G_CALLBACK (terminal_screen_focus_in_event_cb),
+                    NULL);
+  g_signal_connect (screen, "key-press-event",
+                    G_CALLBACK (terminal_screen_key_press_event_cb),
+                    NULL);
+
 #ifdef GNOME_ENABLE_DEBUG
   _TERMINAL_DEBUG_IF (TERMINAL_DEBUG_GEOMETRY)
     {
@@ -431,6 +451,10 @@
       case PROP_TITLE:
         g_value_set_string (value, terminal_screen_get_title (screen));
         break;
+      case PROP_BELL_RAISED:
+        _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "get PROP_BELL_RAISED");
+        g_value_set_boolean (value, terminal_screen_get_bell_raised (screen));
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -461,6 +485,10 @@
       case PROP_INITIAL_ENVIRONMENT:
         terminal_screen_set_initial_environment (screen, g_value_get_boxed (value));
         break;
+      case PROP_BELL_RAISED:
+        _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "set PROP_BELL_RAISED");
+        terminal_screen_set_bell_raised (screen, g_value_get_boolean (value));
+        break;
       case PROP_ICON_TITLE:
       case PROP_ICON_TITLE_SET:
       case PROP_TITLE:
@@ -576,6 +604,15 @@
                          G_TYPE_STRV,
                          G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "installing bell raised property");
+  g_object_class_install_property
+    (object_class,
+     PROP_BELL_RAISED,
+     g_param_spec_boolean ("bell-raised", NULL, NULL,
+                           FALSE,
+                           G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+
   g_type_class_add_private (object_class, sizeof (TerminalScreenPrivate));
 
   /* Precompile the regexes */
@@ -661,6 +698,40 @@
   G_OBJECT_CLASS (terminal_screen_parent_class)->finalize (object);
 }
 
+/* XXX Should this be returning TRUE, FALSE, void? */
+void
+terminal_screen_beep_cb (TerminalScreen *screen)
+{
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "screen beep callback");
+  g_object_set (screen, "bell-raised", TRUE, NULL);
+}
+
+/* The user switched to this tab... */
+gboolean
+terminal_screen_focus_cb (TerminalScreen *screen)
+{
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "screen focus callback");
+  g_object_set (screen, "bell-raised", FALSE, NULL);
+  return FALSE;
+}
+
+/* The user switched to the parent window and this tab was the active one... */
+gboolean
+terminal_screen_focus_in_event_cb (TerminalScreen *screen)
+{
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "screen focus-in-event callback");
+  g_object_set (screen, "bell-raised", FALSE, NULL);
+  return FALSE;
+}
+
+gboolean
+terminal_screen_key_press_event_cb (TerminalScreen *screen)
+{
+  /* pretty sure a print statement here would be a bit annoying! */
+  g_object_set (screen, "bell-raised", FALSE, NULL);
+  return FALSE;
+}
+
 TerminalScreen *
 terminal_screen_new (TerminalProfile *profile,
                      char           **override_command,
@@ -2314,3 +2385,22 @@
   return TRUE;
 #endif
 }
+
+gboolean
+terminal_screen_get_bell_raised (TerminalScreen *screen)
+{
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "get bell raised");
+
+  return screen->priv->bell_raised;
+}
+
+void
+terminal_screen_set_bell_raised (TerminalScreen *screen,
+                                 gboolean raised)
+{
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s %s\n", "set bell raised",
+                         (raised == TRUE)? "TRUE": "FALSE");
+
+  screen->priv->bell_raised = raised;
+}
+
Index: terminal-tab-label.c
===================================================================
--- terminal-tab-label.c	(revision 3436)
+++ terminal-tab-label.c	(working copy)
@@ -22,6 +22,7 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
+#include "terminal-debug.h"
 #include "terminal-tab-label.h"
 
 #define TERMINAL_TAB_LABEL_GET_PRIVATE(tab_label)(G_TYPE_INSTANCE_GET_PRIVATE ((tab_label), TERMINAL_TYPE_TAB_LABEL, TerminalTabLabelPrivate))
@@ -77,6 +78,56 @@
   gtk_widget_set_tooltip_text (hbox, title);
 }
 
+static void
+screen_bell_raised_tab_label_cb (TerminalScreen *screen,
+                                 GParamSpec *pspec,
+                                 TerminalTabLabel *tab_label)
+{
+  gboolean bell_raised;
+
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "tab label got screen bell raised");
+
+  g_object_get (screen, "bell-raised", &bell_raised, NULL);
+
+  if (bell_raised)
+    {
+      gboolean screen_has_focus;
+
+      _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "tab label bell raised");
+
+      /* We need some way of not bolding the current tab if that's what
+       * the user wants.  Whether this is the right way... */
+      g_object_get (screen, "has-focus", &screen_has_focus, NULL);
+
+      if (screen_has_focus)
+        {
+          _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "tab label's screen has focus");
+
+          /* TODO add bold_even_if_focus pref */
+          if (FALSE)
+            _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "not bolding title");
+          else
+            {
+              _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "bolding title");
+              terminal_tab_label_set_bold (tab_label, TRUE);
+            }
+        }
+      else
+        {
+          _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "tab label's screen DOES NOT have focus");
+          _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "bolding title");
+          terminal_tab_label_set_bold (tab_label, TRUE);
+        }
+
+    }
+  else
+    {
+      _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "tab label bell cleared");
+
+      terminal_tab_label_set_bold (tab_label, FALSE);
+    }
+}
+
 /* public functions */
 
 /* Class implementation */
@@ -161,6 +212,9 @@
   g_signal_connect (close_button, "clicked",
 		    G_CALLBACK (close_button_clicked_cb), tab_label);
 
+  g_signal_connect (priv->screen, "notify::bell-raised",
+                    G_CALLBACK (screen_bell_raised_tab_label_cb), tab_label);
+
   gtk_widget_show_all (hbox);
 
   return object;
Index: terminal-screen.h
===================================================================
--- terminal-screen.h	(revision 3436)
+++ terminal-screen.h	(working copy)
@@ -70,6 +70,7 @@
                                int flavour,
                                guint state);
   void (* close_screen)       (TerminalScreen *screen);
+  void (* bell_raised_handler)(TerminalScreen *screen);
 };
 
 GType terminal_screen_get_type (void) G_GNUC_CONST;
@@ -131,6 +132,10 @@
 
 gboolean terminal_screen_has_foreground_process (TerminalScreen *screen);
 
+gboolean terminal_screen_get_bell_raised (TerminalScreen *screen);
+void terminal_screen_set_bell_raised (TerminalScreen *screen,
+                                          gboolean raised);
+
 /* Allow scales a bit smaller and a bit larger than the usual pango ranges */
 #define TERMINAL_SCALE_XXX_SMALL   (PANGO_SCALE_XX_SMALL/1.2)
 #define TERMINAL_SCALE_XXXX_SMALL  (TERMINAL_SCALE_XXX_SMALL/1.2)
Index: terminal-tab-label.h
===================================================================
--- terminal-tab-label.h	(revision 3436)
+++ terminal-tab-label.h	(working copy)
@@ -21,6 +21,7 @@
 
 #include <gtk/gtk.h>
 
+#include "terminal-debug.h"
 #include "terminal-screen.h"
 
 G_BEGIN_DECLS
Index: terminal-window.c
===================================================================
--- terminal-window.c	(revision 3436)
+++ terminal-window.c	(working copy)
@@ -1345,6 +1345,43 @@
   terminal_window_remove_screen (window, screen);
 }
 
+static void
+screen_bell_raised_window_cb (TerminalScreen *screen,
+                              GParamSpec *pspec,
+                              TerminalWindow *window)
+{
+  gboolean bell_raised;
+
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "bell raised window callback");
+
+  if (G_IS_OBJECT (screen))
+    _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "screen is an object");
+  else
+    _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "screen is NOT an object");
+
+  g_object_get (screen, "bell-raised", &bell_raised, NULL);
+
+  if (bell_raised == TRUE)
+    {
+      GtkWidget *toplevel;
+      gboolean has_toplevel_focus;
+
+      _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "bell raised on screen");
+
+      /*toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen)); */
+      toplevel = GTK_WIDGET (window);
+      g_object_get (toplevel, "has-toplevel-focus", &has_toplevel_focus, NULL);
+      if (!has_toplevel_focus)
+        gtk_window_set_urgency_hint (GTK_WINDOW (toplevel), TRUE);
+    }
+  else
+    {
+      _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "bell cleared on screen");
+
+      /* The urgency hint is cleared on focus, not here */
+    }
+}
+
 static gboolean
 terminal_window_accel_activate_cb (GtkAccelGroup  *accel_group,
                                    GObject        *acceleratable,
@@ -1571,6 +1608,14 @@
   terminal_window_update_encoding_menu (window);
 }
 
+static gboolean
+terminal_window_focus_cb (TerminalWindow *window)
+{
+  _terminal_debug_print (TERMINAL_DEBUG_BELL, "%s\n", "window focus callback");
+  gtk_window_set_urgency_hint (GTK_WINDOW (window), FALSE);
+  return FALSE;
+}
+
 static void
 terminal_window_init (TerminalWindow *window)
 {
@@ -1873,6 +1918,10 @@
 
   terminal_window_update_size_to_menu (window);
 
+  g_signal_connect (window, "focus-in-event",
+                    G_CALLBACK (terminal_window_focus_cb), NULL);
+
+
   /* We have to explicitly call this, since screen-changed is NOT
    * emitted for the toplevel the first time!
    */
@@ -2601,6 +2650,10 @@
   g_signal_connect (screen, "close-screen",
                     G_CALLBACK (screen_close_cb), window);
 
+  g_signal_connect (screen, "notify::bell-raised",
+                    G_CALLBACK (screen_bell_raised_window_cb), window);
+
+
   update_notebook (window);
 
   update_tab_visibility (window, 0);
@@ -2690,6 +2743,10 @@
                                         G_CALLBACK (screen_close_cb),
                                         window);
 
+  g_signal_handlers_disconnect_by_func (screen,
+                                        G_CALLBACK (screen_bell_raised_window_cb),
+                                        window);
+
   priv->terms--;
 
   update_notebook (window);
