--- Terminal-0.4.4/terminal/terminal-window.c	2010-02-01 18:07:04.000000000 +0100
+++ Terminal-0.4.4-no-tab-gui/terminal/terminal-window.c	2010-03-19 15:22:00.264759459 +0100
@@ -1,3 +1,4 @@
+/* $Id: terminal-window.c 30361 2009-07-20 17:46:11Z nick $ */
 /*-
  * Copyright (c) 2004-2008 os-cillation e.K.
  *
@@ -90,12 +91,8 @@
                                                                       TerminalScreen         *screen,
                                                                       gint                    force_grid_width,
                                                                       gint                    force_grid_height);
-static gboolean        terminal_window_accel_activate                (GtkAccelGroup          *accel_group,
-                                                                      GObject                *acceleratable,
-                                                                      guint                   accel_key,
-                                                                      GdkModifierType         accel_mods,
-                                                                      TerminalWindow         *window);
 static void            terminal_window_update_actions                (TerminalWindow         *window);
+static void            terminal_window_update_mnemonics              (TerminalWindow         *window);
 static void            terminal_window_rebuild_gomenu                (TerminalWindow         *window);
 static void            terminal_window_notebook_page_switched        (GtkNotebook            *notebook,
                                                                       GtkNotebookPage        *page,
@@ -233,8 +230,8 @@
   { "view-menu", NULL, N_ ("_View"), NULL, NULL, NULL, },
   { "terminal-menu", NULL, N_ ("_Terminal"), NULL, NULL, NULL, },
     { "set-title", NULL, N_ ("_Set Title..."), NULL, N_ ("Set a custom title for the current tab"), G_CALLBACK (terminal_window_action_set_title), },
-    { "reset", GTK_STOCK_REFRESH, N_ ("_Reset"), NULL, N_ ("Reset"), G_CALLBACK (terminal_window_action_reset), },
-    { "reset-and-clear", GTK_STOCK_CLEAR, N_ ("Reset and C_lear"), NULL, N_ ("Reset and clear"), G_CALLBACK (terminal_window_action_reset_and_clear), },
+  { "reset", GTK_STOCK_REFRESH, N_ ("_Reset"), NULL, NULL, G_CALLBACK (terminal_window_action_reset), },
+  { "reset-and-clear", GTK_STOCK_CLEAR, N_ ("Reset and C_lear"), NULL, NULL, G_CALLBACK (terminal_window_action_reset_and_clear), },
   { "go-menu", NULL, N_ ("_Go"), NULL, NULL, NULL, },
     { "prev-tab", GTK_STOCK_GO_BACK, N_ ("_Previous Tab"), NULL, N_ ("Switch to previous tab"), G_CALLBACK (terminal_window_action_prev_tab), },
     { "next-tab", GTK_STOCK_GO_FORWARD, N_ ("_Next Tab"), NULL, N_ ("Switch to next tab"), G_CALLBACK (terminal_window_action_next_tab), },
@@ -312,7 +309,7 @@
   GtkAccelGroup  *accel_group;
   GtkAction      *action;
   GtkWidget      *vbox;
-  gboolean        always_show_tabs;
+  gboolean        no_mnemonics, always_show_tabs;
   gchar          *role;
   GtkRcStyle     *style;
 
@@ -325,6 +322,8 @@
                             G_CALLBACK (terminal_window_set_size), window);
   g_signal_connect_swapped (G_OBJECT (window->preferences), "notify::scrolling-bar",
                             G_CALLBACK (terminal_window_set_size), window);
+  g_signal_connect_swapped (G_OBJECT (window->preferences), "notify::shortcuts-no-mnemonics",
+                            G_CALLBACK (terminal_window_update_mnemonics), window);
 
   window->action_group = gtk_action_group_new ("terminal-window");
   gtk_action_group_set_translation_domain (window->action_group,
@@ -344,13 +343,20 @@
 
   accel_group = gtk_ui_manager_get_accel_group (window->ui_manager);
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
-  g_signal_connect_after (G_OBJECT (accel_group), "accel-activate",
-      G_CALLBACK (terminal_window_accel_activate), window);
 
   vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (window), vbox);
   gtk_widget_show (vbox);
 
+  /* get some preferences */
+  g_object_get (G_OBJECT (window->preferences),
+                "shortcuts-no-mnemonics", &no_mnemonics,
+                "misc-always-show-tabs", &always_show_tabs, NULL);
+
+  /* setup mnemonics */
+  if (G_UNLIKELY (no_mnemonics))
+    terminal_window_update_mnemonics (window);
+
 #if defined(GDK_WINDOWING_X11)
   /* setup fullscreen mode */
   if (!gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE)))
