[nautilus/wip/gaction] port to gaction



commit 28e042816121e9d8d37d0673d33210b23dde902c
Author: Carlos Soriano <carlos sorian89 gmail com>
Date:   Wed Dec 3 16:43:34 2014 +0100

    port to gaction

 libnautilus-private/nautilus-clipboard.c    |  422 ---
 libnautilus-private/nautilus-clipboard.h    |   12 -
 libnautilus-private/nautilus-ui-utilities.c |  131 +
 libnautilus-private/nautilus-ui-utilities.h |   14 +
 src/nautilus-canvas-view.c                  |  433 +--
 src/nautilus-desktop-canvas-view.c          |  227 +-
 src/nautilus-list-view.c                    |  140 +-
 src/nautilus-toolbar.c                      |  435 ++-
 src/nautilus-toolbar.h                      |   20 +-
 src/nautilus-view.c                         | 5255 +++++++--------------------
 src/nautilus-view.h                         |   27 +-
 src/nautilus-window-menus.c                 |  135 +
 src/nautilus-window-private.h               |    2 +
 src/nautilus-window.c                       |   62 +-
 src/nautilus-window.h                       |    1 +
 src/nautilus.gresource.xml                  |    4 +
 16 files changed, 2152 insertions(+), 5168 deletions(-)
---
diff --git a/libnautilus-private/nautilus-clipboard.c b/libnautilus-private/nautilus-clipboard.c
index dd6f9c0..d194cf3 100644
--- a/libnautilus-private/nautilus-clipboard.c
+++ b/libnautilus-private/nautilus-clipboard.c
@@ -33,428 +33,6 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-typedef struct _TargetCallbackData TargetCallbackData;
-
-typedef void (* SelectAllCallback)    (gpointer target);
-typedef void (* ConnectCallbacksFunc) (GObject            *object,
-                                      TargetCallbackData *target_data);
-
-static void selection_changed_callback            (GtkWidget *widget,
-                                                  gpointer callback_data);
-static void owner_change_callback (GtkClipboard        *clipboard,
-                                  GdkEventOwnerChange *event,
-                                  gpointer callback_data);
-struct _TargetCallbackData {
-       GtkUIManager *ui_manager;
-       GtkActionGroup *action_group;
-       gboolean shares_selection_changes;
-
-       SelectAllCallback select_all_callback;
-
-       ConnectCallbacksFunc connect_callbacks;
-       ConnectCallbacksFunc disconnect_callbacks;
-};
-
-static void
-cut_callback (gpointer target)
-{
-       g_assert (target != NULL);
-
-       g_signal_emit_by_name (target, "cut-clipboard");
-}
-
-static void
-copy_callback (gpointer target)
-{
-       g_assert (target != NULL);
-
-       g_signal_emit_by_name (target, "copy-clipboard");
-}
-
-static void
-paste_callback (gpointer target)
-{
-       g_assert (target != NULL);
-
-       g_signal_emit_by_name (target, "paste-clipboard");
-}
-
-static void
-editable_select_all_callback (gpointer target)
-{
-       GtkEditable *editable;
-
-       editable = GTK_EDITABLE (target);
-       g_assert (editable != NULL);
-
-       gtk_editable_set_position (editable, -1);
-       gtk_editable_select_region (editable, 0, -1);
-}
-
-static void
-action_cut_callback (GtkAction *action,
-                    gpointer callback_data)
-{
-       cut_callback (callback_data);
-}
-
-static void
-action_copy_callback (GtkAction *action,
-                     gpointer callback_data)
-{
-       copy_callback (callback_data);
-}
-
-static void
-action_paste_callback (GtkAction *action,
-                      gpointer callback_data)
-{
-       paste_callback (callback_data);
-}
-
-static void
-action_select_all_callback (GtkAction *action,
-                           gpointer callback_data)
-{
-       TargetCallbackData *target_data;
-
-       g_assert (callback_data != NULL);
-
-       target_data = g_object_get_data (callback_data, "Nautilus:clipboard_target_data");
-       g_assert (target_data != NULL);
-
-       target_data->select_all_callback (callback_data);
-}
-
-static void
-received_clipboard_contents (GtkClipboard     *clipboard,
-                            GtkSelectionData *selection_data,
-                            gpointer          data)
-{
-       GtkActionGroup *action_group;
-       GtkAction *action;
-
-       action_group = data;
-
-       action = gtk_action_group_get_action (action_group,
-                                             "Paste");
-       if (action != NULL) {
-               gtk_action_set_sensitive (action,
-                                         gtk_selection_data_targets_include_text (selection_data));
-       }
-
-       g_object_unref (action_group);
-}
-
-
-static void
-set_paste_sensitive_if_clipboard_contains_data (GtkActionGroup *action_group)
-{
-       GtkAction *action;
-       if (gdk_display_supports_selection_notification (gdk_display_get_default ())) {
-               gtk_clipboard_request_contents (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
-                                               gdk_atom_intern ("TARGETS", FALSE),
-                                               received_clipboard_contents,
-                                               g_object_ref (action_group));
-       } else {
-               /* If selection notification isn't supported, always activate Paste */
-               action = gtk_action_group_get_action (action_group,
-                                                     "Paste");
-               gtk_action_set_sensitive (action, TRUE);
-       }
-}
-
-static void
-set_clipboard_menu_items_sensitive (GtkActionGroup *action_group)
-{
-       GtkAction *action;
-
-       action = gtk_action_group_get_action (action_group,
-                                             "Cut");
-       gtk_action_set_sensitive (action, TRUE);
-       action = gtk_action_group_get_action (action_group,
-                                             "Copy");
-       gtk_action_set_sensitive (action, TRUE);
-}
-
-static void
-set_clipboard_menu_items_insensitive (GtkActionGroup *action_group)
-{
-       GtkAction *action;
-
-       action = gtk_action_group_get_action (action_group,
-                                             "Cut");
-       gtk_action_set_sensitive (action, FALSE);
-       action = gtk_action_group_get_action (action_group,
-                                             "Copy");
-       gtk_action_set_sensitive (action, FALSE);
-}
-
-static gboolean
-clipboard_items_are_merged_in (GtkWidget *widget)
-{
-       return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
-                                                  "Nautilus:clipboard_menu_items_merged"));
-}
-
-static void
-set_clipboard_items_are_merged_in (GObject *widget_as_object,
-                                  gboolean merged_in)
-{
-       g_object_set_data (widget_as_object,
-                          "Nautilus:clipboard_menu_items_merged",
-                          GINT_TO_POINTER (merged_in));
-}
-
-static void
-editable_connect_callbacks (GObject *object,
-                           TargetCallbackData *target_data)
-{
-       g_signal_connect_after (object, "selection-changed",
-                               G_CALLBACK (selection_changed_callback), target_data);
-       selection_changed_callback (GTK_WIDGET (object),
-                                   target_data);
-}
-
-static void
-editable_disconnect_callbacks (GObject *object,
-                              TargetCallbackData *target_data)
-{
-       g_signal_handlers_disconnect_matched (object,
-                                             G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
-                                             0, 0, NULL,
-                                             G_CALLBACK (selection_changed_callback),
-                                             target_data);
-}
-
-static void
-merge_in_clipboard_menu_items (GObject *widget_as_object,
-                              TargetCallbackData *target_data)
-{
-       gboolean add_selection_callback;
-
-       g_assert (target_data != NULL);
-       
-       add_selection_callback = target_data->shares_selection_changes;
-
-       gtk_ui_manager_insert_action_group (target_data->ui_manager,
-                                           target_data->action_group, 0);
-
-       set_paste_sensitive_if_clipboard_contains_data (target_data->action_group);
-       
-       g_signal_connect (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), "owner-change",
-                         G_CALLBACK (owner_change_callback), target_data);
-       
-       if (add_selection_callback) {
-               target_data->connect_callbacks (widget_as_object, target_data);
-       } else {
-               /* If we don't use sensitivity, everything should be on */
-               set_clipboard_menu_items_sensitive (target_data->action_group);
-       }
-       set_clipboard_items_are_merged_in (widget_as_object, TRUE);
-}
-
-static void
-merge_out_clipboard_menu_items (GObject *widget_as_object,
-                               TargetCallbackData *target_data)
-
-{
-       gboolean selection_callback_was_added;
-
-       g_assert (target_data != NULL);
-
-       gtk_ui_manager_remove_action_group (target_data->ui_manager,
-                                           target_data->action_group);
-
-       g_signal_handlers_disconnect_matched (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
-                                             G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
-                                             0, 0, NULL,
-                                             G_CALLBACK (owner_change_callback),
-                                             target_data);
-       
-       selection_callback_was_added = target_data->shares_selection_changes;
-
-       if (selection_callback_was_added) {
-               target_data->disconnect_callbacks (widget_as_object, target_data);
-       }
-       set_clipboard_items_are_merged_in (widget_as_object, FALSE);
-}
-
-static gboolean
-focus_changed_callback (GtkWidget *widget,
-                       GdkEventAny *event,
-                       gpointer callback_data)
-{
-       /* Connect the component to the container if the widget has focus. */
-       if (gtk_widget_has_focus (widget)) {
-               if (!clipboard_items_are_merged_in (widget)) {
-                       merge_in_clipboard_menu_items (G_OBJECT (widget), callback_data);
-               }
-       } else {
-               if (clipboard_items_are_merged_in (widget)) {
-                       merge_out_clipboard_menu_items (G_OBJECT (widget), callback_data);
-               }
-       }
-
-       return FALSE;
-}
-
-static void
-selection_changed_callback (GtkWidget *widget,
-                           gpointer callback_data)
-{
-       TargetCallbackData *target_data;
-       GtkEditable *editable;
-       int start, end;
-
-       target_data = (TargetCallbackData *) callback_data;
-       g_assert (target_data != NULL);
-
-       editable = GTK_EDITABLE (widget);
-       g_assert (editable != NULL);
-
-       if (gtk_editable_get_selection_bounds (editable, &start, &end) && start != end) {
-               set_clipboard_menu_items_sensitive (target_data->action_group);
-       } else {
-               set_clipboard_menu_items_insensitive (target_data->action_group);
-       }
-}
-
-static void
-owner_change_callback (GtkClipboard        *clipboard,
-                      GdkEventOwnerChange *event,
-                      gpointer callback_data)
-{
-       TargetCallbackData *target_data;
-
-       g_assert (callback_data != NULL);
-       target_data = callback_data;
-
-       set_paste_sensitive_if_clipboard_contains_data (target_data->action_group);
-}
-
-static void
-target_destroy_callback (GtkWidget *object,
-                        gpointer callback_data)
-{
-       g_assert (callback_data != NULL);
-
-       if (clipboard_items_are_merged_in (object)) {
-               merge_out_clipboard_menu_items (G_OBJECT (object), callback_data);
-       }
-}
-
-static void
-target_data_free (TargetCallbackData *target_data)
-{
-       g_object_unref (target_data->action_group);
-       g_free (target_data);
-}
-
-static const GtkActionEntry clipboard_entries[] = {
-  /* name, stock id */      { "Cut", NULL,
-  /* label, accelerator */    N_("Cu_t"), "<control>X",
-  /* tooltip */               N_("Cut the selected text to the clipboard"),
-                              G_CALLBACK (action_cut_callback) },
-  /* name, stock id */      { "Copy", NULL,
-  /* label, accelerator */    N_("_Copy"), "<control>C",
-  /* tooltip */               N_("Copy the selected text to the clipboard"),
-                              G_CALLBACK (action_copy_callback) },
-  /* name, stock id */      { "Paste", NULL,
-  /* label, accelerator */    N_("_Paste"), "<control>V",
-  /* tooltip */               N_("Paste the text stored on the clipboard"),
-                              G_CALLBACK (action_paste_callback) },
-  /* name, stock id */      { "Select All", NULL,
-  /* label, accelerator */    N_("Select _All"), "<control>A",
-  /* tooltip */               N_("Select all the text in a text field"),
-                              G_CALLBACK (action_select_all_callback) },
-};
-
-static TargetCallbackData *
-initialize_clipboard_component_with_callback_data (GtkEditable *target,
-                                                  GtkUIManager *ui_manager,
-                                                  gboolean shares_selection_changes,
-                                                  SelectAllCallback select_all_callback,
-                                                  ConnectCallbacksFunc connect_callbacks,
-                                                  ConnectCallbacksFunc disconnect_callbacks)
-{
-       GtkActionGroup *action_group;
-       TargetCallbackData *target_data;
-
-       action_group = gtk_action_group_new ("ClipboardActions");
-       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-       gtk_action_group_add_actions (action_group, 
-                                     clipboard_entries, G_N_ELEMENTS (clipboard_entries),
-                                     target);
-       
-       /* Do the actual connection of the UI to the container at
-        * focus time, and disconnect at both focus and destroy
-        * time.
-        */
-       target_data = g_new (TargetCallbackData, 1);
-       target_data->ui_manager = ui_manager;
-       target_data->action_group = action_group;
-       target_data->shares_selection_changes = shares_selection_changes;
-       target_data->select_all_callback = select_all_callback;
-       target_data->connect_callbacks = connect_callbacks;
-       target_data->disconnect_callbacks = disconnect_callbacks;
-
-       return target_data;
-}
-
-static void
-nautilus_clipboard_real_set_up (gpointer target,
-                               GtkUIManager *ui_manager,
-                               gboolean shares_selection_changes,
-                               SelectAllCallback select_all_callback,
-                               ConnectCallbacksFunc connect_callbacks,
-                               ConnectCallbacksFunc disconnect_callbacks)
-{
-       TargetCallbackData *target_data;
-
-       if (g_object_get_data (G_OBJECT (target), "Nautilus:clipboard_target_data") != NULL) {
-               return;
-       }
-
-       target_data = initialize_clipboard_component_with_callback_data
-               (target, 
-                ui_manager,
-                shares_selection_changes,
-                select_all_callback,
-                connect_callbacks,
-                disconnect_callbacks);
-
-       g_signal_connect (target, "focus-in-event",
-                         G_CALLBACK (focus_changed_callback), target_data);
-       g_signal_connect (target, "focus-out-event",
-                         G_CALLBACK (focus_changed_callback), target_data);
-       g_signal_connect (target, "destroy",
-                         G_CALLBACK (target_destroy_callback), target_data);
-
-       g_object_set_data_full (G_OBJECT (target), "Nautilus:clipboard_target_data",
-                               target_data, (GDestroyNotify) target_data_free);
-
-       /* Call the focus changed callback once to merge if the window is
-        * already in focus.
-        */
-       focus_changed_callback (GTK_WIDGET (target), NULL, target_data);
-}
-
-void
-nautilus_clipboard_set_up_editable (GtkEditable *target,
-                                   GtkUIManager *ui_manager,
-                                   gboolean shares_selection_changes)
-{
-       g_return_if_fail (GTK_IS_EDITABLE (target));
-       g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager));
-
-       nautilus_clipboard_real_set_up (target, ui_manager,
-                                       shares_selection_changes,
-                                       editable_select_all_callback,
-                                       editable_connect_callbacks,
-                                       editable_disconnect_callbacks);
-}
-
 static GList *
 convert_lines_to_str_list (char **lines, gboolean *cut)
 {
diff --git a/libnautilus-private/nautilus-clipboard.h b/libnautilus-private/nautilus-clipboard.h
index 26d9762..eee64ef 100644
--- a/libnautilus-private/nautilus-clipboard.h
+++ b/libnautilus-private/nautilus-clipboard.h
@@ -26,18 +26,6 @@
 
 #include <gtk/gtk.h>
 
-/* This makes this editable or text view put clipboard commands into
- * the passed UI manager when the editable/text view is in focus.
- * Callers in Nautilus normally get the UI manager from
- * nautilus_window_get_ui_manager. */
-/* The shares selection changes argument should be set to true if the
- * widget uses the signal "selection-changed" to tell others about
- * text selection changes.  The NautilusEntry widget
- * is currently the only editable in nautilus that shares selection
- * changes. */
-void nautilus_clipboard_set_up_editable            (GtkEditable        *target,
-                                                   GtkUIManager       *ui_manager,
-                                                   gboolean            shares_selection_changes);
 void nautilus_clipboard_clear_if_colliding_uris    (GtkWidget          *widget,
                                                    const GList        *item_uris,
                                                    GdkAtom             copied_files_atom);
diff --git a/libnautilus-private/nautilus-ui-utilities.c b/libnautilus-private/nautilus-ui-utilities.c
index 6fcc3a4..4c6bddd 100644
--- a/libnautilus-private/nautilus-ui-utilities.c
+++ b/libnautilus-private/nautilus-ui-utilities.c
@@ -29,6 +29,128 @@
 
 #include <gio/gio.h>
 #include <gtk/gtk.h>
+#include <string.h>
+
+void
+add_accelerator (GApplication *app,
+                 const gchar *action_name,
+                 const gchar *accel)
+{
+       const gchar *vaccels[] = {
+               accel,
+               NULL
+       };
+
+       gtk_application_set_accels_for_action (GTK_APPLICATION (app), action_name, vaccels);
+}
+
+static GMenuModel *
+find_gmenu_model (GMenuModel  *model,
+                 const gchar *insertion_id)
+{
+       gint i, n_items;
+       GMenuModel *insertion_model = NULL;
+
+       n_items = g_menu_model_get_n_items (model);
+
+       for (i = 0; i < n_items && !insertion_model; i++)
+       {
+               gchar *id = NULL;
+               if (g_menu_model_get_item_attribute (model, i, "id", "s", &id) &&
+                       strcmp (id, insertion_id) == 0)
+               {
+                       insertion_model = g_menu_model_get_item_link (model, i, G_MENU_LINK_SECTION);
+                       if (!insertion_model)
+                       {
+                               insertion_model = g_menu_model_get_item_link (model, i, G_MENU_LINK_SUBMENU);
+                       }
+               }
+               else
+               {
+                       GMenuModel *submodel;
+                       GMenuModel *submenu;
+                       gint j, j_items;
+
+                       submodel = g_menu_model_get_item_link (model, i, G_MENU_LINK_SECTION);
+
+                       if (!submodel)
+                       {
+                               submodel = g_menu_model_get_item_link (model, i, G_MENU_LINK_SUBMENU);
+                               if (!submodel)
+                                       continue;
+                       }
+
+                       j_items = g_menu_model_get_n_items (submodel);
+                       for (j = 0; j < j_items && !insertion_model; j++)
+                       {
+                               submenu = g_menu_model_get_item_link (submodel, j, G_MENU_LINK_SUBMENU);
+                               if (submenu)
+                               {
+                                       insertion_model = find_gmenu_model (submenu, insertion_id);
+                               }
+                       }
+               }
+
+               g_free (id);
+       }
+
+       return insertion_model;
+}
+
+/*
+ * The original GMenu is modified adding to the section @section_name
+ * the items in @gmenu_to_merge.
+ * @gmenu_to_merge should be a list of menu items.
+ */
+void
+nautilus_gmenu_merge (GMenu *original,
+                     GMenu *gmenu_to_merge,
+                     const gchar *section_name)
+{
+       gint i, n_items;
+       GMenuModel *section;
+       GMenuItem *item;
+
+       g_return_if_fail (G_IS_MENU (original));
+       g_return_if_fail (G_IS_MENU (gmenu_to_merge));
+
+       section = find_gmenu_model (G_MENU_MODEL (original), section_name);
+
+       g_return_if_fail (section != NULL);
+
+       n_items = g_menu_model_get_n_items (G_MENU_MODEL (gmenu_to_merge));
+
+       for (i = 0; i < n_items; i++)
+       {
+               item = g_menu_item_new_from_model (G_MENU_MODEL (gmenu_to_merge), i);
+               g_menu_append_item (G_MENU (section), item);
+       }
+}
+
+/*
+ * The GMenu @menu is modified adding to the section @section_name
+ * the item @item.
+ */
+void
+nautilus_gmenu_add_item_in_submodel (GMenu *menu,
+                                    GMenuItem *item,
+                                    const gchar *submodel_name,
+                                    gboolean prepend)
+{
+       GMenuModel *submodel;
+
+       g_return_if_fail (G_IS_MENU (menu));
+       g_return_if_fail (G_IS_MENU_ITEM (item));
+
+       submodel = find_gmenu_model (G_MENU_MODEL (menu), submodel_name);
+
+       g_return_if_fail (submodel != NULL);
+       if (prepend) {
+               g_menu_prepend_item (G_MENU (submodel), item);
+       } else {
+               g_menu_append_item (G_MENU (submodel), item);
+       }
+}
 
 void
 nautilus_ui_unmerge_ui (GtkUIManager *ui_manager,
@@ -161,6 +283,15 @@ nautilus_escape_action_name (const char *action_name,
                case '"':
                        g_string_append (s, "\\q");
                        break;
+               case ' ':
+                       g_string_append (s, "+");
+                       break;
+               case '(':
+                       g_string_append (s, "#");
+                       break;
+               case ')':
+                       g_string_append (s, "^");
+                       break;
                default:
                        g_string_append_c (s, *action_name);
                }
diff --git a/libnautilus-private/nautilus-ui-utilities.h b/libnautilus-private/nautilus-ui-utilities.h
index 0341478..2aaa8c5 100644
--- a/libnautilus-private/nautilus-ui-utilities.h
+++ b/libnautilus-private/nautilus-ui-utilities.h
@@ -33,6 +33,20 @@ void        nautilus_ui_prepare_merge_ui           (GtkUIManager      *ui_manage
                                                    const char        *name,
                                                    guint             *merge_id,
                                                    GtkActionGroup   **action_group);
+
+void nautilus_gmenu_merge                         (GMenu *original,
+                                                   GMenu *gmenu_to_merge,
+                                                   const gchar *section_name);
+
+void nautilus_gmenu_add_item_in_submodel          (GMenu *menu,
+                                                   GMenuItem *item,
+                                                   const gchar *section_name,
+                                                   gboolean prepend);
+
+void add_accelerator                              (GApplication *app,
+                                                   const gchar *action_name,
+                                                   const gchar *accel);
+
 GtkAction * nautilus_action_from_menu_item         (NautilusMenuItem  *item,
                                                    GtkWidget         *parent_widget);
 
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index c3dad37..2934242 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -30,6 +30,7 @@
 #include "nautilus-desktop-canvas-view.h"
 #include "nautilus-error-reporting.h"
 #include "nautilus-view-dnd.h"
+#include "nautilus-toolbar.h"
 
 #include <stdlib.h>
 #include <eel/eel-vfs-extensions.h>
@@ -76,7 +77,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
 typedef struct {
        const NautilusFileSortType sort_type;
        const char *metadata_text;
-       const char *action;
+       const char *action_target_name;
 } SortCriterion;
 
 typedef enum {
@@ -108,7 +109,6 @@ struct NautilusCanvasViewDetails
        gboolean supports_keep_aligned;
 };
 
-
 /* Note that the first item in this list is the default sort,
  * and that the items show up in the menu in the order they
  * appear in this list.
@@ -117,37 +117,37 @@ static const SortCriterion sort_criteria[] = {
        {
                NAUTILUS_FILE_SORT_BY_DISPLAY_NAME,
                "name",
-               "Sort by Name"
+               "name"
        },
        {
                NAUTILUS_FILE_SORT_BY_SIZE,
                "size",
-               "Sort by Size"
+               "size"
        },
        {
                NAUTILUS_FILE_SORT_BY_TYPE,
                "type",
-               "Sort by Type"
+               "type"
        },
        {
                NAUTILUS_FILE_SORT_BY_MTIME,
                "modification date",
-               "Sort by Modification Date"
+               "modification-date"
        },
        {
                NAUTILUS_FILE_SORT_BY_ATIME,
                "access date",
-               "Sort by Access Date"
+               "access-date"
        },
        {
                NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
                "trashed",
-               NAUTILUS_ACTION_SORT_TRASH_TIME
+               "trash-time"
        },
        {
                NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE,
                NULL,
-               NAUTILUS_ACTION_SORT_SEARCH_RELEVANCE,
+               "search-relevance",
        }
 };
 
@@ -161,16 +161,16 @@ static void                 nautilus_canvas_view_update_click_mode            (N
 static gboolean             nautilus_canvas_view_supports_scaling            (NautilusCanvasView           
*canvas_view);
 static void                 nautilus_canvas_view_reveal_selection       (NautilusView               *view);
 static const SortCriterion *get_sort_criterion_by_sort_type           (NautilusFileSortType  sort_type);
-static void                 set_sort_criterion_by_sort_type           (NautilusCanvasView           
*canvas_view,
-                                                                      NautilusFileSortType  sort_type);
 static gboolean             set_sort_reversed                         (NautilusCanvasView     *canvas_view,
                                                                       gboolean              new_value,
                                                                       gboolean              set_metadata);
 static void                 switch_to_manual_layout                   (NautilusCanvasView     *view);
-static void                 update_layout_menus                       (NautilusCanvasView     *view);
 static NautilusFileSortType get_default_sort_order                    (NautilusFile         *file,
                                                                       gboolean             *reversed);
 static void                 nautilus_canvas_view_clear                  (NautilusView         *view);
+static void                action_keep_aligned                         (GSimpleAction *action,
+                                                                        GVariant      *state,
+                                                                        gpointer       user_data);
 
 G_DEFINE_TYPE (NautilusCanvasView, nautilus_canvas_view, NAUTILUS_TYPE_VIEW);
 
@@ -293,9 +293,6 @@ real_set_sort_criterion (NautilusCanvasView *canvas_view,
                                                    file,
                                                    sort->metadata_text);
        }
-
-       /* Update the layout menus to match the new sort setting. */
-       update_layout_menus (canvas_view);
 }
 
 static void
@@ -347,25 +344,6 @@ nautilus_canvas_view_using_auto_layout (NautilusCanvasView *canvas_view)
 }
 
 static void
-action_sort_radio_callback (GtkAction *action,
-                           GtkRadioAction *current,
-                           NautilusCanvasView *view)
-{
-       NautilusFileSortType sort_type;
-       
-       sort_type = gtk_radio_action_get_current_value (current);
-       
-       /* Note that id might be a toggle item.
-        * Ignore non-sort ids so that they don't cause sorting.
-        */
-       if (sort_type == NAUTILUS_FILE_SORT_NONE) {
-               switch_to_manual_layout (view);
-       } else {
-               set_sort_criterion_by_sort_type (view, sort_type);
-       }
-}
-
-static void
 list_covers (NautilusCanvasIconData *data, gpointer callback_data)
 {
        GSList **file_list;
@@ -496,68 +474,6 @@ nautilus_canvas_view_supports_keep_aligned (NautilusCanvasView *view)
        return view->details->supports_keep_aligned;
 }
 
-static void
-update_layout_menus (NautilusCanvasView *view)
-{
-       gboolean is_auto_layout;
-       GtkAction *action;
-       const char *action_name;
-       NautilusFile *file;
-
-       if (view->details->canvas_action_group == NULL) {
-               return;
-       }
-
-       is_auto_layout = nautilus_canvas_view_using_auto_layout (view);
-       file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (view));
-
-       if (nautilus_canvas_view_supports_auto_layout (view)) {
-               /* Mark sort criterion. */
-               action_name = is_auto_layout ? view->details->sort->action : NAUTILUS_ACTION_MANUAL_LAYOUT;
-               action = gtk_action_group_get_action (view->details->canvas_action_group,
-                                                     action_name);
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
-               action = gtk_action_group_get_action (view->details->canvas_action_group,
-                                                     NAUTILUS_ACTION_REVERSED_ORDER);
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-                                             view->details->sort_reversed);
-               gtk_action_set_sensitive (action, is_auto_layout);
-
-               action = gtk_action_group_get_action (view->details->canvas_action_group,
-                                                     NAUTILUS_ACTION_SORT_TRASH_TIME);
-
-               if (file != NULL && nautilus_file_is_in_trash (file)) {
-                       gtk_action_set_visible (action, TRUE);
-               } else {
-                       gtk_action_set_visible (action, FALSE);
-               }
-
-               action = gtk_action_group_get_action (view->details->canvas_action_group,
-                                                     NAUTILUS_ACTION_SORT_SEARCH_RELEVANCE);
-
-               if (file != NULL && nautilus_file_is_in_search (file)) {
-                       gtk_action_set_visible (action, TRUE);
-               } else {
-                       gtk_action_set_visible (action, FALSE);
-               }
-       }
-
-       action = gtk_action_group_get_action (view->details->canvas_action_group,
-                                             NAUTILUS_ACTION_MANUAL_LAYOUT);
-       gtk_action_set_visible (action,
-                               nautilus_canvas_view_supports_manual_layout (view));
-
-       action = gtk_action_group_get_action (view->details->canvas_action_group,
-                                             NAUTILUS_ACTION_KEEP_ALIGNED);
-       gtk_action_set_visible (action,
-                               nautilus_canvas_view_supports_keep_aligned (view));
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-                                     nautilus_canvas_container_is_keep_aligned (get_canvas_container 
(view)));
-       gtk_action_set_sensitive (action, !is_auto_layout);
-}
-
-
 static char *
 nautilus_canvas_view_get_directory_sort_by (NautilusCanvasView *canvas_view,
                                          NautilusFile *file)
@@ -738,9 +654,6 @@ set_sort_reversed (NautilusCanvasView *canvas_view,
                /* Store the new sort setting. */
                nautilus_canvas_view_set_directory_sort_reversed (canvas_view, 
nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)), new_value);
        }
-       
-       /* Update the layout menus to match the new sort-order setting. */
-       update_layout_menus (canvas_view);
 
        return TRUE;
 }
@@ -760,6 +673,19 @@ get_sort_criterion_by_metadata_text (const char *metadata_text)
 }
 
 static const SortCriterion *
+get_sort_criterion_by_action_target_name (const char *action_target_name)
+{
+       guint i;
+       /* Figure out what the new sort setting should be. */
+       for (i = 0; i < G_N_ELEMENTS (sort_criteria); i++) {
+               if (g_strcmp0 (sort_criteria[i].action_target_name, action_target_name) == 0) {
+                       return &sort_criteria[i];
+               }
+       }
+       return NULL;
+}
+
+static const SortCriterion *
 get_sort_criterion_by_sort_type (NautilusFileSortType sort_type)
 {
        guint i;
@@ -832,8 +758,10 @@ nautilus_canvas_view_begin_loading (NautilusView *view)
                (get_canvas_container (canvas_view), 
                 nautilus_canvas_view_get_directory_auto_layout (canvas_view, file));
 
-       /* e.g. keep aligned may have changed */
-       update_layout_menus (canvas_view);
+       /* We could changed to the trash directory or to searching, and then we
+        * need to update the menus */
+       nautilus_view_update_right_click_menus(view);
+       nautilus_view_update_toolbar_menus(view);
 }
 
 static void
@@ -902,10 +830,6 @@ nautilus_canvas_view_set_zoom_level (NautilusCanvasView *view,
        nautilus_canvas_container_set_zoom_level (canvas_container, new_level);
 
        g_signal_emit_by_name (view, "zoom-level-changed");
-       
-       if (nautilus_view_get_active (NAUTILUS_VIEW (view))) {
-               nautilus_view_update_menus (NAUTILUS_VIEW (view));
-       }
 }
 
 static void
@@ -933,6 +857,8 @@ nautilus_canvas_view_zoom_to_level (NautilusView *view,
 
        canvas_view = NAUTILUS_CANVAS_VIEW (view);
        nautilus_canvas_view_set_zoom_level (canvas_view, zoom_level, FALSE);
+
+       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->zoom_to_level (view, zoom_level);
 }
 
 static void
@@ -988,62 +914,72 @@ nautilus_canvas_view_get_selection (NautilusView *view)
 }
 
 static void
-set_sort_criterion_by_sort_type (NautilusCanvasView *canvas_view,
-                                NautilusFileSortType  sort_type)
+action_reversed_order (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
-       const SortCriterion *sort;
+       gboolean reversed_order;
 
-       g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
+       g_assert (NAUTILUS_IS_CANVAS_VIEW (user_data));
 
-       sort = get_sort_criterion_by_sort_type (sort_type);
-       g_return_if_fail (sort != NULL);
-       
-       if (sort == canvas_view->details->sort
-           && nautilus_canvas_view_using_auto_layout (canvas_view)) {
-               return;
+       reversed_order = g_variant_get_boolean (state);
+       if (set_sort_reversed (user_data, reversed_order, TRUE)) {
+               nautilus_canvas_container_sort (get_canvas_container (user_data));
+               nautilus_canvas_view_reveal_selection (NAUTILUS_VIEW (user_data));
        }
 
-       set_sort_criterion (canvas_view, sort, TRUE);
-       nautilus_canvas_container_sort (get_canvas_container (canvas_view));
-       nautilus_canvas_view_reveal_selection (NAUTILUS_VIEW (canvas_view));
+       g_simple_action_set_state (action, state);
 }
 
-
 static void
-action_reversed_order_callback (GtkAction *action,
-                               gpointer user_data)
+action_keep_aligned (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
 {
+       NautilusFile *file;
        NautilusCanvasView *canvas_view;
+       gboolean keep_aligned;
 
        canvas_view = NAUTILUS_CANVAS_VIEW (user_data);
+       file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view));
+       keep_aligned = g_variant_get_boolean (state);
 
-       if (set_sort_reversed (canvas_view,
-                              gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
-                              TRUE)) {
-               nautilus_canvas_container_sort (get_canvas_container (canvas_view));
-               nautilus_canvas_view_reveal_selection (NAUTILUS_VIEW (canvas_view));
-       }
+       nautilus_canvas_view_set_directory_keep_aligned (canvas_view,
+                                                        file,
+                                                        keep_aligned);                       
+       nautilus_canvas_container_set_keep_aligned (get_canvas_container (canvas_view),
+                                                   keep_aligned);
+
+       g_simple_action_set_state (action, state);
 }
 
 static void
-action_keep_aligned_callback (GtkAction *action,
-                             gpointer user_data)
+action_sort_order_changed (GSimpleAction *action,
+                       GVariant      *value,
+                       gpointer       user_data)
 {
-       NautilusCanvasView *canvas_view;
-       NautilusFile *file;
-       gboolean keep_aligned;
+       const gchar *target_name;
+       const SortCriterion *sort_criterion;
 
-       canvas_view = NAUTILUS_CANVAS_VIEW (user_data);
+       g_assert (NAUTILUS_IS_CANVAS_VIEW (user_data));
 
-       keep_aligned = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+       target_name = g_variant_get_string (value, NULL);
+       sort_criterion = get_sort_criterion_by_action_target_name (target_name);
 
-       file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view));
-       nautilus_canvas_view_set_directory_keep_aligned (canvas_view,
-                                                file,
-                                                keep_aligned);
-                                                     
-       nautilus_canvas_container_set_keep_aligned (get_canvas_container (canvas_view),
-                                                 keep_aligned);
+       g_assert (sort_criterion != NULL);
+       /* Note that id might be a toggle item.
+        * Ignore non-sort ids so that they don't cause sorting.
+        */
+       if (sort_criterion->sort_type == NAUTILUS_FILE_SORT_NONE) {
+               switch_to_manual_layout (user_data);
+       } else {
+               set_sort_criterion (user_data, sort_criterion, TRUE);
+
+               nautilus_canvas_container_sort (get_canvas_container (user_data));
+               nautilus_canvas_view_reveal_selection (NAUTILUS_VIEW (user_data));
+       }
+
+       g_simple_action_set_state (action, value);
 }
 
 static void
@@ -1076,8 +1012,6 @@ layout_changed_callback (NautilusCanvasContainer *container,
                         file,
                         nautilus_canvas_view_using_auto_layout (canvas_view));
        }
-
-       update_layout_menus (canvas_view);
 }
 
 static gboolean
@@ -1103,124 +1037,78 @@ nautilus_canvas_view_start_renaming_file (NautilusView *view,
                (get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), select_all);
 }
 
-static const GtkToggleActionEntry canvas_view_toggle_entries[] = {
-  /* name, stock id */      { "Reversed Order", NULL,
-  /* label, accelerator */    N_("Re_versed Order"), NULL,
-  /* tooltip */               N_("Display icons in the opposite order"),
-                              G_CALLBACK (action_reversed_order_callback),
-                              0 },
-  /* name, stock id */      { "Keep Aligned", NULL,
-  /* label, accelerator */    N_("_Keep Aligned"), NULL,
-  /* tooltip */               N_("Keep icons lined up on a grid"),
-                              G_CALLBACK (action_keep_aligned_callback),
-                              0 },
-};
-
-static const GtkRadioActionEntry arrange_radio_entries[] = {
-  { NAUTILUS_ACTION_MANUAL_LAYOUT, NULL,
-    N_("_Manually"), NULL,
-    N_("Leave icons wherever they are dropped"),
-    NAUTILUS_FILE_SORT_NONE },
-  { "Sort by Name", NULL,
-    N_("By _Name"), NULL,
-    N_("Keep icons sorted by name in rows"),
-    NAUTILUS_FILE_SORT_BY_DISPLAY_NAME },
-  { "Sort by Size", NULL,
-    N_("By _Size"), NULL,
-    N_("Keep icons sorted by size in rows"),
-    NAUTILUS_FILE_SORT_BY_SIZE },
-  { "Sort by Type", NULL,
-    N_("By _Type"), NULL,
-    N_("Keep icons sorted by type in rows"),
-    NAUTILUS_FILE_SORT_BY_TYPE },
-  { "Sort by Modification Date", NULL,
-    N_("By Modification _Date"), NULL,
-    N_("Keep icons sorted by modification date in rows"),
-    NAUTILUS_FILE_SORT_BY_MTIME },
-  { "Sort by Access Date", NULL,
-    N_("By _Access Date"), NULL,
-    N_("Keep icons sorted by access date in rows"),
-    NAUTILUS_FILE_SORT_BY_ATIME },
-  { NAUTILUS_ACTION_SORT_TRASH_TIME, NULL,
-    N_("By T_rash Time"), NULL,
-    N_("Keep icons sorted by trash time in rows"),
-    NAUTILUS_FILE_SORT_BY_TRASHED_TIME },
-  { NAUTILUS_ACTION_SORT_SEARCH_RELEVANCE, NULL,
-    N_("By Search Relevance"), NULL,
-    N_("Keep icons sorted by search relevance in rows"),
-    NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE },
+const GActionEntry canvas_view_entries[] = {
+       { "keep-aligned", NULL, NULL, "true", action_keep_aligned },
+       { "reversed-order", NULL, NULL, "false", action_reversed_order },
+       { "sort", NULL, "s", "'name'", action_sort_order_changed },
 };
 
 static void
-nautilus_canvas_view_merge_menus (NautilusView *view)
+nautilus_canvas_view_update_actions_state (NautilusView *view)
 {
+       GActionGroup *view_action_group;
+       NautilusWindow *window;
+       GAction *action;
+       gboolean keep_aligned;  
        NautilusCanvasView *canvas_view;
-       GtkUIManager *ui_manager;
-       GtkActionGroup *action_group;
-       
-        g_assert (NAUTILUS_IS_CANVAS_VIEW (view));
-
-       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->merge_menus (view);
 
        canvas_view = NAUTILUS_CANVAS_VIEW (view);
+       window = nautilus_view_get_window (view);
 
-       ui_manager = nautilus_view_get_ui_manager (NAUTILUS_VIEW (canvas_view));
+       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->update_actions_state (view);
 
-       action_group = gtk_action_group_new ("CanvasViewActions");
-       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-       canvas_view->details->canvas_action_group = action_group;
-       gtk_action_group_add_toggle_actions (action_group, 
-                                            canvas_view_toggle_entries, G_N_ELEMENTS 
(canvas_view_toggle_entries),
-                                            canvas_view);
-       gtk_action_group_add_radio_actions (action_group,
-                                           arrange_radio_entries,
-                                           G_N_ELEMENTS (arrange_radio_entries),
-                                           -1,
-                                           G_CALLBACK (action_sort_radio_callback),
-                                           canvas_view);
- 
-       gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-       g_object_unref (action_group); /* owned by ui manager */
+       view_action_group = NAUTILUS_VIEW_CLASS(nautilus_canvas_view_parent_class)->get_action_group (view);
+       if (nautilus_canvas_view_supports_auto_layout (canvas_view)) {
+               action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "reversed-order");
+               g_action_change_state (action,
+                                       g_variant_new_boolean (NAUTILUS_CANVAS_VIEW 
(view)->details->sort_reversed));
 
-       canvas_view->details->canvas_merge_id =
-               gtk_ui_manager_add_ui_from_resource (ui_manager, 
"/org/gnome/nautilus/nautilus-canvas-view-ui.xml", NULL);
+               action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "sort");
+               g_action_change_state (action,
+                                       g_variant_new_string (NAUTILUS_CANVAS_VIEW 
(view)->details->sort->action_target_name));
+       }
 
