[nautilus/wip/gaction: 7/7] port to gaction



commit ac58581a77765c8af1a8d124135556eae971f48f
Author: Carlos Soriano <carlos sorian89 gmail com>
Date:   Thu Nov 20 15:52:00 2014 +0100

    port to gaction

 libnautilus-private/nautilus-ui-utilities.c |   96 ++
 libnautilus-private/nautilus-ui-utilities.h |    9 +
 src/nautilus-canvas-view.c                  |  395 +++-----
 src/nautilus-desktop-canvas-view.c          |  228 +----
 src/nautilus-list-view.c                    |  139 ++--
 src/nautilus-main-menus.xml                 |  117 +++
 src/nautilus-toolbar-ui.xml                 |  133 +++
 src/nautilus-toolbar-view-menu.xml          |  215 ++++
 src/nautilus-toolbar.c                      |  294 ++++--
 src/nautilus-toolbar.h                      |   12 +-
 src/nautilus-view-right-click-menus.xml     |  152 +++
 src/nautilus-view.c                         | 1429 ++++++++++++++++++++-------
 src/nautilus-view.h                         |   18 +-
 src/nautilus-window-menus.c                 |  129 +++
 src/nautilus-window-private.h               |    2 +
 src/nautilus-window.c                       |   56 +-
 src/nautilus-window.h                       |    1 +
 src/nautilus.gresource.xml                  |    4 +
 18 files changed, 2467 insertions(+), 962 deletions(-)
---
diff --git a/libnautilus-private/nautilus-ui-utilities.c b/libnautilus-private/nautilus-ui-utilities.c
index 6fcc3a4..c61aa77 100644
--- a/libnautilus-private/nautilus-ui-utilities.c
+++ b/libnautilus-private/nautilus-ui-utilities.c
@@ -29,6 +29,102 @@
 
 #include <gio/gio.h>
 #include <gtk/gtk.h>
+#include <string.h>
+
+static GMenuModel *
+find_gmenu_model (GMenuModel  *model,
+                   const gchar *section_id)
+{
+       gint i, n_items;
+       GMenuModel *section = NULL;
+
+       n_items = g_menu_model_get_n_items (model);
+
+       for (i = 0; i < n_items && !section; i++)
+       {
+               gchar *id = NULL;
+
+               if (g_menu_model_get_item_attribute (model, i, "id", "s", &id) &&
+                       strcmp (id, section_id) == 0)
+               {
+                       section = g_menu_model_get_item_link (model, i, G_MENU_LINK_SECTION);
+               }
+               else
+               {
+                       GMenuModel *subsection;
+                       GMenuModel *submenu;
+                       gint j, j_items;
+
+                       subsection = g_menu_model_get_item_link (model, i, G_MENU_LINK_SECTION);
+
+                       j_items = g_menu_model_get_n_items (subsection);
+
+                       for (j = 0; j < j_items && !section; j++)
+                       {
+                               submenu = g_menu_model_get_item_link (subsection, j, G_MENU_LINK_SUBMENU);
+                               if (submenu)
+                               {
+                                       section = find_gmenu_model (submenu, section_id);
+                               }
+                       }
+               }
+
+               g_free (id);
+       }
+
+       return section;
+}
+
+/*
+ * 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_section (GMenu *menu,
+                       GMenuItem *item,
+                       const gchar *section_name)
+{
+       GMenuModel *section;
+
+       g_return_if_fail (G_IS_MENU (menu));
+       g_return_if_fail (G_IS_MENU_ITEM (item));
+
+       section = find_gmenu_model (G_MENU_MODEL (menu), section_name);
+
+       g_return_if_fail (section != NULL);
+
+       g_menu_append_item (G_MENU (section), item);
+}
 
 void
 nautilus_ui_unmerge_ui (GtkUIManager *ui_manager,
diff --git a/libnautilus-private/nautilus-ui-utilities.h b/libnautilus-private/nautilus-ui-utilities.h
index 0341478..6a4a7e0 100644
--- a/libnautilus-private/nautilus-ui-utilities.h
+++ b/libnautilus-private/nautilus-ui-utilities.h
@@ -33,6 +33,15 @@ 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_section (GMenu *menu,
+                                       GMenuItem *item,
+                                       const gchar *section_name);
+
 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..5edd605 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",
        }
 };
 
@@ -167,10 +167,12 @@ static gboolean             set_sort_reversed                         (NautilusC
                                                                       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 +295,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 +346,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 +476,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 +656,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 +675,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 +760,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 +832,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 +859,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
@@ -1008,42 +936,73 @@ set_sort_criterion_by_sort_type (NautilusCanvasView *canvas_view,
        nautilus_canvas_view_reveal_selection (NAUTILUS_VIEW (canvas_view));
 }
 
-
 static void
-action_reversed_order_callback (GtkAction *action,
-                               gpointer user_data)
+action_reversed_order (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
-       NautilusCanvasView *canvas_view;
+       gboolean reversed_order;
 
-       canvas_view = NAUTILUS_CANVAS_VIEW (user_data);
+       g_assert (NAUTILUS_IS_CANVAS_VIEW (user_data));
 
-       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));
+       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));
        }
+
+       g_simple_action_set_state (action, state);
 }
 
 static void
-action_keep_aligned_callback (GtkAction *action,
-                             gpointer user_data)
+action_keep_aligned (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
 {
-       NautilusCanvasView *canvas_view;
        NautilusFile *file;
+       NautilusCanvasView *canvas_view;
        gboolean keep_aligned;
 
        canvas_view = NAUTILUS_CANVAS_VIEW (user_data);
-
-       keep_aligned = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-
        file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view));
+       keep_aligned = g_variant_get_boolean (state);
+
        nautilus_canvas_view_set_directory_keep_aligned (canvas_view,
-                                                file,
-                                                keep_aligned);
-                                                     
+                                                        file,
+                                                        keep_aligned);                       
        nautilus_canvas_container_set_keep_aligned (get_canvas_container (canvas_view),
-                                                 keep_aligned);
+                                                   keep_aligned);
+
+       g_simple_action_set_state (action, state);
+}
+
+static void
+action_sort_order_changed (GSimpleAction *action,
+                       GVariant      *value,
+                       gpointer       user_data)
+{
+       gchar *target_name;
+       const SortCriterion *sort_criterion;
+
+       g_assert (NAUTILUS_IS_CANVAS_VIEW (user_data));
+
+       target_name = g_variant_get_string (value, NULL);
+       sort_criterion = get_sort_criterion_by_action_target_name (target_name);
+
+       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 +1035,6 @@ layout_changed_callback (NautilusCanvasContainer *container,
                         file,
                         nautilus_canvas_view_using_auto_layout (canvas_view));
        }
-
-       update_layout_menus (canvas_view);
 }
 
 static gboolean
@@ -1103,124 +1060,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));
+       }
+
+       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));
+       }
 
-       update_layout_menus (canvas_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_simple_action_set_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;
-
-       canvas_view = NAUTILUS_CANVAS_VIEW (view);
+       NautilusFile *file;
+       NautilusToolbar *toolbar;
+       NautilusCanvasContainer *canvas_container;
+       NautilusZoomLevel zoom_level;
 
-       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->unmerge_menus (view);
+       NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->update_toolbar_menus (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);
-       }
-}
+       toolbar = NAUTILUS_TOOLBAR (nautilus_window_get_toolbar (nautilus_view_get_window (view)));
 
-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 +1149,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);
 }
 
@@ -1506,11 +1415,6 @@ nautilus_canvas_view_react_to_canvas_change_idle_callback (gpointer 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;
@@ -1529,20 +1433,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
@@ -1869,13 +1759,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 +1959,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 +2005,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 +2047,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..531755e 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);
 
@@ -263,7 +262,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 +277,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 +515,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,224 +557,76 @@ get_control_center_command (const gchar ** params_out)
 }
 
 static void
-action_change_background_callback (GtkAction *action, 
-                                  gpointer data)
+action_clean_up_callback (GtkAction *action,
+                         gpointer callback_data)
+{
+       nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (callback_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)
-{
-        g_assert (NAUTILUS_IS_VIEW (data));
-
-       nautilus_file_operations_empty_trash (GTK_WIDGET (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)
+action_organize_desktop_by_name (GSimpleAction *action,
+               GVariant       *state,
+               gpointer       user_data)
 {
-       nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (callback_data));
+       nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (user_data));
 }
 
-static gboolean
-trash_link_is_selection (NautilusView *view)
-{
-       GList *selection;
-       NautilusDesktopLink *link;
-       gboolean result;
-
-       result = FALSE;
-       
-       selection = nautilus_view_get_selection (view);
-
-       if ((g_list_length (selection) == 1) &&
-           NAUTILUS_IS_DESKTOP_ICON_FILE (selection->data)) {
-               link = nautilus_desktop_icon_file_get_link (NAUTILUS_DESKTOP_ICON_FILE (selection->data));
-               /* link may be NULL if the link was recently removed (unmounted) */
-               if (link != NULL &&
-                   nautilus_desktop_link_get_link_type (link) == NAUTILUS_DESKTOP_LINK_TRASH) {
-                       result = TRUE;
-               }
-               if (link) {
-                       g_object_unref (link);
-               }
-       }
-       
-       nautilus_file_list_free (selection);
-
-       return result;
-}
+const GActionEntry gdesktop_view_entries[] = {
+       { "change-background", action_change_background },
+       { "organize-desktop-by-name", action_organize_desktop_by_name },
+};
 
 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;