@@ -361,7 +367,6 @@
 #endif
 
   /* allocate the notebook for the terminal screens */
-  g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL);
   window->notebook = g_object_new (GTK_TYPE_NOTEBOOK,
                                    "homogeneous", TRUE,
                                    "scrollable", TRUE,
@@ -657,42 +662,12 @@
 
 
 
-static gboolean
-terminal_window_accel_activate (GtkAccelGroup   *accel_group,
-                                GObject         *acceleratable,
-                                guint            accel_key,
-                                GdkModifierType  accel_mods,
-                                TerminalWindow  *window)
-{
-  GtkAction   *action;
-  const gchar *names[] = { "prev-tab", "next-tab" };
-  guint        n;
-  GtkAccelKey  key;
-
-  for (n = 0; n < G_N_ELEMENTS (names); n++)
-    {
-      /* pretend we handled the accelerator if the event matches one of
-       * the insensitive actions, so we don't send weird key events to vte
-       * see http://bugzilla.xfce.org/show_bug.cgi?id=3715 */
-      action = gtk_action_group_get_action (window->action_group, names[n]);
-      if (!gtk_action_is_sensitive (action)
-          && gtk_accel_map_lookup_entry (gtk_action_get_accel_path (action), &key)
-          && key.accel_key == accel_key
-          && key.accel_mods == accel_mods)
-        return TRUE;
-    }
-
-  return FALSE;
-}
-
-
-
 static void
 terminal_window_update_actions (TerminalWindow *window)
 {
   GtkNotebook    *notebook = GTK_NOTEBOOK (window->notebook);
   GtkAction      *action;
-  gboolean        cycle_tabs;
+  gboolean        cycle_tabs = 1;
   gint            page_num;
   gint            n_pages;
 
@@ -712,15 +687,15 @@
     {
       page_num = gtk_notebook_page_num (notebook, GTK_WIDGET (window->active));
 
-      g_object_get (G_OBJECT (window->preferences),
+      /*g_object_get (G_OBJECT (window->preferences),
                     "misc-cycle-tabs", &cycle_tabs,
-                    NULL);
+                    NULL);*/
 
       action = gtk_action_group_get_action (window->action_group, "prev-tab");
-      gtk_action_set_sensitive (action, (cycle_tabs && n_pages > 1) || (page_num > 0));
+      gtk_action_set_sensitive (action, cycle_tabs /*&& n_pages > 1) || (page_num > 0)*/);
 
       action = gtk_action_group_get_action (window->action_group, "next-tab");
-      gtk_action_set_sensitive (action, (cycle_tabs && n_pages > 1 ) || (page_num < n_pages - 1));
+      gtk_action_set_sensitive (action, cycle_tabs /*&& n_pages > 1 ) || (page_num < n_pages - 1)*/);
 
       action = gtk_action_group_get_action (window->action_group, "copy");
       gtk_action_set_sensitive (action, terminal_screen_has_selection (window->active));
@@ -733,6 +708,44 @@
 }
 
 
+
+static void
+terminal_window_update_mnemonics (TerminalWindow *window)
+{
+  gboolean disable;
+  GSList  *wp;
+  GList   *actions;
+  GList   *ap;
+  gchar   *label;
+  gchar   *tmp;
+
+  g_object_get (G_OBJECT (window->preferences),
+                "shortcuts-no-mnemonics", &disable,
+                NULL);
+
+  actions = gtk_action_group_list_actions (window->action_group);
+  for (ap = actions; ap != NULL; ap = ap->next)
+    for (wp = gtk_action_get_proxies (ap->data); wp != NULL; wp = wp->next)
+      if (G_TYPE_CHECK_INSTANCE_TYPE (wp->data, GTK_TYPE_MENU_ITEM))
+        {
+          g_object_get (G_OBJECT (ap->data), "label", &label, NULL);
+          if (disable)
+            {
+              tmp = exo_str_elide_underscores (label);
+              g_free (label);
+              label = tmp;
+            }
+
+          g_object_set (G_OBJECT (GTK_BIN (wp->data)->child),
+                        "label", label, NULL);
+
+          g_free (label);
+        }
+  g_list_free (actions);
+}
+
+
+
 static void
 terminal_window_rebuild_gomenu (TerminalWindow *window)
 {
@@ -748,23 +761,27 @@
     {
       /* remove merge id */
       gtk_ui_manager_remove_ui (window->ui_manager, window->gomenu_merge_id);
+      window->gomenu_merge_id = 0;
 
-      /* drop all the old accels from the action group */
+      /* drop all the previous actions from the action group */
       for (n = 1; n < 100 /* arbitrary */; n++)
         {
           g_snprintf (name, sizeof (name), "accel-switch-to-tab%d", n);
           action = gtk_action_group_get_action (window->action_group, name);
-          if (G_UNLIKELY (action == NULL))
-            break;
+          if (G_LIKELY (action != NULL))
           gtk_action_group_remove_action (window->action_group, action);
+          else
+            break;
         }
     }
 
+  npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
+
   /* create a new merge id */
+  if (G_LIKELY (npages > 0))
   window->gomenu_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager);
 
   /* walk the tabs */
-  npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
   for (n = 0; n < npages; n++)
     {
       page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), n);
@@ -858,7 +875,7 @@
 terminal_window_notebook_show_tabs (TerminalWindow *window)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (window->notebook);
-  gboolean     show_tabs = TRUE;
+  gboolean     show_tabs = FALSE;
   gint         npages;
   gint         width_chars, height_chars;
 
@@ -973,11 +990,11 @@
 
 
 
-#define EVENT_IN_ALLOCATION(event_x,event_y,widget) \
-  ((event_x) >= (widget)->allocation.x  \
-  && (event_x) <= (widget)->allocation.x + (widget)->allocation.width \
-  && (event_y) >= (widget)->allocation.y \
-  && (event_y) <= (widget)->allocation.y + (widget)->allocation.height)
+#define EVENT_IN_ALLOCATION(event,widget) \
+  ((widget)->allocation.x <= (event)->x \
+  && (widget)->allocation.x + (widget)->allocation.width >= (event)->x \
+  && (widget)->allocation.y <= (event)->y \
+  && (widget)->allocation.y + (widget)->allocation.height >= (event)->y)
 
 
 
@@ -989,22 +1006,17 @@
   GtkWidget *page, *label, *menu;
   gint       page_num = 0;
   gboolean   close_middle_click;
-  gint       x, y;
 
   terminal_return_val_if_fail (TERMINAL_IS_WINDOW (window), FALSE);
   terminal_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), FALSE);
 