-       update_layout_menus (canvas_view);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "keep-aligned");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    canvas_view->details->supports_keep_aligned);
+       if (canvas_view->details->supports_keep_aligned)
+       {
+               keep_aligned = nautilus_canvas_container_is_keep_aligned (get_canvas_container (canvas_view));
+               g_action_change_state (action, g_variant_new_boolean (keep_aligned));
+       }
+
+       /* Make sure the button is checked on the correct view mode, since this function
+        * could be called for a change in the active slot i.e. when changing the tab */
+       action = g_action_map_lookup_action (G_ACTION_MAP (window), "view-mode");
+       g_action_change_state (G_SIMPLE_ACTION (action), g_variant_new_string ("grid"));
 }
 
 static void
-nautilus_canvas_view_unmerge_menus (NautilusView *view)
+nautilus_canvas_view_update_toolbar_menus (NautilusView *view)
 {
-       NautilusCanvasView *canvas_view;
-       GtkUIManager *ui_manager;
+       NautilusFile *file;
+       NautilusToolbar *toolbar;
+       NautilusCanvasContainer *canvas_container;
+       NautilusZoomLevel zoom_level;
 
-       canvas_view = NAUTILUS_CANVAS_VIEW (view);
+       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->update_toolbar_menus (view);
 
-       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->unmerge_menus (view);
+       toolbar = NAUTILUS_TOOLBAR (nautilus_window_get_toolbar (nautilus_view_get_window (view)));
 
-       ui_manager = nautilus_view_get_ui_manager (view);
-       if (ui_manager != NULL) {
-               nautilus_ui_unmerge_ui (ui_manager,
-                                       &canvas_view->details->canvas_merge_id,
-                                       &canvas_view->details->canvas_action_group);
-       }
-}
-
-static void
-nautilus_canvas_view_update_menus (NautilusView *view)
-{
-       NautilusCanvasView *canvas_view;
-       GtkAction *action;
-       gboolean editable;
+       nautilus_toolbar_view_menu_widget_show_element (toolbar, "sort_menu");
+       
+       file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (view));
+       if (file != NULL && nautilus_file_is_in_trash (file))
+               nautilus_toolbar_view_menu_widget_show_element (toolbar, "sort_trash_time");
 
-        canvas_view = NAUTILUS_CANVAS_VIEW (view);
+       if (file != NULL && nautilus_file_is_in_search (file))
+               nautilus_toolbar_view_menu_widget_show_element (toolbar, "sort_search_relevance");
 
-       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->update_menus(view);
+       canvas_container = get_canvas_container (NAUTILUS_CANVAS_VIEW (view));
+       zoom_level = nautilus_canvas_container_get_zoom_level (canvas_container);
 
-       editable = nautilus_view_is_editable (view);
-       action = gtk_action_group_get_action (canvas_view->details->canvas_action_group,
-                                             NAUTILUS_ACTION_MANUAL_LAYOUT);
-       gtk_action_set_sensitive (action, editable);
+       nautilus_toolbar_view_menu_widget_set_zoom_level (toolbar,
+                                                         (gdouble) (zoom_level));
 }
 
 static void
@@ -1238,8 +1126,6 @@ nautilus_canvas_view_reset_to_defaults (NautilusView *view)
 
        nautilus_canvas_container_sort (canvas_container);
 
-       update_layout_menus (canvas_view);
-
        nautilus_canvas_view_restore_default_zoom_level (view);
 }
 
@@ -1481,8 +1367,7 @@ canvas_container_context_click_selection_callback (NautilusCanvasContainer *cont
        g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container));
        g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
 
-       nautilus_view_pop_up_selection_context_menu 
-               (NAUTILUS_VIEW (canvas_view), event);
+       nautilus_view_pop_up_selection_right_click_menu (NAUTILUS_VIEW (canvas_view), event);
 }
 
 static void
@@ -1493,27 +1378,7 @@ canvas_container_context_click_background_callback (NautilusCanvasContainer *con
        g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container));
        g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
 
-       nautilus_view_pop_up_background_context_menu 
-               (NAUTILUS_VIEW (canvas_view), event);
-}
-
-static gboolean
-nautilus_canvas_view_react_to_canvas_change_idle_callback (gpointer data) 
-{        
-        NautilusCanvasView *canvas_view;
-        
-        g_assert (NAUTILUS_IS_CANVAS_VIEW (data));
-        
-        canvas_view = NAUTILUS_CANVAS_VIEW (data);
-        canvas_view->details->react_to_canvas_change_idle_id = 0;
-        
-       /* Rebuild the menus since some of them (e.g. Restore Stretched Icons)
-        * may be different now.
-        */
-       nautilus_view_update_menus (NAUTILUS_VIEW (canvas_view));
-
-        /* Don't call this again (unless rescheduled) */
-        return FALSE;
+       nautilus_view_pop_up_background_right_click_menu (NAUTILUS_VIEW (canvas_view), event);
 }
 
 static void
@@ -1529,20 +1394,6 @@ icon_position_changed_callback (NautilusCanvasContainer *container,
        g_assert (container == get_canvas_container (canvas_view));
        g_assert (NAUTILUS_IS_FILE (file));
 
-       /* Schedule updating menus for the next idle. Doing it directly here
-        * noticeably slows down canvas stretching.  The other work here to
-        * store the canvas position and scale does not seem to noticeably
-        * slow down canvas stretching. It would be trickier to move to an
-        * idle call, because we'd have to keep track of potentially multiple
-        * sets of file/geometry info.
-        */
-       if (nautilus_view_get_active (NAUTILUS_VIEW (canvas_view)) &&
-           canvas_view->details->react_to_canvas_change_idle_id == 0) {
-                canvas_view->details->react_to_canvas_change_idle_id
-                        = g_idle_add (nautilus_canvas_view_react_to_canvas_change_idle_callback,
-                                     canvas_view);
-       }
-
        /* Store the new position of the canvas in the metadata. */
        if (!nautilus_canvas_view_using_auto_layout (canvas_view)) {
                position_string = g_strdup_printf
@@ -1589,10 +1440,11 @@ icon_rename_started_cb (NautilusCanvasContainer *container,
        NautilusView *directory_view;
 
        directory_view = NAUTILUS_VIEW (callback_data);
-       nautilus_clipboard_set_up_editable
+       //FIXME
+       /*nautilus_clipboard_set_up_editable
                (GTK_EDITABLE (widget),
                 nautilus_view_get_ui_manager (directory_view),
-                FALSE);
+                FALSE);*/
 }
 
 static char *
@@ -1869,13 +1721,6 @@ create_canvas_container (NautilusCanvasView *canvas_view)
                                 G_CALLBACK (icon_rename_started_cb), canvas_view, 0);
        g_signal_connect_object (canvas_container, "icon-rename-ended",
                                 G_CALLBACK (icon_rename_ended_cb), canvas_view, 0);
-       g_signal_connect_object (canvas_container, "icon-stretch-started",
-                                G_CALLBACK (nautilus_view_update_menus), canvas_view,
-                                G_CONNECT_SWAPPED);
-       g_signal_connect_object (canvas_container, "icon-stretch-ended",
-                                G_CALLBACK (nautilus_view_update_menus), canvas_view,
-                                G_CONNECT_SWAPPED);
-
        g_signal_connect_object (canvas_container, "get-stored-layout-timestamp",
                                 G_CALLBACK (get_stored_layout_timestamp), canvas_view, 0);
        g_signal_connect_object (canvas_container, "store-layout-timestamp",
@@ -2076,11 +1921,10 @@ nautilus_canvas_view_class_init (NautilusCanvasViewClass *klass)
        nautilus_view_class->zoom_to_level = nautilus_canvas_view_zoom_to_level;
        nautilus_view_class->get_zoom_level = nautilus_canvas_view_get_zoom_level;
         nautilus_view_class->click_policy_changed = nautilus_canvas_view_click_policy_changed;
-        nautilus_view_class->merge_menus = nautilus_canvas_view_merge_menus;
-        nautilus_view_class->unmerge_menus = nautilus_canvas_view_unmerge_menus;
+       nautilus_view_class->update_toolbar_menus = nautilus_canvas_view_update_toolbar_menus;
+       nautilus_view_class->update_actions_state = nautilus_canvas_view_update_actions_state;
         nautilus_view_class->sort_directories_first_changed = 
nautilus_canvas_view_sort_directories_first_changed;
         nautilus_view_class->start_renaming_file = nautilus_canvas_view_start_renaming_file;
-        nautilus_view_class->update_menus = nautilus_canvas_view_update_menus;
        nautilus_view_class->using_manual_layout = nautilus_canvas_view_using_manual_layout;
        nautilus_view_class->widget_to_file_operation_position = 
nautilus_canvas_view_widget_to_file_operation_position;
        nautilus_view_class->get_view_id = nautilus_canvas_view_get_id;
@@ -2123,6 +1967,7 @@ static void
 nautilus_canvas_view_init (NautilusCanvasView *canvas_view)
 {
        NautilusCanvasContainer *canvas_container;
+       GActionGroup *view_action_group;
 
         g_return_if_fail (gtk_bin_get_child (GTK_BIN (canvas_view)) == NULL);
 
@@ -2164,6 +2009,12 @@ nautilus_canvas_view_init (NautilusCanvasView *canvas_view)
                g_signal_connect (nautilus_clipboard_monitor_get (),
                                  "clipboard-info",
                                  G_CALLBACK (canvas_view_notify_clipboard_info), canvas_view);
+
+       view_action_group = NAUTILUS_VIEW_CLASS(nautilus_canvas_view_parent_class)->get_action_group 
(NAUTILUS_VIEW (canvas_view));
+       g_action_map_add_action_entries (G_ACTION_MAP (view_action_group),
+                                       canvas_view_entries,
+                                       G_N_ELEMENTS (canvas_view_entries),
+                                       canvas_view);
 }
 
 NautilusView *
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index c6971f5..0d62ad0 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -76,8 +76,7 @@ struct NautilusDesktopCanvasViewDetails
 };
 
 static void     default_zoom_level_changed                        (gpointer                user_data);
-static void     real_merge_menus                                  (NautilusView        *view);
-static void     real_update_menus                                 (NautilusView        *view);
+static void     real_update_right_click_menus                                 (NautilusView        *view);
 static void     nautilus_desktop_canvas_view_update_canvas_container_fonts  (NautilusDesktopCanvasView      
*view);
 static void     font_changed_callback                             (gpointer                callback_data);
 
@@ -239,7 +238,6 @@ static void
 nautilus_desktop_canvas_view_dispose (GObject *object)
 {
        NautilusDesktopCanvasView *canvas_view;
-       GtkUIManager *ui_manager;
 
        canvas_view = NAUTILUS_DESKTOP_CANVAS_VIEW (object);
 
@@ -249,13 +247,6 @@ nautilus_desktop_canvas_view_dispose (GObject *object)
                canvas_view->details->reload_desktop_timeout = 0;
        }
 
-       ui_manager = nautilus_view_get_ui_manager (NAUTILUS_VIEW (canvas_view));
-       if (ui_manager != NULL) {
-               nautilus_ui_unmerge_ui (ui_manager,
-                                       &canvas_view->details->desktop_merge_id,
-                                       &canvas_view->details->desktop_action_group);
-       }
-
        g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
                                              default_zoom_level_changed,
                                              canvas_view);
@@ -263,7 +254,7 @@ nautilus_desktop_canvas_view_dispose (GObject *object)
                                              font_changed_callback,
                                              canvas_view);
        g_signal_handlers_disconnect_by_func (gnome_lockdown_preferences,
-                                             nautilus_view_update_menus,
+                                             nautilus_view_update_right_click_menus,
                                              canvas_view);
 
        G_OBJECT_CLASS (nautilus_desktop_canvas_view_parent_class)->dispose (object);
@@ -278,8 +269,7 @@ nautilus_desktop_canvas_view_class_init (NautilusDesktopCanvasViewClass *class)
 
        G_OBJECT_CLASS (class)->dispose = nautilus_desktop_canvas_view_dispose;
 
-       vclass->merge_menus = real_merge_menus;
-       vclass->update_menus = real_update_menus;
+       vclass->update_right_click_menus = real_update_right_click_menus;
        vclass->get_view_id = real_get_id;
 
        g_type_class_add_private (class, sizeof (NautilusDesktopCanvasViewDetails));
@@ -517,7 +507,7 @@ nautilus_desktop_canvas_view_init (NautilusDesktopCanvasView *desktop_canvas_vie
 
        g_signal_connect_swapped (gnome_lockdown_preferences,
                                  "changed::" NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
-                                 G_CALLBACK (nautilus_view_update_menus),
+                                 G_CALLBACK (nautilus_view_update_right_click_menus),
                                  desktop_canvas_view);
 }
 
@@ -559,54 +549,43 @@ get_control_center_command (const gchar ** params_out)
 }
 
 static void
-action_change_background_callback (GtkAction *action, 
-                                  gpointer data)
+action_organize_desktop_by_name (GSimpleAction *action,
+                                GVariant       *state,
+                                gpointer       user_data)
+{
+       nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (user_data));
+}
+
+static void
+action_change_background (GSimpleAction *action,
+                         GVariant      *state,
+                         gpointer       user_data)
 {
        const gchar *control_center_cmd, *params;
 
-        g_assert (NAUTILUS_VIEW (data));
+        g_assert (NAUTILUS_VIEW (user_data));
 
        control_center_cmd = get_control_center_command (&params);
        if (control_center_cmd == NULL) {
                return;
        }
 
-       nautilus_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)),
+       nautilus_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (user_data)),
                                                  control_center_cmd,
                                                  FALSE,
                                                  params, NULL);
 }
 
 static void
-action_empty_trash_conditional_callback (GtkAction *action,
-                                        gpointer data)
+action_empty_trash (GSimpleAction *action,
+                   GVariant      *state,
+                   gpointer       user_data)
 {
-        g_assert (NAUTILUS_IS_VIEW (data));
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-       nautilus_file_operations_empty_trash (GTK_WIDGET (data));
+       nautilus_file_operations_empty_trash (GTK_WIDGET (user_data));
 }
 
-static void
-action_stretch_callback (GtkAction *action,
-                        gpointer callback_data)
-{
-       nautilus_canvas_container_show_stretch_handles
-               (get_canvas_container (callback_data));
-}
-
-static void
-action_unstretch_callback (GtkAction *action,
-                          gpointer callback_data)
-{
-       nautilus_canvas_container_unstretch (get_canvas_container (callback_data));
-}
-
-static void
-action_clean_up_callback (GtkAction *action,
-                         gpointer callback_data)
-{
-       nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (callback_data));
-}
 
 static gboolean
 trash_link_is_selection (NautilusView *view)
@@ -616,7 +595,7 @@ trash_link_is_selection (NautilusView *view)
        gboolean result;
 
        result = FALSE;
-       
+
        selection = nautilus_view_get_selection (view);
 
        if ((g_list_length (selection) == 1) &&
@@ -631,152 +610,46 @@ trash_link_is_selection (NautilusView *view)
                        g_object_unref (link);
                }
        }
-       
+
        nautilus_file_list_free (selection);
 
        return result;
 }
 
+const GActionEntry desktop_view_entries[] = {
+       { "change-background", action_change_background },
+       { "organize-desktop-by-name", action_organize_desktop_by_name },
+       { "empty-trash", action_empty_trash },
+};
+
 static void
-real_update_menus (NautilusView *view)
+real_update_right_click_menus (NautilusView *view)
 {
-       NautilusDesktopCanvasView *desktop_view;
-        NautilusCanvasContainer *canvas_container;
-       gboolean include_empty_trash;
-       char *label;
-       GtkAction *action;
-        int selection_count;
+       GAction *action;
+        GActionGroup *view_action_group;
 
        g_assert (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view));
 
-       NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->update_menus (view);
-
-       desktop_view = NAUTILUS_DESKTOP_CANVAS_VIEW (view);
-
-       /* Empty Trash */
-       include_empty_trash = trash_link_is_selection (view);
-       action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
-                                             NAUTILUS_ACTION_EMPTY_TRASH_CONDITIONAL);
-       gtk_action_set_visible (action,
-                               include_empty_trash);
-       if (include_empty_trash) {
-               label = g_strdup (_("E_mpty Trash"));
-               g_object_set (action , "label", label, NULL);
-               gtk_action_set_sensitive (action,
-                                         !nautilus_trash_monitor_is_empty ());
-               g_free (label);
-       }
+       NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->update_right_click_menus (view);
 
-       /* Stretch */
-        selection_count = nautilus_view_get_selection_count (view);
-        canvas_container = get_canvas_container (desktop_view);
-
-       action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
-                                             NAUTILUS_ACTION_STRETCH);
-       gtk_action_set_sensitive (action,
-                                 selection_count == 1
-                                 && canvas_container != NULL
-                                 && !nautilus_canvas_container_has_stretch_handles (canvas_container));
-       gtk_action_set_visible (action, TRUE);
-
-       /* Unstretch */
-       action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
-                                             NAUTILUS_ACTION_UNSTRETCH);
-       g_object_set (action, "label",
-                     (selection_count > 1)
-                     ? _("Restore Icons' Original Si_zes")
-                     : _("Restore Icon's Original Si_ze"),
-                     NULL);
-       gtk_action_set_sensitive (action,
-                                 canvas_container != NULL
-                                 && nautilus_canvas_container_is_stretched (canvas_container));
-       gtk_action_set_visible (action, TRUE);
-}
+       view_action_group = NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->get_action_group 
(view);
 
-static const GtkActionEntry desktop_view_entries[] = {
-       /* name, stock id */
-       { NAUTILUS_ACTION_CHANGE_BACKGROUND, NULL,
-         /* label, accelerator */
-         N_("Change Desktop _Background"), NULL,
-         /* tooltip */
-         N_("Show a window that lets you set your desktop background's pattern or color"),
-         G_CALLBACK (action_change_background_callback) },
-       /* name, stock id */
-       { "Empty Trash Conditional", NULL,
-         /* label, accelerator */
-         N_("Empty Trash"), NULL,
-         /* tooltip */
-         N_("Delete all items in the Trash"),
-         G_CALLBACK (action_empty_trash_conditional_callback) },
-       /* name, stock id */
-       { NAUTILUS_ACTION_CLEAN_UP, NULL,
-         /* label, accelerator */
-         N_("_Organize Desktop by Name"), NULL,
-         /* tooltip */
-         N_("Reposition icons to better fit in the window and avoid overlapping"),
-         G_CALLBACK (action_clean_up_callback) },
-       /* name, stock id */
-         { "Stretch", NULL,
-          /* label, accelerator */
-          N_("Resize Icon…"), NULL,
-          /* tooltip */
-          N_("Make the selected icons resizable"),
-          G_CALLBACK (action_stretch_callback) },
-       /* name, stock id */
-       { "Unstretch", NULL,
-         /* label, accelerator */
-         N_("Restore Icons' Original Si_zes"), NULL,
-         /* tooltip */
-         N_("Restore each selected icon to its original size"),
-         G_CALLBACK (action_unstretch_callback) },
-};
+       g_action_map_add_action_entries (G_ACTION_MAP (view_action_group),
+                                        desktop_view_entries,
+                                        G_N_ELEMENTS (desktop_view_entries),
+                                        view);
 
-static void
-real_merge_menus (NautilusView *view)
-{
-       NautilusDesktopCanvasView *desktop_view;
-       GtkUIManager *ui_manager;
-       GtkActionGroup *action_group;
-       GtkAction *action;
-
-       NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->merge_menus (view);
-
-       desktop_view = NAUTILUS_DESKTOP_CANVAS_VIEW (view);
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-
-       action_group = gtk_action_group_new ("DesktopViewActions");
-       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-       desktop_view->details->desktop_action_group = action_group;
-       gtk_action_group_add_actions (action_group, 
-                                     desktop_view_entries, G_N_ELEMENTS (desktop_view_entries),
-                                     view);
-
-       gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-       g_object_unref (action_group); /* owned by ui manager */
-
-       desktop_view->details->desktop_merge_id =
-               gtk_ui_manager_add_ui_from_resource (ui_manager, 
"/org/gnome/nautilus/nautilus-desktop-canvas-view-ui.xml", NULL);
-
-       gtk_ui_manager_add_ui (ui_manager,
-                              desktop_view->details->desktop_merge_id,
-                              POPUP_PATH_CANVAS_APPEARANCE,
-                              NAUTILUS_ACTION_STRETCH,
-                              NAUTILUS_ACTION_STRETCH,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
-       gtk_ui_manager_add_ui (ui_manager,
-                              desktop_view->details->desktop_merge_id,
-                              POPUP_PATH_CANVAS_APPEARANCE,
-                              NAUTILUS_ACTION_UNSTRETCH,
-                              NAUTILUS_ACTION_UNSTRETCH,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
-
-       if (get_control_center_command (NULL) == NULL) {
-               action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_CHANGE_BACKGROUND);
-               gtk_action_set_visible (action, FALSE);
-       }
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "empty-trash");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), trash_link_is_selection (view));
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "keep-aligned");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "organize-desktop-by-name");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "change-background");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
 }
 
 NautilusView *
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index b361734..49ebdb4 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -30,6 +30,7 @@
 #include "nautilus-list-model.h"
 #include "nautilus-error-reporting.h"
 #include "nautilus-view-dnd.h"
+#include "nautilus-toolbar.h"
 
 #include <string.h>
 #include <eel/eel-vfs-extensions.h>
@@ -88,7 +89,6 @@ struct NautilusListViewDetails {
        gboolean drag_started;
        gboolean ignore_button_release;
        gboolean row_selected_on_button_down;
-       gboolean menus_ready;
        gboolean active;
        
        GHashTable *columns;
@@ -631,9 +631,9 @@ static void
 do_popup_menu (GtkWidget *widget, NautilusListView *view, GdkEventButton *event)
 {
        if (tree_view_has_selection (GTK_TREE_VIEW (widget))) {
-               nautilus_view_pop_up_selection_context_menu (NAUTILUS_VIEW (view), event);
+               nautilus_view_pop_up_selection_right_click_menu (NAUTILUS_VIEW (view), event);
        } else {
-                nautilus_view_pop_up_background_context_menu (NAUTILUS_VIEW (view), event);
+                nautilus_view_pop_up_background_right_click_menu (NAUTILUS_VIEW (view), event);
        }
 }
 
@@ -1065,7 +1065,7 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
        switch (event->keyval) {
        case GDK_KEY_F10:
                if (event->state & GDK_CONTROL_MASK) {
-                       nautilus_view_pop_up_background_context_menu (view, &button_event);
+                       nautilus_view_pop_up_background_right_click_menu (view, &button_event);
                        handled = TRUE;
                }
                break;
@@ -1286,11 +1286,6 @@ cell_renderer_editing_started_cb (GtkCellRenderer *renderer,
 
        g_signal_connect (entry, "focus-out-event",
                          G_CALLBACK (editable_focus_out_cb), list_view);
-
-       nautilus_clipboard_set_up_editable
-               (GTK_EDITABLE (entry),
-                nautilus_view_get_ui_manager (NAUTILUS_VIEW (list_view)),
-                FALSE);
 }
 
 static void
@@ -2310,7 +2305,7 @@ get_default_zoom_level (void) {
 
        if (default_zoom_level <  NAUTILUS_ZOOM_LEVEL_SMALLEST
            || NAUTILUS_ZOOM_LEVEL_LARGEST < default_zoom_level) {
-               default_zoom_level = NAUTILUS_ZOOM_LEVEL_SMALL;
+               default_zoom_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
        }
 
        return default_zoom_level;
@@ -2995,12 +2990,13 @@ create_column_editor (NautilusListView *view)
 }
 
 static void
-action_visible_columns_callback (GtkAction *action,
-                                gpointer callback_data)
+action_visible_columns (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
        NautilusListView *list_view;
        
-       list_view = NAUTILUS_LIST_VIEW (callback_data);
+       list_view = NAUTILUS_LIST_VIEW (user_data);
 
        if (list_view->details->column_editor) {
                gtk_window_present (GTK_WINDOW (list_view->details->column_editor));
@@ -3013,75 +3009,43 @@ action_visible_columns_callback (GtkAction *action,
        }
 }
 
-static const GtkActionEntry list_view_entries[] = {
-       /* name, stock id */     { "Visible Columns", NULL,
-                                  /* label, accelerator */   N_("Visible _Columns…"), NULL,
-                                  /* tooltip */              N_("Select the columns visible in this folder"),
-                                  G_CALLBACK (action_visible_columns_callback) },
+const GActionEntry list_view_entries[] = {
+       { "visible-columns", action_visible_columns },
 };
 
 static void
-nautilus_list_view_merge_menus (NautilusView *view)
-{
-       NautilusListView *list_view;
-       GtkUIManager *ui_manager;
-       GtkActionGroup *action_group;
-
-       list_view = NAUTILUS_LIST_VIEW (view);
-
-       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->merge_menus (view);
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-
-       action_group = gtk_action_group_new ("ListViewActions");
-       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-       list_view->details->list_action_group = action_group;
-       gtk_action_group_add_actions (action_group, 
-                                     list_view_entries, G_N_ELEMENTS (list_view_entries),
-                                     list_view);
-
-       gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-       g_object_unref (action_group); /* owned by ui manager */
-
-       list_view->details->list_merge_id =
-               gtk_ui_manager_add_ui_from_resource (ui_manager, 
"/org/gnome/nautilus/nautilus-list-view-ui.xml", NULL);
-
-       list_view->details->menus_ready = TRUE;
-}
-
-static void
-nautilus_list_view_unmerge_menus (NautilusView *view)
+nautilus_list_view_update_actions_state (NautilusView *view)
 {
-       NautilusListView *list_view;
-       GtkUIManager *ui_manager;
+       NautilusWindow *window;
+       GSimpleAction *action;
 
-       list_view = NAUTILUS_LIST_VIEW (view);
+       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->update_actions_state (view);
 
-       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->unmerge_menus (view);
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-       if (ui_manager != NULL) {
-               nautilus_ui_unmerge_ui (ui_manager,
-                                       &list_view->details->list_merge_id,
-                                       &list_view->details->list_action_group);
-       }
+       window = nautilus_view_get_window (view);
+       /* Make sure the button is checked on the correct view mode, since this function
+        * could be called for a change in the active slot i.e. when changing the tab */
+       action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window), "view-mode"));
+       g_action_change_state (action, g_variant_new_string ("list"));
 }
 
 static void
-nautilus_list_view_update_menus (NautilusView *view)
+nautilus_list_view_update_toolbar_menus (NautilusView *view)
 {
        NautilusListView *list_view;
+       NautilusToolbar *toolbar;
 
         list_view = NAUTILUS_LIST_VIEW (view);
 
-       /* don't update if the menus aren't ready */
-       if (!list_view->details->menus_ready) {
-               return;
-       }
+       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->update_toolbar_menus (view);
+
+       toolbar = NAUTILUS_TOOLBAR (nautilus_window_get_toolbar (nautilus_view_get_window (view)));
+       nautilus_toolbar_view_menu_widget_set_zoom_level (toolbar,
+                                                         (gdouble) list_view->details->zoom_level);
 
-       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->update_menus (view);
+       nautilus_toolbar_view_menu_widget_show_element (toolbar, "visible_columns");
 }
 
+
 /* Reset sort criteria and zoom level to match defaults */
 static void
 nautilus_list_view_reset_to_defaults (NautilusView *view)
@@ -3145,10 +3109,25 @@ nautilus_list_view_set_zoom_level (NautilusListView *view,
                                             GTK_CELL_RENDERER (view->details->pixbuf_cell),
                                             "surface", column,
                                             NULL);
+       set_up_pixbuf_size (view);
 
-       nautilus_view_update_menus (NAUTILUS_VIEW (view));
+       /* Zoom level changed, notify the toolbar zoom widget about it */
+       //nautilus_view_update_toolbar_menus (NAUTILUS_VIEW (view));
+}
 
-       set_up_pixbuf_size (view);
+static void
+nautilus_list_view_zoom_to_level (NautilusView *view,
+                                 NautilusZoomLevel zoom_level)
+{
+       NautilusListView *list_view;
+
+       g_return_if_fail (NAUTILUS_IS_LIST_VIEW (view));
+
+       list_view = NAUTILUS_LIST_VIEW (view);
+
+       nautilus_list_view_set_zoom_level (list_view, zoom_level, FALSE);
+
+       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->zoom_to_level (view, zoom_level);
 }
 
 static void
@@ -3164,7 +3143,7 @@ nautilus_list_view_bump_zoom_level (NautilusView *view, int zoom_increment)
 
        if (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST &&
            new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST) {
-               nautilus_list_view_set_zoom_level (list_view, new_level, FALSE);
+               nautilus_list_view_zoom_to_level (view, new_level);
        }
 }
 
@@ -3181,19 +3160,6 @@ nautilus_list_view_get_zoom_level (NautilusView *view)
 }
 
 static void
-nautilus_list_view_zoom_to_level (NautilusView *view,
-                                 NautilusZoomLevel zoom_level)
-{
-       NautilusListView *list_view;
-
-       g_return_if_fail (NAUTILUS_IS_LIST_VIEW (view));
-
-       list_view = NAUTILUS_LIST_VIEW (view);
-
-       nautilus_list_view_set_zoom_level (list_view, zoom_level, FALSE);
-}
-
-static void
 nautilus_list_view_restore_default_zoom_level (NautilusView *view)
 {
        NautilusListView *list_view;
@@ -3598,9 +3564,8 @@ nautilus_list_view_class_init (NautilusListViewClass *class)
        nautilus_view_class->get_selection_for_file_transfer = 
nautilus_list_view_get_selection_for_file_transfer;
        nautilus_view_class->is_empty = nautilus_list_view_is_empty;
        nautilus_view_class->remove_file = nautilus_list_view_remove_file;
-       nautilus_view_class->merge_menus = nautilus_list_view_merge_menus;
-       nautilus_view_class->unmerge_menus = nautilus_list_view_unmerge_menus;
-       nautilus_view_class->update_menus = nautilus_list_view_update_menus;
+       nautilus_view_class->update_toolbar_menus = nautilus_list_view_update_toolbar_menus;
+       nautilus_view_class->update_actions_state = nautilus_list_view_update_actions_state;
        nautilus_view_class->reset_to_defaults = nautilus_list_view_reset_to_defaults;
        nautilus_view_class->restore_default_zoom_level = nautilus_list_view_restore_default_zoom_level;
        nautilus_view_class->reveal_selection = nautilus_list_view_reveal_selection;
@@ -3623,6 +3588,7 @@ nautilus_list_view_class_init (NautilusListViewClass *class)
 static void
 nautilus_list_view_init (NautilusListView *list_view)
 {
+       GActionGroup *view_action_group;
        list_view->details = g_new0 (NautilusListViewDetails, 1);
 
        /* ensure that the zoom level is always set before settings up the tree view columns */
@@ -3657,6 +3623,12 @@ nautilus_list_view_init (NautilusListView *list_view)
                g_signal_connect (nautilus_clipboard_monitor_get (),
                                  "clipboard-info",
                                  G_CALLBACK (list_view_notify_clipboard_info), list_view);
+
+       view_action_group = NAUTILUS_VIEW_CLASS(nautilus_list_view_parent_class)->get_action_group 
(NAUTILUS_VIEW (list_view));
+       g_action_map_add_action_entries (G_ACTION_MAP (view_action_group),
+                                       list_view_entries,
+                                       G_N_ELEMENTS (list_view_entries),
+                                       list_view);
 }
 
 NautilusView *
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 642f524..848fb11 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -42,15 +42,33 @@ typedef enum {
        NAUTILUS_NAVIGATION_DIRECTION_FORWARD
 } NautilusNavigationDirection;
 
-struct _NautilusToolbarPriv {
+struct _NautilusToolbarPrivate {
        NautilusWindow *window;
 
+       GtkWidget *path_bar_container;
+       GtkWidget *location_entry_container;
        GtkWidget *path_bar;
        GtkWidget *location_entry;
 
        gboolean show_location_entry;
 
        guint popup_timeout_id;
+
+       gdouble scale_zoom_level;
+
+       GtkWidget *view_button;
+       GtkWidget *action_button;
+
+       GtkWidget *undo_label;
+       GtkWidget *redo_label;
+
+       GtkWidget *view_menu_widget;
+       GtkAdjustment *zoom_adjustment;
+       GtkWidget *zoom_level_scale;
+       GMenu *action_menu;
+
+       GtkWidget *forward_button;
+       GtkWidget *back_button;
 };
 
 enum {
@@ -61,9 +79,32 @@ enum {
 
 static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
 
-G_DEFINE_TYPE (NautilusToolbar, nautilus_toolbar, GTK_TYPE_HEADER_BAR);
+G_DEFINE_TYPE_WITH_PRIVATE(NautilusToolbar, nautilus_toolbar, GTK_TYPE_HEADER_BAR);
 
 static void unschedule_menu_popup_timeout (NautilusToolbar *self);
+static gboolean show_widget_recursive (GtkWidget *widget,
+                                      gchar *id);
+
+static gboolean hide_widget_recursive (GtkWidget *widget,
+                                      gchar *id);
+void
+nautilus_toolbar_update_view_button (NautilusToolbar *self,
+                                    const gchar *view_mode)
+{
+       gchar *name;
+       GtkWidget *image;
+
+       if (g_strcmp0 (view_mode, "list") == 0) {
+               name = "view-list-symbolic";
+       } else if (g_strcmp0 (view_mode, "grid") == 0) {
+               name = "view-grid-symbolic";
+       }
+
+       image = gtk_image_new ();
+       gtk_button_set_image (GTK_BUTTON (self->priv->view_button), image);
+       gtk_image_set_from_icon_name (GTK_IMAGE (image), name,
+                                     GTK_ICON_SIZE_MENU);
+}
 
 static void
 toolbar_update_appearance (NautilusToolbar *self)
@@ -79,45 +120,6 @@ toolbar_update_appearance (NautilusToolbar *self)
                                !show_location_entry);
 }
 
-static GtkWidget *
-toolbar_create_toolbutton (NautilusToolbar *self,
-                          gboolean create_menu,
-                          gboolean create_toggle,
-                          const gchar *name,
-                          const gchar *tooltip)
-{
-       GtkWidget *button, *image;
-       GtkActionGroup *action_group;
-       GtkAction *action;
-
-       action_group = nautilus_window_get_main_action_group (self->priv->window);
-
-       if (create_menu) {
-               button = gtk_menu_button_new ();
-       } else if (create_toggle) {
-               button = gtk_toggle_button_new ();
-       } else {
-               button = gtk_button_new ();
-       }
-
-       image = gtk_image_new ();
-
-       gtk_button_set_image (GTK_BUTTON (button), image);
-
-       if (create_menu) {
-               gtk_image_set_from_icon_name (GTK_IMAGE (image), name,
-                                             GTK_ICON_SIZE_MENU);
-               gtk_widget_set_tooltip_text (button, tooltip);
-       } else {
-               action = gtk_action_group_get_action (action_group, name);
-               gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
-               gtk_button_set_label (GTK_BUTTON (button), NULL);
-               gtk_widget_set_tooltip_text (button, gtk_action_get_tooltip (action));
-       }
-
-       return button;
-}
-
 static void
 activate_back_or_forward_menu_item (GtkMenuItem *menu_item, 
                                    NautilusWindow *window,
@@ -145,6 +147,25 @@ activate_forward_menu_item_callback (GtkMenuItem *menu_item, NautilusWindow *win
        activate_back_or_forward_menu_item (menu_item, window, FALSE);
 }
 
+void
+nautilus_toolbar_sync_navigation_buttons (NautilusToolbar *self)
+{
+       NautilusWindowSlot *active_slot;
+       GAction *action;
+       gboolean enabled;
+
+       /* Check if the back and forward buttons need enabling or disabling. */
+       active_slot = nautilus_window_get_active_slot (self->priv->window);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (self->priv->window), "back");
+       enabled = nautilus_window_slot_get_back_history (active_slot) != NULL;
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (self->priv->window), "forward");
+       enabled = nautilus_window_slot_get_forward_history (active_slot) != NULL;
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
+}
+
 static void
 fill_menu (NautilusWindow *window,
           GtkWidget *menu,
@@ -316,11 +337,10 @@ schedule_menu_popup_timeout (NautilusToolbar *self,
                                    popup_menu_timeout_cb, data,
                                    (GDestroyNotify) schedule_menu_data_free);
 }
-
 static gboolean
-tool_button_press_cb (GtkButton *button,
-                      GdkEventButton *event,
-                      gpointer user_data)
+navigation_button_press_cb (GtkButton *button,
+                           GdkEventButton *event,
+                           gpointer user_data)
 {
         NautilusToolbar *self = user_data;
 
@@ -338,7 +358,7 @@ tool_button_press_cb (GtkButton *button,
 }
 
 static gboolean
-tool_button_release_cb (GtkButton *button,
+navigation_button_release_cb (GtkButton *button,
                         GdkEventButton *event,
                         gpointer user_data)
 {
@@ -350,137 +370,89 @@ tool_button_release_cb (GtkButton *button,
 }
 
 static void
-navigation_button_setup_menu (NautilusToolbar *self,
-                             GtkWidget *button,
-                             NautilusNavigationDirection direction)
+zoom_level_changed (GtkRange *range,
+                   NautilusToolbar *self)
 {
-       g_object_set_data (G_OBJECT (button), "nav-direction", GUINT_TO_POINTER (direction));
+       NautilusWindowSlot *slot;
+       NautilusView *view;
+       gdouble zoom_level;
+       GActionGroup *view_action_group;
+       GAction *action;
 
-       g_signal_connect (button, "button-press-event",
-                         G_CALLBACK (tool_button_press_cb), self);
-       g_signal_connect (button, "button-release-event",
-                         G_CALLBACK (tool_button_release_cb), self);
-}
+       zoom_level = gtk_range_get_value (range);
+       slot = nautilus_window_get_active_slot (self->priv->window);
+       view = nautilus_window_slot_get_current_view (slot);
 
-static gboolean
-gear_menu_key_press (GtkWidget *widget,
-                     GdkEventKey *event,
-                     gpointer user_data)
-{
-        GdkModifierType mask = gtk_accelerator_get_default_mod_mask ();
+       view_action_group = nautilus_view_get_action_group (view);
 
-        if ((event->state & mask) == 0 && (event->keyval == GDK_KEY_F10)) {
-            gtk_menu_shell_deactivate (GTK_MENU_SHELL (widget));
-            return TRUE;
-        }
+       zoom_level = gtk_range_get_value (range);
 
-        return FALSE;
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "zoom-to-level");
+       g_action_change_state (action,
+                              g_variant_new_int32 ((gint) zoom_level));
 }
 
 static void
-nautilus_toolbar_constructed (GObject *obj)
+nautilus_toolbar_init (NautilusToolbar *self)
 {
-       NautilusToolbar *self = NAUTILUS_TOOLBAR (obj);
-       GtkWidget *toolbar;
-       GtkWidget *button;
-       GtkWidget *menu;
-       GtkWidget *box;
-       GtkUIManager *ui_manager;
-
-       G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj);
-
-       toolbar = GTK_WIDGET (obj);
-
-       ui_manager = nautilus_window_get_ui_manager (self->priv->window);
-
-       /* Back and Forward */
-       box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-
-       /* Back */
-       button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_BACK, NULL);
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-       gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)),
-                                 "go-previous-symbolic");
-       navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_BACK);
-       gtk_container_add (GTK_CONTAINER (box), button);
-
-       /* Forward */
-       button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_FORWARD, NULL);
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-       gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)),
-                                 "go-next-symbolic");
-       navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_FORWARD);
-       gtk_container_add (GTK_CONTAINER (box), button);
-
-       gtk_style_context_add_class (gtk_widget_get_style_context (box),
-                                    GTK_STYLE_CLASS_RAISED);
-       gtk_style_context_add_class (gtk_widget_get_style_context (box),
-                                    GTK_STYLE_CLASS_LINKED);
+       GtkBuilder *builder;
+       GMenu *action_menu;
+       gdouble lower, upper;
 