+       GSimpleAction *action;
         int selection_count;
+        GActionGroup *view_action_group;
 
        g_assert (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view));
 
-       NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->update_menus (view);
+       NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->update_right_click_menus (view);
 
        desktop_view = NAUTILUS_DESKTOP_CANVAS_VIEW (view);
+       view_action_group = NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->get_action_group 
(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);
-       }
+       g_action_map_add_action_entries (G_ACTION_MAP (view_action_group),
+                               gdesktop_view_entries,
+                               G_N_ELEMENTS (gdesktop_view_entries),
+                               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);
-}
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "keep-aligned");
+       g_simple_action_set_enabled (action, TRUE);
 
-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) },
-};
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "organize-desktop-by-name");
+       g_simple_action_set_enabled (action, TRUE);
 
-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), "change-background");
+       g_simple_action_set_enabled (action, TRUE);
 }
 
 NautilusView *
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index b361734..ddbd21b 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>
@@ -2310,7 +2311,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;
@@ -3013,75 +3014,78 @@ 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) },
-};
-
 static void
-nautilus_list_view_merge_menus (NautilusView *view)
+action_visible_columns (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
        NautilusListView *list_view;
-       GtkUIManager *ui_manager;
-       GtkActionGroup *action_group;
-
-       list_view = NAUTILUS_LIST_VIEW (view);
+       
+       list_view = NAUTILUS_LIST_VIEW (user_data);
 
-       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->merge_menus (view);
+       if (list_view->details->column_editor) {
+               gtk_window_present (GTK_WINDOW (list_view->details->column_editor));
+       } else {
+               list_view->details->column_editor = create_column_editor (list_view);
+               g_object_add_weak_pointer (G_OBJECT (list_view->details->column_editor),
+                                          (gpointer *) &list_view->details->column_editor);
+               
+               gtk_widget_show (list_view->details->column_editor);
+       }
+}
 
-       ui_manager = nautilus_view_get_ui_manager (view);
+const GActionEntry list_view_entries[] = {
+       { "visible-columns", action_visible_columns },
+};
 
-       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);
+static void
+nautilus_list_view_update_right_click_menus (NautilusView *view)
+{
+       NautilusListView *list_view;
 
-       gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-       g_object_unref (action_group); /* owned by ui manager */
+        list_view = NAUTILUS_LIST_VIEW (view);
 
-       list_view->details->list_merge_id =
-               gtk_ui_manager_add_ui_from_resource (ui_manager, 
"/org/gnome/nautilus/nautilus-list-view-ui.xml", NULL);
+       /* don't update if the menus aren't ready */
+       if (!list_view->details->menus_ready) {
+               return;
+       }
 
-       list_view->details->menus_ready = TRUE;
+       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->update_right_click_menus (view);
 }
 
 static void