-  gdk_window_get_position (event->window, &x, &y);
-  x += event->x;
-  y += event->y;
-
   if (event->button == 1)
     {
       if (event->type == GDK_2BUTTON_PRESS)
         {
           /* check if the user double-clicked on the label */
           label = gtk_notebook_get_tab_label (notebook, GTK_WIDGET (window->active));
-          if (EVENT_IN_ALLOCATION (x, y, label))
+          if (EVENT_IN_ALLOCATION (event, label))
             {
               terminal_window_action_set_title (NULL, window);
               return TRUE;
@@ -1017,7 +1029,7 @@
       while ((page = gtk_notebook_get_nth_page (notebook, page_num)) != NULL)
         {
           label = gtk_notebook_get_tab_label (notebook, page);
-          if (EVENT_IN_ALLOCATION (x, y, label))
+          if (EVENT_IN_ALLOCATION (event, label))
             break;
           page_num++;
         }
@@ -1739,6 +1751,23 @@
 
 
 /**
+ * terminal_window_remove:
+ * @window  : A #TerminalWindow.
+ * @screen  : A #TerminalScreen.
+ **/
+void
+terminal_window_remove (TerminalWindow *window,
+                        TerminalScreen *screen)
+{
+  terminal_return_if_fail (TERMINAL_IS_WINDOW (window));
+  terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
+
+  gtk_widget_destroy (GTK_WIDGET (screen));
+}
+
+
+
+/**
  * terminal_window_get_active:
  * @window : a #TerminalWindow.
  *