-       gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), box);
+       self->priv = nautilus_toolbar_get_instance_private (self);
+       gtk_widget_init_template (GTK_WIDGET (self));
 
        self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
-       gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), self->priv->path_bar);
+       gtk_container_add (GTK_CONTAINER (self->priv->path_bar_container),
+                                         self->priv->path_bar);
 
-       /* entry-like location bar */
        self->priv->location_entry = nautilus_location_entry_new ();
-       gtk_header_bar_pack_start (GTK_HEADER_BAR (toolbar), self->priv->location_entry);
-
-       /* Action Menu */
-       button = toolbar_create_toolbutton (self, TRUE, FALSE, "open-menu-symbolic", _("Location options"));
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-       menu = gtk_ui_manager_get_widget (ui_manager, "/ActionMenu");
-       gtk_widget_set_halign (menu, GTK_ALIGN_END);
-       gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu);
-       gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.gear-menu");
-        g_signal_connect (menu, "key-press-event", G_CALLBACK (gear_menu_key_press), self);
-
-       gtk_header_bar_pack_end (GTK_HEADER_BAR (toolbar), button);
-
-       /* View buttons */
-       box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-
-       button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_LIST, NULL);
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-       gtk_container_add (GTK_CONTAINER (box), button);
-       button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_GRID, NULL);
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-       gtk_container_add (GTK_CONTAINER (box), button);
-       button = toolbar_create_toolbutton (self, TRUE, FALSE, "go-down-symbolic", _("View options"));
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-       gtk_container_add (GTK_CONTAINER (box), button);
-       menu = gtk_ui_manager_get_widget (ui_manager, "/ViewMenu");
-       gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu);
-
-       gtk_style_context_add_class (gtk_widget_get_style_context (box),
-                                    GTK_STYLE_CLASS_RAISED);
-       gtk_style_context_add_class (gtk_widget_get_style_context (box),
-                                    GTK_STYLE_CLASS_LINKED);
-
-       gtk_header_bar_pack_end (GTK_HEADER_BAR (toolbar), box);
-
-       /* search */
-       button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_SEARCH, NULL);
-       gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-       gtk_widget_set_margin_start (button, 76);
-       gtk_header_bar_pack_end (GTK_HEADER_BAR (toolbar), button);
-
-       g_signal_connect_swapped (nautilus_preferences,
-                                 "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY,
-                                 G_CALLBACK (toolbar_update_appearance), self);
-
-       gtk_widget_show_all (toolbar);
+       gtk_container_add (GTK_CONTAINER (self->priv->location_entry_container),
+                                         self->priv->location_entry);
+
+       builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-toolbar-view-menu.xml");
+       self->priv->view_menu_widget = g_object_ref (GTK_WIDGET (gtk_builder_get_object (builder, 
"view_menu_widget")));
+       self->priv->undo_label = g_object_ref (GTK_WIDGET (gtk_builder_get_object (builder, "undo_label")));
+       self->priv->redo_label = g_object_ref (GTK_WIDGET (gtk_builder_get_object (builder, "redo_label")));
+       self->priv->zoom_level_scale = g_object_ref (GTK_WIDGET (gtk_builder_get_object (builder, 
"zoom_level_scale")));
+       self->priv->zoom_adjustment = g_object_ref (GTK_ADJUSTMENT (gtk_builder_get_object (builder, 
"zoom_adjustment")));
+       gtk_menu_button_set_popover (GTK_MENU_BUTTON (self->priv->view_button),
+                                    self->priv->view_menu_widget);
+       g_object_unref (builder);
+
+       builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-main-menus.xml");
+       action_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "action-menu")));
+       gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (self->priv->action_button),
+                                       G_MENU_MODEL (action_menu));
+       g_object_unref (builder);
+
+       g_signal_connect(self->priv->zoom_level_scale, "value-changed",
+                        G_CALLBACK(zoom_level_changed),
+                        self);
+       upper = gtk_adjustment_get_upper (self->priv->zoom_adjustment);
+       lower = gtk_adjustment_get_lower (self->priv->zoom_adjustment);
+       gint i;
+       for (i = (int)lower; i <= (int)upper; i++)
+               gtk_scale_add_mark (GTK_SCALE (self->priv->zoom_level_scale), i, GTK_POS_BOTTOM, NULL);
+
+       g_object_set_data (G_OBJECT (self->priv->back_button), "nav-direction",
+                          GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_BACK));
+       g_object_set_data (G_OBJECT (self->priv->forward_button), "nav-direction",
+                          GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_FORWARD));
+       g_signal_connect (self->priv->back_button, "button-press-event",
+                         G_CALLBACK (navigation_button_press_cb), self);
+       g_signal_connect (self->priv->back_button, "button-release-event",
+                         G_CALLBACK (navigation_button_release_cb), self);
+       g_signal_connect (self->priv->forward_button, "button-press-event",
+                         G_CALLBACK (navigation_button_press_cb), self);
+       g_signal_connect (self->priv->forward_button, "button-release-event",
+                         G_CALLBACK (navigation_button_release_cb), self);
+
+       gtk_widget_show_all (GTK_WIDGET (self));
        toolbar_update_appearance (self);
 }
 
 static void
-nautilus_toolbar_init (NautilusToolbar *self)
-{
-       self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_TOOLBAR,
-                                                 NautilusToolbarPriv);
-}
-
-static void
 nautilus_toolbar_get_property (GObject *object,
                               guint property_id,
                               GValue *value,
@@ -535,11 +507,12 @@ static void
 nautilus_toolbar_class_init (NautilusToolbarClass *klass)
 {
        GObjectClass *oclass;
+       GtkWidgetClass *widget_class;
 
+       widget_class = GTK_WIDGET_CLASS (klass);
        oclass = G_OBJECT_CLASS (klass);
        oclass->get_property = nautilus_toolbar_get_property;
        oclass->set_property = nautilus_toolbar_set_property;
-       oclass->constructed = nautilus_toolbar_constructed;
        oclass->dispose = nautilus_toolbar_dispose;
 
        properties[PROP_WINDOW] =
@@ -556,8 +529,148 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
                                      FALSE,
                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
        
-       g_type_class_add_private (klass, sizeof (NautilusToolbarClass));
        g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+
+       gtk_widget_class_set_template_from_resource (widget_class,
+                                                       "/org/gnome/nautilus/nautilus-toolbar-ui.xml");
+
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, view_button);
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, action_button);
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, path_bar_container);
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, 
location_entry_container);
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, back_button);
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, forward_button);
+}
+
+static gboolean
+hide_widget_recursive (GtkWidget *widget,
+               gchar *id)
+{
+       GList *children;
+       GList *child;
+       gboolean found = FALSE;
+
+       if (g_strcmp0 (gtk_buildable_get_name (GTK_BUILDABLE (widget)), id) == 0)
+       {
+               gtk_widget_hide (widget);
+               return TRUE;
+       }
+
+       if (GTK_IS_CONTAINER (widget))
+       {
+               children = gtk_container_get_children (GTK_CONTAINER (widget));
+               for (child = children; child != NULL && !found; child = child->next)
+               {
+                       found = hide_widget_recursive (child->data, id);
+               }
+       }
+
+       return found;
+}
+
+void
+nautilus_toolbar_action_menu_add_item (NautilusToolbar *self,
+                                      GMenuItem       *item,
+                                      const gchar     *section_name)
+{
+       nautilus_gmenu_add_item_in_submodel (self->priv->action_menu,
+                                            item,
+                                            section_name,
+                                            FALSE);
+}
+
+void
+nautilus_toolbar_reset_menus (NautilusToolbar *self)
+{
+       NautilusWindowSlot *slot;
+       NautilusView *view;
+       GActionGroup *view_action_group;
+       GtkBuilder *builder;
+
+       if (self->priv->action_menu)
+               g_object_unref (self->priv->action_menu);
+
+       builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-main-menus.xml");
+       self->priv->action_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "action-menu")));
+       gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (self->priv->action_button),
+                                       G_MENU_MODEL (self->priv->action_menu));
+       g_object_unref (builder);
+
+       /* Allow actions from the current view to be activated through
+        * the view menu and action menu of the toolbar */
+       slot = nautilus_window_get_active_slot (self->priv->window);
+       view = nautilus_window_slot_get_current_view (slot);
+       view_action_group = nautilus_view_get_action_group (view);
+       gtk_widget_insert_action_group (GTK_WIDGET (self),
+                                       "view",
+                                       G_ACTION_GROUP (view_action_group));
+
+       hide_widget_recursive (GTK_WIDGET (self->priv->view_menu_widget), "sort_menu");
+       hide_widget_recursive (GTK_WIDGET (self->priv->view_menu_widget), "sort_trash_time");
+       hide_widget_recursive (GTK_WIDGET (self->priv->view_menu_widget), "sort_search_relevance");
+       hide_widget_recursive (GTK_WIDGET (self->priv->view_menu_widget), "visible_columns");
+}
+
+void
+nautilus_toolbar_view_menu_widget_show_element (NautilusToolbar *self,
+                                               gchar *id)
+{
+       g_assert (NAUTILUS_IS_TOOLBAR (self));
+
+       show_widget_recursive (GTK_WIDGET (self->priv->view_menu_widget), id);
+}
+
+void
+nautilus_toolbar_view_menu_widget_set_undo_label (NautilusToolbar *self,
+                                                 gchar *label)
+{
+       g_assert (NAUTILUS_IS_TOOLBAR (self));
+
+       gtk_label_set_text (GTK_LABEL (self->priv->undo_label), label);
+}
+
+void
+nautilus_toolbar_view_menu_widget_set_redo_label (NautilusToolbar *self,
+                                                 gchar *label)
+{
+       g_assert (NAUTILUS_IS_TOOLBAR (self));
+
+       gtk_label_set_text (GTK_LABEL (self->priv->redo_label), label);
+}
+
+static gboolean
+show_widget_recursive (GtkWidget *widget,
+               gchar *id)
+{
+       GList *children;
+       GList *child;
+       gboolean found = FALSE;
+
+       if (g_strcmp0 (gtk_buildable_get_name (GTK_BUILDABLE (widget)), id) == 0)
+       {
+               gtk_widget_show (widget);
+               return TRUE;
+       }
+
+       if (GTK_IS_CONTAINER (widget))
+       {
+               children = gtk_container_get_children (GTK_CONTAINER (widget));
+               for (child = children; child != NULL && !found; child = child->next)
+               {
+                       found = show_widget_recursive (child->data, id);
+               }
+       }
+
+       return found;
+}
+
+void nautilus_toolbar_view_menu_widget_set_zoom_level (NautilusToolbar *self,
+                                                      gdouble level)
+{
+       g_assert (NAUTILUS_IS_TOOLBAR (self));
+
+       gtk_adjustment_set_value (GTK_ADJUSTMENT (self->priv->zoom_adjustment),
+                                 level);
 }
 
 GtkWidget *
diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h
index 2a8d2dd..2ea254c 100644
--- a/src/nautilus-toolbar.h
+++ b/src/nautilus-toolbar.h
@@ -42,7 +42,7 @@
        (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_TOOLBAR, NautilusToolbarClass))
 
 typedef struct _NautilusToolbar NautilusToolbar;
-typedef struct _NautilusToolbarPriv NautilusToolbarPriv;
+typedef struct _NautilusToolbarPrivate NautilusToolbarPrivate;
 typedef struct _NautilusToolbarClass NautilusToolbarClass;
 
 typedef enum {
@@ -54,7 +54,7 @@ struct _NautilusToolbar {
        GtkHeaderBar parent;
 
        /* private */
-       NautilusToolbarPriv *priv;
+       NautilusToolbarPrivate *priv;
 };
 
 struct _NautilusToolbarClass {
@@ -72,5 +72,21 @@ void nautilus_toolbar_set_show_main_bar (NautilusToolbar *self,
                                         gboolean show_main_bar);
 void nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
                                               gboolean show_location_entry);
+void nautilus_toolbar_action_menu_add_item (NautilusToolbar *self,
+                                              GMenuItem       *item,
+                                              const gchar     *section_name);
+void nautilus_toolbar_view_menu_widget_set_undo_label (NautilusToolbar *self,
+                                                      gchar *label);
+void nautilus_toolbar_view_menu_widget_set_redo_label (NautilusToolbar *self,
+                                                      gchar *label);
+void nautilus_toolbar_reset_menus (NautilusToolbar *self);
+
+void nautilus_toolbar_sync_navigation_buttons (NautilusToolbar *self);
+void nautilus_toolbar_view_menu_widget_show_element (NautilusToolbar *self,
+                                                    gchar *id);
+void nautilus_toolbar_view_menu_widget_set_zoom_level (NautilusToolbar *self,
+                                                      gdouble level);
+void nautilus_toolbar_update_view_button (NautilusToolbar *self,
+                                         const gchar *view_mode);
 
 #endif /* __NAUTILUS_TOOLBAR_H__ */
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 17d5d49..5a1324f 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -36,6 +36,8 @@
 #include "nautilus-mime-actions.h"
 #include "nautilus-previewer.h"
 #include "nautilus-properties-window.h"
+#include "nautilus-window.h"
+#include "nautilus-toolbar.h"
 
 #if ENABLE_EMPTY_VIEW
 #include "nautilus-empty-view.h"
@@ -130,8 +132,7 @@
 
 #define NAUTILUS_VIEW_POPUP_PATH_LOCATION                        "/location"
 
-#define MAX_MENU_LEVELS 5
-#define TEMPLATE_LIMIT 30
+#define MENU_ITEMS_LIMIT 30
 
 enum {
        ADD_FILE,
@@ -169,26 +170,14 @@ struct NautilusViewDetails
        NautilusWindowSlot *slot;
        NautilusDirectory *model;
        NautilusFile *directory_as_file;
-       NautilusFile *location_popup_directory_as_file;
-       GdkEventButton *location_popup_event;
-       GtkActionGroup *dir_action_group;
+       NautilusFile *pathbar_popup_directory_as_file;
+       GdkEventButton *pathbar_popup_event;
        guint dir_merge_id;
 
        gboolean supports_zooming;
-
-       GList *scripts_directory_list;
-       GtkActionGroup *scripts_action_group;
-       guint scripts_merge_id;
-       
-       GList *templates_directory_list;
-       GtkActionGroup *templates_action_group;
-       guint templates_merge_id;
-
-       GtkActionGroup *extensions_menu_action_group;
-       guint extensions_menu_merge_id;
        
        guint display_selection_idle_id;
-       guint update_menus_timeout_id;
+       guint update_right_click_menus_timeout_id;
        guint update_status_idle_id;
        guint reveal_selection_idle_id;
 
@@ -225,9 +214,8 @@ struct NautilusViewDetails
         * after it finishes loading the directory and its view.
         */
        gboolean loading;
-       gboolean scripts_invalid;
-       gboolean templates_invalid;
        gboolean templates_present;
+       gboolean scripts_present;
 
        /* flag to indicate that no file updates should be dispatched to subclasses.
         * This is a workaround for bug #87701 that prevents the list view from
@@ -253,12 +241,15 @@ struct NautilusViewDetails
        gboolean metadata_for_directory_as_file_pending;
        gboolean metadata_for_files_in_directory_pending;
 
-       GtkActionGroup *open_with_action_group;
-       guint open_with_merge_id;
-
        GList *subdirectory_list;
 
        GdkPoint context_menu_position;
+
+       GMenu *selection_menu;
+       GMenu *background_menu;
+       GMenu *pathbar_menu;
+
+       GActionGroup *view_action_group;
 };
 
 typedef struct {
@@ -269,25 +260,15 @@ typedef struct {
 /* forward declarations */
 
 static gboolean display_selection_info_idle_callback           (gpointer              data);
-static void     nautilus_view_create_links_for_files           (NautilusView      *view,
-                                                               GList                *files,
-                                                               GArray               *item_locations);
 static void     trash_or_delete_files                          (GtkWindow            *parent_window,
                                                                const GList          *files,
-                                                               gboolean              
delete_if_all_already_in_trash,
                                                                NautilusView      *view);
 static void     load_directory                                 (NautilusView      *view,
                                                                NautilusDirectory    *directory);
-static void     nautilus_view_merge_menus                      (NautilusView      *view);
-static void     nautilus_view_unmerge_menus                    (NautilusView      *view);
-static void     nautilus_view_set_show_hidden_files           (NautilusView      *view,
-                                                              gboolean           show_hidden);
 static void     clipboard_changed_callback                     (NautilusClipboardMonitor *monitor,
                                                                NautilusView      *view);
-static void     open_one_in_new_window                         (gpointer              data,
-                                                               gpointer              callback_data);
-static void     schedule_update_menus                          (NautilusView      *view);
-static void     remove_update_menus_timeout_callback           (NautilusView      *view);
+static void     schedule_update_right_click_menus                          (NautilusView      *view);
+static void     remove_update_right_click_menus_timeout_callback           (NautilusView      *view);
 static void     schedule_update_status                          (NautilusView      *view);
 static void     remove_update_status_idle_callback             (NautilusView *view); 
 static void     reset_update_interval                          (NautilusView      *view);
@@ -305,37 +286,37 @@ static void     nautilus_view_trash_state_changed_callback     (NautilusTrashMon
 static void     nautilus_view_select_file                      (NautilusView      *view,
                                                                NautilusFile         *file);
 
-static void     update_templates_directory                     (NautilusView *view);
-
-static gboolean file_list_all_are_folders                      (GList *file_list);
-
-static void unschedule_pop_up_location_context_menu (NautilusView *view);
+static void unschedule_pop_up_pathbar_right_click_menu (NautilusView *view);
+
+static void action_new_folder (GSimpleAction *action,
+                               GVariant      *state,
+                               gpointer       user_data);
+static void action_undo (GSimpleAction *action,
+                         GVariant      *state,
+                         gpointer       user_data);
+static void action_redo (GSimpleAction *action,
+                         GVariant      *state,
+                         gpointer       user_data);
+static void action_select_all (GSimpleAction *action,
+                               GVariant      *state,
+                               gpointer       user_data);
+static void action_zoom_in (GSimpleAction *action,
+                            GVariant      *state,
+                            gpointer       user_data);
+static void action_zoom_out (GSimpleAction *action,
+                             GVariant      *state,
+                             gpointer       user_data);
+static void action_zoom_normal (GSimpleAction *action,
+                                GVariant      *state,
+                                gpointer       user_data);
+static void real_zoom_to_level (NautilusView *view,
+                               NautilusZoomLevel zoom_level);
+static void action_show_hidden_files (GSimpleAction *action,
+                                      GVariant      *state,
+                                      gpointer       user_data);
 
 G_DEFINE_TYPE (NautilusView, nautilus_view, GTK_TYPE_SCROLLED_WINDOW);
 
-/* virtual methods (public and non-public) */
-
-/**
- * nautilus_view_merge_menus:
- * 
- * Add this view's menus to the window's menu bar.
- * @view: NautilusView in question.
- */
-static void
-nautilus_view_merge_menus (NautilusView *view)
-{
-       g_return_if_fail (NAUTILUS_IS_VIEW (view));
-
-       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->merge_menus (view);
-}
-
-static void
-nautilus_view_unmerge_menus (NautilusView *view)
-{
-       g_return_if_fail (NAUTILUS_IS_VIEW (view));
-
-       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->unmerge_menus (view);}
-
 static char *
 real_get_backing_uri (NautilusView *view)
 {
@@ -417,21 +398,6 @@ nautilus_view_get_selection_for_file_transfer (NautilusView *view)
        return NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selection_for_file_transfer (view);
 }
 
-/**
- * nautilus_view_get_selected_icon_locations:
- *
- * return an array of locations of selected icons if available
- * Return value: GArray of GdkPoints
- * 
- **/
-static GArray *
-nautilus_view_get_selected_icon_locations (NautilusView *view)
-{
-       g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL);
-
-       return NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selected_icon_locations (view);
-}
-
 static void
 nautilus_view_invert_selection (NautilusView *view)
 {
@@ -453,25 +419,6 @@ nautilus_view_reveal_selection (NautilusView *view)
        NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->reveal_selection (view);
 }
 
-/**
- * nautilus_view_reset_to_defaults:
- *
- * set sorting order, zoom level, etc. to match defaults
- * 
- **/
-static void
-nautilus_view_reset_to_defaults (NautilusView *view)
-{
-       GtkAction *action;
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SHOW_HIDDEN_FILES);
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-                                     g_settings_get_boolean (gtk_filechooser_preferences, 
NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES));
-
-        NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->reset_to_defaults (view);
-}
-
 static gboolean
 nautilus_view_using_manual_layout (NautilusView  *view)
 {
@@ -576,6 +523,13 @@ nautilus_view_bump_zoom_level (NautilusView *view,
        NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->bump_zoom_level (view, zoom_increment);
 }
 
+static void
+real_zoom_to_level (NautilusView *view,
+                   NautilusZoomLevel zoom_level)
+{
+       nautilus_view_update_toolbar_menus (view);
+}
+
 /**
  * nautilus_view_zoom_to_level:
  *
@@ -714,30 +668,6 @@ nautilus_view_get_selection (NautilusView *view)
        return NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selection (view);
 }
 
-/**
- * nautilus_view_update_menus:
- * 
- * Update the sensitivity and wording of dynamic menu items.
- * @view: NautilusView in question.
- */
-void
-nautilus_view_update_menus (NautilusView *view)
-{
-       g_return_if_fail (NAUTILUS_IS_VIEW (view));
-
-       if (!view->details->active) {
-               return;
-       }
-
-       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_menus (view);
-}
-
-typedef struct {
-       GAppInfo *application;
-       GList *files;
-       NautilusView *directory_view;
-} ApplicationLaunchParameters;
-
 typedef struct {
        NautilusFile *file;
        NautilusView *directory_view;
@@ -748,38 +678,6 @@ typedef struct {
        NautilusView *directory_view;
 } CreateTemplateParameters;
 
-static ApplicationLaunchParameters *
-application_launch_parameters_new (GAppInfo *application,
-                                  GList *files,
-                                  NautilusView *directory_view)
-{
-       ApplicationLaunchParameters *result;
-
-       result = g_new0 (ApplicationLaunchParameters, 1);
-       result->application = g_object_ref (application);
-       result->files = nautilus_file_list_copy (files);
-
-       if (directory_view != NULL) {
-               g_object_ref (directory_view);
-               result->directory_view = directory_view;
-       }
-
-       return result;
-}
-
-static void
-application_launch_parameters_free (ApplicationLaunchParameters *parameters)
-{
-       g_object_unref (parameters->application);
-       nautilus_file_list_free (parameters->files);
-
-       if (parameters->directory_view != NULL) {
-               g_object_unref (parameters->directory_view);
-       }
-
-       g_free (parameters);
-}                            
-
 static GList *
 file_and_directory_list_to_files (GList *fad_list)
 {
@@ -902,7 +800,7 @@ create_templates_parameters_free (CreateTemplateParameters *parameters)
        g_free (parameters);
 }                            
 
-static NautilusWindow *
+NautilusWindow *
 nautilus_view_get_window (NautilusView  *view)
 {
        return nautilus_window_slot_get_window (view->details->slot);
@@ -936,39 +834,6 @@ nautilus_view_get_containing_window (NautilusView *view)
 }
 
 static gboolean
-nautilus_view_confirm_multiple (GtkWindow *parent_window,
-                               int count,
-                               gboolean tabs)
-{
-       GtkDialog *dialog;
-       char *prompt;
-       char *detail;
-       int response;
-
-       if (count <= SILENT_WINDOW_OPEN_LIMIT) {
-               return TRUE;
-       }
-
-       prompt = _("Are you sure you want to open all files?");
-       if (tabs) {
-               detail = g_strdup_printf (ngettext("This will open %'d separate tab.",
-                                                  "This will open %'d separate tabs.", count), count);
-       } else {
-               detail = g_strdup_printf (ngettext("This will open %'d separate window.",
-                                                  "This will open %'d separate windows.", count), count);
-       }
-       dialog = eel_show_yes_no_dialog (prompt, detail, 
-                                        _("_OK"), _("_Cancel"),
-                                        parent_window);
-       g_free (detail);
-
-       response = gtk_dialog_run (dialog);
-       gtk_widget_destroy (GTK_WIDGET (dialog));
-
-       return response == GTK_RESPONSE_YES;
-}
-
-static gboolean
 selection_contains_one_item_in_menu_callback (NautilusView *view, GList *selection)
 {
        if (g_list_length (selection) == 1) {
@@ -1076,35 +941,20 @@ nautilus_view_activate_file (NautilusView *view,
 }
 
 static void
-action_open_callback (GtkAction *action,
-                     gpointer callback_data)
+action_open_with_default_application (GSimpleAction *action,
+                                     GVariant      *state,
+                                     gpointer       user_data)
 {
        NautilusView *view;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
        nautilus_view_activate_selection (view);
 }
 
 static void
-action_open_close_parent_callback (GtkAction *action,
-                                  gpointer callback_data)
-{
-       GList *selection;
-       NautilusView *view;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       selection = nautilus_view_get_selection (view);
-       nautilus_view_activate_files (view,
-                                     selection,
-                                     NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND,
-                                     TRUE);
-       nautilus_file_list_free (selection);
-}
-
-static void
-action_open_item_location_callback (GtkAction *action,
-                                   gpointer callback_data)
+action_open_item_location (GSimpleAction *action,
+                          GVariant      *state,
+                          gpointer       user_data)
 {
        NautilusView *view;
        GList *selection;
@@ -1113,7 +963,7 @@ action_open_item_location_callback (GtkAction *action,
        NautilusFile *activation_file;
        NautilusFile *location;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
        selection = nautilus_view_get_selection (view);
 
        if (!selection)
@@ -1132,48 +982,43 @@ action_open_item_location_callback (GtkAction *action,
        nautilus_file_list_free (selection);
 }
 
-
 static void
-action_open_alternate_callback (GtkAction *action,
-                               gpointer callback_data)
+action_open_item_new_tab (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
        NautilusView *view;
        GList *selection;
-       GtkWindow *window;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
        selection = nautilus_view_get_selection (view);
 
-       window = nautilus_view_get_containing_window (view);
-
-       if (nautilus_view_confirm_multiple (window, g_list_length (selection), FALSE)) {
-               g_list_foreach (selection, open_one_in_new_window, view);
-       }
+       nautilus_view_activate_files (view,
+                                     selection,
+                                     NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB,
+                                     FALSE);
 
        nautilus_file_list_free (selection);
 }
 
 static void
-action_open_new_tab_callback (GtkAction *action,
-                             gpointer callback_data)
+action_pathbar_open_item_new_tab (GSimpleAction *action,
+                                 GVariant      *state,
+                                 gpointer       user_data)
 {
        NautilusView *view;
-       GList *selection;
-       GtkWindow *window;
-
-       view = NAUTILUS_VIEW (callback_data);
-       selection = nautilus_view_get_selection (view);
+       NautilusFile *file;
 
-       window = nautilus_view_get_containing_window (view);
+       view = NAUTILUS_VIEW (user_data);
 
-       if (nautilus_view_confirm_multiple (window, g_list_length (selection), TRUE)) {
-               nautilus_view_activate_files (view,
-                                             selection,
-                                             NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB,
-                                             FALSE);
+       file = view->details->pathbar_popup_directory_as_file;
+       if (file == NULL) {
+               return;
        }
 
-       nautilus_file_list_free (selection);
+       nautilus_view_activate_file (view,
+                                    file,
+                                    NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB);
 }
 
 static void
@@ -1247,7 +1092,6 @@ open_with_other_program (NautilusView *view)
        g_assert (NAUTILUS_IS_VIEW (view));
 
                selection = nautilus_view_get_selection (view);
-
        if (selection_contains_one_item_in_menu_callback (view, selection)) {
                choose_program (view, NAUTILUS_FILE (selection->data));
        }
@@ -1256,12 +1100,13 @@ open_with_other_program (NautilusView *view)
 }
 
 static void
-action_other_application_callback (GtkAction *action,
-                                  gpointer callback_data)
+action_open_with_other_application (GSimpleAction *action,
+                                   GVariant      *state,
+                                   gpointer       user_data)
 {
-       g_assert (NAUTILUS_IS_VIEW (callback_data));
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-       open_with_other_program (NAUTILUS_VIEW (callback_data));
+       open_with_other_program (NAUTILUS_VIEW (user_data));
 }
 
 static void
@@ -1276,33 +1121,19 @@ trash_or_delete_selected_files (NautilusView *view)
        if (!view->details->selection_was_removed) {
                selection = nautilus_view_get_selection_for_file_transfer (view);
                trash_or_delete_files (nautilus_view_get_containing_window (view),
-                                      selection, TRUE,
+                                      selection,
                                       view);
                nautilus_file_list_free (selection);
                view->details->selection_was_removed = TRUE;
        }
 }
 
-static gboolean
-real_trash (NautilusView *view)
-{
-       GtkAction *action;
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_TRASH);
-       if (gtk_action_get_sensitive (action) &&
-           gtk_action_get_visible (action)) {
-               trash_or_delete_selected_files (view);
-               return TRUE;
-       }
-       return FALSE;
-}
-
 static void
-action_trash_callback (GtkAction *action,
-                      gpointer callback_data)
+action_move_to_trash (GSimpleAction *action,
+                     GVariant      *state,
+                     gpointer       user_data)
 {
-        trash_or_delete_selected_files (NAUTILUS_VIEW (callback_data));
+        trash_or_delete_selected_files (NAUTILUS_VIEW (user_data));
 }
 
 static void
@@ -1331,20 +1162,22 @@ delete_selected_files (NautilusView *view)
 }
 
 static void
-action_delete_callback (GtkAction *action,
-                       gpointer callback_data)
+action_delete (GSimpleAction *action,
+              GVariant      *state,
+              gpointer       user_data)
 {
-        delete_selected_files (NAUTILUS_VIEW (callback_data));
+       delete_selected_files (NAUTILUS_VIEW (user_data));
 }
 
 static void
-action_restore_from_trash_callback (GtkAction *action,
-                                   gpointer callback_data)
+action_restore_from_trash (GSimpleAction *action,
+                          GVariant      *state,
+                          gpointer       user_data)
 {
        NautilusView *view;
        GList *selection;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
 
        selection = nautilus_view_get_selection_for_file_transfer (view);
        nautilus_restore_files_from_trash (selection,
@@ -1354,58 +1187,28 @@ action_restore_from_trash_callback (GtkAction *action,
 
 }
 
-static gboolean
-real_delete (NautilusView *view)
-{
-       GtkAction *action;
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_DELETE);
-       if (gtk_action_get_sensitive (action) &&
-           gtk_action_get_visible (action)) {
-               delete_selected_files (view);
-               return TRUE;
-       }
-       return FALSE;
-}
-
 static void
-action_create_link_callback (GtkAction *action,
-                            gpointer callback_data)
+action_select_all (GSimpleAction *action,
+                  GVariant      *state,
+                  gpointer       user_data)
 {
-        NautilusView *view;
-        GList *selection;
-        GArray *selected_item_locations;
-        
-        g_assert (NAUTILUS_IS_VIEW (callback_data));
-
-        view = NAUTILUS_VIEW (callback_data);
-       selection = nautilus_view_get_selection (view);
-       if (selection_not_empty_in_menu_callback (view, selection)) {
-               selected_item_locations = nautilus_view_get_selected_icon_locations (view);
-               nautilus_view_create_links_for_files (view, selection, selected_item_locations);
-               g_array_free (selected_item_locations, TRUE);
-       }
+       NautilusView *view;
 
-        nautilus_file_list_free (selection);
-}
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-static void
-action_select_all_callback (GtkAction *action, 
-                           gpointer callback_data)
-{
-       g_assert (NAUTILUS_IS_VIEW (callback_data));
+       view = NAUTILUS_VIEW (user_data);
 
-       nautilus_view_select_all (callback_data);
+       nautilus_view_select_all (view);
 }
 
 static void
-action_invert_selection_callback (GtkAction *action,
-                                 gpointer callback_data)
+action_invert_selection (GSimpleAction *action,
+                        GVariant      *state,
+                        gpointer       user_data)
 {
-       g_assert (NAUTILUS_IS_VIEW (callback_data));
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-       nautilus_view_invert_selection (callback_data);
+       nautilus_view_invert_selection (user_data);
 }
 
 static void
@@ -1505,171 +1308,13 @@ select_pattern (NautilusView *view)
 }
 
 static void
-action_select_pattern_callback (GtkAction *action, 
-                               gpointer callback_data)
-{
-       g_assert (NAUTILUS_IS_VIEW (callback_data));
-
-       select_pattern(callback_data);
-}
-
-static void
-action_reset_to_defaults_callback (GtkAction *action, 
-                                  gpointer callback_data)
-{
-       g_assert (NAUTILUS_IS_VIEW (callback_data));
-
-       nautilus_view_reset_to_defaults (callback_data);
-}
-
-static void
-action_save_search_callback (GtkAction *action,
-                            gpointer callback_data)
-{                
-       NautilusSearchDirectory *search;
-       NautilusView    *directory_view;
-       
-        directory_view = NAUTILUS_VIEW (callback_data);
-
-       if (directory_view->details->model &&
-           NAUTILUS_IS_SEARCH_DIRECTORY (directory_view->details->model)) {
-               search = NAUTILUS_SEARCH_DIRECTORY (directory_view->details->model);
-               nautilus_search_directory_save_search (search);
-
-               /* Save search is disabled */
-               schedule_update_menus (directory_view);
-       }
-}
-
-static void
-query_name_entry_changed_cb  (GtkWidget *entry, GtkWidget *button)
+action_select_pattern (GSimpleAction *action,
+                      GVariant      *state,
+                      gpointer       user_data)
 {
-       const char *text;
-       gboolean sensitive;
-       
-       text = gtk_entry_get_text (GTK_ENTRY (entry));
-
-       sensitive = (text != NULL) && (*text != 0);
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-       gtk_widget_set_sensitive (button, sensitive);
-}
-
-
-static void
-action_save_search_as_callback (GtkAction *action,
-                               gpointer callback_data)
-{
-       NautilusView    *directory_view;
-       NautilusSearchDirectory *search;
-       GtkWidget *dialog, *grid, *label, *entry, *chooser, *save_button;
-       const char *entry_text;
-       char *filename, *filename_utf8, *dirname, *path, *uri;
-       GFile *location;
-       
-        directory_view = NAUTILUS_VIEW (callback_data);
-
-       if (directory_view->details->model &&
-           NAUTILUS_IS_SEARCH_DIRECTORY (directory_view->details->model)) {
-               search = NAUTILUS_SEARCH_DIRECTORY (directory_view->details->model);
-               
-               dialog = gtk_dialog_new_with_buttons (_("Save Search as"),
-                                                     nautilus_view_get_containing_window (directory_view),
-                                                     0,
-                                                     _("_Cancel"), GTK_RESPONSE_CANCEL,
-                                                     NULL);
-               save_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
-                                                    _("_Save"), GTK_RESPONSE_OK);
-               gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-                                                GTK_RESPONSE_OK);
-               gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-               gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
-               gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
-               grid = gtk_grid_new ();
-               g_object_set (grid,
-                             "orientation", GTK_ORIENTATION_VERTICAL,
-                             "border-width", 5,
-                             "row-spacing", 6,
-                             "column-spacing", 12,
-                             NULL);
-               gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), grid, TRUE, 
TRUE, 0);
-               gtk_widget_show (grid);
-               
-               label = gtk_label_new_with_mnemonic (_("Search _name:"));
-               gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-               gtk_container_add (GTK_CONTAINER (grid), label);
-               gtk_widget_show (label);
-
-               entry = gtk_entry_new ();
-               gtk_widget_set_hexpand (entry, TRUE);
-               gtk_grid_attach_next_to (GTK_GRID (grid), entry, label,
-                                        GTK_POS_RIGHT, 1, 1);
-               gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
-               gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
-               
-               gtk_widget_set_sensitive (save_button, FALSE);
-               g_signal_connect (entry, "changed",
-                                 G_CALLBACK (query_name_entry_changed_cb), save_button);
-               
-               gtk_widget_show (entry);
-               label = gtk_label_new_with_mnemonic (_("_Folder:"));
-               gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5);
-               gtk_container_add (GTK_CONTAINER (grid), label);
-               gtk_widget_show (label);
-
-               chooser = gtk_file_chooser_button_new (_("Select Folder to Save Search In"),
-                                                      GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
-               gtk_widget_set_hexpand (chooser, TRUE);
-               gtk_grid_attach_next_to (GTK_GRID (grid), chooser, label,
-                                        GTK_POS_RIGHT, 1, 1);
-               gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
-               gtk_widget_show (chooser);
-
-               gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
-
-               gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
-                                                    g_get_home_dir ());
-               
-               if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
-                       entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
-                       if (g_str_has_suffix (entry_text, NAUTILUS_SAVED_SEARCH_EXTENSION)) {
-                               filename_utf8 = g_strdup (entry_text);
-                       } else {
-                               filename_utf8 = g_strconcat (entry_text, NAUTILUS_SAVED_SEARCH_EXTENSION, 
NULL);
-                       }
-
-                       filename = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, NULL);
-                       g_free (filename_utf8);
-
-                       dirname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
-                       
-                       path = g_build_filename (dirname, filename, NULL);
-                       g_free (filename);
-                       g_free (dirname);
-
-                       uri = g_filename_to_uri (path, NULL, NULL);
-                       g_free (path);
-                       
-                       nautilus_search_directory_save_to_file (search, uri);
-                       location = g_file_new_for_uri (uri);
-                       nautilus_file_changes_queue_file_added (location);
-                       g_object_unref (location);
-                       nautilus_file_changes_consume_changes (TRUE);
-                       g_free (uri);
-               }
-               
-               gtk_widget_destroy (dialog);
-       }
-}
-
-
-static void
-action_empty_trash_callback (GtkAction *action,
-                            gpointer callback_data)
-{                
-        g_assert (NAUTILUS_IS_VIEW (callback_data));
-
-       nautilus_file_operations_empty_trash (GTK_WIDGET (callback_data));
+       select_pattern(user_data);
 }
 
 typedef struct {
@@ -2077,34 +1722,27 @@ nautilus_view_new_file (NautilusView *directory_view,
 }
 
 static void
-action_new_folder_callback (GtkAction *action,
-                           gpointer callback_data)
-{                
-        g_assert (NAUTILUS_IS_VIEW (callback_data));
-
-       nautilus_view_new_folder (NAUTILUS_VIEW (callback_data), FALSE);
-}
-
-static void
-action_new_folder_with_selection_callback (GtkAction *action,
-                                          gpointer callback_data)
-{                
-        g_assert (NAUTILUS_IS_VIEW (callback_data));
+action_new_folder (GSimpleAction *action,
+                  GVariant      *state,
+                  gpointer       user_data)
+{
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-       nautilus_view_new_folder (NAUTILUS_VIEW (callback_data), TRUE);
+       nautilus_view_new_folder (NAUTILUS_VIEW (user_data), FALSE);
 }
 
 static void
-action_properties_callback (GtkAction *action,
-                           gpointer callback_data)
+action_properties (GSimpleAction *action,
+                  GVariant *state,
+                  gpointer user_data)
 {
         NautilusView *view;
         GList *selection;
        GList *files;
         
-        g_assert (NAUTILUS_IS_VIEW (callback_data));
+        g_assert (NAUTILUS_IS_VIEW (user_data));
 
-        view = NAUTILUS_VIEW (callback_data);
+        view = NAUTILUS_VIEW (user_data);
        selection = nautilus_view_get_selection (view);
        if (g_list_length (selection) == 0) {
                if (view->details->directory_as_file != NULL) {
@@ -2121,64 +1759,249 @@ action_properties_callback (GtkAction *action,
 }
 
 static void
-action_location_properties_callback (GtkAction *action,
-                                    gpointer   callback_data)
+action_pathbar_properties (GSimpleAction *action,
+                          GVariant *state,
+                          gpointer user_data)
 {
        NautilusView *view;
        GList           *files;
 
-       g_assert (NAUTILUS_IS_VIEW (callback_data));
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-       view = NAUTILUS_VIEW (callback_data);
-       g_assert (NAUTILUS_IS_FILE (view->details->location_popup_directory_as_file));
+       view = NAUTILUS_VIEW (user_data);
+       g_assert (NAUTILUS_IS_FILE (view->details->pathbar_popup_directory_as_file));
 
-       files = g_list_append (NULL, nautilus_file_ref (view->details->location_popup_directory_as_file));
+       files = g_list_append (NULL, nautilus_file_ref (view->details->pathbar_popup_directory_as_file));
 
        nautilus_properties_window_present (files, GTK_WIDGET (view), NULL);
 
        nautilus_file_list_free (files);
 }
 
-static gboolean
-all_files_in_trash (GList *files)
+static void
+nautilus_view_set_show_hidden_files (NautilusView *view,
+                                    gboolean show_hidden)
 {
-       GList *node;
-
-       /* Result is ambiguous if called on NULL, so disallow. */
-       g_return_val_if_fail (files != NULL, FALSE);
+       if (view->details->ignore_hidden_file_preferences) {
+               return;
+       }
 
-       for (node = files; node != NULL; node = node->next) {
-               if (!nautilus_file_is_in_trash (NAUTILUS_FILE (node->data))) {
-                       return FALSE;
+       if (show_hidden != view->details->show_hidden_files) {
+               view->details->show_hidden_files = show_hidden;
+               if (view->details->model != NULL) {
+                       load_directory (view, view->details->model);
                }
        }
+}
 
-       return TRUE;
+static void
+action_show_hidden_files (GSimpleAction *action,
+                         GVariant      *state,
+                         gpointer       user_data)
+{
+       gboolean show_hidden;
+       NautilusView *view;
+
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+       show_hidden = g_variant_get_boolean (state);
+
+       nautilus_view_set_show_hidden_files (view, show_hidden);
+
+       g_simple_action_set_state (action, state);
 }
 
-static gboolean
-all_selected_items_in_trash (GList *selection)
+static void
+action_undo (GSimpleAction *action,
+            GVariant      *state,
+            gpointer       user_data)
 {
-       gboolean result;
+       GtkWidget *toplevel;
+       NautilusView *view;
 
-       /* If the contents share a parent directory, we need only
-        * check that parent directory. Otherwise we have to inspect
-        * each selected item.
-        */
-       result = (selection == NULL) ? FALSE : all_files_in_trash (selection);
-       return result;
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+       nautilus_file_undo_manager_undo (GTK_WINDOW (toplevel));
 }
 
 static void
-action_show_hidden_files_callback (GtkAction *action,
-                                  gpointer callback_data)
+action_redo (GSimpleAction *action,
+            GVariant      *state,
+            gpointer       user_data)
 {
+       GtkWidget *toplevel;
        NautilusView *view;
 
-       view = NAUTILUS_VIEW (callback_data);
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+       nautilus_file_undo_manager_redo (GTK_WINDOW (toplevel));
+}
+
+static void
+action_zoom_in (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data) 
+{
+       NautilusView *view;
+
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+
+       nautilus_view_bump_zoom_level (view, 1);
+}
+
+static void
+action_zoom_out (GSimpleAction *action,
+                GVariant      *state,
+                gpointer       user_data) 
+{
+       NautilusView *view;
+
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+
+       nautilus_view_bump_zoom_level (view, -1);
+}
+
+static void
+action_zoom_normal (GSimpleAction *action,
+                   GVariant      *state,
+                   gpointer       user_data) 
+{
+       NautilusView *view;
+
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+
+       nautilus_view_restore_default_zoom_level (view);
+}
+
+static void
+action_zoom_to_level (GSimpleAction *action,
+                     GVariant      *state,
+                     gpointer       user_data)
+{
+       NautilusView *view;
+       gdouble zoom_value;
 
-       nautilus_view_set_show_hidden_files
-               (view, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+       zoom_value = g_variant_get_int32 (state);
+
+       nautilus_view_zoom_to_level (view, zoom_value);
+}
+
+static void
+action_open_item_new_window (GSimpleAction *action,
+                            GVariant      *state,
+                            gpointer       user_data)
+{
+       NautilusView *view;
+       GList *selection;
+
+       view = NAUTILUS_VIEW (user_data);
+       selection = nautilus_view_get_selection (view);
+
+       nautilus_view_activate_files (view,
+                                     selection,
+                                     NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW,
+                                     FALSE);
+
+       nautilus_file_list_free (selection);
+}
+
+static void
+action_pathbar_open_item_new_window (GSimpleAction *action,
+                                    GVariant      *state,
+                                    gpointer       user_data)
+{
+       NautilusView *view;
+       NautilusFile *file;
+
+       view = NAUTILUS_VIEW (user_data);
+
+       file = view->details->pathbar_popup_directory_as_file;
+       if (file == NULL) {
+               return;
+       }
+
+       nautilus_view_activate_file (view,
+                                    file,
+                                    NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW);
+}
+
+static void
+paste_clipboard_data (NautilusView *view,
+                     GtkSelectionData *selection_data,
+                     char *destination_uri)
+{
+       gboolean cut;
+       GList *item_uris;
+
+       cut = FALSE;
+       item_uris = nautilus_clipboard_get_uri_list_from_selection_data (selection_data, &cut,
+                                                                        copied_files_atom);
+
+       if (item_uris != NULL && destination_uri != NULL) {
+               nautilus_view_move_copy_items (view, item_uris, NULL, destination_uri,
+                                              cut ? GDK_ACTION_MOVE : GDK_ACTION_COPY,
+                                              0, 0);
+
+               /* If items are cut then remove from clipboard */
+               if (cut) {
+                       gtk_clipboard_clear (nautilus_clipboard_get (GTK_WIDGET (view)));
+               }
+
+               g_list_free_full (item_uris, g_free);
+       }
+}
+
+static void
+paste_clipboard_received_callback (GtkClipboard     *clipboard,
+                                  GtkSelectionData *selection_data,
+                                  gpointer          data)
+{
+       NautilusView *view;
+       char *view_uri;
+
+       view = NAUTILUS_VIEW (data);
+
+       view_uri = nautilus_view_get_backing_uri (view);
+
+       if (view->details->slot != NULL) {
+               paste_clipboard_data (view, selection_data, view_uri);
+       }
+
+       g_free (view_uri);
+
+       g_object_unref (view);
+}
+
+static void
+action_paste_files (GSimpleAction *action,
+                   GVariant      *state,
+                   gpointer       user_data)
+{
+       NautilusView *view;
+
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+
+       g_object_ref (view);
+       gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
+                                       copied_files_atom,
+                                       paste_clipboard_received_callback,
+                                       view);
 }
 
 static void
@@ -2308,9 +2131,8 @@ scripts_added_or_changed_callback (NautilusDirectory *directory,
 
        view = NAUTILUS_VIEW (callback_data);
 
-       view->details->scripts_invalid = TRUE;
        if (view->details->active) {
-               schedule_update_menus (view);
+               schedule_update_right_click_menus (view);
        }
 }
 
@@ -2323,95 +2145,49 @@ templates_added_or_changed_callback (NautilusDirectory *directory,
 
        view = NAUTILUS_VIEW (callback_data);
 
-       view->details->templates_invalid = TRUE;
        if (view->details->active) {
-               schedule_update_menus (view);
+               schedule_update_right_click_menus (view);
        }
 }
 
 static void
-add_directory_to_directory_list (NautilusView *view,
-                                NautilusDirectory *directory,
-                                GList **directory_list,
-                                GCallback changed_callback)
+monitor_directory_changes (NautilusView *view,
+                          NautilusDirectory *directory,
+                          GCallback changed_callback)
 {
        NautilusFileAttributes attributes;
 
-       if (g_list_find (*directory_list, directory) == NULL) {
-               nautilus_directory_ref (directory);
-
-               attributes =
-                       NAUTILUS_FILE_ATTRIBUTES_FOR_ICON |
-                       NAUTILUS_FILE_ATTRIBUTE_INFO |
-                       NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT;
+       nautilus_directory_ref (directory);
 
-               nautilus_directory_file_monitor_add (directory, directory_list,
-                                                    FALSE, attributes,
-                                                    (NautilusDirectoryCallback)changed_callback, view);
+       attributes =
+               NAUTILUS_FILE_ATTRIBUTES_FOR_ICON |
+               NAUTILUS_FILE_ATTRIBUTE_INFO |
+               NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT;
 
-               g_signal_connect_object (directory, "files-added",
-                                        G_CALLBACK (changed_callback), view, 0);
-               g_signal_connect_object (directory, "files-changed",
-                                        G_CALLBACK (changed_callback), view, 0);
+       nautilus_directory_file_monitor_add (directory, view,
+                                            FALSE, attributes,
+                                            (NautilusDirectoryCallback)changed_callback, view);
 
-               *directory_list = g_list_append (*directory_list, directory);
-       }
+       g_signal_connect_object (directory, "files-added",
+                                G_CALLBACK (changed_callback), view, 0);
+       g_signal_connect_object (directory, "files-changed",
+                                G_CALLBACK (changed_callback), view, 0);
 }
 
 static void
-remove_directory_from_directory_list (NautilusView *view,
-                                     NautilusDirectory *directory,
-                                     GList **directory_list,
-                                     GCallback changed_callback)
+remove_monitor_directory_changes (NautilusView *view,
+                                 NautilusDirectory *directory,
+                                 GCallback changed_callback)
 {
-       *directory_list = g_list_remove (*directory_list, directory);
-
        g_signal_handlers_disconnect_by_func (directory,
                                              G_CALLBACK (changed_callback),
                                              view);
 
-       nautilus_directory_file_monitor_remove (directory, directory_list);
+       nautilus_directory_file_monitor_remove (directory, view);
 
        nautilus_directory_unref (directory);
 }
 
-
-static void
-add_directory_to_scripts_directory_list (NautilusView *view,
-                                        NautilusDirectory *directory)
-{
-       add_directory_to_directory_list (view, directory,
-                                        &view->details->scripts_directory_list,
-                                        G_CALLBACK (scripts_added_or_changed_callback));
-}
-
-static void
-remove_directory_from_scripts_directory_list (NautilusView *view,
-                                             NautilusDirectory *directory)
-{
-       remove_directory_from_directory_list (view, directory,
-                                             &view->details->scripts_directory_list,
-                                             G_CALLBACK (scripts_added_or_changed_callback));
-}
-
-static void
-add_directory_to_templates_directory_list (NautilusView *view,
-                                          NautilusDirectory *directory)
-{
-       add_directory_to_directory_list (view, directory,
-                                        &view->details->templates_directory_list,
-                                        G_CALLBACK (templates_added_or_changed_callback));
-}
-
-static void
-remove_directory_from_templates_directory_list (NautilusView *view,
-                                               NautilusDirectory *directory)
-{
-       remove_directory_from_directory_list (view, directory,
-                                             &view->details->templates_directory_list,
-                                             G_CALLBACK (templates_added_or_changed_callback));
-}
-
 static void
 slot_active (NautilusWindowSlot *slot,
             NautilusView *view)
@@ -2422,8 +2198,10 @@ slot_active (NautilusWindowSlot *slot,
 
        view->details->active = TRUE;
 
-       nautilus_view_merge_menus (view);
-       schedule_update_menus (view);
+       nautilus_view_update_right_click_menus(view);
+       nautilus_view_update_toolbar_menus (view);
+
+       schedule_update_right_click_menus (view);
 }
 
 static void
@@ -2436,8 +2214,7 @@ slot_inactive (NautilusWindowSlot *slot,
 
        view->details->active = FALSE;
 
-       nautilus_view_unmerge_menus (view);
-       remove_update_menus_timeout_callback (view);
+       remove_update_right_click_menus_timeout_callback (view);
 }
 
 void
@@ -2466,92 +2243,14 @@ nautilus_view_get_selection_count (NautilusView *view)
 }
 
 static void
-update_undo_actions (NautilusView *view)
-{
-       NautilusFileUndoInfo *info;
-       NautilusFileUndoManagerState undo_state;
-       GtkAction *action;
-       const gchar *label, *tooltip;
-       gboolean available, is_undo;
-       gboolean undo_active, redo_active;
-       gchar *undo_label, *undo_description, *redo_label, *redo_description;
-
-       undo_label = undo_description = redo_label = redo_description = NULL;
-
-       undo_active = FALSE;
-       redo_active = FALSE;
-
-       info = nautilus_file_undo_manager_get_action ();
-       undo_state = nautilus_file_undo_manager_get_state ();
-
-       if (info != NULL && 
-           (undo_state > NAUTILUS_FILE_UNDO_MANAGER_STATE_NONE)) {
-               is_undo = (undo_state == NAUTILUS_FILE_UNDO_MANAGER_STATE_UNDO);
-
-               if (is_undo) {
-                       undo_active = TRUE;
-               } else {
-                       redo_active = TRUE;
-               }
-
-               nautilus_file_undo_info_get_strings (info,
-                                                    &undo_label, &undo_description,
-                                                    &redo_label, &redo_description);
-       }
-
-       /* Update undo entry */
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             "Undo");
-       available = undo_active;
-       if (available) {
-               label = undo_label;
-               tooltip = undo_description;
-       } else {
-               /* Reset to default info */
-               label = _("Undo");
-               tooltip = _("Undo last action");
-       }
-
-       g_object_set (action,
-                     "label", label,
-                     "tooltip", tooltip,
-                     NULL);
-       gtk_action_set_sensitive (action, available);
-
-       /* Update redo entry */
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             "Redo");
-       available = redo_active;
-       if (available) {
-               label = redo_label;
-               tooltip = redo_description;
-       } else {
-               /* Reset to default info */
-               label = _("Redo");
-               tooltip = _("Redo last undone action");
-       }
-
-       g_object_set (action,
-                     "label", label,
-                     "tooltip", tooltip,
-                     NULL);
-       gtk_action_set_sensitive (action, available);
-
-       g_free (undo_label);
-       g_free (undo_description);
-       g_free (redo_label);
-       g_free (redo_description);
-}
-
-static void
-undo_manager_changed_cb (NautilusFileUndoManager* manager,
+undo_manager_changed (NautilusFileUndoManager* manager,
                         NautilusView *view)
 {
        if (!view->details->active) {
                return;
        }
 
-       update_undo_actions (view);
+       nautilus_view_update_toolbar_menus (view);
 }
 
 void
@@ -2599,155 +2298,43 @@ have_bulk_rename_tool ()
 }
 
 static void
-nautilus_view_init (NautilusView *view)
+nautilus_view_destroy (GtkWidget *object)
 {
-       AtkObject *atk_object;
+       NautilusView *view;
        NautilusDirectory *scripts_directory;
        NautilusDirectory *templates_directory;
-       char *templates_uri;
-
-       nautilus_profile_start (NULL);
+       gchar *templates_uri;
 
-       view->details = G_TYPE_INSTANCE_GET_PRIVATE (view, NAUTILUS_TYPE_VIEW,
-                                                    NautilusViewDetails);
-
-       /* Default to true; desktop-icon-view sets to false */
-       view->details->show_foreign_files = TRUE;
+       view = NAUTILUS_VIEW (object);
 
-       view->details->non_ready_files =
-               g_hash_table_new_full (file_and_directory_hash,
-                                      file_and_directory_equal,
-                                      (GDestroyNotify)file_and_directory_free,
-                                      NULL);
+       disconnect_model_handlers (view);
 
-       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view),
-                                       GTK_POLICY_AUTOMATIC,
-                                       GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (view), NULL);
-       gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (view), NULL);
+       nautilus_view_stop_loading (view);
 
-       gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (view)),
-                                             GTK_JUNCTION_TOP | GTK_JUNCTION_LEFT);
+       while (view->details->subdirectory_list != NULL) {
+               nautilus_view_remove_subdirectory (view,
+                                                  view->details->subdirectory_list->data);
+       }
 