-nautilus_list_view_unmerge_menus (NautilusView *view)
+nautilus_list_view_update_actions_state (NautilusView *view)
 {
-       NautilusListView *list_view;
-       GtkUIManager *ui_manager;
-
-       list_view = NAUTILUS_LIST_VIEW (view);
+       NautilusWindow *window;
+       GSimpleAction *action;
 
-       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->unmerge_menus (view);
+       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->update_actions_state (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_simple_action_set_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);
 
-       NAUTILUS_VIEW_CLASS (nautilus_list_view_parent_class)->update_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_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 +3149,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 +3183,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 +3200,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 +3604,9 @@ 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_right_click_menus = nautilus_list_view_update_right_click_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 +3629,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 +3664,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-main-menus.xml b/src/nautilus-main-menus.xml
new file mode 100644
index 0000000..6ed6a66
--- /dev/null
+++ b/src/nautilus-main-menus.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <menu id="action-menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">New Folder</attribute>
+        <attribute name="action">view.new-folder</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">New Tab</attribute>
+        <attribute name="action">win.new-tab</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Undo</attribute>
+        <attribute name="action">view.undo</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Redo</attribute>
+        <attribute name="action">view.redo</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Select All</attribute>
+        <attribute name="action">view.select-all</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Enter Location</attribute>
+        <attribute name="action">win.enter-location</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Bookmark this Location</attribute>
+        <attribute name="action">win.bookmark-current-location</attribute>
+      </item>
+    </section>
+  </menu>
+  <menu id="background-menu">
+    <section>
+      <attribute name="id">templates-menu</attribute>
+    </section>
+    <item>
+      <attribute name="label" translatable="yes">New Folder</attribute>
+      <attribute name="action">view.new-folder</attribute>
+    </item>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Paste</attribute>
+        <attribute name="action">view.paste</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Mount Volume</attribute>
+        <attribute name="action">view.mount-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Unmount Volume</attribute>
+        <attribute name="action">view.unmount-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Eject Volume</attribute>
+        <attribute name="action">view.eject-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Stop Volume</attribute>
+        <attribute name="action">view.stop-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Poll</attribute>
+        <attribute name="action">view.poll</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Select All</attribute>
+        <attribute name="action">view.select-all</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Properties</attribute>
+        <attribute name="action">view.properties</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Keep aligned</attribute>
+        <attribute name="action">view.keep-aligned</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Organize Desktop by Name</attribute>
+        <attribute name="action">view.organize-desktop-by-name</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Change Background</attribute>
+        <attribute name="action">view.change-background</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+  </menu>
+  <menu id="selection-menu">
+  </menu>
+</interface>
\ No newline at end of file
diff --git a/src/nautilus-toolbar-ui.xml b/src/nautilus-toolbar-ui.xml
new file mode 100644
index 0000000..e074792
--- /dev/null
+++ b/src/nautilus-toolbar-ui.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="NautilusToolbar" parent="GtkHeaderBar">
+    <property name="visible">True</property>
+    <property name="show-close-button">True</property>
+    <child>
+      <object class="GtkBox" id="navigation_box">
+        <property name="visible">True</property>
+        <property name="orientation">horizontal</property>
+        <style>
+          <class name="linked"/>
+          <class name="raised"/>
+        </style>
+        <child>
+          <object class="GtkButton" id="back_button">
+            <property name="visible">True</property>
+            <property name="sensitive">True</property>
+            <property name="action_name">win.back</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="back_icon">
+                <property name="visible">True</property>
+                <property name="icon-name">go-previous-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack-type">start</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="forward_button">
+            <property name="visible">True</property>
+            <property name="sensitive">True</property>
+            <property name="action_name">win.forward</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage" id="forward_icon">
+                <property name="visible">True</property>
+                <property name="icon-name">go-next-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack-type">start</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">start</property>
+      </packing>
+      </child>
+      <child>
+        <object class="GtkBox" id="path_bar_container">
+        </object>
+        <packing>
+            <property name="pack-type">start</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkBox" id="location_entry_container">
+        </object>
+        <packing>
+          <property name="pack-type">start</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkMenuButton" id="action_button">
+          <property name="visible">True</property>
+          <property name="sensitive">True</property>
+          <style>
+            <class name="image-button"/>
+          </style>
+          <child>
+            <object class="GtkImage" id="action_icon">
+              <property name="visible">True</property>
+              <property name="icon-name">open-menu-symbolic</property>
+              <property name="icon-size">1</property>
+            </object>
+          </child>
+        </object>
+        <packing>
+          <property name="pack-type">end</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkMenuButton" id="view_button">
+          <property name="visible">True</property>
+          <property name="sensitive">True</property>
+          <style>
+            <class name="image-button"/>
+          </style>
+          <child>
+            <object class="GtkImage" id="view_icon">
+              <property name="visible">True</property>
+              <property name="icon-name">go-down-symbolic</property>
+              <property name="icon-size">1</property>
+            </object>
+          </child>
+        </object>
+        <packing>
+          <property name="pack-type">end</property>
+        </packing>
+      </child>
+      <child>
+        <object class="GtkToggleButton" id="search_button">
+          <property name="visible">True</property>
+          <property name="sensitive">True</property>
+          <property name="action_name">win.toggle-search</property>
+          <style>
+            <class name="image-button"/>
+          </style>
+          <child>
+            <object class="GtkImage" id="search_icon">
+              <property name="visible">True</property>
+              <property name="icon-name">edit-find-symbolic</property>
+              <property name="icon-size">1</property>
+            </object>
+          </child>
+        </object>
+        <packing>
+          <property name="pack-type">end</property>
+        </packing>
+      </child>
+  </template>
+</interface>
diff --git a/src/nautilus-toolbar-view-menu.xml b/src/nautilus-toolbar-view-menu.xml
new file mode 100644
index 0000000..201ebd6
--- /dev/null
+++ b/src/nautilus-toolbar-view-menu.xml
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class ="GtkPopoverMenu" id="view_menu_widget">
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">9</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <property name="width_request">200</property>
+        <child>
+          <object class="GtkBox" id="views_box">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <style>
+                <class name="linked"/>
+            </style>
+            <child>
+              <object class="GtkModelButton" id="grid_button">
+                <property name="visible">True</property>
+                <property name="text">Grid</property>
+                <property name="action-name">win.view-mode</property>
+                <property name="action-target">'grid'</property>
+                <property name="iconic">True</property>
+                <property name="centered">True</property>
+                <property name="icon">icon_grid</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="list_button">
+                <property name="visible">True</property>
+                <property name="text">List</property>
+                <property name="action-name">win.view-mode</property>
+                <property name="action-target">'list'</property>
+                <property name="iconic">True</property>
+                <property name="centered">True</property>
+                <property name="icon">icon_list</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkScale" id="zoom_level_scale">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="draw_value">False</property>
+            <property name="has_origin">False</property>
+            <property name="adjustment">zoom_adjustment</property>
+            <property name="round_digits">0</property>
+            <property name="restrict_to_fill_level">False</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="sort_menu">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkSeparator">
+                <property name="visible">True</property>
+                <property name="orientation">horizontal</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="sort_label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Sort</property>
+                <style>
+                  <class name="separator"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="sort_name">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Name</property>
+                <property name="action-name">view.sort</property>
+                <property name="action-target">'name'</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="sort_size">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Size</property>
+                <property name="action-name">view.sort</property>
+                <property name="action-target">'size'</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="sort_type">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Type</property>
+                <property name="action-name">view.sort</property>
+                <property name="action-target">'type'</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="sort_modification_date">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Modification Date</property>
+                <property name="action-name">view.sort</property>
+                <property name="action-target">'modification-date'</property>
+              </object>
+            </child>
+              <child>
+              <object class="GtkModelButton" id="sort_access_date">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Access Date</property>
+                <property name="action-name">view.sort</property>
+                <property name="action-target">'access-date'</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="sort_trash_time">
+                <property name="visible">False</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Trash Time</property>
+                <property name="action-name">view.sort</property>
+                <property name="action-target">'trash-time'</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="sort_search_relevance">
+                <property name="visible">False</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Search Relevance</property>
+                <property name="action-name">view.sort</property>
+                <property name="action-target">'search-relevance'</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSeparator">
+                <property name="visible">True</property>
+                <property name="orientation">horizontal</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkModelButton" id="reversed_order">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="text" translatable="yes">Reverse order</property>
+                <property name="action-name">view.reversed-order</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkSeparator">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton" id="visible_columns">
+            <property name="visible">False</property>
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">Visible Columns…</property>
+            <property name="action-name">view.visible-columns</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton" id="show_hidden_files">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">Show Hidden Files</property>
+            <property name="action-name">view.show-hidden-files</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton" id="reload">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">Reload</property>
+            <property name="action-name">win.reload</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GThemedIcon" id="icon_grid">
+    <property name="name">view-grid-symbolic</property>
+  </object>
+  <object class="GThemedIcon" id="icon_list">
+    <property name="name">view-list-symbolic</property>
+  </object>
+  <object class="GtkAdjustment" id="zoom_adjustment">
+    <property name="lower">0</property>
+    <property name="upper">2</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">1</property>
+    <property name="value">1</property>
+  </object>
+</interface>
\ No newline at end of file
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 642f524..c92590d 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -42,15 +42,28 @@ 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;
+       gboolean skip_next_zoom_change;
+
+       GtkWidget *view_button;
+       GtkWidget *action_button;
+
+       GtkWidget *view_menu_widget;
+       GtkAdjustment *zoom_adjustment;
+       GtkWidget *zoom_level_scale;
+       GMenu *action_menu;
 };
 
 enum {
@@ -61,9 +74,14 @@ 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);
 
 static void
 toolbar_update_appearance (NautilusToolbar *self)