-       if (set_up_scripts_directory_global ()) {
-               scripts_directory = nautilus_directory_get_by_uri (scripts_directory_uri);
-               add_directory_to_scripts_directory_list (view, scripts_directory);
+       scripts_directory = nautilus_directory_get_by_uri (scripts_directory_uri);
+       if (scripts_directory) {
+               remove_monitor_directory_changes (view,
+                                                 scripts_directory,
+                                                 G_CALLBACK (scripts_added_or_changed_callback));
                nautilus_directory_unref (scripts_directory);
-       } else {
-               g_warning ("Ignoring scripts directory, it may be a broken link\n");
        }
 
        if (nautilus_should_use_templates_directory ()) {
                templates_uri = nautilus_get_templates_directory_uri ();
                templates_directory = nautilus_directory_get_by_uri (templates_uri);
                g_free (templates_uri);
-               add_directory_to_templates_directory_list (view, templates_directory);
+               remove_monitor_directory_changes (view,
+                                                 templates_directory,
+                                                 G_CALLBACK (templates_added_or_changed_callback));
                nautilus_directory_unref (templates_directory);
        }
-       update_templates_directory (view);
-
-       view->details->sort_directories_first =
-               g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
-       view->details->show_hidden_files =
-               g_settings_get_boolean (gtk_filechooser_preferences, NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
-
-       g_signal_connect_object (nautilus_trash_monitor_get (), "trash-state-changed",
-                                G_CALLBACK (nautilus_view_trash_state_changed_callback), view, 0);
-
-       /* React to clipboard changes */
-       g_signal_connect_object (nautilus_clipboard_monitor_get (), "clipboard-changed",
-                                G_CALLBACK (clipboard_changed_callback), view, 0);
-
-       /* Register to menu provider extension signal managing menu updates */
-       g_signal_connect_object (nautilus_signaller_get_current (), "popup-menu-changed",
-                                G_CALLBACK (schedule_update_menus), view, G_CONNECT_SWAPPED);
-
-       gtk_widget_show (GTK_WIDGET (view));
-
-       g_signal_connect_swapped (nautilus_preferences,
-                                 "changed::" NAUTILUS_PREFERENCES_ENABLE_DELETE,
-                                 G_CALLBACK (schedule_update_menus), view);
-       g_signal_connect_swapped (nautilus_preferences,
-                                 "changed::" NAUTILUS_PREFERENCES_CLICK_POLICY,
-                                 G_CALLBACK (click_policy_changed_callback),
-                                 view);
-       g_signal_connect_swapped (nautilus_preferences,
-                                 "changed::" NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, 
-                                 G_CALLBACK (sort_directories_first_changed_callback), view);
-       g_signal_connect_swapped (gtk_filechooser_preferences,
-                                 "changed::" NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, 
-                                 G_CALLBACK (show_hidden_files_changed_callback), view);
-       g_signal_connect_swapped (gnome_lockdown_preferences,
-                                 "changed::" NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
-                                 G_CALLBACK (schedule_update_menus), view);
-
-       g_signal_connect_object (nautilus_file_undo_manager_get (), "undo-changed",
-                                G_CALLBACK (undo_manager_changed_cb), view, 0);
-
-       /* Accessibility */
-       atk_object = gtk_widget_get_accessible (GTK_WIDGET (view));
-       atk_object_set_name (atk_object, _("Content View"));
-       atk_object_set_description (atk_object, _("View of the current folder"));
-
-       nautilus_profile_end (NULL);
-}
-
-static void
-real_unmerge_menus (NautilusView *view)
-{
-       GtkUIManager *ui_manager;
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-       if (ui_manager == NULL) {
-               return;
-       }
-
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->dir_merge_id,
-                               &view->details->dir_action_group);
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->extensions_menu_merge_id,
-                               &view->details->extensions_menu_action_group);
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->open_with_merge_id,
-                               &view->details->open_with_action_group);
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->scripts_merge_id,
-                               &view->details->scripts_action_group);
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->templates_merge_id,
-                               &view->details->templates_action_group);
-}
-
-static void
-nautilus_view_destroy (GtkWidget *object)
-{
-       NautilusView *view;
-       GList *node, *next;
-
-       view = NAUTILUS_VIEW (object);
-
-       disconnect_model_handlers (view);
-
-       nautilus_view_unmerge_menus (view);
-       nautilus_view_stop_loading (view);
-
-       for (node = view->details->scripts_directory_list; node != NULL; node = next) {
-               next = node->next;
-               remove_directory_from_scripts_directory_list (view, node->data);
-       }
-
-       for (node = view->details->templates_directory_list; node != NULL; node = next) {
-               next = node->next;
-               remove_directory_from_templates_directory_list (view, node->data);
-       }
 
-       while (view->details->subdirectory_list != NULL) {
-               nautilus_view_remove_subdirectory (view,
-                                                  view->details->subdirectory_list->data);
-       }
-
-       remove_update_menus_timeout_callback (view);
+       remove_update_right_click_menus_timeout_callback (view);
        remove_update_status_idle_callback (view);
 
        if (view->details->display_selection_idle_id != 0) {
@@ -2789,7 +2376,7 @@ nautilus_view_finalize (GObject *object)
        view = NAUTILUS_VIEW (object);
 
        g_signal_handlers_disconnect_by_func (nautilus_preferences,
-                                             schedule_update_menus, view);
+                                             schedule_update_right_click_menus, view);
        g_signal_handlers_disconnect_by_func (nautilus_preferences,
                                              click_policy_changed_callback, view);
        g_signal_handlers_disconnect_by_func (nautilus_preferences,
@@ -2800,11 +2387,11 @@ nautilus_view_finalize (GObject *object)
                                              nautilus_view_display_selection_info, view);
 
        g_signal_handlers_disconnect_by_func (gnome_lockdown_preferences,
-                                             schedule_update_menus, view);
+                                             schedule_update_right_click_menus, view);
 
-       unschedule_pop_up_location_context_menu (view);
-       if (view->details->location_popup_event != NULL) {
-               gdk_event_free ((GdkEvent *) view->details->location_popup_event);
+       unschedule_pop_up_pathbar_right_click_menu (view);
+       if (view->details->pathbar_popup_event != NULL) {
+               gdk_event_free ((GdkEvent *) view->details->pathbar_popup_event);
        }
 
        g_hash_table_destroy (view->details->non_ready_files);
@@ -3042,7 +2629,7 @@ done_loading (NautilusView *view,
         * is no NautilusWindow any more.
         */
        if (window != NULL) {
-               schedule_update_menus (view);
+               schedule_update_right_click_menus (view);
                schedule_update_status (view);
                reset_update_interval (view);
 
@@ -3294,7 +2881,7 @@ copy_move_done_callback (GHashTable *debuting_files,
                                               G_CONNECT_AFTER);
                }
                /* Schedule menu update for undo items */
-               schedule_update_menus (directory_view);
+               schedule_update_right_click_menus (directory_view);
        }
 
        copy_move_done_data_free (copy_move_done_data);
@@ -3555,27 +3142,24 @@ display_selection_info_idle_callback (gpointer data)
 }
 
 static void
-remove_update_menus_timeout_callback (NautilusView *view) 
+remove_update_right_click_menus_timeout_callback (NautilusView *view) 
 {
-       if (view->details->update_menus_timeout_id != 0) {
-               g_source_remove (view->details->update_menus_timeout_id);
-               view->details->update_menus_timeout_id = 0;
+       if (view->details->update_right_click_menus_timeout_id != 0) {
+               g_source_remove (view->details->update_right_click_menus_timeout_id);
+               view->details->update_right_click_menus_timeout_id = 0;
        }
 }
 
 static void
-update_menus_if_pending (NautilusView *view)
+update_right_click_menus_if_pending (NautilusView *view)
 {
-       if (view->details->update_menus_timeout_id == 0) {
-               return;
-       }
+       remove_update_right_click_menus_timeout_callback (view);
 
-       remove_update_menus_timeout_callback (view);
-       nautilus_view_update_menus (view);
+       nautilus_view_update_right_click_menus(view);
 }
 
 static gboolean
-update_menus_timeout_callback (gpointer data)
+update_right_click_menus_timeout_callback (gpointer data)
 {
        NautilusView *view;
 
@@ -3583,8 +3167,8 @@ update_menus_timeout_callback (gpointer data)
 
        g_object_ref (G_OBJECT (view));
 
-       view->details->update_menus_timeout_id = 0;
-       nautilus_view_update_menus (view);
+       view->details->update_right_click_menus_timeout_id = 0;
+       nautilus_view_update_right_click_menus(view);
 
        g_object_unref (G_OBJECT (view));
 
@@ -3806,7 +3390,7 @@ files_changed_callback (NautilusDirectory *directory,
        /* A change in MIME type could affect the Open with menu, for
         * one thing, so we need to update menus when files change.
         */
-       schedule_update_menus (view);
+       schedule_update_right_click_menus (view);
 }
 
 static void
@@ -3921,19 +3505,6 @@ nautilus_view_get_loading (NautilusView *view)
        return view->details->loading;
 }
 
-GtkUIManager *
-nautilus_view_get_ui_manager (NautilusView  *view)
-{
-       NautilusWindow *window;
-
-       if (view->details->slot == NULL) {
-               return NULL;
-       }
-
-       window = nautilus_window_slot_get_window (view->details->slot);
-       return nautilus_window_get_ui_manager (window);
-}
-
 /**
  * nautilus_view_get_model:
  *
@@ -3960,20 +3531,6 @@ nautilus_view_get_copied_files_atom (NautilusView *view)
 }
 
 static void
-prepend_uri_one (gpointer data, gpointer callback_data)
-{
-       NautilusFile *file;
-       GList **result;
-       
-       g_assert (NAUTILUS_IS_FILE (data));
-       g_assert (callback_data != NULL);
-
-       result = (GList **) callback_data;
-       file = (NautilusFile *) data;
-       *result = g_list_prepend (*result, nautilus_file_get_uri (file));
-}
-
-static void
 offset_drop_points (GArray *relative_item_points,
                    int x_offset, int y_offset)
 {
@@ -3989,41 +3546,6 @@ offset_drop_points (GArray *relative_item_points,
        }
 }
 
-static void
-nautilus_view_create_links_for_files (NautilusView *view, GList *files,
-                                     GArray *relative_item_points)
-{
-       GList *uris;
-       char *dir_uri;
-       CopyMoveDoneData *copy_move_done_data;
-       g_assert (relative_item_points->len == 0
-                 || g_list_length (files) == relative_item_points->len);
-       
-        g_assert (NAUTILUS_IS_VIEW (view));
-        g_assert (files != NULL);
-
-       /* create a list of URIs */
-       uris = NULL;
-       g_list_foreach (files, prepend_uri_one, &uris);
-       uris = g_list_reverse (uris);
-
-        g_assert (g_list_length (uris) == g_list_length (files));
-
-       /* offset the drop locations a bit so that we don't pile
-        * up the icons on top of each other
-        */
-       offset_drop_points (relative_item_points,
-                           DUPLICATE_HORIZONTAL_ICON_OFFSET,
-                           DUPLICATE_VERTICAL_ICON_OFFSET);
-
-        copy_move_done_data = pre_copy_move (view);
-       dir_uri = nautilus_view_get_backing_uri (view);
-       nautilus_file_operations_copy_move (uris, relative_item_points, dir_uri, GDK_ACTION_LINK, 
-                                           GTK_WIDGET (view), copy_move_done_callback, copy_move_done_data);
-       g_free (dir_uri);
-       g_list_free_full (uris, g_free);
-}
-
 /* special_link_in_selection
  * 
  * Return TRUE if one of our special links is in the selection.
@@ -4095,7 +3617,6 @@ trash_or_delete_done_cb (GHashTable *debuting_uris,
 static void
 trash_or_delete_files (GtkWindow *parent_window,
                       const GList *files,
-                      gboolean delete_if_all_already_in_trash,
                       NautilusView *view)
 {
        GList *locations;
@@ -4162,19 +3683,6 @@ update_context_menu_position_from_event (NautilusView *view,
        }
 }
 
-/* handle the open command */
-
-static void
-open_one_in_new_window (gpointer data, gpointer callback_data)
-{
-       g_assert (NAUTILUS_IS_FILE (data));
-       g_assert (NAUTILUS_IS_VIEW (callback_data));
-
-       nautilus_view_activate_file (NAUTILUS_VIEW (callback_data),
-                                    NAUTILUS_FILE (data),
-                                    NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW);
-}
-
 NautilusFile *
 nautilus_view_get_directory_as_file (NautilusView *view)
 {
@@ -4183,470 +3691,6 @@ nautilus_view_get_directory_as_file (NautilusView *view)
        return view->details->directory_as_file; 
 }
 
-static void
-open_with_launch_application_callback (GtkAction *action,
-                                      gpointer callback_data)
-{
-       ApplicationLaunchParameters *launch_parameters;
-       
-       launch_parameters = (ApplicationLaunchParameters *) callback_data;
-       nautilus_launch_application 
-               (launch_parameters->application,
-                launch_parameters->files,
-                nautilus_view_get_containing_window (launch_parameters->directory_view));
-}
-
-static char *
-escape_action_path (const char *action_path)
-{
-       GString *s;
-
-       if (action_path == NULL) {
-               return NULL;
-       }
-       
-       s = g_string_sized_new (strlen (action_path) + 2);
-
-       while (*action_path != 0) {
-               switch (*action_path) {
-               case '\\':
-                       g_string_append (s, "\\\\");
-                       break;
-               case '&':
-                       g_string_append (s, "\\a");
-                       break;
-               case '"':
-                       g_string_append (s, "\\q");
-                       break;
-               default:
-                       g_string_append_c (s, *action_path);
-               }
-
-               action_path ++;
-       }
-       return g_string_free (s, FALSE);
-}
-
-
-static void
-add_submenu (GtkUIManager *ui_manager,
-            GtkActionGroup *action_group,
-            guint merge_id,
-            const char *parent_path,
-            const char *uri,
-            const char *label,
-            GdkPixbuf *pixbuf,
-            gboolean add_action)
-{
-       char *escaped_label;
-       char *action_name;
-       char *submenu_name;
-       char *escaped_submenu_name;
-       GtkAction *action;
-       
-       if (parent_path != NULL) {
-               action_name = nautilus_escape_action_name (uri, "submenu_");
-               submenu_name = g_path_get_basename (uri);
-               escaped_submenu_name = escape_action_path (submenu_name);
-               escaped_label = eel_str_double_underscores (label);
-
-               if (add_action) {
-                       action = gtk_action_new (action_name,
-                                                escaped_label,
-                                                NULL,
-                                                NULL);
-                       if (pixbuf != NULL) {
-                               gtk_action_set_gicon (action, G_ICON (pixbuf));
-                       }
-                       
-                       g_object_set (action, "hide-if-empty", FALSE, NULL);
-                       
-                       gtk_action_group_add_action (action_group,
-                                                    action);
-                       g_object_unref (action);
-               }
-
-               gtk_ui_manager_add_ui (ui_manager,
-                                      merge_id,
-                                      parent_path,
-                                      escaped_submenu_name,
-                                      action_name,
-                                      GTK_UI_MANAGER_MENU,
-                                      FALSE);
-               g_free (action_name);
-               g_free (escaped_label);
-               g_free (submenu_name);
-               g_free (escaped_submenu_name);
-       }
-}
-
-static void
-menu_item_show_image (GtkUIManager *ui_manager,
-                     const char   *parent_path,
-                     const char   *action_name)
-{
-       char *path;
-       GtkWidget *menuitem;
-
-       path = g_strdup_printf ("%s/%s", parent_path, action_name);
-       menuitem = gtk_ui_manager_get_widget (ui_manager,
-                                             path);
-       if (menuitem != NULL) {
-               gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem),
-                                                          TRUE);
-       }
-       g_free (path);
-}
-
-static void
-add_application_to_open_with_menu (NautilusView *view,
-                                  GAppInfo *application, 
-                                  GList *files,
-                                  int index,
-                                  const char *menu_placeholder,
-                                  const char *popup_placeholder,
-                                  const gboolean submenu)
-{
-       ApplicationLaunchParameters *launch_parameters;
-       char *tip;
-       char *label;
-       char *action_name;
-       char *escaped_app;
-       GtkAction *action;
-       GIcon *app_icon;
-       GtkUIManager *ui_manager;
-
-       launch_parameters = application_launch_parameters_new 
-               (application, files, view);
-       escaped_app = eel_str_double_underscores (g_app_info_get_name (application));
-       if (submenu)
-               label = g_strdup_printf ("%s", escaped_app);
-       else
-               label = g_strdup_printf (_("Open With %s"), escaped_app);
-
-       tip = g_strdup_printf (ngettext ("Use “%s” to open the selected item",
-                                        "Use “%s” to open the selected items",
-                                        g_list_length (files)),
-                              escaped_app);
-       g_free (escaped_app);
-
-       action_name = g_strdup_printf ("open_with_%d", index);
-       
-       action = gtk_action_new (action_name,
-                                label,
-                                tip,
-                                NULL);
-
-       app_icon = g_app_info_get_icon (application);
-       if (app_icon != NULL) {
-               g_object_ref (app_icon);
-       } else {
-               app_icon = g_themed_icon_new ("application-x-executable");
-       }
-
-       gtk_action_set_gicon (action, app_icon);
-       g_object_unref (app_icon);
-
-       g_signal_connect_data (action, "activate",
-                              G_CALLBACK (open_with_launch_application_callback),
-                              launch_parameters, 
-                              (GClosureNotify)application_launch_parameters_free, 0);
-
-       gtk_action_group_add_action (view->details->open_with_action_group,
-                                    action);
-       g_object_unref (action);
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-       gtk_ui_manager_add_ui (ui_manager,
-                              view->details->open_with_merge_id,
-                              popup_placeholder,
-                              action_name,
-                              action_name,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
-
-       menu_item_show_image (ui_manager, popup_placeholder, action_name);
-
-       g_free (action_name);
-       g_free (label);
-       g_free (tip);
-}
-
-static void
-get_x_content_async_callback (const char **content,
-                             gpointer user_data)
-{
-       NautilusView *view;
-
-       view = NAUTILUS_VIEW (user_data);
-
-       if (view->details->slot != NULL) {
-               schedule_update_menus (view);
-       }
-       g_object_unref (view);
-}
-
-static void
-add_x_content_apps (NautilusView *view, NautilusFile *file, GList **applications)
-{
-       GMount *mount;
-       char **x_content_types;
-       unsigned int n;
-
-       g_return_if_fail (applications != NULL);
-
-       mount = nautilus_file_get_mount (file);
-
-       if (mount == NULL) {
-               return;
-       }
-       
-       x_content_types = nautilus_get_cached_x_content_types_for_mount (mount);
-       if (x_content_types != NULL) {
-               for (n = 0; x_content_types[n] != NULL; n++) {
-                       char *x_content_type = x_content_types[n];
-                       GList *app_info_for_x_content_type;
-                       
-                       app_info_for_x_content_type = g_app_info_get_all_for_type (x_content_type);
-                       *applications = g_list_concat (*applications, app_info_for_x_content_type);
-               }
-               g_strfreev (x_content_types);
-       } else {
-               nautilus_get_x_content_types_for_mount_async (mount,
-                                                             get_x_content_async_callback,
-                                                             NULL,
-                                                             g_object_ref (view));
-               
-       }
-
-       g_object_unref (mount);
-}
-
-static void
-reset_open_with_menu (NautilusView *view, GList *selection)
-{
-       GList *applications, *node;
-       NautilusFile *file;
-       gboolean submenu_visible, filter_default;
-       int num_applications;
-       int index;
-       gboolean other_applications_visible;
-       gboolean open_with_chooser_visible;
-       GtkUIManager *ui_manager;
-       GtkAction *action;
-       GAppInfo *default_app;
-
-       /* Clear any previous inserted items in the applications and viewers placeholders */
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->open_with_merge_id,
-                               &view->details->open_with_action_group);
-       
-       nautilus_ui_prepare_merge_ui (ui_manager,
-                                     "OpenWithGroup",
-                                     &view->details->open_with_merge_id,
-                                     &view->details->open_with_action_group);
-
-       other_applications_visible = (selection != NULL);
-       filter_default = (selection != NULL);
-
-       for (node = selection; node != NULL; node = node->next) {
-
-               file = NAUTILUS_FILE (node->data);
-
-               other_applications_visible &= (!nautilus_mime_file_opens_in_view (file) &&
-                                              !nautilus_file_is_nautilus_link (file));
-       }
-
-       default_app = NULL;
-       if (filter_default) {
-               default_app = nautilus_mime_get_default_application_for_files (selection);
-       }
-
-       applications = NULL;
-       if (other_applications_visible) {
-               applications = nautilus_mime_get_applications_for_files (selection);
-       }
-
-       if (g_list_length (selection) == 1) {
-               add_x_content_apps (view, NAUTILUS_FILE (selection->data), &applications);
-       }
-
-
-       num_applications = g_list_length (applications);
-
-       submenu_visible = (num_applications > 1);
-
-       for (node = applications, index = 0; node != NULL; node = node->next, index++) {
-               GAppInfo *application;
-               char *menu_path;
-               char *popup_path;
-               
-               application = node->data;
-
-               if (default_app != NULL && g_app_info_equal (default_app, application)) {
-                       continue;
-               }
-
-               if (submenu_visible) {
-                       menu_path = NAUTILUS_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER;
-                       popup_path = NAUTILUS_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER;
-               } else {
-                       menu_path = NAUTILUS_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER;
-                       popup_path = NAUTILUS_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER;
-               }
-
-               gtk_ui_manager_add_ui (nautilus_view_get_ui_manager (view),
-                                      view->details->open_with_merge_id,
-                                      menu_path,
-                                      "separator",
-                                      NULL,
-                                      GTK_UI_MANAGER_SEPARATOR,
-                                      FALSE);
-                                      
-               add_application_to_open_with_menu (view, 
-                                                  node->data, 
-                                                  selection, 
-                                                  index, 
-                                                  menu_path, popup_path, submenu_visible);
-       }
-       g_list_free_full (applications, g_object_unref);
-       if (default_app != NULL) {
-               g_object_unref (default_app);
-       }
-
-       open_with_chooser_visible = other_applications_visible &&
-               g_list_length (selection) == 1;
-
-       if (submenu_visible) {
-               action = gtk_action_group_get_action (view->details->dir_action_group,
-                                                     NAUTILUS_ACTION_OTHER_APPLICATION1);
-               gtk_action_set_visible (action, open_with_chooser_visible);
-               action = gtk_action_group_get_action (view->details->dir_action_group,
-                                                     NAUTILUS_ACTION_OTHER_APPLICATION2);
-               gtk_action_set_visible (action, FALSE);
-       } else {
-               action = gtk_action_group_get_action (view->details->dir_action_group,
-                                                     NAUTILUS_ACTION_OTHER_APPLICATION1);
-               gtk_action_set_visible (action, FALSE);
-               action = gtk_action_group_get_action (view->details->dir_action_group,
-                                                     NAUTILUS_ACTION_OTHER_APPLICATION2);
-               gtk_action_set_visible (action, open_with_chooser_visible);
-       }
-}
-
-static GList *
-get_all_extension_menu_items (GtkWidget *window,
-                             GList *selection)
-{
-       GList *items;
-       GList *providers;
-       GList *l;
-       
-       providers = nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_MENU_PROVIDER);
-       items = NULL;
-
-       for (l = providers; l != NULL; l = l->next) {
-               NautilusMenuProvider *provider;
-               GList *file_items;
-               
-               provider = NAUTILUS_MENU_PROVIDER (l->data);
-               file_items = nautilus_menu_provider_get_file_items (provider,
-                                                                   window,
-                                                                   selection);
-               items = g_list_concat (items, file_items);              
-       }
-
-       nautilus_module_extension_list_free (providers);
-
-       return items;
-}
-
-typedef struct 
-{
-       NautilusMenuItem *item;
-       NautilusView *view;
-       GList *selection;
-       GtkAction *action;
-} ExtensionActionCallbackData;
-
-
-static void
-extension_action_callback_data_free (ExtensionActionCallbackData *data)
-{
-       g_object_unref (data->item);
-       nautilus_file_list_free (data->selection);
-       
-       g_free (data);
-}
-
-static gboolean
-search_in_menu_items (GList* items, const char *item_name)
-{
-       GList* list;
-       
-       for (list = items; list != NULL; list = list->next) {
-               NautilusMenu* menu;
-               char *name;
-               
-               g_object_get (list->data, "name", &name, NULL);
-               if (strcmp (name, item_name) == 0) {
-                       g_free (name);
-                       return TRUE;
-               }
-               g_free (name);
-
-               menu = NULL;
-               g_object_get (list->data, "menu", &menu, NULL);
-               if (menu != NULL) {
-                       gboolean ret;
-                       GList* submenus;
-
-                       submenus = nautilus_menu_get_items (menu);
-                       ret = search_in_menu_items (submenus, item_name);
-                       nautilus_menu_item_list_free (submenus);
-                       g_object_unref (menu);
-                       if (ret) {
-                               return TRUE;
-                       }
-               }
-       }
-       return FALSE;
-}
-
-static void
-extension_action_callback (GtkAction *action,
-                          gpointer callback_data)
-{
-       ExtensionActionCallbackData *data;
-       char *item_name;
-       gboolean is_valid;
-       GList *l;
-       GList *items;
-
-       data = callback_data;
-
-       /* Make sure the selected menu item is valid for the final sniffed
-        * mime type */
-       g_object_get (data->item, "name", &item_name, NULL);
-       items = get_all_extension_menu_items (gtk_widget_get_toplevel (GTK_WIDGET (data->view)), 
-                                             data->selection);
-       
-       is_valid = search_in_menu_items (items, item_name);
-
-       for (l = items; l != NULL; l = l->next) {
-               g_object_unref (l->data);
-       }
-       g_list_free (items);
-       
-       g_free (item_name);
-
-       if (is_valid) {
-               nautilus_menu_item_activate (data->item);
-       }
-}
-
 static GdkPixbuf *
 get_menu_icon_for_file (NautilusFile *file,
                        GtkWidget    *widget)
@@ -4665,153 +3709,6 @@ get_menu_icon_for_file (NautilusFile *file,
        return pixbuf;
 }
 
-static GtkAction *
-add_extension_action_for_files (NautilusView *view, 
-                               NautilusMenuItem *item,
-                               GList *files)
-{
-       char *name, *label, *tip, *icon;
-       gboolean sensitive, priority;
-       GtkAction *action;
-       GdkPixbuf *pixbuf;
-       ExtensionActionCallbackData *data;
-       
-       g_object_get (G_OBJECT (item), 
-                     "name", &name, "label", &label, 
-                     "tip", &tip, "icon", &icon,
-                     "sensitive", &sensitive,
-                     "priority", &priority,
-                     NULL);
-
-       action = gtk_action_new (name,
-                                label,
-                                tip,
-                                NULL);
-
-       if (icon != NULL) {
-               pixbuf = nautilus_ui_get_menu_icon (icon, GTK_WIDGET (view));
-               if (pixbuf != NULL) {
-                       gtk_action_set_gicon (action, G_ICON (pixbuf));
-                       g_object_unref (pixbuf);
-               }
-       }
-
-       gtk_action_set_sensitive (action, sensitive);
-       g_object_set (action, "is-important", priority, NULL);
-
-       data = g_new0 (ExtensionActionCallbackData, 1);
-       data->item = g_object_ref (item);
-       data->view = view;
-       data->selection = nautilus_file_list_copy (files);
-       data->action = action;
-
-       g_signal_connect_data (action, "activate",
-                              G_CALLBACK (extension_action_callback),
-                              data,
-                              (GClosureNotify)extension_action_callback_data_free, 0);
-               
-       gtk_action_group_add_action (view->details->extensions_menu_action_group,
-                                    GTK_ACTION (action));
-       g_object_unref (action);
-       
-       g_free (name);
-       g_free (label);
-       g_free (tip);
-       g_free (icon);
-
-       return action;
-}
-
-static void
-add_extension_menu_items (NautilusView *view,
-                         GList *files,
-                         GList *menu_items,
-                         const char *subdirectory)
-{
-       GtkUIManager *ui_manager;
-       GList *l;
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-       
-       for (l = menu_items; l; l = l->next) {
-               NautilusMenuItem *item;
-               NautilusMenu *menu;
-               GtkAction *action;
-               char *path;
-               
-               item = NAUTILUS_MENU_ITEM (l->data);
-               
-               g_object_get (item, "menu", &menu, NULL);
-               
-               action = add_extension_action_for_files (view, item, files);
-               
-               path = g_build_path ("/", NAUTILUS_VIEW_POPUP_PATH_EXTENSION_ACTIONS, subdirectory, NULL);
-               gtk_ui_manager_add_ui (ui_manager,
-                                      view->details->extensions_menu_merge_id,
-                                      path,
-                                      gtk_action_get_name (action),
-                                      gtk_action_get_name (action),
-                                      (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM,
-                                      FALSE);
-               g_free (path);
-
-               path = g_build_path ("/", NAUTILUS_VIEW_MENU_PATH_EXTENSION_ACTIONS_PLACEHOLDER, 
subdirectory, NULL);
-               gtk_ui_manager_add_ui (ui_manager,
-                                      view->details->extensions_menu_merge_id,
-                                      path,
-                                      gtk_action_get_name (action),
-                                      gtk_action_get_name (action),
-                                      (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM,
-                                      FALSE);
-               g_free (path);
-
-               /* recursively fill the menu */                
-               if (menu != NULL) {
-                       char *subdir;
-                       GList *children;
-                       
-                       children = nautilus_menu_get_items (menu);
-                       
-                       subdir = g_build_path ("/", subdirectory, gtk_action_get_name (action), NULL);
-                       add_extension_menu_items (view,
-                                                 files,
-                                                 children,
-                                                 subdir);
-
-                       nautilus_menu_item_list_free (children);
-                       g_free (subdir);
-               }                       
-       }
-}
-
-static void
-reset_extension_actions_menu (NautilusView *view, GList *selection)
-{
-       GList *items;
-       GtkUIManager *ui_manager;
-       
-       /* Clear any previous inserted items in the extension actions placeholder */
-       ui_manager = nautilus_view_get_ui_manager (view);
-
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->extensions_menu_merge_id,
-                               &view->details->extensions_menu_action_group);
-       
-       nautilus_ui_prepare_merge_ui (ui_manager,
-                                     "DirExtensionsMenuGroup",
-                                     &view->details->extensions_menu_merge_id,
-                                     &view->details->extensions_menu_action_group);
-
-       items = get_all_extension_menu_items (gtk_widget_get_toplevel (GTK_WIDGET (view)), 
-                                             selection);
-       if (items != NULL) {
-               add_extension_menu_items (view, selection, items, "");
-
-               g_list_foreach (items, (GFunc) g_object_unref, NULL);
-               g_list_free (items);
-       }
-}
-
 static char *
 change_to_view_directory (NautilusView *view)
 {
@@ -5005,7 +3902,9 @@ unset_script_environment_variables (void)
 }
 
 static void
-run_script_callback (GtkAction *action, gpointer callback_data)
+run_script (GSimpleAction *action,      
+            GVariant      *state,       
+            gpointer       user_data)   
 {
        ScriptLaunchParameters *launch_parameters;
        GdkScreen *screen;
@@ -5016,7 +3915,7 @@ run_script_callback (GtkAction *action, gpointer callback_data)
        char *old_working_dir;
        char **parameters;
        
-       launch_parameters = (ScriptLaunchParameters *) callback_data;
+       launch_parameters = (ScriptLaunchParameters *) user_data;
 
        file_uri = nautilus_file_get_uri (launch_parameters->file);
        local_file_path = g_filename_from_uri (file_uri, NULL, NULL);
@@ -5036,7 +3935,7 @@ run_script_callback (GtkAction *action, gpointer callback_data)
 
        screen = gtk_widget_get_screen (GTK_WIDGET (launch_parameters->directory_view));
 
-       DEBUG ("run_script_callback, script_path=“%s” (omitting script parameters)",
+       DEBUG ("run_script, script_path=“%s” (omitting script parameters)",
               local_file_path);
 
        nautilus_launch_application_from_command_array (screen, quoted_path, FALSE,
@@ -5051,513 +3950,191 @@ run_script_callback (GtkAction *action, gpointer callback_data)
 }
 
 static void
-add_script_to_scripts_menus (NautilusView *directory_view,
-                            NautilusFile *file,
-                            const char *menu_path,
-                            const char *popup_path, 
-                            const char *popup_bg_path)
+add_script_to_scripts_menus (NautilusView *view,
+                            NautilusFile *file)
 {
+       gchar *name;
+       GdkPixbuf *mimetype_icon;
+       gchar *action_name, *detailed_action_name;
        ScriptLaunchParameters *launch_parameters;
-       char *tip;
-       char *name;
-       char *uri;
-       char *action_name;
-       char *escaped_label;
-       GdkPixbuf *pixbuf;
-       GtkUIManager *ui_manager;
-       GtkAction *action;
+       GAction *action;
+       GMenuItem *menu_item;
 
-       name = nautilus_file_get_display_name (file);
-       uri = nautilus_file_get_uri (file);
-       tip = g_strdup_printf (_("Run “%s” on any selected items"), name);
+       launch_parameters = script_launch_parameters_new (file, view);
 
-       launch_parameters = script_launch_parameters_new (file, directory_view);
-
-       action_name = nautilus_escape_action_name (uri, "script_");
-       escaped_label = eel_str_double_underscores (name);
-
-       action = gtk_action_new (action_name,
-                                escaped_label,
-                                tip,
-                                NULL);
-
-       pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view));
-       if (pixbuf != NULL) {
-               gtk_action_set_gicon (action, G_ICON (pixbuf));
-               g_object_unref (pixbuf);
-       }
+       name = nautilus_file_get_display_name (file);
+       action_name = nautilus_escape_action_name (name, "script_");
 
+       action = G_ACTION (g_simple_action_new (action_name, NULL));
+       
        g_signal_connect_data (action, "activate",
-                              G_CALLBACK (run_script_callback),
+                              G_CALLBACK (run_script),
                               launch_parameters,
                               (GClosureNotify)script_launch_parameters_free, 0);
 
-       gtk_action_group_add_action_with_accel (directory_view->details->scripts_action_group,
-                                               action, NULL);
+       g_action_map_add_action (G_ACTION_MAP (view->details->view_action_group), action);
+       
        g_object_unref (action);
+       
+       detailed_action_name =  g_strconcat ("view.", action_name, NULL);
+       menu_item = g_menu_item_new (name, detailed_action_name);
 
-       ui_manager = nautilus_view_get_ui_manager (directory_view);
-
-       gtk_ui_manager_add_ui (ui_manager,
-                              directory_view->details->scripts_merge_id,
-                              menu_path,
-                              action_name,
-                              action_name,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
-       gtk_ui_manager_add_ui (ui_manager,
-                              directory_view->details->scripts_merge_id,
-                              popup_path,
-                              action_name,
-                              action_name,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
-       gtk_ui_manager_add_ui (ui_manager,
-                              directory_view->details->scripts_merge_id,
-                              popup_bg_path,
-                              action_name,
-                              action_name,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
-
-       menu_item_show_image (ui_manager, menu_path, action_name);
-       menu_item_show_image (ui_manager, popup_path, action_name);
-       menu_item_show_image (ui_manager, popup_bg_path, action_name);
+       mimetype_icon = get_menu_icon_for_file (file, GTK_WIDGET (view));
+       if (mimetype_icon != NULL) {
+               g_menu_item_set_icon (menu_item, G_ICON (mimetype_icon));
+               g_object_unref (mimetype_icon);
+       }
 
+       nautilus_gmenu_add_item_in_submodel (view->details->selection_menu,
+                                           menu_item,
+                                           "scripts-submenu",
+                                           TRUE);
        g_free (name);
-       g_free (uri);
-       g_free (tip);
        g_free (action_name);
-       g_free (escaped_label);
+       g_free (detailed_action_name);
 }
 
 static void
-add_submenu_to_directory_menus (NautilusView *directory_view,
-                               GtkActionGroup *action_group,
-                               guint merge_id,
-                               NautilusFile *file,
-                               const char *menu_path,
-                               const char *popup_path,
-                               const char *popup_bg_path)
-{
-       char *name;
-       GdkPixbuf *pixbuf;
-       char *uri;
-       GtkUIManager *ui_manager;
-
-       ui_manager = nautilus_view_get_ui_manager (directory_view);
-       uri = nautilus_file_get_uri (file);
-       name = nautilus_file_get_display_name (file);
-       pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view));
-       add_submenu (ui_manager, action_group, merge_id, menu_path, uri, name, pixbuf, TRUE);
-       add_submenu (ui_manager, action_group, merge_id, popup_path, uri, name, pixbuf, FALSE);
-       add_submenu (ui_manager, action_group, merge_id, popup_bg_path, uri, name, pixbuf, FALSE);
-       if (pixbuf) {
-               g_object_unref (pixbuf);
-       }
-       g_free (name);
-       g_free (uri);
-}
-
-static gboolean
-directory_belongs_in_scripts_menu (const char *uri)
-{
-       int num_levels;
-       int i;
-
-       if (!g_str_has_prefix (uri, scripts_directory_uri)) {
-               return FALSE;
-       }
-
-       num_levels = 0;
-       for (i = scripts_directory_uri_length; uri[i] != '\0'; i++) {
-               if (uri[i] == '/') {
-                       num_levels++;
-               }
-       }
-
-       if (num_levels > MAX_MENU_LEVELS) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static gboolean
-update_directory_in_scripts_menu (NautilusView *view, NautilusDirectory *directory)
+update_scripts_menu (NautilusView *view)
 {
-       char *menu_path, *popup_path, *popup_bg_path;
        GList *file_list, *filtered, *node;
-       gboolean any_scripts;
        NautilusFile *file;
-       NautilusDirectory *dir;
-       char *uri;
-       char *escaped_path;
-       
-       uri = nautilus_directory_get_uri (directory);
-       escaped_path = escape_action_path (uri + scripts_directory_uri_length);
-       g_free (uri);
-       menu_path = g_strconcat (NAUTILUS_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER,
-                                escaped_path,
-                                NULL);
-       popup_path = g_strconcat (NAUTILUS_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER,
-                                 escaped_path,
-                                 NULL);
-       popup_bg_path = g_strconcat (NAUTILUS_VIEW_POPUP_PATH_BACKGROUND_SCRIPTS_PLACEHOLDER,
-                                    escaped_path,
-                                    NULL);
-       g_free (escaped_path);
+       NautilusDirectory *scripts_directory;
+       gint num;
+
+       scripts_directory = nautilus_directory_get_by_uri (scripts_directory_uri);
 
-       file_list = nautilus_directory_get_file_list (directory);
+       file_list = nautilus_directory_get_file_list (scripts_directory);
        filtered = nautilus_file_list_filter_hidden (file_list, FALSE);
        nautilus_file_list_free (file_list);
 
        file_list = nautilus_file_list_sort_by_display_name (filtered);
 
-       any_scripts = FALSE;
-       for (node = file_list; node != NULL; node = node->next) {
+       view->details->scripts_present = FALSE;
+       num = 0;
+       for (node = file_list; num < MENU_ITEMS_LIMIT && node != NULL; node = node->next, num++) {
                file = node->data;
 
                if (nautilus_file_is_launchable (file)) {
-                       add_script_to_scripts_menus (view, file, menu_path, popup_path, popup_bg_path);
-                       any_scripts = TRUE;
-               } else if (nautilus_file_is_directory (file)) {
-                       uri = nautilus_file_get_uri (file);
-                       if (directory_belongs_in_scripts_menu (uri)) {
-                               dir = nautilus_directory_get_by_uri (uri);
-                               add_directory_to_scripts_directory_list (view, dir);
-                               nautilus_directory_unref (dir);
-
-                               add_submenu_to_directory_menus (view,
-                                                               view->details->scripts_action_group,
-                                                               view->details->scripts_merge_id,
-                                                               file, menu_path, popup_path, popup_bg_path);
-
-                               any_scripts = TRUE;
-                       }
-                       g_free (uri);
+                       add_script_to_scripts_menus (view, file);
+                       view->details->scripts_present = TRUE;
                }
        }
 
        nautilus_file_list_free (file_list);
-
-       g_free (popup_path);
-       g_free (popup_bg_path);
-       g_free (menu_path);
-
-       return any_scripts;
 }
 
 static void
-update_scripts_menu (NautilusView *view)
+create_template (GSimpleAction *action,
+                 GVariant      *state,
+                 gpointer       user_data)
 {
-       gboolean any_scripts;
-       GList *sorted_copy, *node;
-       NautilusDirectory *directory;
-       char *uri;
-       GtkUIManager *ui_manager;
-       GtkAction *action;
-
-       /* There is a race condition here.  If we don't mark the scripts menu as
-          valid before we begin our task then we can lose script menu updates that
-          occur before we finish. */
-       view->details->scripts_invalid = FALSE;
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->scripts_merge_id,
-                               &view->details->scripts_action_group);
-       
-       nautilus_ui_prepare_merge_ui (ui_manager,
-                                     "ScriptsGroup",
-                                     &view->details->scripts_merge_id,
-                                     &view->details->scripts_action_group);
-
-       /* As we walk through the directories, remove any that no longer belong. */
-       any_scripts = FALSE;
-       sorted_copy = nautilus_directory_list_sort_by_uri
-               (nautilus_directory_list_copy (view->details->scripts_directory_list));
-       for (node = sorted_copy; node != NULL; node = node->next) {
-               directory = node->data;
-
-               uri = nautilus_directory_get_uri (directory);
-               if (!directory_belongs_in_scripts_menu (uri)) {
-                       remove_directory_from_scripts_directory_list (view, directory);
-               } else if (update_directory_in_scripts_menu (view, directory)) {
-                       any_scripts = TRUE;
-               }
-               g_free (uri);
-       }
-       nautilus_directory_list_free (sorted_copy);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group, NAUTILUS_ACTION_SCRIPTS);
-       gtk_action_set_visible (action, any_scripts);
-}
 
-static void
-create_template_callback (GtkAction *action, gpointer callback_data)
-{
        CreateTemplateParameters *parameters;
 
-       parameters = callback_data;
+       parameters = user_data;
        
        nautilus_view_new_file (parameters->directory_view, NULL, parameters->file);
 }
 
 static void
-add_template_to_templates_menus (NautilusView *directory_view,
-                                NautilusFile *file,
-                                const char *menu_path,
-                                const char *popup_bg_path)
+add_template_to_templates_menus (NautilusView *view,
+                                NautilusFile *file)
 {
-       char *tmp, *tip, *uri, *name;
+       char *tmp, *uri, *name;
        char *escaped_label;
-       GdkPixbuf *pixbuf;
-       char *action_name;
+       GdkPixbuf *mimetype_icon;
+       gchar *action_name, *detailed_action_name;
        CreateTemplateParameters *parameters;
-       GtkUIManager *ui_manager;
-       GtkAction *action;
+       GAction *action;
+       GMenuItem *menu_item;
 
        tmp = nautilus_file_get_display_name (file);
        name = eel_filename_strip_extension (tmp);
        g_free (tmp);
 
        uri = nautilus_file_get_uri (file);
-       tip = g_strdup_printf (_("Create a new document from template “%s”"), name);
 
-       action_name = nautilus_escape_action_name (uri, "template_");
+       action_name = nautilus_escape_action_name (name, "template_");
        escaped_label = eel_str_double_underscores (name);
        
-       parameters = create_template_parameters_new (file, directory_view);
+       parameters = create_template_parameters_new (file, view);
 
-       action = gtk_action_new (action_name,
-                                escaped_label,
-                                tip,
-                                NULL);
+       action = G_ACTION (g_simple_action_new (action_name, NULL));
        
-       pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view));
-       if (pixbuf != NULL) {
-               gtk_action_set_gicon (action, G_ICON (pixbuf));
-               g_object_unref (pixbuf);
-       }
-
        g_signal_connect_data (action, "activate",
-                              G_CALLBACK (create_template_callback),
+                              G_CALLBACK (create_template),
                               parameters, 
                               (GClosureNotify)create_templates_parameters_free, 0);
+
+       g_action_map_add_action (G_ACTION_MAP (view->details->view_action_group), action);
        
-       gtk_action_group_add_action (directory_view->details->templates_action_group,
-                                    action);
        g_object_unref (action);
-
-       ui_manager = nautilus_view_get_ui_manager (directory_view);
-
-       gtk_ui_manager_add_ui (ui_manager,
-                              directory_view->details->templates_merge_id,
-                              menu_path,
-                              action_name,
-                              action_name,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
        
-       gtk_ui_manager_add_ui (ui_manager,
-                              directory_view->details->templates_merge_id,
-                              popup_bg_path,
-                              action_name,
-                              action_name,
-                              GTK_UI_MANAGER_MENUITEM,
-                              FALSE);
+       detailed_action_name =  g_strconcat ("view.", action_name, NULL);
+       menu_item = g_menu_item_new (name, detailed_action_name);
 
-       menu_item_show_image (ui_manager, menu_path, action_name);
-       menu_item_show_image (ui_manager, popup_bg_path, action_name);
+       mimetype_icon = get_menu_icon_for_file (file, GTK_WIDGET (view));
+       if (mimetype_icon != NULL) {
+               g_menu_item_set_icon (menu_item, G_ICON (mimetype_icon));
+               g_object_unref (mimetype_icon);
+       }
+
+       nautilus_gmenu_add_item_in_submodel (view->details->background_menu,
+                                            menu_item,
+                                            "templates-submenu",
+                                            FALSE);
 
        g_free (escaped_label);
        g_free (name);
-       g_free (tip);
        g_free (uri);
        g_free (action_name);
+       g_free (detailed_action_name);
 }
 
 static void
-update_templates_directory (NautilusView *view)
-{
-       NautilusDirectory *templates_directory;
-       GList *node, *next;
-       char *templates_uri;
-
-       for (node = view->details->templates_directory_list; node != NULL; node = next) {
-               next = node->next;
-               remove_directory_from_templates_directory_list (view, node->data);
-       }
-       
-       if (nautilus_should_use_templates_directory ()) {
-               templates_uri = nautilus_get_templates_directory_uri ();
-               templates_directory = nautilus_directory_get_by_uri (templates_uri);
-               g_free (templates_uri);
-               add_directory_to_templates_directory_list (view, templates_directory);
-               nautilus_directory_unref (templates_directory);
-       }
-}
-
-static gboolean
-directory_belongs_in_templates_menu (const char *templates_directory_uri,
-                                    const char *uri)
-{
-       int num_levels;
-       int i;
-
-       if (templates_directory_uri == NULL) {
-               return FALSE;
-       }
-       
-       if (!g_str_has_prefix (uri, templates_directory_uri)) {
-               return FALSE;
-       }
-
-       num_levels = 0;
-       for (i = strlen (templates_directory_uri); uri[i] != '\0'; i++) {
-               if (uri[i] == '/') {
-                       num_levels++;
-               }
-       }
-
-       if (num_levels > MAX_MENU_LEVELS) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static gboolean
-update_directory_in_templates_menu (NautilusView *view,
-                                   const char *templates_directory_uri,
-                                   NautilusDirectory *directory)
+update_templates_menu (NautilusView *view)
 {
-       char *menu_path, *popup_bg_path;
        GList *file_list, *filtered, *node;
-       gboolean any_templates;
        NautilusFile *file;
-       NautilusDirectory *dir;
-       char *escaped_path;
-       char *uri;
-       int num;
+       gint num;
+       NautilusDirectory *templates_directory;
+       gchar *templates_directory_uri;
 
-       /* We know this directory belongs to the template dir, so it must exist */
-       g_assert (templates_directory_uri);
-       
-       uri = nautilus_directory_get_uri (directory);
-       escaped_path = escape_action_path (uri + strlen (templates_directory_uri));
-       g_free (uri);
-       menu_path = g_strconcat (NAUTILUS_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER,
-                                escaped_path,
-                                NULL);
-       popup_bg_path = g_strconcat (NAUTILUS_VIEW_POPUP_PATH_BACKGROUND_NEW_DOCUMENTS_PLACEHOLDER,
-                                    escaped_path,
-                                    NULL);
-       g_free (escaped_path);
+       if (!nautilus_should_use_templates_directory ())
+               return;
 
-       file_list = nautilus_directory_get_file_list (directory);
+       templates_directory_uri = nautilus_get_templates_directory_uri ();
+       templates_directory = nautilus_directory_get_by_uri (templates_directory_uri);
+       g_free (templates_directory_uri);
+
+       file_list = nautilus_directory_get_file_list (templates_directory);
        filtered = nautilus_file_list_filter_hidden (file_list, FALSE);
        nautilus_file_list_free (file_list);
 
        file_list = nautilus_file_list_sort_by_display_name (filtered);
 
+       view->details->templates_present = FALSE;
        num = 0;
-       any_templates = FALSE;
-       for (node = file_list; num < TEMPLATE_LIMIT && node != NULL; node = node->next, num++) {
+       for (node = file_list; num < MENU_ITEMS_LIMIT && node != NULL; node = node->next, num++) {
                file = node->data;
 
-               if (nautilus_file_is_directory (file)) {
-                       uri = nautilus_file_get_uri (file);
-                       if (directory_belongs_in_templates_menu (templates_directory_uri, uri)) {
-                               dir = nautilus_directory_get_by_uri (uri);
-                               add_directory_to_templates_directory_list (view, dir);
-                               nautilus_directory_unref (dir);
-
-                               add_submenu_to_directory_menus (view,
-                                                               view->details->templates_action_group,
-                                                               view->details->templates_merge_id,
-                                                               file, menu_path, NULL, popup_bg_path);
-
-                               any_templates = TRUE;
-                       }
-                       g_free (uri);
-               } else if (nautilus_file_can_read (file)) {
-                       add_template_to_templates_menus (view, file, menu_path, popup_bg_path);
-                       any_templates = TRUE;
+               if (nautilus_file_can_read (file) &&
+                   !nautilus_file_is_directory (file)) {
+                       add_template_to_templates_menus (view, file);
+                       view->details->templates_present = TRUE;
                }
        }
 
        nautilus_file_list_free (file_list);
-
-       g_free (popup_bg_path);
-       g_free (menu_path);
-
-       return any_templates;
 }
 
 
-
 static void
-update_templates_menu (NautilusView *view)
+action_open_scripts_folder (GSimpleAction *action,    
+                           GVariant      *state,     
+                            gpointer       user_data)
 {
-       gboolean any_templates;
-       GList *sorted_copy, *node;
-       NautilusDirectory *directory;
-       GtkUIManager *ui_manager;
-       char *uri;
-       char *templates_directory_uri;
-
-       if (nautilus_should_use_templates_directory ()) {
-               templates_directory_uri = nautilus_get_templates_directory_uri ();
-       } else {
-               templates_directory_uri = NULL;
-       }
-
-       /* There is a race condition here.  If we don't mark the scripts menu as
-          valid before we begin our task then we can lose template menu updates that
-          occur before we finish. */
-       view->details->templates_invalid = FALSE;
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-       nautilus_ui_unmerge_ui (ui_manager,
-                               &view->details->templates_merge_id,
-                               &view->details->templates_action_group);
-
-       nautilus_ui_prepare_merge_ui (ui_manager,
-                                     "TemplatesGroup",
-                                     &view->details->templates_merge_id,
-                                     &view->details->templates_action_group);
-
-       /* As we walk through the directories, remove any that no longer belong. */
-       any_templates = FALSE;
-       sorted_copy = nautilus_directory_list_sort_by_uri
-               (nautilus_directory_list_copy (view->details->templates_directory_list));
-       for (node = sorted_copy; node != NULL; node = node->next) {
-               directory = node->data;
-
-               uri = nautilus_directory_get_uri (directory);
-               if (!directory_belongs_in_templates_menu (templates_directory_uri, uri)) {
-                       remove_directory_from_templates_directory_list (view, directory);
-               } else if (update_directory_in_templates_menu (view,
-                                                              templates_directory_uri,
-                                                              directory)) {
-                       any_templates = TRUE;
-               }
-               g_free (uri);
-       }
-       nautilus_directory_list_free (sorted_copy);
-
-       view->details->templates_present = any_templates;
-
-       g_free (templates_directory_uri);
-}
-
-
-static void
-action_open_scripts_folder_callback (GtkAction *action, 
-                                    gpointer callback_data)
-{      
        NautilusView *view;
        static GFile *location = NULL;
 
@@ -5565,24 +4142,10 @@ action_open_scripts_folder_callback (GtkAction *action,
                location = g_file_new_for_uri (scripts_directory_uri);
        }
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
        nautilus_window_slot_open_location (view->details->slot, location, 0);
 }
 
-static GtkMenu *
-create_popup_menu (NautilusView *view, const char *popup_path)
-{
-       GtkWidget *menu;
-       
-       menu = gtk_ui_manager_get_widget (nautilus_view_get_ui_manager (view),
-                                         popup_path);
-       gtk_menu_set_screen (GTK_MENU (menu),
-                            gtk_widget_get_screen (GTK_WIDGET (view)));
-       gtk_widget_show (GTK_WIDGET (menu));
-
-       return GTK_MENU (menu);
-}
-
 typedef struct _CopyCallbackData {
        NautilusView   *view;
        GtkFileChooser *chooser;
@@ -5999,13 +4562,14 @@ copy_or_cut_files (NautilusView *view,
 }
 
 static void
-action_copy_files_callback (GtkAction *action,
-                           gpointer callback_data)
+action_copy (GSimpleAction *action,
+            GVariant      *state,
+            gpointer       user_data)
 {
        NautilusView *view;
        GList *selection;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
 
        selection = nautilus_view_get_selection_for_file_transfer (view);
        copy_or_cut_files (view, selection, FALSE);
@@ -6013,13 +4577,14 @@ action_copy_files_callback (GtkAction *action,
 }
 
 static void
-action_cut_files_callback (GtkAction *action,
-                          gpointer callback_data)
+action_cut (GSimpleAction *action,
+           GVariant      *state,
+           gpointer       user_data)
 {
        NautilusView *view;
        GList *selection;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
 
        selection = nautilus_view_get_selection_for_file_transfer (view);
        copy_or_cut_files (view, selection, TRUE);
@@ -6027,72 +4592,27 @@ action_cut_files_callback (GtkAction *action,
 }
 
 static void
-action_copy_to_callback (GtkAction *action,
-                        gpointer callback_data)
+action_copy_to (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
        NautilusView *view;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
        copy_or_move_selection (view, FALSE);
 }
 
 static void
-action_move_to_callback (GtkAction *action,
-                        gpointer callback_data)
+action_move_to (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
 {
        NautilusView *view;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
        copy_or_move_selection (view, TRUE);
 }
 
-static void
-paste_clipboard_data (NautilusView *view,
-                     GtkSelectionData *selection_data,
-                     char *destination_uri)
-{
-       gboolean cut;
-       GList *item_uris;
-
-       cut = FALSE;
-       item_uris = nautilus_clipboard_get_uri_list_from_selection_data (selection_data, &cut,
-                                                                        copied_files_atom);
-
-       if (item_uris != NULL && destination_uri != NULL) {
-               nautilus_view_move_copy_items (view, item_uris, NULL, destination_uri,
-                                              cut ? GDK_ACTION_MOVE : GDK_ACTION_COPY,
-                                              0, 0);
-
-               /* If items are cut then remove from clipboard */
-               if (cut) {
-                       gtk_clipboard_clear (nautilus_clipboard_get (GTK_WIDGET (view)));
-               }
-
-               g_list_free_full (item_uris, g_free);
-       }
-}
-
-static void
-paste_clipboard_received_callback (GtkClipboard     *clipboard,
-                                  GtkSelectionData *selection_data,
-                                  gpointer          data)
-{
-       NautilusView *view;
-       char *view_uri;
-
-       view = NAUTILUS_VIEW (data);
-
-       view_uri = nautilus_view_get_backing_uri (view);
-
-       if (view->details->slot != NULL) {
-               paste_clipboard_data (view, selection_data, view_uri);
-       }
-
-       g_free (view_uri);
-
-       g_object_unref (view);
-}
-
 typedef struct {
        NautilusView *view;
        NautilusFile *target;
@@ -6125,21 +4645,6 @@ paste_into_clipboard_received_callback (GtkClipboard     *clipboard,
 }
 
 static void
-action_paste_files_callback (GtkAction *action,
-                            gpointer callback_data)
-{
-       NautilusView *view;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       g_object_ref (view);
-       gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
-                                       copied_files_atom,
-                                       paste_clipboard_received_callback,
-                                       view);
-}
-
-static void
 paste_into (NautilusView *view,
            NautilusFile *target)
 {
@@ -6160,13 +4665,14 @@ paste_into (NautilusView *view,
 }
 
 static void
-action_paste_files_into_callback (GtkAction *action,
-                                 gpointer callback_data)
+action_paste_files_into (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
        NautilusView *view;
        GList *selection;
 
-       view = NAUTILUS_VIEW (callback_data);
+       view = NAUTILUS_VIEW (user_data);
        selection = nautilus_view_get_selection (view);
        if (selection != NULL) {
                paste_into (view, NAUTILUS_FILE (selection->data));
@@ -6207,38 +4713,6 @@ invoke_external_bulk_rename_utility (NautilusView *view,
 }
 
 static void
-real_action_undo (NautilusView *view)
-{
-       GtkWidget *toplevel;
-
-       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
-       nautilus_file_undo_manager_undo (GTK_WINDOW (toplevel));
-}
-
-static void
-real_action_redo (NautilusView *view)
-{
-       GtkWidget *toplevel;
-
-       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
-       nautilus_file_undo_manager_redo (GTK_WINDOW (toplevel));
-}
-
-static void
-action_undo_callback (GtkAction *action,
-                     gpointer callback_data)
-{
-       real_action_undo (NAUTILUS_VIEW (callback_data));
-}
-
-static void
-action_redo_callback (GtkAction *action,
-                     gpointer callback_data)
-{
-       real_action_redo (NAUTILUS_VIEW (callback_data));
-}
-
-static void
 real_action_rename (NautilusView *view,
                    gboolean select_all)
 {
@@ -6270,17 +4744,11 @@ real_action_rename (NautilusView *view,
 }
 
 static void
-action_rename_callback (GtkAction *action,
-                       gpointer callback_data)
+action_rename (GSimpleAction *action,
+              GVariant      *state,
+              gpointer       user_data)
 {
-       real_action_rename (NAUTILUS_VIEW (callback_data), FALSE);
-}
-
-static void
-action_rename_select_all_callback (GtkAction *action,
-                                  gpointer callback_data)
-{
-       real_action_rename (NAUTILUS_VIEW (callback_data), TRUE);
+       real_action_rename (NAUTILUS_VIEW (user_data), FALSE);
 }
 
 #define BG_KEY_PRIMARY_COLOR      "primary-color"
@@ -6349,20 +4817,21 @@ can_set_wallpaper (GList *selection)
 }
 
 static void
-action_set_as_wallpaper_callback (GtkAction    *action,
-                                 NautilusView *view)
+action_set_as_wallpaper (GSimpleAction *action,
+                        GVariant      *state,
+                        gpointer       user_data)
 {
        GList *selection;
 
        /* Copy the item to Pictures/Wallpaper since it may be
           remote. Then set it as the current wallpaper. */
 
-       g_assert (NAUTILUS_IS_VIEW (view));
+       g_assert (NAUTILUS_IS_VIEW (user_data));
 
-       selection = nautilus_view_get_selection (view);
+       selection = nautilus_view_get_selection (user_data);
 
        if (can_set_wallpaper (selection)
-           && selection_not_empty_in_menu_callback (view, selection)) {
+           && selection_not_empty_in_menu_callback (user_data, selection)) {
                NautilusFile *file;
                char *target_uri;
                GList *uris;
@@ -6382,7 +4851,7 @@ action_set_as_wallpaper_callback (GtkAction    *action,
                                                    NULL,
                                                    target_uri,
                                                    GDK_ACTION_COPY,
-                                                   GTK_WIDGET (view),
+                                                   GTK_WIDGET (user_data),
                                                    wallpaper_copy_done_callback,
                                                    NULL);
                g_free (target_uri);
@@ -6494,15 +4963,16 @@ file_stop_callback (NautilusFile  *file,
 }
 
 static void
-action_mount_volume_callback (GtkAction *action,
-                             gpointer data)
+action_mount_volume (GSimpleAction *action,
+                    GVariant      *state,
+                    gpointer       user_data)
 {
        NautilusFile *file;
        GList *selection, *l;
        NautilusView *view;
        GMountOperation *mount_op;
 
-        view = NAUTILUS_VIEW (data);
+        view = NAUTILUS_VIEW (user_data);
        
        selection = nautilus_view_get_selection (view);
        for (l = selection; l != NULL; l = l->next) {
@@ -6521,14 +4991,15 @@ action_mount_volume_callback (GtkAction *action,
 }
 
 static void
-action_unmount_volume_callback (GtkAction *action,
-                               gpointer data)
+action_unmount_volume (GSimpleAction *action,
+                      GVariant      *state,
+                      gpointer       user_data)
 {
        NautilusFile *file;
        GList *selection, *l;
        NautilusView *view;
 
-        view = NAUTILUS_VIEW (data);
+        view = NAUTILUS_VIEW (user_data);
        
        selection = nautilus_view_get_selection (view);
 
@@ -6546,14 +5017,15 @@ action_unmount_volume_callback (GtkAction *action,
 }
 
 static void
-action_eject_volume_callback (GtkAction *action,
-                             gpointer data)
+action_eject_volume (GSimpleAction *action,
+                    GVariant      *state,
+                    gpointer       user_data)
 {
        NautilusFile *file;
        GList *selection, *l;
        NautilusView *view;
 
-        view = NAUTILUS_VIEW (data);
+        view = NAUTILUS_VIEW (user_data);
        
        selection = nautilus_view_get_selection (view);
        for (l = selection; l != NULL; l = l->next) {
@@ -6598,15 +5070,16 @@ file_start_callback (NautilusFile  *file,
 }
 
 static void
-action_start_volume_callback (GtkAction *action,
-                             gpointer   data)
+action_start_volume (GSimpleAction *action,
+                    GVariant      *state,
+                    gpointer       user_data)
 {
        NautilusFile *file;
        GList *selection, *l;
        NautilusView *view;
        GMountOperation *mount_op;
 
-       view = NAUTILUS_VIEW (data);
+       view = NAUTILUS_VIEW (user_data);
 
        selection = nautilus_view_get_selection (view);
        for (l = selection; l != NULL; l = l->next) {
@@ -6623,14 +5096,15 @@ action_start_volume_callback (GtkAction *action,
 }
 
 static void
-action_stop_volume_callback (GtkAction *action,
-                            gpointer   data)
+action_stop_volume (GSimpleAction *action,
+                   GVariant      *state,
+                   gpointer       user_data)
 {
        NautilusFile *file;
        GList *selection, *l;
        NautilusView *view;
 
-        view = NAUTILUS_VIEW (data);
+        view = NAUTILUS_VIEW (user_data);
 
        selection = nautilus_view_get_selection (view);
        for (l = selection; l != NULL; l = l->next) {
@@ -6648,14 +5122,15 @@ action_stop_volume_callback (GtkAction *action,
 }
 
 static void
-action_detect_media_callback (GtkAction *action,
-                             gpointer   data)
+action_detect_media (GSimpleAction *action,
+                    GVariant      *state,
+                    gpointer       user_data)
 {
        NautilusFile *file;
        GList *selection, *l;
        NautilusView *view;
 
-        view = NAUTILUS_VIEW (data);
+        view = NAUTILUS_VIEW (user_data);
 
        selection = nautilus_view_get_selection (view);
        for (l = selection; l != NULL; l = l->next) {
@@ -6668,768 +5143,60 @@ action_detect_media_callback (GtkAction *action,
        nautilus_file_list_free (selection);
 }
 
-static void
-action_self_mount_volume_callback (GtkAction *action,
-                                  gpointer data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = nautilus_view_get_directory_as_file (view);
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
-       nautilus_file_mount (file, mount_op, NULL, file_mount_callback, view);
-       g_object_unref (mount_op);
-}
-
-static void
-action_self_unmount_volume_callback (GtkAction *action,
-                                    gpointer data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = nautilus_view_get_directory_as_file (view);
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_unmount (file, mount_op, NULL, file_unmount_callback, g_object_ref (view));
-       g_object_unref (mount_op);
-}
-
-static void
-action_self_eject_volume_callback (GtkAction *action,
-                                  gpointer data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = nautilus_view_get_directory_as_file (view);
-       if (file == NULL) {
-               return;
-       }
-       
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_eject (file, mount_op, NULL, file_eject_callback, g_object_ref (view));
-       g_object_unref (mount_op);
-}
-
-static void
-action_self_start_volume_callback (GtkAction *action,
-                                  gpointer   data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = nautilus_view_get_directory_as_file (view);
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_start (file, mount_op, NULL, file_start_callback, view);
-       g_object_unref (mount_op);
-}
-
-static void
-action_self_stop_volume_callback (GtkAction *action,
-                                 gpointer   data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = nautilus_view_get_directory_as_file (view);
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_stop (file, mount_op, NULL,
-                           file_stop_callback, view);
-       g_object_unref (mount_op);
-}
-
-static void
-action_self_detect_media_callback (GtkAction *action,
-                                  gpointer   data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = nautilus_view_get_directory_as_file (view);
-       if (file == NULL) {
-               return;
-       }
-
-       nautilus_file_poll_for_media (file);
-}
-
-static void
-action_location_mount_volume_callback (GtkAction *action,
-                                      gpointer data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
-       nautilus_file_mount (file, mount_op, NULL, file_mount_callback, view);
-       g_object_unref (mount_op);
-}
-
-static void
-action_location_unmount_volume_callback (GtkAction *action,
-                                        gpointer data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_unmount (file, mount_op, NULL,
-                              file_unmount_callback, g_object_ref (view));
-       g_object_unref (mount_op);
-}
-
-static void
-action_location_eject_volume_callback (GtkAction *action,
-                                      gpointer data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-       
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_eject (file, mount_op, NULL,
-                            file_eject_callback, g_object_ref (view));
-       g_object_unref (mount_op);
-}
-
-static void
-action_location_start_volume_callback (GtkAction *action,
-                                      gpointer   data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_start (file, mount_op, NULL, file_start_callback, view);
-       g_object_unref (mount_op);
-}
-
-static void
-action_location_stop_volume_callback (GtkAction *action,
-                                     gpointer   data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-       GMountOperation *mount_op;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-
-       mount_op = gtk_mount_operation_new (nautilus_view_get_containing_window (view));
-       nautilus_file_stop (file, mount_op, NULL,
-                           file_stop_callback, view);
-       g_object_unref (mount_op);
-}
-
-static void
-action_location_detect_media_callback (GtkAction *action,
-                                      gpointer   data)
-{
-       NautilusFile *file;
-       NautilusView *view;
-
-       view = NAUTILUS_VIEW (data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-
-       nautilus_file_poll_for_media (file);
-}
-
-static void
-action_location_open_alternate_callback (GtkAction *action,
-                                        gpointer   callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-       nautilus_view_activate_file (view,
-                                    file,
-                                    NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW);
-}
-
-static void
-action_location_open_in_new_tab_callback (GtkAction *action,
-                                         gpointer   callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       file = view->details->location_popup_directory_as_file;
-       if (file == NULL) {
-               return;
-       }
-
-       nautilus_view_activate_file (view,
-                                    file,
-                                    NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB);
-}
-
-static void
-action_location_cut_callback (GtkAction *action,
-                             gpointer   callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-       GList *files;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       file = view->details->location_popup_directory_as_file;
-       g_return_if_fail (file != NULL);
-
-       files = g_list_append (NULL, file);
-       copy_or_cut_files (view, files, TRUE);
-       g_list_free (files);
-}
-
-static void
-action_location_copy_callback (GtkAction *action,
-                              gpointer   callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-       GList *files;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       file = view->details->location_popup_directory_as_file;
-       g_return_if_fail (file != NULL);
-
-       files = g_list_append (NULL, file);
-       copy_or_cut_files (view, files, FALSE);
-       g_list_free (files);
-}
-
-static void
-action_location_paste_files_into_callback (GtkAction *action,
-                                          gpointer callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       file = view->details->location_popup_directory_as_file;
-       g_return_if_fail (file != NULL);
-
-       paste_into (view, file);
-}
-
-static void
-action_location_trash_callback (GtkAction *action,
-                               gpointer   callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-       GList *files;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       file = view->details->location_popup_directory_as_file;
-       g_return_if_fail (file != NULL);
-
-       files = g_list_append (NULL, file);
-       trash_or_delete_files (nautilus_view_get_containing_window (view),
-                              files, TRUE,
-                              view);
-       g_list_free (files);
-}
-
-static void
-action_location_delete_callback (GtkAction *action,
-                                gpointer   callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-       GFile *location;
-       GList *files;
-
-       view = NAUTILUS_VIEW (callback_data);
-
-       file = view->details->location_popup_directory_as_file;
-       g_return_if_fail (file != NULL);
-
-       location = nautilus_file_get_location (file);
-
-       files = g_list_append (NULL, location);
-       nautilus_file_operations_delete (files, nautilus_view_get_containing_window (view),
-                                        NULL, NULL);
-
-       g_list_free_full (files, g_object_unref);
-}
-
-static void
-action_location_restore_from_trash_callback (GtkAction *action,
-                                            gpointer callback_data)
-{
-       NautilusView *view;
-       NautilusFile *file;
-       GList l;
-
-       view = NAUTILUS_VIEW (callback_data);
-       file = view->details->location_popup_directory_as_file;
-
-       l.prev = NULL;
-       l.next = NULL;
-       l.data = file;
-       nautilus_restore_files_from_trash (&l,
-                                          nautilus_view_get_containing_window (view));
-}
-
 gboolean
 nautilus_view_get_show_hidden_files (NautilusView *view)
 {
        return view->details->show_hidden_files;
 }
 
-static void
-nautilus_view_set_show_hidden_files (NautilusView *view,
-                                    gboolean show_hidden)
-{
-       if (view->details->ignore_hidden_file_preferences) {
-               return;
-       }
-
-       if (show_hidden != view->details->show_hidden_files) {
-               view->details->show_hidden_files = show_hidden;
-               if (view->details->model != NULL) {
-                       load_directory (view, view->details->model);
-               }
-       }
-}
-
-static const GtkActionEntry directory_view_entries[] = {
-  /* name, stock id, label */  { NAUTILUS_ACTION_NEW_DOCUMENTS, "document-new", N_("New _Document") },
-  /* name, stock id, label */  { NAUTILUS_ACTION_OPEN_WITH, NULL, N_("Open Wit_h"),
-                                NULL, N_("Choose a program with which to open the selected item") },
-  /* name, stock id */         { NAUTILUS_ACTION_PROPERTIES, NULL,
-  /* label, accelerator */       N_("P_roperties"), "<alt>Return",
-  /* tooltip */                  N_("View or modify the properties of each selected item"),
-                                G_CALLBACK (action_properties_callback) },
-  /* name, stock id */         { "PropertiesAccel", NULL,
-  /* label, accelerator */       "PropertiesAccel", "<control>I",
-  /* tooltip */                  NULL,
-                                G_CALLBACK (action_properties_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_NEW_FOLDER, "folder-new",
-  /* label, accelerator */       N_("New _Folder"), "<control><shift>N",
-  /* tooltip */                  N_("Create a new empty folder inside this folder"),
-                                G_CALLBACK (action_new_folder_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_NEW_FOLDER_WITH_SELECTION, NULL,
-  /* label, accelerator */       N_("New Folder with Selection"), NULL,
-  /* tooltip */                  N_("Create a new folder containing the selected items"),
-                                G_CALLBACK (action_new_folder_with_selection_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_OPEN, NULL,
-  /* label, accelerator */       N_("_Open"), "<control>o",
-  /* tooltip */                  N_("Open the selected item in this window"),
-                                G_CALLBACK (action_open_callback) },
-  /* name, stock id */         { "OpenAccel", NULL,
-  /* label, accelerator */       "OpenAccel", "<alt>Down",
-  /* tooltip */                  NULL,
-                                G_CALLBACK (action_open_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_OPEN_ITEM_LOCATION, NULL,
-  /* label, accelerator */       N_("Open _Item Location"), "<control><alt>o",
-  /* tooltip */                  N_("Open the selected item's location in this window"),
-                                G_CALLBACK (action_open_item_location_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_OPEN_ALTERNATE, NULL,
-  /* label, accelerator */       N_("Open in Navigation Window"), "<control><shift>o",
-  /* tooltip */                  N_("Open each selected item in a navigation window"),
-                                G_CALLBACK (action_open_alternate_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_OPEN_IN_NEW_TAB, NULL,
-  /* label, accelerator */       N_("Open in New _Tab"), "<control><shift>t",
-  /* tooltip */                  N_("Open each selected item in a new tab"),
-                                G_CALLBACK (action_open_new_tab_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_OTHER_APPLICATION1, NULL,
-  /* label, accelerator */       N_("Other _Application…"), NULL,
-  /* tooltip */                  N_("Choose another application with which to open the selected item"),
-                                G_CALLBACK (action_other_application_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_OTHER_APPLICATION2, NULL,
-  /* label, accelerator */       N_("Open With Other _Application…"), NULL,
-  /* tooltip */                  N_("Choose another application with which to open the selected item"),
-                                G_CALLBACK (action_other_application_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_OPEN_SCRIPTS_FOLDER, NULL,
-  /* label, accelerator */       N_("_Open Scripts Folder"), NULL,
-  /* tooltip */                 N_("Show the folder containing the scripts that appear in this menu"),
-                                G_CALLBACK (action_open_scripts_folder_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_EMPTY_TRASH, NULL,
-  /* label, accelerator */       N_("E_mpty Trash"), NULL,
-  /* tooltip */                  N_("Delete all items in the Trash"),
-                                G_CALLBACK (action_empty_trash_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_CUT, NULL,
-  /* label, accelerator */       N_("Cu_t"), "<control>X",
-  /* tooltip */                  N_("Prepare the selected files to be moved with a Paste command"),
-                                G_CALLBACK (action_cut_files_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_COPY, NULL,
-  /* label, accelerator */       N_("_Copy"), "<control>C",
-  /* tooltip */                  N_("Prepare the selected files to be copied with a Paste command"),
-                                G_CALLBACK (action_copy_files_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_PASTE, NULL,
-  /* label, accelerator */       N_("_Paste"), "<control>V",
-  /* tooltip */                  N_("Move or copy files previously selected by a Cut or Copy command"),
-                                G_CALLBACK (action_paste_files_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_PASTE_FILES_INTO, NULL,
-  /* label, accelerator */       N_("_Paste Into Folder"), NULL,
-  /* tooltip */                  N_("Move or copy files previously selected by a Cut or Copy command into 
the selected folder"),
-                                G_CALLBACK (action_paste_files_into_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_COPY_TO, NULL,
-  /* label, accelerator */       N_("Copy To…"), NULL,
-  /* tooltip */                  N_("Copy selected files to another location"),
-                                G_CALLBACK (action_copy_to_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_MOVE_TO, NULL,
-  /* label, accelerator */       N_("Move To…"), NULL,
-  /* tooltip */                  N_("Move selected files to another location"),
-                                G_CALLBACK (action_move_to_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELECT_ALL, NULL,
-  /* label, accelerator */       N_("Select _All"), "<control>A",
-  /* tooltip */                  N_("Select all items in this window"),
-                                G_CALLBACK (action_select_all_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELECT_PATTERN, NULL,
-  /* label, accelerator */       N_("Select I_tems Matching…"), "<control>S",
-  /* tooltip */                  N_("Select items in this window matching a given pattern"),
-                                G_CALLBACK (action_select_pattern_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_INVERT_SELECTION, NULL,
-  /* label, accelerator */       N_("_Invert Selection"), "<control><shift>I",
-  /* tooltip */                  N_("Select all and only the items that are not currently selected"),
-                                G_CALLBACK (action_invert_selection_callback) }, 
-  /* name, stock id */         { NAUTILUS_ACTION_CREATE_LINK, NULL,
-  /* label, accelerator */       N_("Ma_ke Link"), "<control>M",
-  /* tooltip */                  N_("Create a symbolic link for each selected item"),
-                                G_CALLBACK (action_create_link_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_RENAME, NULL,
-  /* label, accelerator */       N_("Rena_me…"), "F2",
-  /* tooltip */                  N_("Rename selected item"),
-                                G_CALLBACK (action_rename_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SET_AS_WALLPAPER, NULL,
-  /* label, accelerator */       N_("Set as Wallpaper"), NULL,
-  /* tooltip */                  N_("Make item the wallpaper"),
-                                G_CALLBACK (action_set_as_wallpaper_callback) },
-  /* name, stock id */         { "RenameSelectAll", NULL,
-  /* label, accelerator */       "RenameSelectAll", "<shift>F2",
-  /* tooltip */                  NULL,
-                                G_CALLBACK (action_rename_select_all_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_TRASH, NULL,
-  /* label, accelerator */       N_("Mo_ve to Trash"), "<control>Delete",
-  /* tooltip */                  N_("Move each selected item to the Trash"),
-                                G_CALLBACK (action_trash_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_DELETE, NULL,
-  /* label, accelerator */       N_("_Delete"), "<shift>Delete",
-  /* tooltip */                  N_("Delete each selected item, without moving to the Trash"),
-                                G_CALLBACK (action_delete_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_RESTORE_FROM_TRASH, NULL,
-  /* label, accelerator */       N_("_Restore"), NULL,
-                                NULL,
-                 G_CALLBACK (action_restore_from_trash_callback) },
- /* name, stock id */          { NAUTILUS_ACTION_UNDO, NULL,
- /* label, accelerator */        N_("_Undo"), "<control>Z",
- /* tooltip */                   N_("Undo the last action"),
-                                 G_CALLBACK (action_undo_callback) },
- /* name, stock id */         { NAUTILUS_ACTION_REDO, NULL,
- /* label, accelerator */        N_("_Redo"), "<shift><control>Z",
- /* tooltip */                   N_("Redo the last undone action"),
-                                 G_CALLBACK (action_redo_callback) },
-  /*
-   * multiview-TODO: decide whether "Reset to Defaults" should
-   * be window-wide, and not just view-wide.
-   * Since this also resets the "Show hidden files" mode,
-   * it is a mixture of both ATM.
-   */
-  /* name, stock id */         { NAUTILUS_ACTION_RESET_TO_DEFAULTS, NULL,
-  /* label, accelerator */       N_("Reset View to _Defaults"), NULL,
-  /* tooltip */                  N_("Reset sorting order and zoom level to match preferences for this view"),
-                                G_CALLBACK (action_reset_to_defaults_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_MOUNT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Mount"), NULL,
-  /* tooltip */                  N_("Mount the selected volume"),
-                                G_CALLBACK (action_mount_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_UNMOUNT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Unmount"), NULL,
-  /* tooltip */                  N_("Unmount the selected volume"),
-                                G_CALLBACK (action_unmount_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_EJECT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Eject"), NULL,
-  /* tooltip */                  N_("Eject the selected volume"),
-                                G_CALLBACK (action_eject_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_START_VOLUME, NULL,
-  /* label, accelerator */       N_("_Start"), NULL,
-  /* tooltip */                  N_("Start the selected volume"),
-                                G_CALLBACK (action_start_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_STOP_VOLUME, NULL,
-  /* label, accelerator */       N_("_Stop"), NULL,
-  /* tooltip */                  N_("Stop the selected volume"),
-                                G_CALLBACK (action_stop_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_POLL, NULL,
-  /* label, accelerator */       N_("_Detect Media"), NULL,
-  /* tooltip */                  N_("Detect media in the selected drive"),
-                                G_CALLBACK (action_detect_media_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELF_MOUNT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Mount"), NULL,
-  /* tooltip */                  N_("Mount the volume associated with the open folder"),
-                                G_CALLBACK (action_self_mount_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELF_UNMOUNT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Unmount"), NULL,
-  /* tooltip */                  N_("Unmount the volume associated with the open folder"),
-                                G_CALLBACK (action_self_unmount_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELF_EJECT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Eject"), NULL,
-  /* tooltip */                  N_("Eject the volume associated with the open folder"),
-                                G_CALLBACK (action_self_eject_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELF_START_VOLUME, NULL,
-  /* label, accelerator */       N_("_Start"), NULL,
-  /* tooltip */                  N_("Start the volume associated with the open folder"),
-                                G_CALLBACK (action_self_start_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELF_STOP_VOLUME, NULL,
-  /* label, accelerator */       N_("_Stop"), NULL,
-  /* tooltip */                  N_("Stop the volume associated with the open folder"),
-                                G_CALLBACK (action_self_stop_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SELF_POLL, NULL,
-  /* label, accelerator */       N_("_Detect Media"), NULL,
-  /* tooltip */                  N_("Detect media in the selected drive"),
-                                G_CALLBACK (action_self_detect_media_callback) },
-  /* name, stock id */         { "OpenCloseParent", NULL,
-  /* label, accelerator */       N_("Open File and Close window"), "<alt><shift>Down",
-  /* tooltip */                  NULL,
-                                G_CALLBACK (action_open_close_parent_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SAVE_SEARCH, NULL,
-  /* label, accelerator */       N_("Sa_ve Search"), NULL,
-  /* tooltip */                  N_("Save the edited search"),
-                                G_CALLBACK (action_save_search_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_SAVE_SEARCH_AS, NULL,
-  /* label, accelerator */       N_("Sa_ve Search As…"), NULL,
-  /* tooltip */                  N_("Save the current search as a file"),
-                                G_CALLBACK (action_save_search_as_callback) },
-
-  /* Location-specific actions */
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_OPEN_ALTERNATE, NULL,
-  /* label, accelerator */       N_("Open in Navigation Window"), NULL,
-  /* tooltip */                  N_("Open this folder in a navigation window"),
-                                G_CALLBACK (action_location_open_alternate_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_OPEN_IN_NEW_TAB, NULL,
-  /* label, accelerator */       N_("Open in New _Tab"), NULL,
-  /* tooltip */                  N_("Open this folder in a new tab"),
-                                G_CALLBACK (action_location_open_in_new_tab_callback) },
-
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_CUT, NULL,
-  /* label, accelerator */       N_("Cu_t"), NULL,
-  /* tooltip */                  N_("Prepare this folder to be moved with a Paste command"),
-                                G_CALLBACK (action_location_cut_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_COPY, NULL,
-  /* label, accelerator */       N_("_Copy"), NULL,
-  /* tooltip */                  N_("Prepare this folder to be copied with a Paste command"),
-                                G_CALLBACK (action_location_copy_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_PASTE_FILES_INTO, NULL,
-  /* label, accelerator */       N_("_Paste Into Folder"), NULL,
-  /* tooltip */                  N_("Move or copy files previously selected by a Cut or Copy command into 
this folder"),
-                                G_CALLBACK (action_location_paste_files_into_callback) },
-
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_TRASH, NULL,
-  /* label, accelerator */       N_("Mo_ve to Trash"), NULL,
-  /* tooltip */                  N_("Move this folder to the Trash"),
-                                G_CALLBACK (action_location_trash_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_DELETE, NAUTILUS_ICON_DELETE,
-  /* label, accelerator */       N_("_Delete"), NULL,
-  /* tooltip */                  N_("Delete this folder, without moving to the Trash"),
-                                G_CALLBACK (action_location_delete_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_RESTORE_FROM_TRASH, NULL,
-  /* label, accelerator */       N_("_Restore"), NULL, NULL,
-                                G_CALLBACK (action_location_restore_from_trash_callback) },
-
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_MOUNT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Mount"), NULL,
-  /* tooltip */                  N_("Mount the volume associated with this folder"),
-                                G_CALLBACK (action_location_mount_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_UNMOUNT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Unmount"), NULL,
-  /* tooltip */                  N_("Unmount the volume associated with this folder"),
-                                G_CALLBACK (action_location_unmount_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_EJECT_VOLUME, NULL,
-  /* label, accelerator */       N_("_Eject"), NULL,
-  /* tooltip */                  N_("Eject the volume associated with this folder"),
-                                G_CALLBACK (action_location_eject_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_START_VOLUME, NULL,
-  /* label, accelerator */       N_("_Start"), NULL,
-  /* tooltip */                  N_("Start the volume associated with this folder"),
-                                G_CALLBACK (action_location_start_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_STOP_VOLUME, NULL,
-  /* label, accelerator */       N_("_Stop"), NULL,
-  /* tooltip */                  N_("Stop the volume associated with this folder"),
-                                G_CALLBACK (action_location_stop_volume_callback) },
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_POLL, NULL,
-  /* label, accelerator */       N_("_Detect Media"), NULL,
-  /* tooltip */                  N_("Detect media in the selected drive"),
-                                G_CALLBACK (action_location_detect_media_callback) },
-
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_PROPERTIES, NULL,
-  /* label, accelerator */       N_("P_roperties"), NULL,
-  /* tooltip */                  N_("View or modify the properties of this folder"),
-                                G_CALLBACK (action_location_properties_callback) },
+const GActionEntry view_entries[] = {
+       /* Toolbar menu */
+       { "zoom-in",  action_zoom_in },
+       { "zoom-out", action_zoom_out },
+       { "zoom-to-level", NULL, NULL, "1", action_zoom_to_level },
+       { "zoom-normal", action_zoom_normal },
+       { "undo", action_undo },
+       { "redo", action_redo },
+       { "show-hidden-files", NULL, NULL, "true", action_show_hidden_files },
+       /* Background menu */
+       { "new-folder", action_new_folder },
+       { "select-all", action_select_all },
+       { "paste", action_paste_files },
+       { "new-document" },
+       /* Selection menu */
+       { "scripts" },
+       { "open-scripts-folder", action_open_scripts_folder },
+       { "open-item-location", action_open_item_location },
+       { "open-with-default-application", action_open_with_default_application },
+       { "open-with-other-application", action_open_with_other_application },
+       { "open-item-new-window", action_open_item_new_window },
+       { "open-item-new-tab", action_open_item_new_tab },
+       { "cut", action_cut},
+       { "copy", action_copy},
+       { "move-to", action_move_to},
+       { "copy-to", action_copy_to},
+       { "move-to-trash", action_move_to_trash},
+       { "delete", action_delete},
+       { "restore-from-trash", action_restore_from_trash},
+       { "paste-into", action_paste_files_into },
+       { "rename", action_rename},
+       { "properties", action_properties},
+       { "set-as-wallpaper", action_set_as_wallpaper },
+       { "mount-volume", action_mount_volume },
+       { "unmount-volume", action_unmount_volume },
+       { "eject-volume", action_eject_volume },
+       { "start-volume", action_start_volume },
+       { "stop-volume", action_stop_volume },
+       { "detect-media", action_detect_media },
+       /* Pathbar menu */
+       { "pathbar-open-item-new-window", action_pathbar_open_item_new_window },
+       { "pathbar-open-item-new-tab", action_pathbar_open_item_new_tab },
+       { "pathbar-properties", action_pathbar_properties},
+       /* Only accesible by shorcuts */
+       { "select-pattern", action_select_pattern },
+       { "invert-selection", action_invert_selection }
 };
 
-static const GtkToggleActionEntry directory_view_toggle_entries[] = {
-  /* name, stock id */         { NAUTILUS_ACTION_SHOW_HIDDEN_FILES, NULL,
-  /* label, accelerator */       N_("Show _Hidden Files"), "<control>H",
-  /* tooltip */                  N_("Toggle the display of hidden files in the current window"),
-                                 G_CALLBACK (action_show_hidden_files_callback),
-                                 TRUE },
-};
-
-static void
-pre_activate (NautilusView *view,
-             GtkAction *action,
-             GtkActionGroup *action_group)
-{
-       GdkEvent *event;
-       GtkWidget *proxy;
-       gboolean activated_from_popup;
-
-       /* check whether action was activated through a popup menu.
-        * If not, unset the last stored context menu popup position */
-       activated_from_popup = FALSE;
-
-       event = gtk_get_current_event ();
-       proxy = gtk_get_event_widget (event);
-
-       if (proxy != NULL) {
-               GtkWidget *toplevel;
-               GdkWindowTypeHint hint;
-
-               toplevel = gtk_widget_get_toplevel (proxy);
-
-               if (GTK_IS_WINDOW (toplevel)) {
-                       hint = gtk_window_get_type_hint (GTK_WINDOW (toplevel));
-
-                       if (hint == GDK_WINDOW_TYPE_HINT_POPUP_MENU) {
-                               activated_from_popup = TRUE;
-                       }
-               }
-       }
-
-       if (!activated_from_popup) {
-               update_context_menu_position_from_event (view, NULL);
-       }
-}
-
-static void
-real_merge_menus (NautilusView *view)
-{
-       GtkActionGroup *action_group;
-       GtkUIManager *ui_manager;
-       GtkAction *action;
-       char *tooltip;
-
-       ui_manager = nautilus_view_get_ui_manager (view);
-
-       action_group = gtk_action_group_new ("DirViewActions");
-       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-       view->details->dir_action_group = action_group;
-       gtk_action_group_add_actions (action_group, 
-                                     directory_view_entries, G_N_ELEMENTS (directory_view_entries),
-                                     view);
-       gtk_action_group_add_toggle_actions (action_group,
-                                            directory_view_toggle_entries, G_N_ELEMENTS 
(directory_view_toggle_entries),
-                                            view);
-
-       tooltip = g_strdup (_("Run or manage scripts"));
-       /* Create a script action here specially because its tooltip is dynamic */
-       action = gtk_action_new ("Scripts", _("_Scripts"), tooltip, NULL);
-       gtk_action_group_add_action (action_group, action);
-       g_object_unref (action);
-       g_free (tooltip);
-
-       g_signal_connect_object (action_group, "pre-activate",
-                                G_CALLBACK (pre_activate), G_OBJECT (view),
-                                G_CONNECT_SWAPPED);
-
-       /* Insert action group at end so clipboard action group ends up before it */
-       gtk_ui_manager_insert_action_group (ui_manager, action_group, -1);
-       g_object_unref (action_group); /* owned by ui manager */
-
-       view->details->dir_merge_id = gtk_ui_manager_add_ui_from_resource (ui_manager, 
"/org/gnome/nautilus/nautilus-directory-view-ui.xml", NULL);
-       
-       view->details->scripts_invalid = TRUE;
-       view->details->templates_invalid = TRUE;
-}
-
-
 static gboolean
 can_paste_into_file (NautilusFile *file)
 {
@@ -7470,9 +5237,7 @@ clipboard_targets_received (GtkClipboard     *clipboard,
        NautilusView *view;
        gboolean can_paste;
        int i;
-       GList *selection;
-       int count;
-       GtkAction *action;
+       GAction *action;
 
        view = NAUTILUS_VIEW (user_data);
        can_paste = FALSE;
@@ -7485,99 +5250,28 @@ clipboard_targets_received (GtkClipboard     *clipboard,
        }
 
        if (targets) {
-               for (i=0; i < n_targets; i++) {
+               for (i = 0; i < n_targets; i++) {
                        if (targets[i] == copied_files_atom) {
                                can_paste = TRUE;
                        }
                }
        }
-       
-       
-       selection = nautilus_view_get_selection (view);
-       count = g_list_length (selection);
-       
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_PASTE);
-       gtk_action_set_sensitive (action,
-                                 can_paste && !nautilus_view_is_read_only (view));
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_PASTE_FILES_INTO);
-       gtk_action_set_sensitive (action,
-                                 can_paste && count == 1 &&
-                                 can_paste_into_file (NAUTILUS_FILE (selection->data)));
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_PASTE_FILES_INTO);
-       g_object_set_data (G_OBJECT (action),
-                          "can-paste-according-to-clipboard",
-                          GINT_TO_POINTER (can_paste));
-       gtk_action_set_sensitive (action,
-                                 GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),
-                                                                     "can-paste-according-to-clipboard")) &&
-                                 GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),
-                                                                     "can-paste-according-to-destination")));
 
-       nautilus_file_list_free (selection);
-       
-       g_object_unref (view);
-}
-
-static gboolean
-should_show_empty_trash (NautilusView *view)
-{
-       return (showing_trash_directory (view));
-}
+       action = g_action_map_lookup_action (G_ACTION_MAP (view->details->view_action_group),
+                                            "paste");
+       /* Take into account if the action was previously disabled for other reasons,
+          like the directory not being writabble */
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    can_paste && g_action_get_enabled (action));
 
-static gboolean
-file_list_all_are_folders (GList *file_list)
-{
-       GList *l;
-       NautilusFile *file, *linked_file;
-       char *activation_uri;
-       gboolean is_dir;
-       
-       for (l = file_list; l != NULL; l = l->next) {
-               file = NAUTILUS_FILE (l->data);
-               if (nautilus_file_is_nautilus_link (file) &&
-                   !NAUTILUS_IS_DESKTOP_ICON_FILE (file)) {
-                       if (nautilus_file_is_launcher (file)) {
-                               return FALSE;
-                       }
-                               
-                       activation_uri = nautilus_file_get_activation_uri (file);
-                       
-                       if (activation_uri == NULL) {
-                               g_free (activation_uri);
-                               return FALSE;
-                       }
+       action = g_action_map_lookup_action (G_ACTION_MAP (view->details->view_action_group),
+                                            "paste-into");
 
-                       linked_file = nautilus_file_get_existing_by_uri (activation_uri);
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    can_paste && g_action_get_enabled (action));
 
-                       /* We might not actually know the type of the linked file yet,
-                        * however we don't want to schedule a read, since that might do things
-                        * like ask for password etc. This is a bit unfortunate, but I don't
-                        * know any way around it, so we do various heuristics here
-                        * to get things mostly right 
-                        */
-                       is_dir =
-                               (linked_file != NULL &&
-                                nautilus_file_is_directory (linked_file)) ||
-                               (activation_uri != NULL &&
-                                activation_uri[strlen (activation_uri) - 1] == '/');
-                       
-                       nautilus_file_unref (linked_file);
-                       g_free (activation_uri);
-                       
-                       if (!is_dir) {
-                               return FALSE;
-                       }
-               } else if (!(nautilus_file_is_directory (file) ||
-                            NAUTILUS_IS_DESKTOP_ICON_FILE (file))) {
-                       return FALSE;
-               }
-       }
-       return TRUE;
+       
+       g_object_unref (view);
 }
 
 static void
@@ -7626,109 +5320,19 @@ file_should_show_foreach (NautilusFile        *file,
        *start_stop_type = nautilus_file_get_start_stop_type (file);
 }
 
-static void
-file_should_show_self (NautilusFile        *file,
-                      gboolean            *show_mount,
-                      gboolean            *show_unmount,
-                      gboolean            *show_eject,
-                      gboolean            *show_start,
-                      gboolean            *show_stop,
-                      gboolean            *show_poll,
-                      GDriveStartStopType *start_stop_type)
-{
-       *show_mount = FALSE;
-       *show_unmount = FALSE;
-       *show_eject = FALSE;
-       *show_start = FALSE;
-       *show_stop = FALSE;
-       *show_poll = FALSE;
-
-       if (file == NULL) {
-               return;
-       }
-
-       if (nautilus_file_can_eject (file)) {
-               *show_eject = TRUE;
-       }
-
-       if (nautilus_file_can_mount (file)) {
-               *show_mount = TRUE;
-       }
-
-       if (nautilus_file_can_start (file) || nautilus_file_can_start_degraded (file)) {
-               *show_start = TRUE;
-       }
-
-       if (nautilus_file_can_stop (file)) {
-               *show_stop = TRUE;
-       }
-
-       /* Dot not show both Unmount and Eject/Safe Removal; too confusing to
-        * have too many menu entries */
-       if (nautilus_file_can_unmount (file) && !*show_eject && !*show_stop) {
-               *show_unmount = TRUE;
-       }
-
-       if (nautilus_file_can_poll_for_media (file) && !nautilus_file_is_media_check_automatic (file)) {
-               *show_poll = TRUE;
-       }
-
-       *start_stop_type = nautilus_file_get_start_stop_type (file);
-
-}
-
 static gboolean
-files_are_all_directories (GList *files)
-{
-       NautilusFile *file;
-       GList *l;
-       gboolean all_directories;
-
-       all_directories = TRUE;
-
-       for (l = files; l != NULL; l = l->next) {
-               file = NAUTILUS_FILE (l->data);
-               all_directories &= nautilus_file_is_directory (file);
-       }
-
-       return all_directories;
-}
-
-static gboolean
-files_is_none_directory (GList *files)
-{
-       NautilusFile *file;
-       GList *l;
-       gboolean no_directory;
-
-       no_directory = TRUE;
-
-       for (l = files; l != NULL; l = l->next) {
-               file = NAUTILUS_FILE (l->data);
-               no_directory &= !nautilus_file_is_directory (file);
-       }
-
-       return no_directory;
-}
-
-static void
-update_restore_from_trash_action (GtkAction *action,
-                                 GList *files,
-                                 gboolean is_self)
+can_restore_from_trash (GList *files)
 {
        NautilusFile *original_file;
        NautilusFile *original_dir;
        GHashTable *original_dirs_hash;
        GList *original_dirs;
-       GFile *original_location;
-       char *tooltip, *original_name;
+       gboolean can_restore;
 
        original_file = NULL;
        original_dir = NULL;
        original_dirs = NULL;
        original_dirs_hash = NULL;
-       original_location = NULL;
-       original_name = NULL;
 
        if (files != NULL) {
                if (g_list_length (files) == 1) {
@@ -7744,83 +5348,7 @@ update_restore_from_trash_action (GtkAction *action,
                }
        }
 
-       if (original_file != NULL || original_dirs != NULL) {
-               gtk_action_set_visible (action, TRUE);
-
-               if (original_file != NULL) {
-                       original_location = nautilus_file_get_location (original_file);
-               } else if (original_dir != NULL) {
-                       original_location = nautilus_file_get_location (original_dir);
-               }
-
-               if (original_location != NULL) {
-                       original_name = g_file_get_parse_name (original_location);
-               }
-
-               if (is_self) {
-                       g_assert (g_list_length (files) == 1);
-                       g_assert (original_location != NULL);
-                       tooltip = g_strdup_printf (_("Move the open folder out of the trash to “%s”"), 
original_name);
-               } else if (files_are_all_directories (files)) {
-                       if (original_name != NULL) {
-                               if (g_list_length (files) == 1) {
-                                       tooltip = g_strdup_printf (_("Move the selected folder out of the 
trash to “%s”"),
-                                                                  original_name);
-                               } else {
-                                       tooltip = g_strdup_printf (_("Move the selected folders out of the 
trash to “%s”"),
-                                                                  original_name);
-                               }
-                       } else {
-                               if (g_list_length (files) == 1) {
-                                       tooltip = g_strdup (_("Move the selected folder out of the trash"));
-                               } else {
-                                       tooltip = g_strdup (_("Move the selected folders out of the trash"));
-                               }
-                       }
-               } else if (files_is_none_directory (files)) {
-                       if (original_name != NULL) {
-                               if (g_list_length (files) == 1) {
-                                       tooltip = g_strdup_printf (_("Move the selected file out of the trash 
to “%s”"),
-                                                                  original_name);
-                               } else {
-                                       tooltip = g_strdup_printf (_("Move the selected files out of the 
trash to “%s”"),
-                                                                  original_name);
-                               }
-                       } else {
-                               if (g_list_length (files) == 1) {
-                                       tooltip = g_strdup (_("Move the selected file out of the trash"));
-                               } else {
-                                       tooltip = g_strdup (_("Move the selected files out of the trash"));
-                               }
-                       }
-               } else {
-                       if (original_name != NULL) {
-                               if (g_list_length (files) == 1) {
-                                       tooltip = g_strdup_printf (_("Move the selected item out of the trash 
to “%s”"),
-                                                                  original_name);
-                               } else {
-                                       tooltip = g_strdup_printf (_("Move the selected items out of the 
trash to “%s”"),
-                                                                  original_name);
-                               }
-                       } else {
-                               if (g_list_length (files) == 1) {
-                                       tooltip = g_strdup (_("Move the selected item out of the trash"));
-                               } else {
-                                       tooltip = g_strdup (_("Move the selected items out of the trash"));
-                               }
-                       }
-               }
-               g_free (original_name);
-
-               g_object_set (action, "tooltip", tooltip, NULL);
-               g_free (tooltip);
-
-               if (original_location != NULL) {
-                       g_object_unref (original_location);
-               }
-       } else {
-               gtk_action_set_visible (action, FALSE);
-       }
+       can_restore = original_file != NULL || original_dirs != NULL;
 
        nautilus_file_unref (original_file);
        nautilus_file_unref (original_dir);
@@ -7829,508 +5357,15 @@ update_restore_from_trash_action (GtkAction *action,
        if (original_dirs_hash != NULL) {
                g_hash_table_destroy (original_dirs_hash);
        }
-}
-
-static void
-real_update_menus_volumes (NautilusView *view,
-                          GList *selection,
-                          gint selection_count)
-{
-       GList *l;
-       NautilusFile *file;
-       gboolean show_mount;
-       gboolean show_unmount;
-       gboolean show_eject;
-       gboolean show_start;
-       gboolean show_stop;
-       gboolean show_poll;
-       GDriveStartStopType start_stop_type;
-       gboolean show_self_mount;
-       gboolean show_self_unmount;
-       gboolean show_self_eject;
-       gboolean show_self_start;
-       gboolean show_self_stop;
-       gboolean show_self_poll;
-       GDriveStartStopType self_start_stop_type;
-       GtkAction *action;
-
-       show_mount = (selection != NULL);
-       show_unmount = (selection != NULL);
-       show_eject = (selection != NULL);
-       show_start = (selection != NULL && selection_count == 1);
-       show_stop = (selection != NULL && selection_count == 1);
-       show_poll = (selection != NULL && selection_count == 1);
-       start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN;
-       self_start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN;
-
-       for (l = selection; l != NULL && (show_mount || show_unmount
-                                         || show_eject
-                                          || show_start || show_stop
-                                         || show_poll);
-            l = l->next) {
-               gboolean show_mount_one;
-               gboolean show_unmount_one;
-               gboolean show_eject_one;
-               gboolean show_start_one;
-               gboolean show_stop_one;
-               gboolean show_poll_one;
-
-               file = NAUTILUS_FILE (l->data);
-               file_should_show_foreach (file,
-                                         &show_mount_one,
-                                         &show_unmount_one,
-                                         &show_eject_one,
-                                          &show_start_one,
-                                          &show_stop_one,
-                                         &show_poll_one,
-                                         &start_stop_type);
-
-               show_mount &= show_mount_one;
-               show_unmount &= show_unmount_one;
-               show_eject &= show_eject_one;
-               show_start &= show_start_one;
-               show_stop &= show_stop_one;
-               show_poll &= show_poll_one;
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_MOUNT_VOLUME);
-       gtk_action_set_visible (action, show_mount);
-       
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_UNMOUNT_VOLUME);
-       gtk_action_set_visible (action, show_unmount);
-       
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_EJECT_VOLUME);
-       gtk_action_set_visible (action, show_eject);
-       
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_START_VOLUME);
-       gtk_action_set_visible (action, show_start);
-       if (show_start) {
-               switch (start_stop_type) {
-               default:
-               case G_DRIVE_START_STOP_TYPE_UNKNOWN:
-                       gtk_action_set_label (action, _("_Start"));
-                       gtk_action_set_tooltip (action, _("Start the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
-                       gtk_action_set_label (action, _("_Start"));
-                       gtk_action_set_tooltip (action, _("Start the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_NETWORK:
-                       gtk_action_set_label (action, _("_Connect"));
-                       gtk_action_set_tooltip (action, _("Connect to the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_MULTIDISK:
-                       gtk_action_set_label (action, _("_Start Multi-disk Drive"));
-                       gtk_action_set_tooltip (action, _("Start the selected multi-disk drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_PASSWORD:
-                       gtk_action_set_label (action, _("U_nlock Drive"));
-                       gtk_action_set_tooltip (action, _("Unlock the selected drive"));
-                       break;
-               }
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_STOP_VOLUME);
-       gtk_action_set_visible (action, show_stop);
-       if (show_stop) {
-               switch (start_stop_type) {
-               default:
-               case G_DRIVE_START_STOP_TYPE_UNKNOWN:
-                       gtk_action_set_label (action, _("_Stop"));
-                       gtk_action_set_tooltip (action, _("Stop the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
-                       gtk_action_set_label (action, _("_Safely Remove Drive"));
-                       gtk_action_set_tooltip (action, _("Safely remove the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_NETWORK:
-                       gtk_action_set_label (action, _("_Disconnect"));
-                       gtk_action_set_tooltip (action, _("Disconnect the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_MULTIDISK:
-                       gtk_action_set_label (action, _("_Stop Multi-disk Drive"));
-                       gtk_action_set_tooltip (action, _("Stop the selected multi-disk drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_PASSWORD:
-                       gtk_action_set_label (action, _("_Lock Drive"));
-                       gtk_action_set_tooltip (action, _("Lock the selected drive"));
-                       break;
-               }
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_POLL);
-       gtk_action_set_visible (action, show_poll);
-
-       show_self_mount = show_self_unmount = show_self_eject =
-               show_self_start = show_self_stop = show_self_poll = FALSE;
-
-       file = nautilus_view_get_directory_as_file (view);
-       file_should_show_self (file,
-                              &show_self_mount,
-                              &show_self_unmount,
-                              &show_self_eject,
-                              &show_self_start,
-                              &show_self_stop,
-                              &show_self_poll,
-                              &self_start_stop_type);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELF_MOUNT_VOLUME);
-       gtk_action_set_visible (action, show_self_mount);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELF_UNMOUNT_VOLUME);
-       gtk_action_set_visible (action, show_self_unmount);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELF_EJECT_VOLUME);
-       gtk_action_set_visible (action, show_self_eject);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELF_START_VOLUME);
-       gtk_action_set_visible (action, show_self_start);
-       if (show_self_start) {
-               switch (self_start_stop_type) {
-               default:
-               case G_DRIVE_START_STOP_TYPE_UNKNOWN:
-                       gtk_action_set_label (action, _("_Start"));
-                       gtk_action_set_tooltip (action, _("Start the drive associated with the open folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
-                       gtk_action_set_label (action, _("_Start"));
-                       gtk_action_set_tooltip (action, _("Start the drive associated with the open folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_NETWORK:
-                       gtk_action_set_label (action, _("_Connect"));
-                       gtk_action_set_tooltip (action, _("Connect to the drive associated with the open 
folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_MULTIDISK:
-                       gtk_action_set_label (action, _("_Start Multi-disk Drive"));
-                       gtk_action_set_tooltip (action, _("Start the multi-disk drive associated with the 
open folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_PASSWORD:
-                       gtk_action_set_label (action, _("_Unlock Drive"));
-                       gtk_action_set_tooltip (action, _("Unlock the drive associated with the open 
folder"));
-                       break;
-               }
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELF_STOP_VOLUME);
-       gtk_action_set_visible (action, show_self_stop);
-       if (show_self_stop) {
-               switch (self_start_stop_type) {
-               default:
-               case G_DRIVE_START_STOP_TYPE_UNKNOWN:
-                       gtk_action_set_label (action, _("_Stop"));
-                       gtk_action_set_tooltip (action, _("_Stop the drive associated with the open folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
-                       gtk_action_set_label (action, _("_Safely Remove Drive"));
-                       gtk_action_set_tooltip (action, _("Safely remove the drive associated with the open 
folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_NETWORK:
-                       gtk_action_set_label (action, _("_Disconnect"));
-                       gtk_action_set_tooltip (action, _("Disconnect the drive associated with the open 
folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_MULTIDISK:
-                       gtk_action_set_label (action, _("_Stop Multi-disk Drive"));
-                       gtk_action_set_tooltip (action, _("Stop the multi-disk drive associated with the open 
folder"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_PASSWORD:
-                       gtk_action_set_label (action, _("_Lock Drive"));
-                       gtk_action_set_tooltip (action, _("Lock the drive associated with the open folder"));
-                       break;
-               }
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELF_POLL);
-       gtk_action_set_visible (action, show_self_poll);
-
-}
-
-static void
-real_update_location_menu_volumes (NautilusView *view)
-{
-       GtkAction *action;
-       NautilusFile *file;
-       gboolean show_mount;
-       gboolean show_unmount;
-       gboolean show_eject;
-       gboolean show_start;
-       gboolean show_stop;
-       gboolean show_poll;
-       GDriveStartStopType start_stop_type;
-
-       g_assert (NAUTILUS_IS_VIEW (view));
-       g_assert (NAUTILUS_IS_FILE (view->details->location_popup_directory_as_file));
-
-       file = NAUTILUS_FILE (view->details->location_popup_directory_as_file);
-       file_should_show_foreach (file,
-                                 &show_mount,
-                                 &show_unmount,
-                                 &show_eject,
-                                 &show_start,
-                                 &show_stop,
-                                 &show_poll,
-                                 &start_stop_type);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_MOUNT_VOLUME);
-       gtk_action_set_visible (action, show_mount);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_UNMOUNT_VOLUME);
-       gtk_action_set_visible (action, show_unmount);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_EJECT_VOLUME);
-       gtk_action_set_visible (action, show_eject);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_START_VOLUME);
-       gtk_action_set_visible (action, show_start);
-       if (show_start) {
-               switch (start_stop_type) {
-               default:
-               case G_DRIVE_START_STOP_TYPE_UNKNOWN:
-                       gtk_action_set_label (action, _("_Start"));
-                       gtk_action_set_tooltip (action, _("Start the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
-                       gtk_action_set_label (action, _("_Start"));
-                       gtk_action_set_tooltip (action, _("Start the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_NETWORK:
-                       gtk_action_set_label (action, _("_Connect"));
-                       gtk_action_set_tooltip (action, _("Connect to the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_MULTIDISK:
-                       gtk_action_set_label (action, _("_Start Multi-disk Drive"));
-                       gtk_action_set_tooltip (action, _("Start the selected multi-disk drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_PASSWORD:
-                       gtk_action_set_label (action, _("_Unlock Drive"));
-                       gtk_action_set_tooltip (action, _("Unlock the selected drive"));
-                       break;
-               }
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_STOP_VOLUME);
-       gtk_action_set_visible (action, show_stop);
-       if (show_stop) {
-               switch (start_stop_type) {
-               default:
-               case G_DRIVE_START_STOP_TYPE_UNKNOWN:
-                       gtk_action_set_label (action, _("_Stop"));
-                       gtk_action_set_tooltip (action, _("Stop the selected volume"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
-                       gtk_action_set_label (action, _("_Safely Remove Drive"));
-                       gtk_action_set_tooltip (action, _("Safely remove the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_NETWORK:
-                       gtk_action_set_label (action, _("_Disconnect"));
-                       gtk_action_set_tooltip (action, _("Disconnect the selected drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_MULTIDISK:
-                       gtk_action_set_label (action, _("_Stop Multi-disk Drive"));
-                       gtk_action_set_tooltip (action, _("Stop the selected multi-disk drive"));
-                       break;
-               case G_DRIVE_START_STOP_TYPE_PASSWORD:
-                       gtk_action_set_label (action, _("_Lock Drive"));
-                       gtk_action_set_tooltip (action, _("Lock the selected drive"));
-                       break;
-               }
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_POLL);
-       gtk_action_set_visible (action, show_poll);
-}
-
-/* TODO: we should split out this routine into two functions:
- * Update on clipboard changes
- * Update on selection changes
- */
-static void
-real_update_paste_menu (NautilusView *view,
-                       GList *selection,
-                       gint selection_count)
-{
-       gboolean can_paste_files_into;
-       gboolean selection_is_read_only;
-       gboolean selection_contains_recent;
-       gboolean is_read_only;
-       GtkAction *action;
-
-       selection_is_read_only = selection_count == 1 &&
-               (!nautilus_file_can_write (NAUTILUS_FILE (selection->data)) &&
-                !nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
-
-       is_read_only = nautilus_view_is_read_only (view);
-       selection_contains_recent = showing_recent_directory (view);
-
-       can_paste_files_into = (!selection_contains_recent &&
-                               selection_count == 1 &&
-                               can_paste_into_file (NAUTILUS_FILE (selection->data)));
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_PASTE);
-       gtk_action_set_sensitive (action, !is_read_only);
-       gtk_action_set_visible (action, !selection_contains_recent);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_PASTE_FILES_INTO);
-       gtk_action_set_visible (action, can_paste_files_into);
-       gtk_action_set_sensitive (action, !selection_is_read_only);
-
-       /* Ask the clipboard */
-       g_object_ref (view); /* Need to keep the object alive until we get the reply */
-       gtk_clipboard_request_targets (nautilus_clipboard_get (GTK_WIDGET (view)),
-                                      clipboard_targets_received,
-                                      view);
-}
-
-static void
-real_update_location_menu (NautilusView *view)
-{
-       GtkAction *action;
-       NautilusFile *file;
-       gboolean is_special_link;
-       gboolean is_desktop_or_home_dir;
-       gboolean is_recent;
-       gboolean can_delete_file, show_delete;
-       gboolean show_separate_delete_command;
-       GList l;
-       char *label;
-       char *tip;
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_OPEN_ALTERNATE);
-
-       label = _("Open in New _Window");
-       g_object_set (action,
-                     "label", label,
-                     NULL);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_OPEN_IN_NEW_TAB);
-
-       label = _("Open in New _Tab");
-       g_object_set (action,
-                     "label", label,
-                     NULL);
-
-       file = view->details->location_popup_directory_as_file;
-       g_assert (NAUTILUS_IS_FILE (file));
-       g_assert (nautilus_file_check_if_ready (file, NAUTILUS_FILE_ATTRIBUTE_INFO |
-                                               NAUTILUS_FILE_ATTRIBUTE_MOUNT |
-                                               NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO));
-
-       is_special_link = NAUTILUS_IS_DESKTOP_ICON_FILE (file);
-       is_desktop_or_home_dir = nautilus_file_is_home (file)
-               || nautilus_file_is_desktop_directory (file);
-       is_recent = nautilus_file_is_in_recent (file);
-
-       can_delete_file =
-               nautilus_file_can_delete (file) &&
-               !is_special_link &&
-               !is_desktop_or_home_dir;
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_CUT);
-       gtk_action_set_sensitive (action, !is_recent && can_delete_file);
-       gtk_action_set_visible (action, !is_recent);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_PASTE_FILES_INTO);
-       g_object_set_data (G_OBJECT (action),
-                          "can-paste-according-to-destination",
-                          GINT_TO_POINTER (can_paste_into_file (file)));
-       gtk_action_set_sensitive (action,
-                                 !is_recent &&
-                                 GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),
-                                                                     "can-paste-according-to-clipboard")) &&
-                                 GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),
-                                                                     "can-paste-according-to-destination")));
-       gtk_action_set_visible (action, !is_recent);
-
-       show_delete = TRUE;
-
-       if (file != NULL &&
-           nautilus_file_is_in_trash (file)) {
-               if (nautilus_file_is_self_owned (file)) {
-                       show_delete = FALSE;
-               }
-
-               label = _("_Delete Permanently");
-               tip = _("Delete the open folder permanently");
-               show_separate_delete_command = FALSE;
-       } else {
-               label = _("Mo_ve to Trash");
-               tip = _("Move the open folder to the Trash");
-               show_separate_delete_command = g_settings_get_boolean (nautilus_preferences, 
NAUTILUS_PREFERENCES_ENABLE_DELETE);
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_TRASH);
-       g_object_set (action,
-                     "label", label,
-                     "tooltip", tip,
-                     "icon-name", (file != NULL &&
-                                   nautilus_file_is_in_trash (file)) ?
-                     NAUTILUS_ICON_DELETE : NAUTILUS_ICON_TRASH_FULL,
-                     NULL);
-       gtk_action_set_sensitive (action, can_delete_file);
-       gtk_action_set_visible (action, show_delete);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_DELETE);
-       gtk_action_set_visible (action, show_separate_delete_command);
-       if (show_separate_delete_command) {
-               gtk_action_set_sensitive (action, can_delete_file);
-               g_object_set (action,
-                             "icon-name", NAUTILUS_ICON_DELETE,
-                             "sensitive", can_delete_file,
-                             NULL);
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_LOCATION_RESTORE_FROM_TRASH);
-       l.prev = NULL;
-       l.next = NULL;
-       l.data = file;
-       update_restore_from_trash_action (action, &l, TRUE);
 
-       real_update_location_menu_volumes (view);
+       return can_restore;
 }
 
 static void
 clipboard_changed_callback (NautilusClipboardMonitor *monitor, NautilusView *view)
 {
-       GList *selection;
-       gint selection_count;
-
-       if (!view->details->active) {
-               return;
-       }
-
-       selection = nautilus_view_get_selection (view);
-       selection_count = g_list_length (selection);
-
-       real_update_paste_menu (view, selection, selection_count);
-
-       nautilus_file_list_free (selection);
-       
+       /* Update paste menu item */
+       nautilus_view_update_right_click_menus (view);
 }
 
 static gboolean
@@ -8363,48 +5398,65 @@ can_trash_all (GList *files)
        return TRUE;
 }
 
+GActionGroup *
+nautilus_view_get_action_group (NautilusView *view)
+{
+       g_assert (NAUTILUS_IS_VIEW (view));
+
+       return view->details->view_action_group;
+}
+
 static void
-real_update_menus (NautilusView *view)
+real_update_actions_state (NautilusView *view)
 {
-       GList *selection, *l;
+       GList *selection;
+       NautilusFile *file;
        gint selection_count;
-       const char *tip, *label;
-       char *label_with_underscore;
        gboolean selection_contains_special_link;
        gboolean selection_contains_desktop_or_home_dir;
        gboolean selection_contains_recent;
        gboolean selection_contains_search;
-       gboolean selection_all_in_trash;
+       gboolean selection_is_read_only;
        gboolean can_create_files;
        gboolean can_delete_files;
        gboolean can_move_files;
        gboolean can_trash_files;
        gboolean can_copy_files;
-       gboolean can_link_files;
+       gboolean can_paste_files_into;
        gboolean show_separate_delete_command;
-       gboolean show_open_alternate;
-       gboolean show_open_in_new_tab;
-       gboolean can_open;
        gboolean show_app, show_run;
-       gboolean show_save_search;
-       gboolean save_search_sensitive;
-       gboolean show_save_search_as;
-       GtkAction *action;
+       gboolean item_opens_in_view;
+       gboolean is_read_only;
+       GAction *action;
        GAppInfo *app;
-       GIcon *app_icon;
-       GtkWidget *menuitem;
        gboolean show_properties;
+       GActionGroup *view_action_group;
+       gboolean show_mount;
+       gboolean show_unmount;
+       gboolean show_eject;
+       gboolean show_start;
+       gboolean show_stop;
+       gboolean show_detect_media;
+       GDriveStartStopType start_stop_type;
+       NautilusFileUndoInfo *info;
+       NautilusFileUndoManagerState undo_state;
+       gboolean undo_active, redo_active;
+       gboolean is_undo;
+
+       view_action_group = view->details->view_action_group;
 
        selection = nautilus_view_get_selection (view);
        selection_count = g_list_length (selection);
-
        selection_contains_special_link = special_link_in_selection (selection);
        selection_contains_desktop_or_home_dir = desktop_or_home_dir_in_selection (selection);
        selection_contains_recent = showing_recent_directory (view);
        selection_contains_search = view->details->model &&
                NAUTILUS_IS_SEARCH_DIRECTORY (view->details->model);
-       selection_all_in_trash = all_selected_items_in_trash (selection);
+       selection_is_read_only = selection_count == 1 &&
+               (!nautilus_file_can_write (NAUTILUS_FILE (selection->data)) &&
+                !nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
 
+       is_read_only = nautilus_view_is_read_only (view);
        can_create_files = nautilus_view_supports_creating_files (view);
        can_delete_files =
                can_delete_all (selection) &&
@@ -8418,479 +5470,625 @@ real_update_menus (NautilusView *view)
                !selection_contains_desktop_or_home_dir;
        can_copy_files = selection_count != 0
                && !selection_contains_special_link;
-
        can_move_files = can_delete_files && !selection_contains_recent;
-       can_link_files = can_create_files && can_copy_files;
+       can_paste_files_into = (!selection_contains_recent &&
+                               selection_count == 1 &&
+                               can_paste_into_file (NAUTILUS_FILE (selection->data)));
+       show_properties = !showing_network_directory (view) &&
+                         (!NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view) || selection_count > 0);
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_RENAME);
-       /* rename sensitivity depending on selection */
+       /* Right click actions */
+       /* Selection menu actions */
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "rename");
        if (selection_count > 1) {
-               /* If multiple files are selected, sensitivity depends on whether a bulk renamer is 
registered. */
-               gtk_action_set_sensitive (action, have_bulk_rename_tool ());
-       } else {
-               gtk_action_set_sensitive (action,
-                                         selection_count == 1 &&
-                                         nautilus_view_can_rename_file (view, selection->data));
-       }
-       gtk_action_set_visible (action, !selection_contains_recent);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SET_AS_WALLPAPER);
-       /* rename sensitivity depending on selection */
-       if (can_set_wallpaper (selection)) {
-               gtk_action_set_visible (action, TRUE);
+               g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                      have_bulk_rename_tool ());
        } else {
-               gtk_action_set_visible (action, FALSE);
+               g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                      selection_count == 1 &&
+                                      nautilus_view_can_rename_file (view, selection->data));
        }
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_OPEN_ITEM_LOCATION);
-       if (selection_count == 1 &&
-           (selection_contains_recent || selection_contains_search))
-       {
-               gtk_action_set_visible (action, TRUE);
-       } else {
-               gtk_action_set_visible (action, FALSE);
-       }
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_NEW_FOLDER);
-       gtk_action_set_sensitive (action, can_create_files);
-       gtk_action_set_visible (action, !selection_contains_recent);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_NEW_FOLDER_WITH_SELECTION);
-       gtk_action_set_sensitive (action, can_create_files && can_delete_files && (selection_count > 1));
-       gtk_action_set_visible (action, !selection_contains_recent && (selection_count > 1));
-       label_with_underscore = g_strdup_printf (ngettext("New Folder with Selection (%'d Item)",
-                                                         "New Folder with Selection (%'d Items)",
-                                                         selection_count),
-                                                selection_count);
-       g_object_set (action, "label", label_with_underscore, NULL);
-       g_free (label_with_underscore);
-
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_OPEN);
-       gtk_action_set_sensitive (action, selection_count != 0);
-       
-       can_open = show_app = show_run = selection_count != 0;
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "open-item-location");
 
-       for (l = selection; l != NULL; l = l->next) {
-               NautilusFile *file;
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    selection_count == 1 &&
+                                    (selection_contains_recent || selection_contains_search));
 
-               file = NAUTILUS_FILE (selection->data);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "new-folder");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_create_files);
 
-               if (!nautilus_mime_file_opens_in_external_app (file)) {
-                       show_app = FALSE;
-               }
 
-               if (!nautilus_mime_file_launches (file)) {
-                       show_run = FALSE;
-               }
+       selection = nautilus_view_get_selection (view);
+       selection_count = g_list_length (selection);
 
-               if (!show_app && !show_run) {
-                       break;
-               }
-       } 
+       file = NULL;
+       if (selection_count == 1)
+               file = NAUTILUS_FILE (selection->data);
 
-       label_with_underscore = NULL;
+       item_opens_in_view = show_app = show_run = selection_count == 1 && file != NULL;
+       item_opens_in_view = item_opens_in_view && nautilus_mime_file_opens_in_view (file);
+       show_app = show_app && nautilus_mime_file_opens_in_external_app (file);
+       show_run = show_run && nautilus_mime_file_launches (file);
 
+       /* Open With <App> menu item */
        app = NULL;
-       app_icon = NULL;
-
-       if (can_open && show_app) {
+       if (show_app) {
                app = nautilus_mime_get_default_application_for_files (selection);
        }
 
-       if (app != NULL) {
-               char *escaped_app;
-
-               escaped_app = eel_str_double_underscores (g_app_info_get_name (app));
-               label_with_underscore = g_strdup_printf (_("_Open With %s"),
-                                                        escaped_app);
-
-               app_icon = g_app_info_get_icon (app);
-               if (app_icon != NULL) {
-                       g_object_ref (app_icon);
-               }
-
-               g_free (escaped_app);
-               g_object_unref (app);
-       } else if (show_run) {
-               label_with_underscore = g_strdup (_("Run"));
-       } else {
-               label_with_underscore = g_strdup (_("_Open"));
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "open-with-default-application");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), app != NULL || show_run || item_opens_in_view);
+       /* Allow to select a different application to open the item */
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "open-with-other-application");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), app != NULL);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "open-item-new-tab");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), item_opens_in_view);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "open-item-new-window");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), item_opens_in_view);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "set-as-wallpaper");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),  can_set_wallpaper (selection));
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "restore-from-trash");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_restore_from_trash (selection));
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "move-to-trash");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_trash_files);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "delete");
+       /* Only show it in trash folder or the setting to include a delete menu item
+        * is enabled */
+       show_separate_delete_command = g_settings_get_boolean (nautilus_preferences, 
NAUTILUS_PREFERENCES_ENABLE_DELETE);
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), 
+                                    can_delete_files &&
+                                    (!can_trash_files || show_separate_delete_command));
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "cut");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    can_move_files && !selection_contains_recent);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "copy");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    can_copy_files);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "copy-to");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    can_copy_files);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "move-to");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    can_move_files && !selection_contains_recent);
+
+       /* Drive menu */
+       show_mount = show_unmount = show_eject = show_start = show_stop = show_detect_media = FALSE;
+       if (file != NULL && selection_count == 1) {
+               start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN;
+               file_should_show_foreach (file,
+                                         &show_mount,
+                                         &show_unmount,
+                                         &show_eject,
+                                         &show_start,
+                                         &show_stop,
+                                         &show_detect_media,
+                                         &start_stop_type);
        }
 
-       g_object_set (action, "label", label_with_underscore, NULL);
-       g_free (label_with_underscore);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "mount-volume");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    show_mount);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "unmount-volume");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    show_unmount);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "eject-volume");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    show_eject);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "start-volume");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    show_start);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "stop-volume");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    show_stop);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "detect-media");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    show_detect_media);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "scripts");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    view->details->scripts_present);
+
+       /* Background menu actions */
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "new-folder");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_create_files);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "paste");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    !is_read_only && !selection_contains_recent);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "paste-into");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    !selection_is_read_only && !selection_contains_recent &&
+                                    can_paste_files_into);
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "properties");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    show_properties);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "new-document");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    can_create_files &&
+                                    !selection_contains_recent &&
+                                    view->details->templates_present);
 
-       menuitem = gtk_ui_manager_get_widget (
-                                             nautilus_view_get_ui_manager (view),
-                                             NAUTILUS_VIEW_POPUP_PATH_OPEN);
+       /* Ask the clipboard */
+       g_object_ref (view); /* Need to keep the object alive until we get the reply */
+       gtk_clipboard_request_targets (nautilus_clipboard_get (GTK_WIDGET (view)),
+                                      clipboard_targets_received,
+                                      view);
 
-       /* Only force displaying the icon if it is an application icon */
-       gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), app_icon != NULL);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "select-all");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    !nautilus_view_is_empty (view));
 
-       if (app_icon == NULL) {
-               app_icon = g_themed_icon_new ("gtk-open");
+       /* Toolbar menu actions */
+       /* Undo and Redo */
+       info = nautilus_file_undo_manager_get_action ();
+       undo_state = nautilus_file_undo_manager_get_state ();
+       undo_active = redo_active = FALSE;
+       if (info != NULL && 
+           (undo_state > NAUTILUS_FILE_UNDO_MANAGER_STATE_NONE)) {
+               is_undo = (undo_state == NAUTILUS_FILE_UNDO_MANAGER_STATE_UNDO);
+               undo_active = is_undo;
+               redo_active = !is_undo;
        }
 
-       gtk_action_set_gicon (action, app_icon);
-       g_object_unref (app_icon);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "undo");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), undo_active);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "redo");
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), redo_active);
 
-       gtk_action_set_visible (action, can_open);
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "show-hidden-files");
+       g_action_change_state (action,
+                              g_variant_new_boolean (view->details->show_hidden_files));
+}
 
-       show_open_alternate = file_list_all_are_folders (selection) &&
-               selection_count > 0 &&
-               !NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view);
+/* Convenience function to be called when updating menus,
+ * so children can subclass it and it will be called when
+ * they chain up to the parent in update_right_click_menus
+ * or update_toolbar_menus
+ */
+void
+nautilus_view_update_actions_state (NautilusView *view)
+{
+       g_assert(NAUTILUS_IS_VIEW (view));
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_OPEN_ALTERNATE);
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_actions_state (view);
+}
 
-       gtk_action_set_sensitive (action,  selection_count != 0);
-       gtk_action_set_visible (action, show_open_alternate);
+static void
+update_selection_menu (NautilusView *view)
+{
+       GList *selection;
+       NautilusFile *file;
+       gint selection_count;
+       gboolean show_app, show_run;
+       gboolean item_opens_in_view;
+       gchar *label_with_underscore;
+       gchar *start_label, *stop_label;        
+       GAppInfo *app;
+       GIcon *app_icon;
+       GMenuItem *open_menu_item, *start_menu_item, *stop_menu_item;
+       gboolean show_mount;
+       gboolean show_unmount;
+       gboolean show_eject;
+       gboolean show_start;
+       gboolean show_stop;
+       gboolean show_detect_media;
+       GDriveStartStopType start_stop_type;
 
-       if (selection_count == 0 || selection_count == 1) {
-               label_with_underscore = g_strdup (_("Open in New _Window"));
-       } else {
-               label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Window",
-                                                                 "Open in %'d New _Windows",
-                                                                 selection_count), 
-                                                        selection_count);
-       }
+       selection = nautilus_view_get_selection (view);
+       selection_count = g_list_length (selection);
 
-       g_object_set (action, "label", 
-                     label_with_underscore,
-                     NULL);
-       g_free (label_with_underscore);
+       file = NULL;
+       if (selection_count == 1)
+               file = NAUTILUS_FILE (selection->data);
 
-       show_open_in_new_tab = show_open_alternate;
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_OPEN_IN_NEW_TAB);
-       gtk_action_set_sensitive (action, selection_count != 0);
-       gtk_action_set_visible (action, show_open_in_new_tab);
+       /* Open With <App> menu item */
+       item_opens_in_view = show_app = show_run = selection_count == 1 && file != NULL;
+       item_opens_in_view = item_opens_in_view && nautilus_mime_file_opens_in_view (file);
+       show_app = show_app && nautilus_mime_file_opens_in_external_app (file);
+       show_run = show_run && nautilus_mime_file_launches (file);
 
-       if (selection_count == 0 || selection_count == 1) {
-               label_with_underscore = g_strdup (_("Open in New _Tab"));
-       } else {
-               label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Tab",
-                                                                 "Open in %'d New _Tabs",
-                                                                 selection_count), 
-                                                        selection_count);
+       label_with_underscore = NULL;
+       app = NULL;
+       app_icon = NULL;
+       if (show_app) {
+               app = nautilus_mime_get_default_application_for_files (selection);
        }
 
-       g_object_set (action, "label", 
-                     label_with_underscore,
-                     NULL);
-       g_free (label_with_underscore);
+       if (app != NULL || show_run || item_opens_in_view) {
+               char *escaped_app;
 
-       /* Broken into its own function just for convenience */
-       reset_open_with_menu (view, selection);
-       reset_extension_actions_menu (view, selection);
+               if (app != NULL) {
+                       escaped_app = eel_str_double_underscores (g_app_info_get_name (app));
+                       label_with_underscore = g_strdup_printf (_("Open With %s"),
+                                                                escaped_app);
 
-       if (selection_all_in_trash) {
-               label = _("_Delete Permanently");
-               tip = _("Delete all selected items permanently");
-               show_separate_delete_command = FALSE;
-       } else {
-               label = _("Mo_ve to Trash");
-               tip = _("Move each selected item to the Trash");
-               show_separate_delete_command = g_settings_get_boolean (nautilus_preferences, 
NAUTILUS_PREFERENCES_ENABLE_DELETE);
-       }
-       
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_TRASH);
-       g_object_set (action,
-                     "label", label,
-                     "tooltip", tip,
-                     "icon-name", selection_all_in_trash ?
-                     NAUTILUS_ICON_DELETE : NAUTILUS_ICON_TRASH_FULL,
-                     NULL);
-       /* if the backend supports delete but not trash then don't show trash */
-       if (!can_trash_files && can_delete_files) {
-               gtk_action_set_visible (action, FALSE);
-       } else {
-               gtk_action_set_visible (action, TRUE);
-               gtk_action_set_sensitive (action, can_trash_files);
-       }
+                       app_icon = g_app_info_get_icon (app);
+                       if (app_icon != NULL) {
+                               g_object_ref (app_icon);
+                       }
+                       g_free (escaped_app);
+                       g_object_unref (app);
+               } else if (show_run) {
+                       label_with_underscore = g_strdup (_("Run"));
+               } else {
+                       label_with_underscore = g_strdup (_("Open"));
+               }
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_DELETE);
-       /* if the backend doesn't support trash but supports delete
-          show the delete option. or if the user set this  pref */
-       gtk_action_set_visible (action, (!can_trash_files && can_delete_files) || 
show_separate_delete_command);
+               open_menu_item = g_menu_item_new (label_with_underscore, 
"view.open-with-default-application");
+               if (app_icon != NULL)
+                       g_menu_item_set_icon (open_menu_item, app_icon);
 
-       if (selection_contains_recent) {
-               label = _("Remo_ve from Recent");
-               tip = _("Remove each selected item from the recently used list");
-       } else {
-               label = _("_Delete");
-               tip = _("Delete each selected item, without moving to the Trash");
-       }
+               nautilus_gmenu_add_item_in_submodel (view->details->selection_menu,
+                                                    open_menu_item,
+                                                    "open-with-default-application-section",
+                                                    FALSE);
 
-       if ((!can_trash_files && can_delete_files) || show_separate_delete_command) {
-               g_object_set (action,
-                             "label", label,
-                             "tooltip", tip,
-                             "icon-name", NAUTILUS_ICON_DELETE,
-                             NULL);
+               g_free (label_with_underscore);
        }
-       gtk_action_set_sensitive (action, can_delete_files);
 
+       /* Drives */
+       if (file != NULL && selection_count == 1) {
+               start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN;
+               file_should_show_foreach (file,
+                                         &show_mount,
+                                         &show_unmount,
+                                         &show_eject,
+                                         &show_start,
+                                         &show_stop,
+                                         &show_detect_media,
+                                         &start_stop_type);
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_RESTORE_FROM_TRASH);
-       update_restore_from_trash_action (action, selection, FALSE);
+               if (show_start) {
+                       switch (start_stop_type) {
+                       default:
+                       case G_DRIVE_START_STOP_TYPE_UNKNOWN:
+                       case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
+                               start_label = _("_Start");
+                               break;
+                       case G_DRIVE_START_STOP_TYPE_NETWORK:
+                               start_label = _("_Connect");
+                               break;
+                       case G_DRIVE_START_STOP_TYPE_MULTIDISK:
+                               start_label = _("_Start Multi-disk Drive");
+                               break;
+                       case G_DRIVE_START_STOP_TYPE_PASSWORD:
+                               start_label = _("U_nlock Drive");
+                               break;
+                       }
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_CREATE_LINK);
-       gtk_action_set_sensitive (action, can_link_files);
-       gtk_action_set_visible (action, !selection_contains_recent);
-       g_object_set (action, "label",
-                     ngettext ("Ma_ke Link",
-                               "Ma_ke Links",
-                               selection_count),
-                     NULL);
+                       start_menu_item = g_menu_item_new (start_label, "view.start-volume");
+                       nautilus_gmenu_add_item_in_submodel (view->details->selection_menu,
+                                                            start_menu_item,
+                                                            "drive-section",
+                                                            FALSE);
 
-       show_properties = !showing_network_directory (view)
-               && (!NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view) || selection_count > 0);
+               }
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_PROPERTIES);
+               if (show_stop) {
+                       switch (start_stop_type) {
+                       default:
+                       case G_DRIVE_START_STOP_TYPE_UNKNOWN:
+                               stop_label = _("Stop Drive");
+                               break;
+                       case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
+                               stop_label = _("_Safely Remove Drive");
+                               break;
+                       case G_DRIVE_START_STOP_TYPE_NETWORK:
+                               stop_label = _("_Disconnect");
+                               break;
+                       case G_DRIVE_START_STOP_TYPE_MULTIDISK:
+                               stop_label = _("_Stop Multi-disk Drive");
+                               break;
+                       case G_DRIVE_START_STOP_TYPE_PASSWORD:
+                               stop_label = _("_Lock Drive");
+                               break;
+                       }
 
-       gtk_action_set_sensitive (action, show_properties);
-       gtk_action_set_visible (action, show_properties);
+                       stop_menu_item = g_menu_item_new (stop_label, "view.stop-volume");
+                       nautilus_gmenu_add_item_in_submodel (view->details->selection_menu,
+                                                            stop_menu_item,
+                                                            "drive-section",
+                                                            FALSE);
+               }
 
-       if (selection_count == 0) {
-               gtk_action_set_tooltip (action, _("View or modify the properties of the open folder"));
-       } else {
-               gtk_action_set_tooltip (action, _("View or modify the properties of each selected item"));
        }
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_PROPERTIES_ACCEL);
+       update_scripts_menu (view);
+}
 
-       gtk_action_set_sensitive (action, show_properties);
-       gtk_action_set_visible (action, show_properties);
+static void
+update_background_menu (NautilusView *view)
+{
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_EMPTY_TRASH);
-       g_object_set (action,
-                     "label", _("E_mpty Trash"),
-                     NULL);
-       gtk_action_set_sensitive (action, !nautilus_trash_monitor_is_empty ());
-       gtk_action_set_visible (action, should_show_empty_trash (view));
-
-       show_save_search = FALSE;
-       save_search_sensitive = FALSE;
-       show_save_search_as = FALSE;
-       if (selection_contains_search) {
-               NautilusSearchDirectory *search;
-
-               search = NAUTILUS_SEARCH_DIRECTORY (view->details->model);
-               if (nautilus_search_directory_is_saved_search (search)) {
-                       show_save_search = TRUE;
-                       save_search_sensitive = nautilus_search_directory_is_modified (search);
-               } else {
-                       show_save_search_as = TRUE;
-               }
-       } 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SAVE_SEARCH);
-       gtk_action_set_visible (action, show_save_search);
-       gtk_action_set_sensitive (action, save_search_sensitive);
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SAVE_SEARCH_AS);
-       gtk_action_set_visible (action, show_save_search_as);
+       if (nautilus_view_supports_creating_files (view) &&
+           !showing_recent_directory (view))
+               update_templates_menu (view);
+}
 
+static void
+real_update_right_click_menus (NautilusView *view)
+{
+       if (view->details->background_menu != NULL)
+               g_object_unref (view->details->background_menu);
+       if (view->details->selection_menu != NULL)
+               g_object_unref (view->details->selection_menu);
+       if (view->details->pathbar_menu != NULL)
+               g_object_unref (view->details->pathbar_menu);
+       
+       GtkBuilder *builder;
+       builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-view-right-click-menus.xml");
+       view->details->background_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, 
"background-menu")));
+       view->details->selection_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, 
"selection-menu")));
+       view->details->pathbar_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, 
"pathbar-menu")));
+       g_object_unref (builder);
+
+       update_selection_menu (view);
+       update_background_menu (view);
+       nautilus_view_update_actions_state (view);
+}
+
+/* Convenience function to reset the menus owned
+ * by the view and update them with the current state.
+ * Children can subclass it and add items on the menu
+ * after chaining up to the parent, so menus are already
+ * reseted.
+ * It will also update the actions state, which will also
+ * update children actions state if the children subclass
+ * nautilus_view_update_actions_state
+ */
+void
+nautilus_view_update_right_click_menus (NautilusView *view)
+{
+       g_assert(NAUTILUS_IS_VIEW (view));
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELECT_ALL);
-       gtk_action_set_sensitive (action, !nautilus_view_is_empty (view));
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_right_click_menus (view);
+}
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_SELECT_PATTERN);
-       gtk_action_set_sensitive (action, !nautilus_view_is_empty (view));
+static void
+real_update_toolbar_menus (NautilusView *view)
+{
+       NautilusToolbar *toolbar;
+       NautilusFileUndoInfo *info;
+       NautilusFileUndoManagerState undo_state;
+       gboolean undo_active, redo_active;
+       gchar *undo_label, *undo_description, *redo_label, *redo_description;
+       GMenuItem *undo_menu_item, *redo_menu_item;
+       gboolean is_undo;
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_INVERT_SELECTION);
-       gtk_action_set_sensitive (action, !nautilus_view_is_empty (view));
+       undo_label = undo_description = redo_label = redo_description = NULL;
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_CUT);
-       gtk_action_set_sensitive (action, can_move_files);
-       gtk_action_set_visible (action, !selection_contains_recent);
+       toolbar = NAUTILUS_TOOLBAR (nautilus_window_get_toolbar (nautilus_view_get_window (view)));
+       nautilus_toolbar_reset_menus (toolbar);
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_COPY);
-       gtk_action_set_sensitive (action, can_copy_files);
+       /* Undo and Redo */
+       info = nautilus_file_undo_manager_get_action ();
+       undo_state = nautilus_file_undo_manager_get_state ();
+       undo_active = redo_active = FALSE;
+       if (info != NULL && 
+           (undo_state > NAUTILUS_FILE_UNDO_MANAGER_STATE_NONE)) {
+               is_undo = (undo_state == NAUTILUS_FILE_UNDO_MANAGER_STATE_UNDO);
+               undo_active = is_undo;
+               redo_active = !is_undo;
+               nautilus_file_undo_info_get_strings (info,
+                                                    &undo_label, &undo_description,
+                                                    &redo_label, &redo_description);
+       }
 