@@ -145,6 +163,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,
@@ -377,107 +414,81 @@ gear_menu_key_press (GtkWidget *widget,
         return FALSE;
 }
 
-static void
-nautilus_toolbar_constructed (GObject *obj)
+static gint
+transform_zoom_level_for_ui (gint zoom_level)
 {
-       NautilusToolbar *self = NAUTILUS_TOOLBAR (obj);
-       GtkWidget *toolbar;
-       GtkWidget *button;
-       GtkWidget *menu;
-       GtkWidget *box;
-       GtkUIManager *ui_manager;
+       return (gint) floor (zoom_level / 2);
+}
 
-       G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj);
+static gint
+transform_zoom_level_for_backend (gint zoom_level)
+{
+       return zoom_level * 2;
+}
 
-       toolbar = GTK_WIDGET (obj);
+static void
+zoom_level_changed (GtkRange *range,
+                   NautilusToolbar *self)
+{
+       NautilusWindowSlot *slot;
+       NautilusView *view;
+       gdouble zoom_level;
+       GActionGroup *view_action_group;
+       GAction *action;
+       gint transformed_level;
 
-       ui_manager = nautilus_window_get_ui_manager (self->priv->window);
+       zoom_level = gtk_range_get_value (range);
+       slot = nautilus_window_get_active_slot (self->priv->window);
+       view = nautilus_window_slot_get_current_view (slot);
 
-       /* Back and Forward */
-       box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+       view_action_group = nautilus_view_get_action_group (view);
 
-       /* 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);
+       zoom_level = gtk_range_get_value (range);
 
-       /* 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);
+       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));
+}
 
-       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);
+static void
+nautilus_toolbar_init (NautilusToolbar *self)
+{
+       GtkBuilder *builder;
+       GMenu *action_menu;
 
-       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->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);
+
+       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);
+       self->priv->skip_next_zoom_change = FALSE;
 }
 
 static void
@@ -535,11 +546,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 +568,110 @@ 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);
+}
+
+static gboolean
+hide_widget_recursive (GtkWidget *widget,
+               gchar *id)
+{
+       GList *children;
+       GList *child;
+       GtkWidget *widget_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_reset_menus (NautilusToolbar *self)
+{
+       NautilusWindowSlot *slot;
+       NautilusView *view;
+       GActionGroup *view_action_group;
+
+       /* Map view actions to the view menu and action menu */
+       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));
+       //gtk_widget_show_all (self->priv->view_menu_widget);
+       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);
+}
+
+static gboolean
+show_widget_recursive (GtkWidget *widget,
+               gchar *id)
+{
+       GList *children;
+       GList *child;
+       GtkWidget *widget_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)
+{
+       gint transformed_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..ad6616f 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 {
@@ -73,4 +73,12 @@ void nautilus_toolbar_set_show_main_bar (NautilusToolbar *self,
 void nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
                                               gboolean show_location_entry);
 
+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);
+
 #endif /* __NAUTILUS_TOOLBAR_H__ */
diff --git a/src/nautilus-view-right-click-menus.xml b/src/nautilus-view-right-click-menus.xml
new file mode 100755
index 0000000..2d21374
--- /dev/null
+++ b/src/nautilus-view-right-click-menus.xml
@@ -0,0 +1,152 @@
+<?xml version="1.0"?>
+<interface>
+  <menu id="background-menu">
+    <section>
+      <attribute name="id">templates-menu</attribute>
+    </section>
+    <item>
+      <attribute name="label" translatable="yes">New Folder</attribute>
+      <attribute name="action">view.new-folder</attribute>
+    </item>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Paste</attribute>
+        <attribute name="action">view.paste</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Mount Volume</attribute>
+        <attribute name="action">view.mount-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Unmount Volume</attribute>
+        <attribute name="action">view.unmount-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Eject Volume</attribute>
+        <attribute name="action">view.eject-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Stop Volume</attribute>
+        <attribute name="action">view.stop-volume</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Poll</attribute>
+        <attribute name="action">view.poll</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Select All</attribute>
+        <attribute name="action">view.select-all</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Properties</attribute>
+        <attribute name="action">view.properties</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Keep aligned</attribute>
+        <attribute name="action">view.keep-aligned</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Organize Desktop by Name</attribute>
+        <attribute name="action">view.organize-desktop-by-name</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Change Background</attribute>
+        <attribute name="action">view.change-background</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+  </menu>
+  <menu id="selection-menu">
+    <section>
+      <attribute name="id">open-with-default-application-section</attribute>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Open Item Location</attribute>
+        <attribute name="action">view.open-item-location</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Open In New Window</attribute>
+        <attribute name="action">view.open-item-new-window</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Open In New Tab</attribute>
+        <attribute name="action">view.open-item-new-tab</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Open With Other Application</attribute>
+        <attribute name="action">view.open-with-other-application</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Cut</attribute>
+        <attribute name="action">view.cut</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Copy</attribute>
+        <attribute name="action">view.copy</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Paste Into Folder</attribute>
+        <attribute name="action">view.paste-into</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Move to…</attribute>
+        <attribute name="action">view.move-to</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Copy to…</attribute>
+        <attribute name="action">view.copy-to</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Send to…</attribute>
+        <attribute name="action">view.send-to</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Move to Trash</attribute>
+        <attribute name="action">view.move-to-trash</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Rename</attribute>
+        <attribute name="action">view.rename</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Properties</attribute>
+        <attribute name="action">view.properties</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
\ No newline at end of file
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
old mode 100644
new mode 100755
index 17d5d49..59e39a0
--- 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"
@@ -188,7 +190,7 @@ struct NautilusViewDetails
        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;
 
@@ -259,6 +261,11 @@ struct NautilusViewDetails
        GList *subdirectory_list;
 
        GdkPoint context_menu_position;
+
+       GMenu *selection_menu;
+       GMenu *background_menu;
+
+       GActionGroup *view_action_group;
 };
 
 typedef struct {
@@ -280,14 +287,12 @@ static void     load_directory                                 (NautilusView
                                                                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);
@@ -311,6 +316,36 @@ static gboolean file_list_all_are_folders                      (GList *file_list
 
 static void unschedule_pop_up_location_context_menu (NautilusView *view);
 
+static void action_new_folder (GSimpleAction *action,
+                               GVariant      *state,
+                               gpointer       user_data);
+static void action_new_item_tab (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 action_show_hidden_files (GSimpleAction *action,
+                               GVariant      *state,
+                               gpointer       user_data);
+static void real_zoom_to_level (NautilusView *view,
+                               NautilusZoomLevel *zoom_level);
+
 G_DEFINE_TYPE (NautilusView, nautilus_view, GTK_TYPE_SCROLLED_WINDOW);
 
 /* virtual methods (public and non-public) */
@@ -334,7 +369,8 @@ 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);}
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->unmerge_menus (view);
+}
 
 static char *
 real_get_backing_uri (NautilusView *view)