-       real_update_paste_menu (view, selection, selection_count);
+       undo_label = undo_active ? undo_label : _("Undo");
+       redo_label = redo_active ? redo_label : _("Redo");
+       undo_menu_item = g_menu_item_new (undo_label, "view.undo");
+       redo_menu_item = g_menu_item_new (redo_label, "view.redo");
+       nautilus_toolbar_action_menu_add_item (toolbar, undo_menu_item, "undo-redo-section");
+       nautilus_toolbar_action_menu_add_item (toolbar, redo_menu_item, "undo-redo-section");
 
-       real_update_menus_volumes (view, selection, selection_count);
+       nautilus_view_update_actions_state (view);
+}
 
-       update_undo_actions (view);
+void
+nautilus_view_update_toolbar_menus (NautilusView *view)
+{
+       g_assert(NAUTILUS_IS_VIEW (view));
 
-       nautilus_file_list_free (selection);
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_toolbar_menus (view);
+}
 
-       if (view->details->scripts_invalid) {
-               update_scripts_menu (view);
-       }
 
-       if (can_create_files
-           && !selection_contains_recent
-           && view->details->templates_invalid) {
-               update_templates_menu (view);
-       }
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_NEW_DOCUMENTS);
-       gtk_action_set_sensitive (action, can_create_files);
-       gtk_action_set_visible (action, !selection_contains_recent && view->details->templates_present);
+static void 
+create_right_click_menu (NautilusView *view,
+                        GMenu *menu,
+                        GdkEventButton *event)
+{
+       GtkWidget *gtk_menu;
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_COPY_TO);
-       gtk_action_set_sensitive (action, can_copy_files);
+       int button;
 
-       action = gtk_action_group_get_action (view->details->dir_action_group,
-                                             NAUTILUS_ACTION_MOVE_TO);
-       gtk_action_set_sensitive (action, can_move_files);
-       gtk_action_set_visible (action, !selection_contains_recent);
+       g_return_if_fail (G_IS_MENU (menu));
 
-       action = gtk_action_group_get_action (view->details->dir_action_group, 
NAUTILUS_ACTION_SHOW_HIDDEN_FILES);
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), view->details->show_hidden_files);
+       gtk_menu = gtk_menu_new_from_model (G_MENU_MODEL (menu));
+       gtk_menu_attach_to_widget (GTK_MENU (gtk_menu), GTK_WIDGET (view), NULL);
+       /* The event button needs to be 0 if we're popping up this menu from
+        * a button release, else a 2nd click outside the menu with any button
+        * other than the one that invoked the menu will be ignored (instead
+        * of dismissing the menu). This is a subtle fragility of the GTK menu code.
+        */
+       if (event) {
+               button = event->type == GDK_BUTTON_RELEASE
+                       ? 0
+                       : event->button;
+       } else {
+               button = 0;
+       }
+       
+       gtk_menu_popup (GTK_MENU (gtk_menu),                    /* menu */
+                       NULL,                                   /* parent_menu_shell */
+                       NULL,                                   /* parent_menu_item */
+                       NULL,                                   /* popup_position_func */
+                       NULL,                                   /* popup_position_data */
+                       button,                                 /* button */
+                       event ? event->time : gtk_get_current_event_time ()); /* activate_time */
+
+       g_object_ref_sink (gtk_menu);
+       g_object_unref (gtk_menu);
 }
 