@@ -576,6 +612,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:
  *
@@ -715,13 +758,13 @@ nautilus_view_get_selection (NautilusView *view)
 }
 
 /**
- * nautilus_view_update_menus:
+ * nautilus_view_update_right_click_menus:
  * 
  * Update the sensitivity and wording of dynamic menu items.
  * @view: NautilusView in question.
  */
 void
-nautilus_view_update_menus (NautilusView *view)
+nautilus_view_update_right_click_menus_old (NautilusView *view)
 {
        g_return_if_fail (NAUTILUS_IS_VIEW (view));
 
@@ -729,7 +772,7 @@ nautilus_view_update_menus (NautilusView *view)
                return;
        }
 
-       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_menus (view);
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_right_click_menus (view);
 }
 
 typedef struct {
@@ -902,7 +945,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);
@@ -1075,6 +1118,8 @@ nautilus_view_activate_file (NautilusView *view,
        g_free (path);
 }
 
+/********* ACTIONS *********/
+
 static void
 action_open_callback (GtkAction *action,
                      gpointer callback_data)
@@ -1086,6 +1131,17 @@ action_open_callback (GtkAction *action,
 }
 
 static void
+action_open_with_default_application (GSimpleAction *action,
+                               GVariant      *state,
+                               gpointer       user_data)
+{
+       NautilusView *view;
+
+       view = NAUTILUS_VIEW (user_data);
+       nautilus_view_activate_selection (view);
+}
+
+static void
 action_open_close_parent_callback (GtkAction *action,
                                   gpointer callback_data)
 {
@@ -1132,6 +1188,36 @@ action_open_item_location_callback (GtkAction *action,
        nautilus_file_list_free (selection);
 }
 
+static void
+action_open_item_location (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
+{
+       NautilusView *view;
+       GList *selection;
+       NautilusFile *item;
+       GFile *activation_location;
+       NautilusFile *activation_file;
+       NautilusFile *location;
+
+       view = NAUTILUS_VIEW (user_data);
+       selection = nautilus_view_get_selection (view);
+
+       if (!selection)
+               return;
+
+       item = NAUTILUS_FILE (selection->data);
+       activation_location = nautilus_file_get_activation_location (item);
+       activation_file = nautilus_file_get (activation_location);
+       location = nautilus_file_get_parent (activation_file);
+
+       nautilus_view_activate_file (view, location, 0);
+
+       nautilus_file_unref (location);
+       nautilus_file_unref (activation_file);
+       g_object_unref (activation_location);
+       nautilus_file_list_free (selection);
+}
 
 static void
 action_open_alternate_callback (GtkAction *action,
@@ -1177,6 +1263,30 @@ action_open_new_tab_callback (GtkAction *action,
 }
 
 static void
+action_open_item_new_tab (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
+{
+       NautilusView *view;
+       GList *selection;
+       GtkWindow *window;
+
+       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), TRUE)) {
+               nautilus_view_activate_files (view,
+                                             selection,
+                                             NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB,
+                                             FALSE);
+       }
+
+       nautilus_file_list_free (selection);
+}
+
+static void
 app_chooser_dialog_response_cb (GtkDialog *dialog,
                                gint response_id,
                                gpointer user_data)
@@ -1247,8 +1357,9 @@ open_with_other_program (NautilusView *view)
        g_assert (NAUTILUS_IS_VIEW (view));
 
                selection = nautilus_view_get_selection (view);
-
+               g_print ("open with other program\n");
        if (selection_contains_one_item_in_menu_callback (view, selection)) {
+               g_print ("one item in election open with other program\n");
                choose_program (view, NAUTILUS_FILE (selection->data));
        }
 
@@ -1265,6 +1376,16 @@ action_other_application_callback (GtkAction *action,
 }
 
 static void
+action_open_with_other_application (GSimpleAction *action,
+                               GVariant      *state,
+                               gpointer       user_data)
+{
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       open_with_other_program (NAUTILUS_VIEW (user_data));
+}
+
+static void
 trash_or_delete_selected_files (NautilusView *view)
 {
         GList *selection;
@@ -1306,6 +1427,14 @@ action_trash_callback (GtkAction *action,
 }
 
 static void
+action_move_to_trash (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+        trash_or_delete_selected_files (NAUTILUS_VIEW (user_data));
+}
+
+static void
 delete_selected_files (NautilusView *view)
 {
         GList *selection;
@@ -1400,6 +1529,20 @@ action_select_all_callback (GtkAction *action,
 }
 
 static void
+action_select_all (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+       NautilusView *view;
+
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       view = NAUTILUS_VIEW (user_data);
+
+       nautilus_view_select_all (view);
+}
+
+static void
 action_invert_selection_callback (GtkAction *action,
                                  gpointer callback_data)
 {
@@ -1537,7 +1680,7 @@ action_save_search_callback (GtkAction *action,
                nautilus_search_directory_save_search (search);
 
                /* Save search is disabled */
-               schedule_update_menus (directory_view);
+               schedule_update_right_click_menus (directory_view);
        }
 }
 
@@ -2086,6 +2229,16 @@ action_new_folder_callback (GtkAction *action,
 }
 
 static void
+action_new_folder (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+       g_assert (NAUTILUS_IS_VIEW (user_data));
+
+       nautilus_view_new_folder (NAUTILUS_VIEW (user_data), FALSE);
+}
+
+static void
 action_new_folder_with_selection_callback (GtkAction *action,
                                           gpointer callback_data)
 {                
@@ -2121,6 +2274,33 @@ action_properties_callback (GtkAction *action,
 }
 
 static void
+action_properties (GSimpleAction *action,
+                       GVariant *state,
+                       gpointer user_data)
+{
+        NautilusView *view;
+        GList *selection;
+       GList *files;
+        
+        g_assert (NAUTILUS_IS_VIEW (user_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) {
+                       files = g_list_append (NULL, nautilus_file_ref (view->details->directory_as_file));
+
+                       nautilus_properties_window_present (files, GTK_WIDGET (view), NULL);
+
+                       nautilus_file_list_free (files);
+               }
+       } else {
+               nautilus_properties_window_present (selection, GTK_WIDGET (view), NULL);
+       }
+        nautilus_file_list_free (selection);
+}
+
+static void
 action_location_properties_callback (GtkAction *action,
                                     gpointer   callback_data)
 {
@@ -2170,6 +2350,22 @@ all_selected_items_in_trash (GList *selection)
 }
 
 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 void
 action_show_hidden_files_callback (GtkAction *action,
                                   gpointer callback_data)
 {
@@ -2182,6 +2378,237 @@ action_show_hidden_files_callback (GtkAction *action,
 }
 
 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 void
+action_undo (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+       GtkWidget *toplevel;
+       NautilusView *view;
+
+       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_redo (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+       GtkWidget *toplevel;
+       NautilusView *view;
+
+       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;
+
+       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_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_open_item_new_window (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
+{
+       NautilusView *view;
+       GList *selection;
+       GtkWindow *window;
+
+       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), TRUE)) {
+               nautilus_view_activate_files (view,
+                                             selection,
+                                             NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW,
+                                             FALSE);
+       }
+
+       nautilus_file_list_free (selection);
+}
+
+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_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
+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);
+}
+
+/*************** END ACTIONS **********************/
+
+static void
 click_policy_changed_callback (gpointer callback_data)
 {
        NautilusView *view;
@@ -2310,7 +2737,7 @@ scripts_added_or_changed_callback (NautilusDirectory *directory,
 
        view->details->scripts_invalid = TRUE;
        if (view->details->active) {
-               schedule_update_menus (view);
+               schedule_update_right_click_menus (view);
        }
 }
 
@@ -2325,7 +2752,7 @@ templates_added_or_changed_callback (NautilusDirectory *directory,
 
        view->details->templates_invalid = TRUE;
        if (view->details->active) {
-               schedule_update_menus (view);
+               schedule_update_right_click_menus (view);
        }
 }
 
@@ -2422,8 +2849,14 @@ slot_active (NautilusWindowSlot *slot,
 
        view->details->active = TRUE;
 
+       g_print ("slot active\n");
+
        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
@@ -2434,10 +2867,11 @@ slot_inactive (NautilusWindowSlot *slot,
                return;
        }
 
+       g_print ("slot inactive\n");
        view->details->active = FALSE;
 
        nautilus_view_unmerge_menus (view);
-       remove_update_menus_timeout_callback (view);
+       remove_update_right_click_menus_timeout_callback (view);
 }
 
 void
@@ -2599,104 +3033,10 @@ have_bulk_rename_tool ()
 }
 
 static void
-nautilus_view_init (NautilusView *view)
-{
-       AtkObject *atk_object;
-       NautilusDirectory *scripts_directory;
-       NautilusDirectory *templates_directory;
-       char *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);
-
-       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);
-               add_directory_to_scripts_directory_list (view, scripts_directory);
-               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);
-               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;
-
+       g_print(" real unmerge menus\n");
        ui_manager = nautilus_view_get_ui_manager (view);
        if (ui_manager == NULL) {
                return;
@@ -2747,7 +3087,7 @@ nautilus_view_destroy (GtkWidget *object)
                                                   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 +3129,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,7 +3140,7 @@ 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) {
@@ -2838,6 +3178,7 @@ nautilus_view_display_selection_info (NautilusView *view)
        char *detail_status;
        NautilusFile *file;
 
+       g_print ("display select info %s\n", G_OBJECT_TYPE_NAME (view));
        g_return_if_fail (NAUTILUS_IS_VIEW (view));
 
        selection = nautilus_view_get_selection (view);
@@ -3042,7 +3383,8 @@ done_loading (NautilusView *view,
         * is no NautilusWindow any more.
         */
        if (window != NULL) {
-               schedule_update_menus (view);
+               g_print ("done_loading\n");
+               schedule_update_right_click_menus (view);
                schedule_update_status (view);
                reset_update_interval (view);
 
@@ -3294,7 +3636,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 +3897,25 @@ 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);
+       g_print ("update_menus if pending \n");
 
-       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 +3923,9 @@ 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;
+       g_print("update_menus_timeout_callback\n");
+       nautilus_view_update_right_click_menus(view);
 
        g_object_unref (G_OBJECT (view));
 
@@ -3806,7 +4147,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
@@ -4381,7 +4722,7 @@ get_x_content_async_callback (const char **content,
        view = NAUTILUS_VIEW (user_data);
 
        if (view->details->slot != NULL) {
-               schedule_update_menus (view);
+               schedule_update_right_click_menus (view);
        }
        g_object_unref (view);
 }
@@ -6013,6 +6354,21 @@ action_copy_files_callback (GtkAction *action,
 }
 
 static void
+action_copy(GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+       NautilusView *view;
+       GList *selection;
+
+       view = NAUTILUS_VIEW (user_data);
+
+       selection = nautilus_view_get_selection_for_file_transfer (view);
+       copy_or_cut_files (view, selection, FALSE);
+       nautilus_file_list_free (selection);
+}
+
+static void
 action_cut_files_callback (GtkAction *action,
                           gpointer callback_data)
 {
@@ -6027,70 +6383,60 @@ action_cut_files_callback (GtkAction *action,
 }
 
 static void
-action_copy_to_callback (GtkAction *action,
-                        gpointer callback_data)
+action_cut (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
        NautilusView *view;
+       GList *selection;
 
-       view = NAUTILUS_VIEW (callback_data);
-       copy_or_move_selection (view, FALSE);
+       view = NAUTILUS_VIEW (user_data);
+
+       selection = nautilus_view_get_selection_for_file_transfer (view);
+       copy_or_cut_files (view, selection, TRUE);
+       nautilus_file_list_free (selection);
 }
 
 static void
-action_move_to_callback (GtkAction *action,
+action_copy_to_callback (GtkAction *action,
                         gpointer callback_data)
 {
        NautilusView *view;
 
        view = NAUTILUS_VIEW (callback_data);
-       copy_or_move_selection (view, TRUE);
+       copy_or_move_selection (view, FALSE);
 }
 
 static void
-paste_clipboard_data (NautilusView *view,
-                     GtkSelectionData *selection_data,
-                     char *destination_uri)
+action_copy_to (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
 {
-       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)));
-               }
+       NautilusView *view;
 
-               g_list_free_full (item_uris, g_free);
-       }
+       view = NAUTILUS_VIEW (user_data);
+       copy_or_move_selection (view, FALSE);
 }
 
 static void
-paste_clipboard_received_callback (GtkClipboard     *clipboard,
-                                  GtkSelectionData *selection_data,
-                                  gpointer          data)
+action_move_to_callback (GtkAction *action,
+                        gpointer callback_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);
-       }
+       view = NAUTILUS_VIEW (callback_data);
+       copy_or_move_selection (view, TRUE);
+}
 
-       g_free (view_uri);
+static void
+action_move_to (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+       NautilusView *view;
 
-       g_object_unref (view);
+       view = NAUTILUS_VIEW (user_data);
+       copy_or_move_selection (view, TRUE);
 }
 
 typedef struct {
@@ -6125,21 +6471,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)
 {
@@ -6161,7 +6492,7 @@ paste_into (NautilusView *view,
 
 static void
 action_paste_files_into_callback (GtkAction *action,
-                                 gpointer callback_data)
+                                 gpointer callback_data)
 {
        NautilusView *view;
        GList *selection;
@@ -6176,6 +6507,23 @@ action_paste_files_into_callback (GtkAction *action,
 }
 
 static void
+action_paste_files_into (GSimpleAction *action,
+                       GVariant      *state,
+                       gpointer       user_data)
+{
+       NautilusView *view;
+       GList *selection;
+
+       view = NAUTILUS_VIEW (user_data);
+       selection = nautilus_view_get_selection (view);
+       if (selection != NULL) {
+               paste_into (view, NAUTILUS_FILE (selection->data));
+               nautilus_file_list_free (selection);
+       }
+
+}
+
+static void
 invoke_external_bulk_rename_utility (NautilusView *view,
                                     GList *selection)
 {
@@ -6277,6 +6625,15 @@ action_rename_callback (GtkAction *action,
 }
 
 static void
+action_rename (GSimpleAction *action,
+               GVariant      *state,
+               gpointer       user_data)
+{
+       real_action_rename (NAUTILUS_VIEW (user_data), FALSE);
+}
+
+
+static void
 action_rename_select_all_callback (GtkAction *action,
                                   gpointer callback_data)
 {
@@ -6909,24 +7266,6 @@ action_location_detect_media_callback (GtkAction *action,
 }
 
 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)
 {
@@ -7063,21 +7402,32 @@ 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);
-               }
-       }
-}
+const GActionEntry view_entries[] = {
+       { "new-folder", action_new_folder },
+       { "select-all", action_select_all },
+       { "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 },
+       /* Selection menu */
+       { "open-item-location", action_open_item_location },
+       { "open-with-default-application", action_open_with_default_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},
+       { "paste", action_paste_files },
+       { "paste-into", action_paste_files_into },
+       { "rename", action_rename},
+       { "properties", action_properties},
+       { "open-with-other-application", action_open_with_other_application }
+};
 
 static const GtkActionEntry directory_view_entries[] = {
   /* name, stock id, label */  { NAUTILUS_ACTION_NEW_DOCUMENTS, "document-new", N_("New _Document") },
@@ -7396,6 +7746,8 @@ real_merge_menus (NautilusView *view)
        GtkAction *action;
        char *tooltip;
 
+       g_print("real merge menus\n");
+
        ui_manager = nautilus_view_get_ui_manager (view);
 
        action_group = gtk_action_group_new ("DirViewActions");
@@ -7469,13 +7821,12 @@ clipboard_targets_received (GtkClipboard     *clipboard,
 {
        NautilusView *view;
        gboolean can_paste;
+       gboolean can_paste_into;
        int i;
-       GList *selection;
-       int count;
-       GtkAction *action;
+       GAction *action;
 
        view = NAUTILUS_VIEW (user_data);
-       can_paste = FALSE;
+       can_paste_into = can_paste = FALSE;
 
        if (view->details->slot == NULL ||
            !view->details->active) {
@@ -7485,40 +7836,26 @@ 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 = 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));
 
-       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")));
+       action = g_action_map_lookup_action (G_ACTION_MAP (view->details->view_action_group),
+                                            "paste-into");
+
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                               can_paste && g_action_get_enabled (action));
 
-       nautilus_file_list_free (selection);
        
        g_object_unref (view);
 }
@@ -8157,49 +8494,6 @@ real_update_location_menu_volumes (NautilusView *view)
        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)
 {
@@ -8317,20 +8611,8 @@ real_update_location_menu (NautilusView *view)
 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
@@ -8364,7 +8646,7 @@ can_trash_all (GList *files)
 }
 
 static void