+
 /**
- * nautilus_view_pop_up_selection_context_menu
+ * nautilus_view_pop_up_selection_right_click_menu
  *
  * Pop up a context menu appropriate to the selected items.
  * @view: NautilusView of interest.
  * @event: The event that triggered this context menu.
  * 
- * Return value: NautilusDirectory for this view.
- * 
  **/
 void 
-nautilus_view_pop_up_selection_context_menu  (NautilusView *view, 
-                                             GdkEventButton  *event)
+nautilus_view_pop_up_selection_right_click_menu  (NautilusView *view, 
+                                               GdkEventButton  *event)
 {
        g_assert (NAUTILUS_IS_VIEW (view));
 
        /* Make the context menu items not flash as they update to proper disabled,
         * etc. states by forcing menus to update now.
         */
-       update_menus_if_pending (view);
+       update_right_click_menus_if_pending (view);
 
        update_context_menu_position_from_event (view, event);
 
-       eel_pop_up_context_menu (create_popup_menu 
-                                (view, NAUTILUS_VIEW_POPUP_PATH_SELECTION),
-                                event);
+       create_right_click_menu (view, view->details->selection_menu, event);
 }
 
 /**
- * nautilus_view_pop_up_background_context_menu
+ * nautilus_view_pop_up_background_right_click_menu
  *
  * Pop up a context menu appropriate to the view globally at the last right click location.
  * @view: NautilusView of interest.
- * 
- * Return value: NautilusDirectory for this view.
- * 
+ *
  **/
 void 
-nautilus_view_pop_up_background_context_menu (NautilusView *view, 
-                                             GdkEventButton  *event)
+nautilus_view_pop_up_background_right_click_menu (NautilusView *view, 
+                                                 GdkEventButton  *event)
 {
        g_assert (NAUTILUS_IS_VIEW (view));
 
        /* Make the context menu items not flash as they update to proper disabled,
         * etc. states by forcing menus to update now.
         */
-       update_menus_if_pending (view);
+       update_right_click_menus_if_pending (view);
 
        update_context_menu_position_from_event (view, event);
 
-
-       eel_pop_up_context_menu (create_popup_menu 
-                                (view, NAUTILUS_VIEW_POPUP_PATH_BACKGROUND),
-                                event);
+       create_right_click_menu (view, view->details->background_menu, event);
 }
 
 static void
-real_pop_up_location_context_menu (NautilusView *view)
+real_pop_up_pathbar_right_click_menu (NautilusView *view)
 {
-       /* always update the menu before showing it. Shouldn't be too expensive. */
-       real_update_location_menu (view);
+       /* Make the context menu items not flash as they update to proper disabled,
+        * etc. states by forcing menus to update now.
+        */
+       update_right_click_menus_if_pending (view);
 
-       update_context_menu_position_from_event (view, view->details->location_popup_event);
+       update_context_menu_position_from_event (view, view->details->pathbar_popup_event);
 
-       eel_pop_up_context_menu (create_popup_menu 
-                                (view, NAUTILUS_VIEW_POPUP_PATH_LOCATION),
-                                view->details->location_popup_event);
+       create_right_click_menu (view, view->details->pathbar_menu, view->details->pathbar_popup_event);
 }
 
 static void
-location_popup_file_attributes_ready (NautilusFile *file,
-                                     gpointer      data)
+pathbar_popup_file_attributes_ready (NautilusFile *file,
+                                    gpointer      data)
 {
        NautilusView *view;
 
        view = NAUTILUS_VIEW (data);
        g_assert (NAUTILUS_IS_VIEW (view));
 
-       g_assert (file == view->details->location_popup_directory_as_file);
+       g_assert (file == view->details->pathbar_popup_directory_as_file);
 
-       real_pop_up_location_context_menu (view);
+       real_pop_up_pathbar_right_click_menu (view);
 }
 
 static void
-unschedule_pop_up_location_context_menu (NautilusView *view)
+unschedule_pop_up_pathbar_right_click_menu (NautilusView *view)
 {
-       if (view->details->location_popup_directory_as_file != NULL) {
-               g_assert (NAUTILUS_IS_FILE (view->details->location_popup_directory_as_file));
-               nautilus_file_cancel_call_when_ready (view->details->location_popup_directory_as_file,
-                                                     location_popup_file_attributes_ready,
+       if (view->details->pathbar_popup_directory_as_file != NULL) {
+               g_assert (NAUTILUS_IS_FILE (view->details->pathbar_popup_directory_as_file));
+               nautilus_file_cancel_call_when_ready (view->details->pathbar_popup_directory_as_file,
+                                                     pathbar_popup_file_attributes_ready,
                                                      view);
-               nautilus_file_unref (view->details->location_popup_directory_as_file);
-               view->details->location_popup_directory_as_file = NULL;
+               nautilus_file_unref (view->details->pathbar_popup_directory_as_file);
+               view->details->pathbar_popup_directory_as_file = NULL;
        }
 }
 
 static void
-schedule_pop_up_location_context_menu (NautilusView *view,
+schedule_pop_up_pathbar_right_click_menu (NautilusView *view,
                                       GdkEventButton  *event,
                                       NautilusFile    *file)
 {
        g_assert (NAUTILUS_IS_FILE (file));
 
-       if (view->details->location_popup_event != NULL) {
-               gdk_event_free ((GdkEvent *) view->details->location_popup_event);
+       if (view->details->pathbar_popup_event != NULL) {
+               gdk_event_free ((GdkEvent *) view->details->pathbar_popup_event);
        }
-       view->details->location_popup_event = (GdkEventButton *) gdk_event_copy ((GdkEvent *)event);
+       view->details->pathbar_popup_event = (GdkEventButton *) gdk_event_copy ((GdkEvent *)event);
 
-       if (file == view->details->location_popup_directory_as_file) {
+       if (file == view->details->pathbar_popup_directory_as_file) {
                if (nautilus_file_check_if_ready (file, NAUTILUS_FILE_ATTRIBUTE_INFO |
                                                  NAUTILUS_FILE_ATTRIBUTE_MOUNT |
                                                  NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO)) {
-                       real_pop_up_location_context_menu (view);
+                       real_pop_up_pathbar_right_click_menu (view);
                }
        } else {
-               unschedule_pop_up_location_context_menu (view);
+               unschedule_pop_up_pathbar_right_click_menu (view);
 
-               view->details->location_popup_directory_as_file = nautilus_file_ref (file);
-               nautilus_file_call_when_ready (view->details->location_popup_directory_as_file,
+               view->details->pathbar_popup_directory_as_file = nautilus_file_ref (file);
+               nautilus_file_call_when_ready (view->details->pathbar_popup_directory_as_file,
                                               NAUTILUS_FILE_ATTRIBUTE_INFO |
                                               NAUTILUS_FILE_ATTRIBUTE_MOUNT |
                                               NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO,
-                                              location_popup_file_attributes_ready,
+                                              pathbar_popup_file_attributes_ready,
                                               view);
        }
 }
 
 /**
- * nautilus_view_pop_up_location_context_menu
+ * nautilus_view_pop_up_pathbar_right_click_menu
  *
  * Pop up a context menu appropriate to the view globally.
  * @view: NautilusView of interest.
@@ -8900,9 +6098,9 @@ schedule_pop_up_location_context_menu (NautilusView *view,
  *
  **/
 void 
-nautilus_view_pop_up_location_context_menu (NautilusView *view, 
-                                           GdkEventButton  *event,
-                                           const char      *location)
+nautilus_view_pop_up_pathbar_right_click_menu (NautilusView *view, 
+                                              GdkEventButton  *event,
+                                              const char      *location)
 {
        NautilusFile *file;
 
@@ -8915,13 +6113,13 @@ nautilus_view_pop_up_location_context_menu (NautilusView *view,
        }
 
        if (file != NULL) {
-               schedule_pop_up_location_context_menu (view, event, file);
+               schedule_pop_up_pathbar_right_click_menu (view, event, file);
                nautilus_file_unref (file);
        }
 }
 
 static void
-schedule_update_menus (NautilusView *view) 
+schedule_update_right_click_menus (NautilusView *view) 
 {
        g_assert (NAUTILUS_IS_VIEW (view));
 
@@ -8934,9 +6132,9 @@ schedule_update_menus (NautilusView *view)
        }
        
        /* Schedule a menu update with the current update interval */
-       if (view->details->update_menus_timeout_id == 0) {
-               view->details->update_menus_timeout_id
-                       = g_timeout_add (view->details->update_interval, update_menus_timeout_callback, view);
+       if (view->details->update_right_click_menus_timeout_id == 0) {
+               view->details->update_right_click_menus_timeout_id
+                       = g_timeout_add (view->details->update_interval, 
update_right_click_menus_timeout_callback, view);
        }
 }
 
@@ -9022,7 +6220,7 @@ nautilus_view_notify_selection_changed (NautilusView *view)
                 */
 
                /* Schedule an update of menu item states to match selection */
-               schedule_update_menus (view);
+               schedule_update_right_click_menus (view);
        }
 }
 
@@ -9033,7 +6231,7 @@ file_changed_callback (NautilusFile *file, gpointer callback_data)
 
        schedule_changes (view);
 
-       schedule_update_menus (view);
+       schedule_update_right_click_menus (view);
        schedule_update_status (view);
 }
 
@@ -9068,7 +6266,7 @@ load_directory (NautilusView *view,
         * location, so they won't have any false lingering knowledge
         * of old selection.
         */
-       schedule_update_menus (view);
+       schedule_update_right_click_menus (view);
        
        while (view->details->subdirectory_list != NULL) {
                nautilus_view_remove_subdirectory (view,
@@ -9500,7 +6698,7 @@ nautilus_view_trash_state_changed_callback (NautilusTrashMonitor *trash_monitor,
        view = (NautilusView *) callback_data;
        g_assert (NAUTILUS_IS_VIEW (view));
        
-       schedule_update_menus (view);
+       schedule_update_right_click_menus (view);
 }
 
 void
@@ -9649,7 +6847,6 @@ nautilus_view_parent_set (GtkWidget *widget,
 {
        NautilusView *view;
        GtkWidget *parent;
-
        view = NAUTILUS_VIEW (widget);
 
        parent = gtk_widget_get_parent (widget);
@@ -9666,12 +6863,11 @@ nautilus_view_parent_set (GtkWidget *widget,
                    nautilus_window_get_active_slot (nautilus_view_get_window (view))) {
                        view->details->active = TRUE;
 
-                       nautilus_view_merge_menus (view);
-                       schedule_update_menus (view);
+                       nautilus_view_update_right_click_menus(view);
+                       nautilus_view_update_toolbar_menus (view);
                }
        } else {
-               nautilus_view_unmerge_menus (view);
-               remove_update_menus_timeout_callback (view);
+               remove_update_right_click_menus_timeout_callback (view);
        }
 }
 
@@ -9681,7 +6877,6 @@ nautilus_view_class_init (NautilusViewClass *klass)
        GObjectClass *oclass;
        GtkWidgetClass *widget_class;
        GtkScrolledWindowClass *scrolled_window_class;
-       GtkBindingSet *binding_set;
 
        widget_class = GTK_WIDGET_CLASS (klass);
        scrolled_window_class = GTK_SCROLLED_WINDOW_CLASS (klass);
@@ -9780,22 +6975,6 @@ nautilus_view_class_init (NautilusViewClass *klass)
                              NULL, NULL,
                              g_cclosure_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);
-       signals[TRASH] =
-               g_signal_new ("trash",
-                             G_TYPE_FROM_CLASS (klass),
-                             G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                             G_STRUCT_OFFSET (NautilusViewClass, trash),
-                             g_signal_accumulator_true_handled, NULL,
-                             g_cclosure_marshal_generic,
-                             G_TYPE_BOOLEAN, 0);
-       signals[DELETE] =
-               g_signal_new ("delete",
-                             G_TYPE_FROM_CLASS (klass),
-                             G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                             G_STRUCT_OFFSET (NautilusViewClass, delete),
-                             g_signal_accumulator_true_handled, NULL,
-                             g_cclosure_marshal_generic,
-                             G_TYPE_BOOLEAN, 0);
 
        klass->get_selected_icon_locations = real_get_selected_icon_locations;
        klass->is_read_only = real_is_read_only;
@@ -9803,11 +6982,12 @@ nautilus_view_class_init (NautilusViewClass *klass)
        klass->start_renaming_file = start_renaming_file;
        klass->get_backing_uri = real_get_backing_uri;
        klass->using_manual_layout = real_using_manual_layout;
-        klass->merge_menus = real_merge_menus;
-        klass->unmerge_menus = real_unmerge_menus;
-        klass->update_menus = real_update_menus;
-       klass->trash = real_trash;
-       klass->delete = real_delete;
+       klass->get_window = nautilus_view_get_window;
+       klass->get_action_group = nautilus_view_get_action_group;
+       klass->update_right_click_menus = real_update_right_click_menus;
+       klass->update_actions_state = real_update_actions_state;
+       klass->update_toolbar_menus = real_update_toolbar_menus;
+       klass->zoom_to_level = real_zoom_to_level;
 
        copied_files_atom = gdk_atom_intern ("x-special/gnome-copied-files", FALSE);
 
@@ -9827,14 +7007,143 @@ nautilus_view_class_init (NautilusViewClass *klass)
                                      G_PARAM_STATIC_STRINGS);
 
        g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+}
+
+static void
+nautilus_view_init (NautilusView *view)
+{
+       AtkObject *atk_object;
+       NautilusDirectory *scripts_directory;
+       NautilusDirectory *templates_directory;
+       gchar *templates_uri;
+
+       nautilus_profile_start (NULL);
+
+       view->details = G_TYPE_INSTANCE_GET_PRIVATE (view, NAUTILUS_TYPE_VIEW,
+                                                    NautilusViewDetails);
+
+       /* Default to true; desktop-icon-view sets to false */
+       view->details->show_foreign_files = TRUE;
+
+       view->details->non_ready_files =
+               g_hash_table_new_full (file_and_directory_hash,
+                                      file_and_directory_equal,
+                                      (GDestroyNotify)file_and_directory_free,
+                                      NULL);
 
-       binding_set = gtk_binding_set_by_class (klass);
-       gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_CONTROL_MASK,
-                                     "trash", 0);
-       gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_CONTROL_MASK,
-                                     "trash", 0);
-       gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
-                                     "delete", 0);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view),
+                                       GTK_POLICY_AUTOMATIC,
+                                       GTK_POLICY_AUTOMATIC);
+       gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (view), NULL);
+       gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (view), NULL);
+
+       gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (view)),
+                                             GTK_JUNCTION_TOP | GTK_JUNCTION_LEFT);
+
+       if (set_up_scripts_directory_global ()) {
+               scripts_directory = nautilus_directory_get_by_uri (scripts_directory_uri);
+               monitor_directory_changes (view,
+                                          scripts_directory,
+                                          G_CALLBACK (scripts_added_or_changed_callback));
+               nautilus_directory_unref (scripts_directory);
+       } else {
+               g_warning ("Ignoring scripts directory, it may be a broken link\n");
+       }
+
+       if (nautilus_should_use_templates_directory ()) {
+               templates_uri = nautilus_get_templates_directory_uri ();
+               templates_directory = nautilus_directory_get_by_uri (templates_uri);
+               g_free (templates_uri);
+               monitor_directory_changes (view,
+                                          templates_directory,
+                                          G_CALLBACK (templates_added_or_changed_callback));
+               nautilus_directory_unref (templates_directory);
+       }
+
+       if (!set_up_scripts_directory_global ()) {
+               g_warning ("Ignoring scripts directory, it may be a broken link\n");
+       }
+
+       view->details->sort_directories_first =
+               g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
+       view->details->show_hidden_files =
+               g_settings_get_boolean (gtk_filechooser_preferences, NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
+
+       g_signal_connect_object (nautilus_trash_monitor_get (), "trash-state-changed",
+                                G_CALLBACK (nautilus_view_trash_state_changed_callback), view, 0);
+
+       /* React to clipboard changes */
+       g_signal_connect_object (nautilus_clipboard_monitor_get (), "clipboard-changed",
+                                G_CALLBACK (clipboard_changed_callback), view, 0);
+
+       /* Register to menu provider extension signal managing menu updates */
+       g_signal_connect_object (nautilus_signaller_get_current (), "popup-menu-changed",
+                                G_CALLBACK (schedule_update_right_click_menus), view, G_CONNECT_SWAPPED);
+
+       gtk_widget_show (GTK_WIDGET (view));
+
+       g_signal_connect_swapped (nautilus_preferences,
+                                 "changed::" NAUTILUS_PREFERENCES_ENABLE_DELETE,
+                                 G_CALLBACK (schedule_update_right_click_menus), view);
+       g_signal_connect_swapped (nautilus_preferences,
+                                 "changed::" NAUTILUS_PREFERENCES_CLICK_POLICY,
+                                 G_CALLBACK (click_policy_changed_callback),
+                                 view);
+       g_signal_connect_swapped (nautilus_preferences,
+                                 "changed::" NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, 
+                                 G_CALLBACK (sort_directories_first_changed_callback), view);
+       g_signal_connect_swapped (gtk_filechooser_preferences,
+                                 "changed::" NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, 
+                                 G_CALLBACK (show_hidden_files_changed_callback), view);
+       g_signal_connect_swapped (gnome_lockdown_preferences,
+                                 "changed::" NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
+                                 G_CALLBACK (schedule_update_right_click_menus), view);
+
+       g_signal_connect_object (nautilus_file_undo_manager_get (), "undo-changed",
+                                G_CALLBACK (undo_manager_changed), view, 0);
+
+       /* Accessibility */
+       atk_object = gtk_widget_get_accessible (GTK_WIDGET (view));
+       atk_object_set_name (atk_object, _("Content View"));
+       atk_object_set_description (atk_object, _("View of the current folder"));
+
+       view->details->view_action_group = G_ACTION_GROUP (g_simple_action_group_new ());
+       g_action_map_add_action_entries (G_ACTION_MAP (view->details->view_action_group),
+                                       view_entries,
+                                       G_N_ELEMENTS (view_entries),
+                                       view);
+       gtk_widget_insert_action_group (GTK_WIDGET (view),
+                                       "view",
+                                       G_ACTION_GROUP (view->details->view_action_group));
+
+       GApplication *app = g_application_get_default ();
+
+       /* Toolbar menu */
+       add_accelerator (app, "view.zoom-in", "<control>plus");
+       add_accelerator (app, "view.zoom-out", "<control>minus");
+       add_accelerator (app, "view.undo", "<control>z");
+       add_accelerator (app, "view.redo", "<shift><control>z");
+       add_accelerator (app, "view.show-hidden-files", "<control>h");
+       /* Background menu */
+       add_accelerator (app, "view.select-all", "<control>a");
+       add_accelerator (app, "view.paste", "<control>v");
+       /* Selection menu */
+       add_accelerator (app, "view.open-with-default-application", "<control>o");
+       add_accelerator (app, "view.open-item-new-tab", "<shift><control>t");
+       add_accelerator (app, "view.open-item-new-window", "<shift><control>w");
+       add_accelerator (app, "view.move-to-trash", "<control>Delete");
+       add_accelerator (app, "view.delete", "<shift>Delete");
+       add_accelerator (app, "view.properties", "<control>i");
+       add_accelerator (app, "view.open-item-location", "<control><alt>o");
+       add_accelerator (app, "view.rename", "F2");
+       add_accelerator (app, "view.cut", "<control>x");
+       add_accelerator (app, "view.copy", "<control>c");
+       /* Only accesible by shorcuts */
+       add_accelerator (app, "view.select-pattern", "<control>s");
+       add_accelerator (app, "view.invert-selection", "<shift><control>i");
+       add_accelerator (app, "view.delete", "<shift>Delete");
+
+       nautilus_profile_end (NULL);
 }
 
 NautilusView *
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 98f3d57..7ce4113 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -227,7 +227,11 @@ struct NautilusViewClass {
          * It is called (at least) whenever the selection changes. If overridden, 
          * subclasses must call parent class's function.
          */
-        void    (* update_menus)               (NautilusView *view);
+        void    (* update_right_click_menus)           (NautilusView *view);
+
+        void    (* update_toolbar_menus)               (NautilusView *view);
+
+        void    (* update_actions_state)               (NautilusView *view);
 
        /* sort_files is a function pointer that subclasses can override
         * to provide a sorting order to determine which files should be
@@ -292,9 +296,8 @@ struct NautilusViewClass {
        void           (* scroll_to_file)         (NautilusView          *view,
                                                   const char            *uri);
 
-        /* Signals used only for keybindings */
-        gboolean (* trash)                         (NautilusView *view);
-        gboolean (* delete)                        (NautilusView *view);
+       NautilusWindow * (*get_window)  (NautilusView *view);
+       GActionGroup * (*get_action_group)      (NautilusView *view);
 };
 
 /* GObject support */
@@ -331,12 +334,11 @@ void                nautilus_view_preview_files                    (NautilusView
 void                nautilus_view_start_batching_selection_changes (NautilusView  *view);
 void                nautilus_view_stop_batching_selection_changes  (NautilusView  *view);
 void                nautilus_view_notify_selection_changed         (NautilusView  *view);
-GtkUIManager *      nautilus_view_get_ui_manager                   (NautilusView  *view);
 NautilusDirectory  *nautilus_view_get_model                        (NautilusView  *view);
 NautilusFile       *nautilus_view_get_directory_as_file            (NautilusView  *view);
-void                nautilus_view_pop_up_background_context_menu   (NautilusView  *view,
+void                nautilus_view_pop_up_background_right_click_menu   (NautilusView  *view,
                                                                    GdkEventButton   *event);
-void                nautilus_view_pop_up_selection_context_menu    (NautilusView  *view,
+void                nautilus_view_pop_up_selection_right_click_menu    (NautilusView  *view,
                                                                    GdkEventButton   *event); 
 gboolean            nautilus_view_should_show_file                 (NautilusView  *view,
                                                                    NautilusFile     *file);
@@ -358,6 +360,7 @@ void                nautilus_view_remove_subdirectory             (NautilusView
                                                                   NautilusDirectory*directory);
 
 gboolean            nautilus_view_is_editable                     (NautilusView *view);
+NautilusWindow *    nautilus_view_get_window                     (NautilusView *view);
 
 /* NautilusView methods */
 const char *      nautilus_view_get_view_id                (NautilusView      *view);
@@ -403,12 +406,20 @@ void              nautilus_view_restore_default_zoom_level (NautilusView      *v
 gboolean          nautilus_view_can_zoom_in                (NautilusView      *view);
 gboolean          nautilus_view_can_zoom_out               (NautilusView      *view);
 NautilusZoomLevel nautilus_view_get_zoom_level             (NautilusView      *view);
-void              nautilus_view_pop_up_location_context_menu (NautilusView    *view,
+void              nautilus_view_pop_up_pathbar_right_click_menu (NautilusView    *view,
                                                              GdkEventButton  *event,
                                                              const char      *location);
 void              nautilus_view_grab_focus                 (NautilusView      *view);
 void              nautilus_view_update_menus               (NautilusView      *view);
 
+void              nautilus_view_update_right_click_menus               (NautilusView      *view);
+void              nautilus_view_update_toolbar_menus               (NautilusView      *view);
+void              nautilus_view_update_actions_state              (NautilusView      *view);
+
 gboolean          nautilus_view_get_show_hidden_files      (NautilusView      *view);
+void nautilus_view_action_show_hidden_files (NautilusView *view,
+                                       gboolean show_hidden);
+
+GActionGroup * nautilus_view_get_action_group (NautilusView *view);
 
 #endif /* NAUTILUS_VIEW_H */
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 999d163..3f15517 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -39,6 +39,8 @@
 #include "nautilus-window-private.h"
 #include "nautilus-desktop-window.h"
 #include "nautilus-properties-window.h"
+#include "nautilus-view.h"
+#include "nautilus-toolbar.h"
 
 #include <gtk/gtk.h>
 #include <gio/gio.h>
@@ -494,6 +496,25 @@ static const GtkRadioActionEntry view_radio_entries[] = {
 };
 
 static void
+action_back (GSimpleAction *action,
+            GVariant      *state,
+            gpointer       user_data) 
+{
+       nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data), 
+                                        TRUE, 0, nautilus_event_get_window_open_flags ());
+}
+
+static void
+action_forward (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data) 
+{
+       nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data), 
+                                        FALSE, 0, nautilus_event_get_window_open_flags ());
+}
+
+
+static void
 action_toggle_state (GSimpleAction *action,
                     GVariant *parameter,
                     gpointer user_data)
@@ -506,16 +527,130 @@ action_toggle_state (GSimpleAction *action,
        g_variant_unref (state);
 }
 
+static void
+action_show_sidebar (GSimpleAction *action,
+                    GVariant      *state,
+                    gpointer       user_data) 
+{
+       NautilusWindow *window;
+
+       window = NAUTILUS_WINDOW (user_data);
+
+       if (g_variant_get_boolean (state)) {
+               nautilus_window_show_sidebar (window);
+       } else {
+               nautilus_window_hide_sidebar (window);
+       }
+
+       g_simple_action_set_state (action, state);
+}
+
+static void
+action_reload (GSimpleAction *action,
+              GVariant      *state,
+              gpointer       user_data) 
+{
+       NautilusWindowSlot *slot;
+
+       slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (user_data));
+       nautilus_window_slot_queue_reload (slot);
+}
+
+static void
+action_new_tab (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data) 
+{
+       nautilus_window_new_tab (NAUTILUS_WINDOW (user_data));
+}
+
+static void
+action_enter_location (GSimpleAction *action,
+                      GVariant      *state,
+                      gpointer       user_data) 
+{
+       g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
+                                       "enter-location", NULL);
+}
+
+static void
+action_bookmark_current_location (GSimpleAction *action,
+                                 GVariant      *state,
+                                 gpointer       user_data) 
+{
+       NautilusWindow *window = user_data;
+       NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
+       NautilusWindowSlot *slot;
+
+       slot = nautilus_window_get_active_slot (window);
+       nautilus_bookmark_list_append (nautilus_application_get_bookmarks (app),
+                                      nautilus_window_slot_get_bookmark (slot));
+}
+
+static void
+action_toggle_search (GSimpleAction *action,
+                     GVariant      *state,
+                     gpointer       user_data)
+{
+       NautilusWindowSlot *slot;
+
+       slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (user_data));
+       nautilus_window_slot_set_search_visible (slot, g_variant_get_boolean (state));
+
+       g_simple_action_set_state (action, state);
+}
+
+static void
+action_view_mode (GSimpleAction *action,
+                 GVariant      *value,
+                 gpointer       user_data)
+{
+       const gchar *name;
+       NautilusWindowSlot *slot;
+       NautilusToolbar *toolbar;
+
+       name =  g_variant_get_string (value, NULL);
+       slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (user_data));
+       toolbar = nautilus_window_get_toolbar (NAUTILUS_WINDOW (user_data));
+
+       if (g_strcmp0 (name, "list") == 0) {
+               nautilus_window_slot_set_content_view (slot, NAUTILUS_LIST_VIEW_ID);
+       } else if (g_strcmp0 (name, "grid") == 0) {
+               nautilus_window_slot_set_content_view (slot, NAUTILUS_CANVAS_VIEW_ID);
+       } else {
+               g_assert_not_reached ();
+       }
+
+       nautilus_toolbar_update_view_button (toolbar, name);
+
+       g_simple_action_set_state (action, value);
+}
+
 const GActionEntry win_entries[] = {
+       { "back",  action_back },
+       { "forward",  action_forward },
        { "gear-menu", action_toggle_state, NULL, "false", NULL },
+       { "show-sidebar", NULL, NULL, "false", action_show_sidebar },
+       { "reload", action_reload },
+       { "new-tab", action_new_tab },
+       { "enter-location", action_enter_location },
+       { "bookmark-current-location", action_bookmark_current_location },
+       { "toggle-search", NULL, NULL, "false", action_toggle_search },
+       { "view-mode", NULL, "s", "''", action_view_mode },
 };
 
 void 
 nautilus_window_initialize_actions (NautilusWindow *window)
 {
+       gboolean show_sidebar;
+
        g_action_map_add_action_entries (G_ACTION_MAP (window),
                                         win_entries, G_N_ELEMENTS (win_entries),
                                         window);
+
+       show_sidebar = g_settings_get_boolean (nautilus_window_state, 
NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR);
+       GAction *action = g_action_map_lookup_action (G_ACTION_MAP (window), "show-sidebar");
+       g_action_change_state (action, g_variant_new_boolean (show_sidebar));
 }
 
 /**
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 5531d8e..fd12397 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -112,4 +112,6 @@ void               nautilus_window_initialize_menus                      (Nautil
 
 void               nautilus_window_update_show_hide_menu_items           (NautilusWindow     *window);
 
+void               nautilus_window_reset_menus           (NautilusWindow     *window);
+
 #endif /* NAUTILUS_WINDOW_PRIVATE_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 124fc57..d41174c 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -42,7 +42,7 @@
 #include "nautilus-toolbar.h"
 #include "nautilus-window-slot.h"
 #include "nautilus-list-view.h"
-#include "nautilus-canvas-view.h"
+#include "nautilus-view.h"
 
 #include <eel/eel-debug.h>
 #include <eel/eel-gtk-extensions.h>
@@ -452,8 +452,6 @@ nautilus_window_set_initial_window_geometry (NautilusWindow *window)
        GdkScreen *screen;
        guint max_width_for_screen, max_height_for_screen;
        guint default_width, default_height;
-       gboolean show_sidebar;
-       GtkAction *action;
 
        screen = gtk_window_get_screen (GTK_WINDOW (window));
        
@@ -468,17 +466,6 @@ nautilus_window_set_initial_window_geometry (NautilusWindow *window)
                                          max_width_for_screen), 
                                     MIN (default_height, 
                                          max_height_for_screen));
-
-       show_sidebar = g_settings_get_boolean (nautilus_window_state, 
NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR);
-       action = gtk_action_group_get_action (window->details->main_action_group,
-                                             NAUTILUS_ACTION_SHOW_HIDE_SIDEBAR);
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_sidebar);
-
-       if (show_sidebar) {
-               nautilus_window_show_sidebar (window);
-       } else {
-               nautilus_window_hide_sidebar (window);
-       }
 }
 
 static gboolean
@@ -1012,10 +999,8 @@ nautilus_window_sync_bookmarks (NautilusWindow *window)
 void
 nautilus_window_sync_location_widgets (NautilusWindow *window)
 {
-       NautilusWindowSlot *slot, *active_slot;
+       NautilusWindowSlot *slot;
        GFile *location;
-       GtkActionGroup *action_group;
-       GtkAction *action;
 
        slot = window->details->active_slot;
        location = nautilus_window_slot_get_location (slot);
@@ -1036,15 +1021,7 @@ nautilus_window_sync_location_widgets (NautilusWindow *window)
 
        nautilus_window_sync_up_button (window);
 
-       /* Check if the back and forward buttons need enabling or disabling. */
-       active_slot = nautilus_window_get_active_slot (window);
-       action_group = nautilus_window_get_main_action_group (window);
-
-       action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_BACK);
-       gtk_action_set_sensitive (action, nautilus_window_slot_get_back_history (active_slot) != NULL);
-
-       action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_FORWARD);
-       gtk_action_set_sensitive (action, nautilus_window_slot_get_forward_history (active_slot) != NULL);
+       nautilus_toolbar_sync_navigation_buttons (NAUTILUS_TOOLBAR (window->details->toolbar));
 
        nautilus_window_sync_bookmarks (window);
 }
@@ -1117,7 +1094,7 @@ path_bar_path_event_callback (NautilusPathBar *path_bar,
                view = nautilus_window_slot_get_view (slot);
                if (view != NULL) {
                        uri = g_file_get_uri (location);
-                       nautilus_view_pop_up_location_context_menu (view, event, uri);
+                       nautilus_view_pop_up_pathbar_right_click_menu (view, event, uri);
                        g_free (uri);
                }
 
@@ -1271,6 +1248,12 @@ notebook_popup_menu_cb (GtkWidget *widget,
        return TRUE;
 }
 
+GtkWidget *
+nautilus_window_get_toolbar (NautilusWindow *window)
+{
+       return window->details->toolbar;
+}
+
 static GtkWidget *
 create_toolbar (NautilusWindow *window)
 {
@@ -1296,10 +1279,6 @@ create_toolbar (NautilusWindow *window)
        /* connect to the location entry signals */
        location_entry = nautilus_toolbar_get_location_entry (NAUTILUS_TOOLBAR (toolbar));
 
-       nautilus_clipboard_set_up_editable (GTK_EDITABLE (location_entry),
-                                           nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)),
-                                           TRUE);
-
        g_signal_connect_object (location_entry, "location-changed",
                                 G_CALLBACK (location_entry_location_changed_callback), window, 0);
        g_signal_connect_object (location_entry, "cancel",
@@ -1459,13 +1438,6 @@ nautilus_window_constructed (GObject *self)
        gtk_widget_show (grid);
        gtk_container_add (GTK_CONTAINER (window), grid);
 
-       nautilus_window_initialize_menus (window);
-       nautilus_window_initialize_actions (window);
-
-       /* Register to menu provider extension signal managing menu updates */
-       g_signal_connect_object (nautilus_signaller_get_current (), "popup-menu-changed",
-                        G_CALLBACK (nautilus_window_load_extension_menus), window, G_CONNECT_SWAPPED);
-
        window->details->toolbar = create_toolbar (window);
        gtk_window_set_titlebar (GTK_WINDOW (window), window->details->toolbar);
 
@@ -1484,6 +1456,16 @@ nautilus_window_constructed (GObject *self)
        window->details->notebook = create_notebook (window);
        nautilus_window_set_initial_window_geometry (window);
 
+       /* Is required that the UI is constructed before initializating the actions, since
+        * some actions trigger UI widgets to show/hide. */
+       nautilus_window_initialize_menus (window);
+       nautilus_window_initialize_actions (window);
+
+       /* Register to menu provider extension signal managing menu updates */
+       g_signal_connect_object (nautilus_signaller_get_current (), "popup-menu-changed",
+                        G_CALLBACK (nautilus_window_load_extension_menus), window, G_CONNECT_SWAPPED);
+
+
        slot = nautilus_window_open_slot (window, 0);
        nautilus_window_set_active_slot (window, slot);
 
@@ -1492,6 +1474,8 @@ nautilus_window_constructed (GObject *self)
                                          G_CALLBACK (nautilus_window_sync_bookmarks), window);
 
        nautilus_profile_end (NULL);
+
+       g_print("construction ended\n");
 }
 
 static void
@@ -2108,6 +2092,8 @@ nautilus_window_init (NautilusWindow *window)
 
        window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_WINDOW, NautilusWindowDetails);
 
+       g_print("priv set\n");
+
        window->details->slots = NULL;
        window->details->active_slot = NULL;
 
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index f95eede..ac29a16 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -135,4 +135,5 @@ gboolean nautilus_window_disable_chrome_mapping (GValue *value,
 NautilusWindowOpenFlags nautilus_event_get_window_open_flags   (void);
 void     nautilus_window_show_about_dialog    (NautilusWindow *window);
 
+GtkWidget *nautilus_window_get_toolbar (NautilusWindow *window);
 #endif
diff --git a/src/nautilus.gresource.xml b/src/nautilus.gresource.xml
index 37a5bbf..1b0e47a 100644
--- a/src/nautilus.gresource.xml
+++ b/src/nautilus.gresource.xml
@@ -9,6 +9,10 @@
     <file>nautilus-list-view-ui.xml</file>
     <file>nautilus-shell-ui.xml</file>
     <file>nautilus-app-menu.ui</file>
+    <file>nautilus-main-menus.xml</file>
+    <file>nautilus-toolbar-ui.xml</file>
+    <file>nautilus-toolbar-view-menu.xml</file>
+    <file>nautilus-view-right-click-menus.xml</file>
     <file alias="icons/thumbnail_frame.png">../icons/thumbnail_frame.png</file>
     <file alias="icons/filmholes.png">../icons/filmholes.png</file>
     <file alias="icons/knob.png">../icons/knob.png</file>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]