-real_update_menus (NautilusView *view)
+real_update_menus_old (NautilusView *view)
 {
        GList *selection, *l;
        gint selection_count;
@@ -8727,8 +9009,6 @@ real_update_menus (NautilusView *view)
                                              NAUTILUS_ACTION_COPY);
        gtk_action_set_sensitive (action, can_copy_files);
 
-       real_update_paste_menu (view, selection, selection_count);
-
        real_update_menus_volumes (view, selection, selection_count);
 
        update_undo_actions (view);
@@ -8762,6 +9042,387 @@ real_update_menus (NautilusView *view)
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), view->details->show_hidden_files);
 }
 
+GActionGroup *
+nautilus_view_get_action_group (NautilusView *view)
+{
+       g_assert (NAUTILUS_IS_VIEW (view));
+
+       return view->details->view_action_group;
+}
+
+static void
+real_update_actions_state (NautilusView *view)
+{
+       GList *selection, *l;
+       NautilusFile *file;
+       gint selection_count;
+       const char *tip, *label;
+       gboolean selection_contains_special_link;
+       gboolean selection_contains_desktop_or_home_dir;
+       gboolean selection_contains_recent;
+       gboolean selection_contains_search;
+       gboolean selection_is_read_only;
+       gboolean selection_all_in_trash;
+       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 show_app, show_run;
+       gboolean show_save_search;
+       gboolean save_search_sensitive;
+       gboolean show_save_search_as;
+       gboolean item_opens_in_view;
+       gboolean is_read_only;
+       gboolean test;
+       GAction *action;
+       GAppInfo *app;
+       GIcon *app_icon;
+       GtkWidget *menuitem;
+       gboolean show_properties;
+       GActionGroup *view_action_group;
+       gchar *detailed_action;
+       GMenuItem *open_menu_item;
+
+       view_action_group = view->details->view_action_group;
+
+       g_print ("entering update actions state\n");
+
+       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) &&
+               selection_count != 0 &&
+               !selection_contains_special_link &&
+               !selection_contains_desktop_or_home_dir;
+       can_trash_files =
+               can_trash_all (selection) &&
+               selection_count != 0 &&
+               !selection_contains_special_link &&
+               !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);
+
+       /* Right click actions */
+       /* Selection menu actions */
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "rename");
+       if (selection_count > 1) {
+               g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                      have_bulk_rename_tool ());
+       } else {
+               g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                      selection_count == 1 &&
+                                      nautilus_view_can_rename_file (view, selection->data));
+       }
+
+       action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
+                                            "open-item-location");
+
+       g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+                                    selection_count == 1 &&
+                                    (selection_contains_recent || selection_contains_search));
+
+       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);
+
+
+       selection = nautilus_view_get_selection (view);
+       selection_count = g_list_length (selection);
+
+       file = NULL;
+       if (selection_count == 1)
+               file = NAUTILUS_FILE (selection->data);
+
+       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);
+
+       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);
+
+       /* Open With <App> menu item */
+       app = NULL;
+       if (show_app) {
+               app = nautilus_mime_get_default_application_for_files (selection);
+       }
+
+       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),
+                                            "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);
+
+       /* 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),
+                                    !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);
+       /* 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);
+
+       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));
+
+       /* Toolbar menu actions */
+       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));
+
+       g_print ("exiting update actions state\n");
+
+}
+
+/* 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));
+
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_actions_state (view);
+}
+
+static void
+update_background_menu (NautilusView *view)
+{
+
+}
+
+static void
+update_selection_menu (NautilusView *view)
+{
+       GList *selection, *l;
+       NautilusFile *file;
+       gint selection_count;
+       gboolean can_open;
+       gboolean show_app, show_run;
+       gboolean item_opens_in_view;
+       GAction *action;
+       GAppInfo *app;
+       GMenuItem *open_menu_item;
+       GIcon *app_icon;
+       char *label_with_underscore;
+
+       selection = nautilus_view_get_selection (view);
+       selection_count = g_list_length (selection);
+
+       file = NULL;
+       if (selection_count == 1)
+               file = NAUTILUS_FILE (selection->data);
+
+       /* 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);
+
+       label_with_underscore = NULL;
+       app = NULL;
+       app_icon = NULL;
+       if (show_app) {
+               app = nautilus_mime_get_default_application_for_files (selection);
+       }
+
+       if (app != NULL || show_run || item_opens_in_view) {
+               char *escaped_app;
+
+               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);
+
+                       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"));
+               }
+
+               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);
+
+               nautilus_gmenu_add_item_in_section (view->details->selection_menu,
+                                                   open_menu_item,
+                                                   "open-with-default-application-section");
+
+               g_free (label_with_underscore);
+       }
+}
+
+static void
+real_update_right_click_menus (NautilusView *view)
+{
+       g_print ("view real_update_right_click_menus\n");
+       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);
+       
+       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")));
+       g_object_unref (builder);
+
+       update_background_menu (view);
+       update_selection_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));
+
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_right_click_menus (view);
+}
+
+static void
+real_update_toolbar_menus (NautilusView *view)
+{
+       NautilusToolbar *toolbar;
+
+       toolbar = nautilus_window_get_toolbar (nautilus_view_get_window (view));
+       nautilus_toolbar_reset_menus (toolbar);
+       nautilus_view_update_actions_state (view);
+}
+
+void
+nautilus_view_update_toolbar_menus (NautilusView *view)
+{
+       g_assert(NAUTILUS_IS_VIEW (view));
+
+       NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_toolbar_menus (view);
+}
+
+
+static void 
+create_right_click_menu (NautilusView *view,
+               GMenu *menu,
+               GdkEventButton *event)
+{
+       GtkWidget *gtk_menu;
+
+       int button;
+
+       g_return_if_fail (G_IS_MENU (menu));
+
+       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
  *
@@ -8781,13 +9442,11 @@ nautilus_view_pop_up_selection_context_menu  (NautilusView *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);
 }
 
 /**
@@ -8808,14 +9467,11 @@ nautilus_view_pop_up_background_context_menu (NautilusView *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
@@ -8921,7 +9577,7 @@ nautilus_view_pop_up_location_context_menu (NautilusView *view,
 }
 
 static void
-schedule_update_menus (NautilusView *view) 
+schedule_update_right_click_menus (NautilusView *view) 
 {
        g_assert (NAUTILUS_IS_VIEW (view));
 
@@ -8934,9 +9590,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 +9678,8 @@ nautilus_view_notify_selection_changed (NautilusView *view)
                 */
 
                /* Schedule an update of menu item states to match selection */
-               schedule_update_menus (view);
+                g_print ("selection_changed\n");
+               schedule_update_right_click_menus (view);
        }
 }
 
@@ -9033,7 +9690,8 @@ file_changed_callback (NautilusFile *file, gpointer callback_data)
 
        schedule_changes (view);
 
-       schedule_update_menus (view);
+       g_print ("file_changed\n");
+       schedule_update_right_click_menus (view);
        schedule_update_status (view);
 }
 
@@ -9068,7 +9726,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 +10158,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 +10307,6 @@ nautilus_view_parent_set (GtkWidget *widget,
 {
        NautilusView *view;
        GtkWidget *parent;
-
        view = NAUTILUS_VIEW (widget);
 
        parent = gtk_widget_get_parent (widget);
@@ -9667,11 +10324,13 @@ nautilus_view_parent_set (GtkWidget *widget,
                        view->details->active = TRUE;
 
                        nautilus_view_merge_menus (view);
-                       schedule_update_menus (view);
+                       g_print("parent set \n");
+                       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);
        }
 }
 
@@ -9805,7 +10464,12 @@ nautilus_view_class_init (NautilusViewClass *klass)
        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->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;
        klass->trash = real_trash;
        klass->delete = real_delete;
 
@@ -9837,6 +10501,109 @@ nautilus_view_class_init (NautilusViewClass *klass)
                                      "delete", 0);
 }
 
+static void
+nautilus_view_init (NautilusView *view)
+{
+       AtkObject *atk_object;
+       NautilusDirectory *scripts_directory;
+       NautilusDirectory *templates_directory;
+       char *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);
+
+       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);
+               add_directory_to_scripts_directory_list (view, scripts_directory);
+               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);
+               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_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_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"));
+
+       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));
+
+       nautilus_profile_end (NULL);
+}
+
 NautilusView *
 nautilus_view_new (const gchar         *id,
                   NautilusWindowSlot   *slot)
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 98f3d57..a4a5923 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
@@ -295,6 +299,9 @@ struct NautilusViewClass {
         /* 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 */
@@ -358,6 +365,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);
@@ -409,6 +417,14 @@ void              nautilus_view_pop_up_location_context_menu (NautilusView    *v
 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..6b64e30 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,124 @@ 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;
+
+       name =  g_variant_get_string (value, NULL);
+       slot = nautilus_window_get_active_slot (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);
+       }
+
+       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", "'grid'", 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..49db5c0 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);
 }
@@ -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)
 {
@@ -1459,13 +1442,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 +1460,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 +1478,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 +2096,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]