Blame SOURCES/Add-actions-to-the-toolbar.patch

82f35c
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
82f35c
index 0c7380ae9..08107a64e 100644
82f35c
--- a/src/nautilus-files-view.c
82f35c
+++ b/src/nautilus-files-view.c
82f35c
@@ -146,6 +146,8 @@ enum
82f35c
     PROP_IS_LOADING,
82f35c
     PROP_LOCATION,
82f35c
     PROP_SEARCH_QUERY,
82f35c
+    PROP_EXTENSIONS_BACKGROUND_MENU,
82f35c
+    PROP_TEMPLATES_MENU,
82f35c
     NUM_PROPERTIES
82f35c
 };
82f35c
 
82f35c
@@ -264,6 +266,10 @@ typedef struct
82f35c
     GtkWidget *zoom_controls_box;
82f35c
     GtkWidget *zoom_level_label;
82f35c
 
82f35c
+    /* Exposed menus, for the path bar etc. */
82f35c
+    GMenu *extensions_background_menu;
82f35c
+    GMenu *templates_menu;
82f35c
+
82f35c
     gulong stop_signal_handler;
82f35c
     gulong reload_signal_handler;
82f35c
 
82f35c
@@ -691,6 +697,98 @@ nautilus_files_view_get_toolbar_menu_sections (NautilusView *view)
82f35c
     return priv->toolbar_menu_sections;
82f35c
 }
82f35c
 
82f35c
+static GMenu*
82f35c
+nautilus_files_view_get_templates_menu (NautilusView *self)
82f35c
+{
82f35c
+    GMenu *menu;
82f35c
+
82f35c
+    g_object_get (self, "templates-menu", &menu, NULL);
82f35c
+
82f35c
+    return menu;
82f35c
+}
82f35c
+
82f35c
+static GMenu*
82f35c
+nautilus_files_view_get_extensions_background_menu (NautilusView *self)
82f35c
+{
82f35c
+    GMenu *menu;
82f35c
+
82f35c
+    g_object_get (self, "extensions-background-menu", &menu, NULL);
82f35c
+
82f35c
+    return menu;
82f35c
+}
82f35c
+
82f35c
+static GMenu*
82f35c
+real_get_extensions_background_menu (NautilusView *view)
82f35c
+{
82f35c
+    NautilusFilesViewPrivate *priv;
82f35c
+
82f35c
+    g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
82f35c
+
82f35c
+    priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
82f35c
+
82f35c
+    return priv->extensions_background_menu;
82f35c
+}
82f35c
+
82f35c
+static GMenu*
82f35c
+real_get_templates_menu (NautilusView *view)
82f35c
+{
82f35c
+    NautilusFilesViewPrivate *priv;
82f35c
+
82f35c
+    g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
82f35c
+
82f35c
+    priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
82f35c
+
82f35c
+    return priv->templates_menu;
82f35c
+}
82f35c
+
82f35c
+static void
82f35c
+nautilus_files_view_set_templates_menu (NautilusView *self,
82f35c
+                                        GMenu        *menu)
82f35c
+{
82f35c
+    g_object_set (self, "templates-menu", menu, NULL);
82f35c
+}
82f35c
+
82f35c
+static void
82f35c
+nautilus_files_view_set_extensions_background_menu (NautilusView *self,
82f35c
+                                                    GMenu        *menu)
82f35c
+{
82f35c
+    g_object_set (self, "extensions-background-menu", menu, NULL);
82f35c
+}
82f35c
+
82f35c
+static void
82f35c
+real_set_extensions_background_menu (NautilusView *view,
82f35c
+                                     GMenu        *menu)
82f35c
+{
82f35c
+    NautilusFilesViewPrivate *priv;
82f35c
+
82f35c
+    g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
82f35c
+
82f35c
+    priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
82f35c
+
82f35c
+    if (priv->extensions_background_menu != NULL)
82f35c
+    {
82f35c
+        g_clear_object (&priv->extensions_background_menu);
82f35c
+    }
82f35c
+    priv->extensions_background_menu = menu;
82f35c
+}
82f35c
+
82f35c
+static void
82f35c
+real_set_templates_menu (NautilusView *view,
82f35c
+                         GMenu        *menu)
82f35c
+{
82f35c
+    NautilusFilesViewPrivate *priv;
82f35c
+
82f35c
+    g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
82f35c
+
82f35c
+    priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view));
82f35c
+
82f35c
+    if (priv->templates_menu != NULL)
82f35c
+    {
82f35c
+        g_clear_object (&priv->templates_menu);
82f35c
+    }
82f35c
+    priv->templates_menu = menu;
82f35c
+}
82f35c
+
82f35c
 static gboolean
82f35c
 showing_trash_directory (NautilusFilesView *view)
82f35c
 {
82f35c
@@ -2446,6 +2544,30 @@ action_properties (GSimpleAction *action,
82f35c
     }
82f35c
 }
82f35c
 
82f35c
+static void
82f35c
+action_current_dir_properties (GSimpleAction *action,
82f35c
+                               GVariant      *state,
82f35c
+                               gpointer       user_data)
82f35c
+{
82f35c
+    NautilusFilesView *view;
82f35c
+    NautilusFilesViewPrivate *priv;
82f35c
+    GList *files;
82f35c
+
82f35c
+    g_return_if_fail (NAUTILUS_IS_FILES_VIEW (user_data));
82f35c
+
82f35c
+    view = NAUTILUS_FILES_VIEW (user_data);
82f35c
+    priv = nautilus_files_view_get_instance_private (view);
82f35c
+
82f35c
+    if (priv->directory_as_file != NULL)
82f35c
+    {
82f35c
+        files = g_list_append (NULL, nautilus_file_ref (priv->directory_as_file));
82f35c
+
82f35c
+        nautilus_properties_window_present (files, GTK_WIDGET (view), NULL, NULL, NULL);
82f35c
+
82f35c
+        nautilus_file_list_free (files);
82f35c
+    }
82f35c
+}
82f35c
+
82f35c
 static void
82f35c
 nautilus_files_view_set_show_hidden_files (NautilusFilesView *view,
82f35c
                                            gboolean           show_hidden)
82f35c
@@ -3192,6 +3314,8 @@ nautilus_files_view_finalize (GObject *object)
82f35c
     g_clear_object (&priv->selection_menu);
82f35c
     g_clear_object (&priv->toolbar_menu_sections->zoom_section);
82f35c
     g_clear_object (&priv->toolbar_menu_sections->extended_section);
82f35c
+    g_clear_object (&priv->extensions_background_menu);
82f35c
+    g_clear_object (&priv->templates_menu);
82f35c
     g_clear_object (&priv->rename_file_controller);
82f35c
     g_clear_object (&priv->new_folder_controller);
82f35c
     g_clear_object (&priv->compress_controller);
82f35c
@@ -4899,49 +5023,42 @@ build_menu_for_extension_menu_items (NautilusFilesView *view,
82f35c
     return gmenu;
82f35c
 }
82f35c
 
82f35c
-static void
82f35c
-add_extension_menu_items (NautilusFilesView *view,
82f35c
-                          const gchar       *extension_prefix,
82f35c
-                          GList             *menu_items,
82f35c
-                          GMenu             *insertion_menu)
82f35c
-{
82f35c
-    GMenu *menu;
82f35c
-
82f35c
-    menu = build_menu_for_extension_menu_items (view, extension_prefix, menu_items);
82f35c
-    nautilus_gmenu_merge (insertion_menu,
82f35c
-                          menu,
82f35c
-                          "extensions",
82f35c
-                          FALSE);
82f35c
-
82f35c
-    g_object_unref (menu);
82f35c
-}
82f35c
-
82f35c
 static void
82f35c
 update_extensions_menus (NautilusFilesView *view)
82f35c
 {
82f35c
     NautilusFilesViewPrivate *priv;
82f35c
     GList *selection_items, *background_items;
82f35c
+    g_autoptr (GMenu) background_menu = NULL;
82f35c
+    g_autoptr (GMenu) selection_menu = NULL;
82f35c
 
82f35c
     priv = nautilus_files_view_get_instance_private (view);
82f35c
     selection_items = get_extension_selection_menu_items (view);
82f35c
     if (selection_items != NULL)
82f35c
     {
82f35c
-        add_extension_menu_items (view,
82f35c
-                                  "selection",
82f35c
-                                  selection_items,
82f35c
-                                  priv->selection_menu);
82f35c
+        selection_menu = build_menu_for_extension_menu_items (view, "extensions",
82f35c
+                                                              selection_items);
82f35c
+
82f35c
+        nautilus_gmenu_merge (priv->selection_menu,
82f35c
+                              selection_menu,
82f35c
+                              "extensions",
82f35c
+                              FALSE);
82f35c
         nautilus_menu_item_list_free (selection_items);
82f35c
     }
82f35c
 
82f35c
     background_items = get_extension_background_menu_items (view);
82f35c
     if (background_items != NULL)
82f35c
     {
82f35c
-        add_extension_menu_items (view,
82f35c
-                                  "background",
82f35c
-                                  background_items,
82f35c
-                                  priv->background_menu);
82f35c
+        background_menu = build_menu_for_extension_menu_items (view, "extensions",
82f35c
+                                                               background_items);
82f35c
+
82f35c
+        nautilus_gmenu_merge (priv->background_menu,
82f35c
+                              background_menu,
82f35c
+                              "extensions",
82f35c
+                              FALSE);
82f35c
         nautilus_menu_item_list_free (background_items);
82f35c
     }
82f35c
+
82f35c
+    nautilus_view_set_extensions_background_menu (NAUTILUS_VIEW (view), background_menu);
82f35c
 }
82f35c
 
82f35c
 static char *
82f35c
@@ -5646,7 +5763,7 @@ update_templates_menu (NautilusFilesView *view)
82f35c
     NautilusFilesViewPrivate *priv;
82f35c
     GList *sorted_copy, *node;
82f35c
     NautilusDirectory *directory;
82f35c
-    GMenu *submenu;
82f35c
+    g_autoptr (GMenu) submenu = NULL;
82f35c
     char *uri;
82f35c
     char *templates_directory_uri;
82f35c
 
82f35c
@@ -5687,9 +5804,10 @@ update_templates_menu (NautilusFilesView *view)
82f35c
                               submenu,
82f35c
                               "templates-submenu",
82f35c
                               FALSE);
82f35c
-        g_object_unref (submenu);
82f35c
     }
82f35c
 
82f35c
+    nautilus_view_set_templates_menu (NAUTILUS_VIEW (view), submenu);
82f35c
+
82f35c
     nautilus_directory_unref (directory);
82f35c
 
82f35c
     priv->templates_present = submenu != NULL;
82f35c
@@ -6880,6 +6998,7 @@ const GActionEntry view_entries[] =
82f35c
     { "extract-to", action_extract_to },
82f35c
     { "compress", action_compress },
82f35c
     { "properties", action_properties},
82f35c
+    { "current-directory-properties", action_current_dir_properties},
82f35c
     { "set-as-wallpaper", action_set_as_wallpaper },
82f35c
     { "mount-volume", action_mount_volume },
82f35c
     { "unmount-volume", action_unmount_volume },
82f35c
@@ -8871,8 +8990,25 @@ nautilus_files_view_get_property (GObject    *object,
82f35c
         }
82f35c
         break;
82f35c
 
82f35c
+        case PROP_EXTENSIONS_BACKGROUND_MENU:
82f35c
+        {
82f35c
+            g_value_set_object (value,
82f35c
+                                real_get_extensions_background_menu (NAUTILUS_VIEW (view)));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
+        case PROP_TEMPLATES_MENU:
82f35c
+        {
82f35c
+            g_value_set_object (value,
82f35c
+                                real_get_templates_menu (NAUTILUS_VIEW (view)));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
         default:
82f35c
+        {
82f35c
             g_assert_not_reached ();
82f35c
+        }
82f35c
+        break;
82f35c
     }
82f35c
 }
82f35c
 
82f35c
@@ -8925,6 +9061,20 @@ nautilus_files_view_set_property (GObject      *object,
82f35c
         }
82f35c
         break;
82f35c
 
82f35c
+        case PROP_EXTENSIONS_BACKGROUND_MENU:
82f35c
+        {
82f35c
+            real_set_extensions_background_menu (NAUTILUS_VIEW (directory_view),
82f35c
+                                                 g_value_get_object (value));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
+        case PROP_TEMPLATES_MENU:
82f35c
+        {
82f35c
+            real_set_templates_menu (NAUTILUS_VIEW (directory_view),
82f35c
+                                     g_value_get_object (value));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
         default:
82f35c
         {
82f35c
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
82f35c
@@ -9286,6 +9436,10 @@ nautilus_files_view_iface_init (NautilusViewInterface *iface)
82f35c
     iface->is_searching = nautilus_files_view_is_searching;
82f35c
     iface->is_loading = nautilus_files_view_is_loading;
82f35c
     iface->get_view_id = nautilus_files_view_get_view_id;
82f35c
+    iface->get_templates_menu = nautilus_files_view_get_templates_menu;
82f35c
+    iface->set_templates_menu = nautilus_files_view_set_templates_menu;
82f35c
+    iface->get_extensions_background_menu = nautilus_files_view_get_extensions_background_menu;
82f35c
+    iface->set_extensions_background_menu = nautilus_files_view_set_extensions_background_menu;
82f35c
 }
82f35c
 
82f35c
 static void
82f35c
@@ -9410,6 +9564,8 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
82f35c
     g_object_class_override_property (oclass, PROP_IS_SEARCH, "is-searching");
82f35c
     g_object_class_override_property (oclass, PROP_LOCATION, "location");
82f35c
     g_object_class_override_property (oclass, PROP_SEARCH_QUERY, "search-query");
82f35c
+    g_object_class_override_property (oclass, PROP_EXTENSIONS_BACKGROUND_MENU, "extensions-background-menu");
82f35c
+    g_object_class_override_property (oclass, PROP_TEMPLATES_MENU, "templates-menu");
82f35c
 }
82f35c
 
82f35c
 static void
82f35c
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
82f35c
index 630b8ed33..3681ce2d8 100644
82f35c
--- a/src/nautilus-pathbar.c
82f35c
+++ b/src/nautilus-pathbar.c
82f35c
@@ -73,6 +73,7 @@ typedef struct
82f35c
     GtkWidget *image;
82f35c
     GtkWidget *label;
82f35c
     GtkWidget *bold_label;
82f35c
+    GtkWidget *disclosure_arrow;
82f35c
 
82f35c
     guint ignore_changes : 1;
82f35c
     guint is_root : 1;
82f35c
@@ -100,9 +101,13 @@ typedef struct
82f35c
 
82f35c
     GActionGroup *action_group;
82f35c
 
82f35c
-    GMenu *context_menu;
82f35c
     NautilusFile *context_menu_file;
82f35c
-    GdkEvent *context_menu_event;
82f35c
+    GtkPopover *current_view_menu_popover;
82f35c
+    GtkPopover *button_menu_popover;
82f35c
+    GMenu *current_view_menu;
82f35c
+    GMenu *button_menu;
82f35c
+    GMenu *extensions_background_menu;
82f35c
+    GMenu *templates_menu;
82f35c
 } NautilusPathBarPrivate;
82f35c
 
82f35c
 
82f35c
@@ -120,8 +125,9 @@ static gboolean nautilus_path_bar_slider_button_release (GtkWidget       *widget
82f35c
                                                          NautilusPathBar *self);
82f35c
 static void     nautilus_path_bar_check_icon_theme (NautilusPathBar *self);
82f35c
 static void     nautilus_path_bar_update_button_appearance (ButtonData *button_data);
82f35c
-static void     nautilus_path_bar_update_button_state (ButtonData *button_data,
82f35c
-                                                       gboolean    current_dir);
82f35c
+static void     nautilus_path_bar_update_button_state (NautilusPathBar *self,
82f35c
+                                                       ButtonData      *button_data,
82f35c
+                                                       gboolean         current_dir);
82f35c
 static void     nautilus_path_bar_update_path (NautilusPathBar *self,
82f35c
                                                GFile           *file_path);
82f35c
 static void     unschedule_pop_up_context_menu (NautilusPathBar *self);
82f35c
@@ -134,6 +140,8 @@ static void     action_pathbar_open_item_new_tab (GSimpleAction *action,
82f35c
 static void     action_pathbar_properties (GSimpleAction *action,
82f35c
                                            GVariant      *state,
82f35c
                                            gpointer       user_data);
82f35c
+static void     pop_up_pathbar_context_menu (NautilusPathBar *self,
82f35c
+                                             NautilusFile    *file);
82f35c
 
82f35c
 const GActionEntry path_bar_actions[] =
82f35c
 {
82f35c
@@ -333,7 +341,12 @@ nautilus_path_bar_init (NautilusPathBar *self)
82f35c
 
82f35c
     /* Context menu */
82f35c
     builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-pathbar-context-menu.ui");
82f35c
-    priv->context_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "pathbar-menu")));
82f35c
+    priv->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "current-view-menu")));
82f35c
+    priv->button_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "button-menu")));
82f35c
+    priv->current_view_menu_popover = g_object_ref_sink (GTK_POPOVER (gtk_popover_new_from_model (NULL,
82f35c
+                                                                                                  G_MENU_MODEL (priv->current_view_menu))));
82f35c
+    priv->button_menu_popover = g_object_ref_sink (GTK_POPOVER (gtk_popover_new_from_model (NULL,
82f35c
+                                                                                            G_MENU_MODEL (priv->button_menu))));
82f35c
     g_object_unref (builder);
82f35c
 
82f35c
     gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
82f35c
@@ -402,12 +415,12 @@ nautilus_path_bar_finalize (GObject *object)
82f35c
     }
82f35c
 
82f35c
     g_list_free (priv->button_list);
82f35c
+    g_clear_object (&priv->current_view_menu);
82f35c
+    g_clear_object (&priv->button_menu);
82f35c
+    g_clear_object (&priv->button_menu_popover);
82f35c
+    g_clear_object (&priv->current_view_menu_popover);
82f35c
 
82f35c
     unschedule_pop_up_context_menu (NAUTILUS_PATH_BAR (object));
82f35c
-    if (priv->context_menu_event)
82f35c
-    {
82f35c
-        gdk_event_free ((GdkEvent *) priv->context_menu_event);
82f35c
-    }
82f35c
 
82f35c
     G_OBJECT_CLASS (nautilus_path_bar_parent_class)->finalize (object);
82f35c
 }
82f35c
@@ -1293,6 +1306,81 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
82f35c
     gtk_container_class_handle_border_width (container_class);
82f35c
 }
82f35c
 
82f35c
+static void
82f35c
+update_current_view_menu (NautilusPathBar *self)
82f35c
+{
82f35c
+    NautilusPathBarPrivate *priv;
82f35c
+
82f35c
+    priv = nautilus_path_bar_get_instance_private (self);
82f35c
+    if (priv->extensions_background_menu != NULL)
82f35c
+    {
82f35c
+        nautilus_gmenu_merge (priv->current_view_menu,
82f35c
+                              priv->extensions_background_menu,
82f35c
+                              "extensions",
82f35c
+                              TRUE);
82f35c
+    }
82f35c
+
82f35c
+    if (priv->templates_menu != NULL)
82f35c
+    {
82f35c
+        nautilus_gmenu_merge (priv->current_view_menu, priv->templates_menu,
82f35c
+                              "templates-submenu", TRUE);
82f35c
+    }
82f35c
+}
82f35c
+
82f35c
+static void
82f35c
+reset_current_view_menu (NautilusPathBar *self)
82f35c
+{
82f35c
+    NautilusPathBarPrivate *priv;
82f35c
+    g_autoptr (GtkBuilder) builder = NULL;
82f35c
+
82f35c
+    priv = nautilus_path_bar_get_instance_private (self);
82f35c
+
82f35c
+    g_clear_object (&priv->current_view_menu);
82f35c
+    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-pathbar-context-menu.ui");
82f35c
+    priv->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder,
82f35c
+                                                                                 "current-view-menu")));
82f35c
+    gtk_popover_bind_model (priv->current_view_menu_popover,
82f35c
+                            G_MENU_MODEL (priv->current_view_menu), NULL);
82f35c
+}
82f35c
+
82f35c
+void
82f35c
+nautilus_path_bar_set_extensions_background_menu (NautilusPathBar *self,
82f35c
+                                                  GMenu           *menu)
82f35c
+{
82f35c
+    NautilusPathBarPrivate *priv;
82f35c
+
82f35c
+    g_return_if_fail (NAUTILUS_IS_PATH_BAR (self));
82f35c
+
82f35c
+    priv = nautilus_path_bar_get_instance_private (self);
82f35c
+    reset_current_view_menu (self);
82f35c
+    g_clear_object (&priv->extensions_background_menu);
82f35c
+    if (menu != NULL)
82f35c
+    {
82f35c
+        priv->extensions_background_menu = g_object_ref (menu);
82f35c
+    }
82f35c
+
82f35c
+    update_current_view_menu (self);
82f35c
+}
82f35c
+
82f35c
+void
82f35c
+nautilus_path_bar_set_templates_menu (NautilusPathBar *self,
82f35c
+                                      GMenu           *menu)
82f35c
+{
82f35c
+    NautilusPathBarPrivate *priv;
82f35c
+
82f35c
+    g_return_if_fail (NAUTILUS_IS_PATH_BAR (self));
82f35c
+
82f35c
+    priv = nautilus_path_bar_get_instance_private (self);
82f35c
+    reset_current_view_menu (self);
82f35c
+    g_clear_object (&priv->templates_menu);
82f35c
+    if (menu != NULL)
82f35c
+    {
82f35c
+        priv->templates_menu = g_object_ref (menu);
82f35c
+    }
82f35c
+
82f35c
+    update_current_view_menu (self);
82f35c
+}
82f35c
+
82f35c
 static void
82f35c
 nautilus_path_bar_scroll_down (NautilusPathBar *self)
82f35c
 {
82f35c
@@ -1599,7 +1687,9 @@ button_clicked_cb (GtkWidget *button,
82f35c
     ButtonData *button_data;
82f35c
     NautilusPathBarPrivate *priv;
82f35c
     NautilusPathBar *self;
82f35c
-    GList *button_list;
82f35c
+    GdkEvent *event;
82f35c
+    GdkModifierType state;
82f35c
+    gboolean current_dir;
82f35c
 
82f35c
     button_data = BUTTON_DATA (data);
82f35c
     if (button_data->ignore_changes)
82f35c
@@ -1609,13 +1699,29 @@ button_clicked_cb (GtkWidget *button,
82f35c
 
82f35c
     self = NAUTILUS_PATH_BAR (gtk_widget_get_parent (button));
82f35c
     priv = nautilus_path_bar_get_instance_private (self);
82f35c
+    event = gtk_get_current_event ();
82f35c
+    current_dir = g_file_equal (button_data->path, priv->current_path);
82f35c
 
82f35c
-    button_list = g_list_find (priv->button_list, button_data);
82f35c
-    g_assert (button_list != NULL);
82f35c
+    gdk_event_get_state (event, &state);
82f35c
 
82f35c
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
82f35c
+    button_data->ignore_changes = TRUE;
82f35c
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), current_dir);
82f35c
+    button_data->ignore_changes = FALSE;
82f35c
 
82f35c
-    g_signal_emit (self, path_bar_signals [PATH_CLICKED], 0, button_data->path);
82f35c
+    if ((state & GDK_CONTROL_MASK) != 0)
82f35c
+    {
82f35c
+        g_signal_emit (self, path_bar_signals[OPEN_LOCATION], 0,
82f35c
+                       button_data->path,
82f35c
+                       GTK_PLACES_OPEN_NEW_WINDOW);
82f35c
+    }
82f35c
+    else if (current_dir)
82f35c
+    {
82f35c
+        gtk_popover_popup (priv->current_view_menu_popover);
82f35c
+    }
82f35c
+    else
82f35c
+    {
82f35c
+        g_signal_emit (self, path_bar_signals [PATH_CLICKED], 0, button_data->path);
82f35c
+    }
82f35c
 }
82f35c
 
82f35c
 
82f35c
@@ -1626,9 +1732,7 @@ real_pop_up_pathbar_context_menu (NautilusPathBar *self)
82f35c
 
82f35c
     priv = nautilus_path_bar_get_instance_private (self);
82f35c
 
82f35c
-    nautilus_pop_up_context_menu_at_pointer (GTK_WIDGET (self),
82f35c
-                                             priv->context_menu,
82f35c
-                                             priv->context_menu_event);
82f35c
+    gtk_popover_popup (priv->button_menu_popover);
82f35c
 }
82f35c
 
82f35c
 static void
82f35c
@@ -1668,7 +1772,6 @@ unschedule_pop_up_context_menu (NautilusPathBar *self)
82f35c
 
82f35c
 static void
82f35c
 schedule_pop_up_context_menu (NautilusPathBar *self,
82f35c
-                              GdkEventButton  *event,
82f35c
                               NautilusFile    *file)
82f35c
 {
82f35c
     NautilusPathBarPrivate *priv;
82f35c
@@ -1677,12 +1780,6 @@ schedule_pop_up_context_menu (NautilusPathBar *self,
82f35c
 
82f35c
     priv = nautilus_path_bar_get_instance_private (self);
82f35c
 
82f35c
-    if (priv->context_menu_event != NULL)
82f35c
-    {
82f35c
-        gdk_event_free ((GdkEvent *) priv->context_menu_event);
82f35c
-    }
82f35c
-    priv->context_menu_event = gdk_event_copy ((GdkEvent *) event);
82f35c
-
82f35c
     if (file == priv->context_menu_file)
82f35c
     {
82f35c
         if (nautilus_file_check_if_ready (file,
82f35c
@@ -1709,12 +1806,11 @@ schedule_pop_up_context_menu (NautilusPathBar *self,
82f35c
 
82f35c
 static void
82f35c
 pop_up_pathbar_context_menu (NautilusPathBar *self,
82f35c
-                             GdkEventButton  *event,
82f35c
                              NautilusFile    *file)
82f35c
 {
82f35c
     if (file)
82f35c
     {
82f35c
-        schedule_pop_up_context_menu (self, event, file);
82f35c
+        schedule_pop_up_context_menu (self, file);
82f35c
     }
82f35c
 }
82f35c
 
82f35c
@@ -1723,22 +1819,31 @@ button_event_cb (GtkWidget      *button,
82f35c
                  GdkEventButton *event,
82f35c
                  gpointer        data)
82f35c
 {
82f35c
-    GtkPlacesOpenFlags flags;
82f35c
     ButtonData *button_data;
82f35c
     NautilusPathBar *self;
82f35c
+    NautilusPathBarPrivate *priv;
82f35c
     int mask;
82f35c
+    gboolean current_dir;
82f35c
 
82f35c
     button_data = BUTTON_DATA (data);
82f35c
     self = NAUTILUS_PATH_BAR (gtk_widget_get_parent (button));
82f35c
+    priv = nautilus_path_bar_get_instance_private (self);
82f35c
     mask = event->state & gtk_accelerator_get_default_mod_mask ();
82f35c
 
82f35c
     if (event->type == GDK_BUTTON_PRESS)
82f35c
     {
82f35c
-        g_object_set_data (G_OBJECT (button), "handle-button-release", GINT_TO_POINTER (TRUE));
82f35c
-
82f35c
         if (event->button == GDK_BUTTON_SECONDARY)
82f35c
         {
82f35c
-            pop_up_pathbar_context_menu (self, event, button_data->file);
82f35c
+            current_dir = g_file_equal (button_data->path, priv->current_path);
82f35c
+            if (current_dir)
82f35c
+            {
82f35c
+                gtk_popover_popup (priv->current_view_menu_popover);
82f35c
+            }
82f35c
+            else
82f35c
+            {
82f35c
+                gtk_popover_set_relative_to (priv->button_menu_popover, button);
82f35c
+                pop_up_pathbar_context_menu (self, button_data->file);
82f35c
+            }
82f35c
             return GDK_EVENT_STOP;
82f35c
         }
82f35c
         else if (event->button == GDK_BUTTON_MIDDLE && mask == 0)
82f35c
@@ -1751,27 +1856,6 @@ button_event_cb (GtkWidget      *button,
82f35c
             return GDK_EVENT_STOP;
82f35c
         }
82f35c
     }
82f35c
-    else if (event->type == GDK_BUTTON_RELEASE)
82f35c
-    {
82f35c
-        flags = 0;
82f35c
-
82f35c
-        if (!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "handle-button-release")))
82f35c
-        {
82f35c
-            return GDK_EVENT_PROPAGATE;
82f35c
-        }
82f35c
-
82f35c
-        if (event->button == GDK_BUTTON_PRIMARY && mask == GDK_CONTROL_MASK)
82f35c
-        {
82f35c
-            flags = GTK_PLACES_OPEN_NEW_WINDOW;
82f35c
-        }
82f35c
-
82f35c
-        if (flags != 0)
82f35c
-        {
82f35c
-            g_signal_emit (self, path_bar_signals[OPEN_LOCATION], 0, button_data->path, flags);
82f35c
-        }
82f35c
-
82f35c
-        return GDK_EVENT_PROPAGATE;
82f35c
-    }
82f35c
 
82f35c
     return GDK_EVENT_PROPAGATE;
82f35c
 }
82f35c
@@ -1880,9 +1964,14 @@ nautilus_path_bar_update_button_appearance (ButtonData *button_data)
82f35c
 }
82f35c
 
82f35c
 static void
82f35c
-nautilus_path_bar_update_button_state (ButtonData *button_data,
82f35c
-                                       gboolean    current_dir)
82f35c
+nautilus_path_bar_update_button_state (NautilusPathBar *self,
82f35c
+                                       ButtonData      *button_data,
82f35c
+                                       gboolean         current_dir)
82f35c
 {
82f35c
+    NautilusPathBarPrivate *priv;
82f35c
+
82f35c
+    priv = nautilus_path_bar_get_instance_private (self);
82f35c
+
82f35c
     if (button_data->label != NULL)
82f35c
     {
82f35c
         gtk_label_set_label (GTK_LABEL (button_data->label), NULL);
82f35c
@@ -1898,6 +1987,12 @@ nautilus_path_bar_update_button_state (ButtonData *button_data,
82f35c
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_data->button), current_dir);
82f35c
         button_data->ignore_changes = FALSE;
82f35c
     }
82f35c
+
82f35c
+    gtk_widget_set_visible (button_data->disclosure_arrow, current_dir);
82f35c
+    if (current_dir)
82f35c
+    {
82f35c
+        gtk_popover_set_relative_to (priv->current_view_menu_popover, button_data->button);
82f35c
+    }
82f35c
 }
82f35c
 
82f35c
 static void
82f35c
@@ -2096,13 +2191,17 @@ make_button_data (NautilusPathBar *self,
82f35c
     /* TODO update button type when xdg directories change */
82f35c
 
82f35c
     button_data->image = gtk_image_new ();
82f35c
+    button_data->disclosure_arrow = gtk_image_new_from_icon_name ("pan-down-symbolic",
82f35c
+                                                                  GTK_ICON_SIZE_MENU);
82f35c
 
82f35c
     switch (button_data->type)
82f35c
     {
82f35c
         case ROOT_BUTTON:
82f35c
         {
82f35c
-            child = button_data->image;
82f35c
             button_data->label = NULL;
82f35c
+            child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
82f35c
+            gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
82f35c
+            gtk_box_pack_start (GTK_BOX (child), button_data->disclosure_arrow, FALSE, FALSE, 0);
82f35c
         }
82f35c
         break;
82f35c
 
82f35c
@@ -2115,10 +2214,13 @@ make_button_data (NautilusPathBar *self,
82f35c
             child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
82f35c
             gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
82f35c
             gtk_box_pack_start (GTK_BOX (child), button_data->label, FALSE, FALSE, 0);
82f35c
+            gtk_box_pack_start (GTK_BOX (child), button_data->disclosure_arrow, FALSE, FALSE, 0);
82f35c
         }
82f35c
         break;
82f35c
     }
82f35c
 
82f35c
+    gtk_widget_set_no_show_all (button_data->disclosure_arrow, TRUE);
82f35c
+
82f35c
     if (button_data->label != NULL)
82f35c
     {
82f35c
         gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_MIDDLE);
82f35c
@@ -2152,11 +2254,10 @@ make_button_data (NautilusPathBar *self,
82f35c
     gtk_container_add (GTK_CONTAINER (button_data->button), child);
82f35c
     gtk_widget_show_all (button_data->button);
82f35c
 
82f35c
-    nautilus_path_bar_update_button_state (button_data, current_dir);
82f35c
+    nautilus_path_bar_update_button_state (self, button_data, current_dir);
82f35c
 
82f35c
     g_signal_connect (button_data->button, "clicked", G_CALLBACK (button_clicked_cb), button_data);
82f35c
     g_signal_connect (button_data->button, "button-press-event", G_CALLBACK (button_event_cb), button_data);
82f35c
-    g_signal_connect (button_data->button, "button-release-event", G_CALLBACK (button_event_cb), button_data);
82f35c
     g_object_weak_ref (G_OBJECT (button_data->button), (GWeakNotify) button_data_free, button_data);
82f35c
 
82f35c
     nautilus_drag_slot_proxy_init (button_data->button, button_data->file, NULL);
82f35c
@@ -2198,7 +2299,7 @@ nautilus_path_bar_check_parent_path (NautilusPathBar  *self,
82f35c
             is_active = FALSE;
82f35c
         }
82f35c
 
82f35c
-        nautilus_path_bar_update_button_state (button_data, is_active);
82f35c
+        nautilus_path_bar_update_button_state (self, button_data, is_active);
82f35c
     }
82f35c
 
82f35c
     if (current_button_data != NULL)
82f35c
diff --git a/src/nautilus-pathbar.h b/src/nautilus-pathbar.h
82f35c
index 8651b7bc2..cbe427cf7 100644
82f35c
--- a/src/nautilus-pathbar.h
82f35c
+++ b/src/nautilus-pathbar.h
82f35c
@@ -36,5 +36,9 @@ struct _NautilusPathBarClass
82f35c
                                      GtkPlacesOpenFlags flags);
82f35c
 };
82f35c
 void     nautilus_path_bar_set_path    (NautilusPathBar *self, GFile *file);
82f35c
+void     nautilus_path_bar_set_extensions_background_menu (NautilusPathBar *self,
82f35c
+                                                           GMenu           *menu);
82f35c
+void     nautilus_path_bar_set_templates_menu (NautilusPathBar *self,
82f35c
+                                               GMenu           *menu);
82f35c
 
82f35c
 #endif /* NAUTILUS_PATHBAR_H */
82f35c
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
82f35c
index 26a978e7d..18e0421de 100644
82f35c
--- a/src/nautilus-toolbar.c
82f35c
+++ b/src/nautilus-toolbar.c
82f35c
@@ -1199,6 +1199,24 @@ nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
82f35c
     }
82f35c
 }
82f35c
 
82f35c
+static void
82f35c
+slot_on_extensions_background_menu_changed (NautilusToolbar    *self,
82f35c
+                                            GParamSpec         *param,
82f35c
+                                            NautilusWindowSlot *slot)
82f35c
+{
82f35c
+    nautilus_path_bar_set_extensions_background_menu (NAUTILUS_PATH_BAR (self->path_bar),
82f35c
+                                                      nautilus_window_slot_get_extensions_background_menu (slot));
82f35c
+}
82f35c
+
82f35c
+static void
82f35c
+slot_on_templates_menu_changed (NautilusToolbar    *self,
82f35c
+                                GParamSpec         *param,
82f35c
+                                NautilusWindowSlot *slot)
82f35c
+{
82f35c
+    nautilus_path_bar_set_templates_menu (NAUTILUS_PATH_BAR (self->path_bar),
82f35c
+                                          nautilus_window_slot_get_templates_menu (slot));
82f35c
+}
82f35c
+
82f35c
 static gboolean
82f35c
 nautilus_toolbar_view_toggle_icon_transform_to (GBinding     *binding,
82f35c
                                                 const GValue *from_value,
82f35c
@@ -1304,6 +1322,10 @@ nautilus_toolbar_set_active_slot (NautilusToolbar    *toolbar,
82f35c
             on_slot_toolbar_menu_sections_changed (toolbar, NULL, slot);
82f35c
             g_signal_connect_swapped (slot, "notify::toolbar-menu-sections",
82f35c
                                       G_CALLBACK (on_slot_toolbar_menu_sections_changed), toolbar);
82f35c
+            g_signal_connect_swapped (slot, "notify::extensions-background-menu",
82f35c
+                                      G_CALLBACK (slot_on_extensions_background_menu_changed), toolbar);
82f35c
+            g_signal_connect_swapped (slot, "notify::templates-menu",
82f35c
+                                      G_CALLBACK (slot_on_templates_menu_changed), toolbar);
82f35c
         }
82f35c
     }
82f35c
 }
82f35c
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
82f35c
index 7b3a3c973..a1c32f248 100644
82f35c
--- a/src/nautilus-view.c
82f35c
+++ b/src/nautilus-view.c
82f35c
@@ -72,6 +72,29 @@ nautilus_view_default_init (NautilusViewInterface *iface)
82f35c
                                                               "The search query being performed on the view",
82f35c
                                                               NAUTILUS_TYPE_QUERY,
82f35c
                                                               G_PARAM_READWRITE));
82f35c
+
82f35c
+    /**
82f35c
+     * NautilusView::extensions-background-menu:
82f35c
+     *
82f35c
+     * Menu for the background click of extensions
82f35c
+     */
82f35c
+    g_object_interface_install_property (iface,
82f35c
+                                         g_param_spec_object ("extensions-background-menu",
82f35c
+                                                              "Menu for the background click of extensions",
82f35c
+                                                              "Menu for the background click of extensions",
82f35c
+                                                              G_TYPE_MENU,
82f35c
+                                                              G_PARAM_READWRITE));
82f35c
+    /**
82f35c
+     * NautilusView::templates-menu:
82f35c
+     *
82f35c
+     * Menu of templates
82f35c
+     */
82f35c
+    g_object_interface_install_property (iface,
82f35c
+                                         g_param_spec_object ("templates-menu",
82f35c
+                                                              "Menu of templates",
82f35c
+                                                              "Menu of templates",
82f35c
+                                                              G_TYPE_MENU,
82f35c
+                                                              G_PARAM_READWRITE));
82f35c
 }
82f35c
 
82f35c
 /**
82f35c
@@ -137,6 +160,42 @@ nautilus_view_get_toolbar_menu_sections (NautilusView *view)
82f35c
     return NAUTILUS_VIEW_GET_IFACE (view)->get_toolbar_menu_sections (view);
82f35c
 }
82f35c
 
82f35c
+GMenu *
82f35c
+nautilus_view_get_extensions_background_menu (NautilusView *view)
82f35c
+{
82f35c
+    g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_extensions_background_menu, NULL);
82f35c
+
82f35c
+    return NAUTILUS_VIEW_GET_IFACE (view)->get_extensions_background_menu (view);
82f35c
+}
82f35c
+
82f35c
+/* Protected */
82f35c
+void
82f35c
+nautilus_view_set_extensions_background_menu (NautilusView *view,
82f35c
+                                              GMenu        *menu)
82f35c
+{
82f35c
+    g_return_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->set_extensions_background_menu);
82f35c
+
82f35c
+    NAUTILUS_VIEW_GET_IFACE (view)->set_extensions_background_menu (view, menu);
82f35c
+}
82f35c
+
82f35c
+GMenu *
82f35c
+nautilus_view_get_templates_menu (NautilusView *view)
82f35c
+{
82f35c
+    g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_templates_menu, NULL);
82f35c
+
82f35c
+    return NAUTILUS_VIEW_GET_IFACE (view)->get_templates_menu (view);
82f35c
+}
82f35c
+
82f35c
+/* Protected */
82f35c
+void
82f35c
+nautilus_view_set_templates_menu (NautilusView *view,
82f35c
+                                  GMenu        *menu)
82f35c
+{
82f35c
+    g_return_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->set_templates_menu);
82f35c
+
82f35c
+    NAUTILUS_VIEW_GET_IFACE (view)->set_templates_menu (view, menu);
82f35c
+}
82f35c
+
82f35c
 /**
82f35c
  * nautilus_view_get_search_query:
82f35c
  * @view: a #NautilusView
82f35c
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
82f35c
index dcd39e0ad..c3042bebd 100644
82f35c
--- a/src/nautilus-view.h
82f35c
+++ b/src/nautilus-view.h
82f35c
@@ -52,6 +52,20 @@ struct _NautilusViewInterface
82f35c
          */
82f35c
         NautilusToolbarMenuSections *   (*get_toolbar_menu_sections) (NautilusView         *view);
82f35c
 
82f35c
+        /*
82f35c
+         * Returns the menu for the background click of extensions.
82f35c
+         */
82f35c
+        GMenu *   (*get_extensions_background_menu) (NautilusView         *view);
82f35c
+
82f35c
+        void     (*set_extensions_background_menu) (NautilusView *view,
82f35c
+                                                    GMenu        *menu);
82f35c
+        /*
82f35c
+         * Returns the menu for templates.
82f35c
+         */
82f35c
+        GMenu *   (*get_templates_menu) (NautilusView         *view);
82f35c
+
82f35c
+        void     (*set_templates_menu) (NautilusView *view,
82f35c
+                                        GMenu        *menu);
82f35c
         /* Current location of the view */
82f35c
         GFile*                          (*get_location)              (NautilusView         *view);
82f35c
         void                            (*set_location)              (NautilusView         *view,
82f35c
@@ -99,6 +113,13 @@ gboolean                       nautilus_view_is_loading                (Nautilus
82f35c
 
82f35c
 gboolean                       nautilus_view_is_searching              (NautilusView         *view);
82f35c
 
82f35c
+void                           nautilus_view_set_templates_menu        (NautilusView *view,
82f35c
+                                                                        GMenu        *menu);
82f35c
+GMenu*                         nautilus_view_get_templates_menu        (NautilusView *view);
82f35c
+void                           nautilus_view_set_extensions_background_menu (NautilusView *view,
82f35c
+                                                                             GMenu        *menu);
82f35c
+GMenu*                         nautilus_view_get_extensions_background_menu (NautilusView *view);
82f35c
+
82f35c
 G_END_DECLS
82f35c
 
82f35c
 #endif /* NAUTILUS_VIEW_H */
82f35c
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
82f35c
index c3260aeb0..ea2197849 100644
82f35c
--- a/src/nautilus-window-slot.c
82f35c
+++ b/src/nautilus-window-slot.c
82f35c
@@ -60,6 +60,8 @@ enum
82f35c
     PROP_WINDOW,
82f35c
     PROP_ICON,
82f35c
     PROP_TOOLBAR_MENU_SECTIONS,
82f35c
+    PROP_EXTENSIONS_BACKGROUND_MENU,
82f35c
+    PROP_TEMPLATES_MENU,
82f35c
     PROP_LOADING,
82f35c
     PROP_LOCATION,
82f35c
     NUM_PROPERTIES
82f35c
@@ -124,6 +126,14 @@ typedef struct
82f35c
     GError *mount_error;
82f35c
     gboolean tried_mount;
82f35c
     gint view_mode_before_search;
82f35c
+
82f35c
+    /* Menus */
82f35c
+    GMenu *extensions_background_menu;
82f35c
+    GMenu *templates_menu;
82f35c
+
82f35c
+    /* View bindings */
82f35c
+    GBinding *extensions_background_menu_binding;
82f35c
+    GBinding *templates_menu_binding;
82f35c
 } NautilusWindowSlotPrivate;
82f35c
 
82f35c
 G_DEFINE_TYPE_WITH_PRIVATE (NautilusWindowSlot, nautilus_window_slot, GTK_TYPE_BOX);
82f35c
@@ -154,6 +164,12 @@ static void nautilus_window_slot_set_location (NautilusWindowSlot *self,
82f35c
 static void trash_state_changed_cb (NautilusTrashMonitor *monitor,
82f35c
                                     gboolean              is_empty,
82f35c
                                     gpointer              user_data);
82f35c
+static void real_set_extensions_background_menu (NautilusWindowSlot *self,
82f35c
+                                                 GMenu              *menu);
82f35c
+static GMenu* real_get_extensions_background_menu (NautilusWindowSlot *self);
82f35c
+static void real_set_templates_menu (NautilusWindowSlot *self,
82f35c
+                                     GMenu              *menu);
82f35c
+static GMenu* real_get_templates_menu (NautilusWindowSlot *self);
82f35c
 
82f35c
 void
82f35c
 free_navigation_state (gpointer data)
82f35c
@@ -727,6 +743,26 @@ nautilus_window_slot_add_extra_location_widget (NautilusWindowSlot *self,
82f35c
     gtk_widget_show (priv->extra_location_widgets);
82f35c
 }
82f35c
 
82f35c
+static void
82f35c
+real_set_extensions_background_menu (NautilusWindowSlot *self,
82f35c
+                                     GMenu              *menu)
82f35c
+{
82f35c
+    NautilusWindowSlotPrivate *priv;
82f35c
+    priv = nautilus_window_slot_get_instance_private (self);
82f35c
+
82f35c
+    priv->extensions_background_menu = menu != NULL ? g_object_ref (menu) : NULL;
82f35c
+}
82f35c
+
82f35c
+static void
82f35c
+real_set_templates_menu (NautilusWindowSlot *self,
82f35c
+                         GMenu              *menu)
82f35c
+{
82f35c
+    NautilusWindowSlotPrivate *priv;
82f35c
+    priv = nautilus_window_slot_get_instance_private (self);
82f35c
+
82f35c
+    priv->templates_menu = menu != NULL ? g_object_ref (menu) : NULL;
82f35c
+}
82f35c
+
82f35c
 static void
82f35c
 nautilus_window_slot_set_property (GObject      *object,
82f35c
                                    guint         property_id,
82f35c
@@ -755,6 +791,18 @@ nautilus_window_slot_set_property (GObject      *object,
82f35c
         }
82f35c
         break;
82f35c
 
82f35c
+        case PROP_EXTENSIONS_BACKGROUND_MENU:
82f35c
+        {
82f35c
+            real_set_extensions_background_menu (self, g_value_get_object (value));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
+        case PROP_TEMPLATES_MENU:
82f35c
+        {
82f35c
+            real_set_templates_menu (self, g_value_get_object (value));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
         default:
82f35c
         {
82f35c
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
82f35c
@@ -763,6 +811,44 @@ nautilus_window_slot_set_property (GObject      *object,
82f35c
     }
82f35c
 }
82f35c
 
82f35c
+static GMenu*
82f35c
+real_get_extensions_background_menu (NautilusWindowSlot *self)
82f35c
+{
82f35c
+    NautilusWindowSlotPrivate *priv;
82f35c
+
82f35c
+    priv = nautilus_window_slot_get_instance_private (self);
82f35c
+    return priv->extensions_background_menu;
82f35c
+}
82f35c
+
82f35c
+GMenu*
82f35c
+nautilus_window_slot_get_extensions_background_menu (NautilusWindowSlot *self)
82f35c
+{
82f35c
+    GMenu *menu = NULL;
82f35c
+
82f35c
+    g_object_get (self, "extensions-background-menu", &menu, NULL);
82f35c
+
82f35c
+    return menu;
82f35c
+}
82f35c
+
82f35c
+static GMenu*
82f35c
+real_get_templates_menu (NautilusWindowSlot *self)
82f35c
+{
82f35c
+    NautilusWindowSlotPrivate *priv;
82f35c
+
82f35c
+    priv = nautilus_window_slot_get_instance_private (self);
82f35c
+    return priv->templates_menu;
82f35c
+}
82f35c
+
82f35c
+GMenu*
82f35c
+nautilus_window_slot_get_templates_menu (NautilusWindowSlot *self)
82f35c
+{
82f35c
+    GMenu *menu = NULL;
82f35c
+
82f35c
+    g_object_get (self, "templates-menu", &menu, NULL);
82f35c
+
82f35c
+    return menu;
82f35c
+}
82f35c
+
82f35c
 static void
82f35c
 nautilus_window_slot_get_property (GObject    *object,
82f35c
                                    guint       property_id,
82f35c
@@ -796,7 +882,19 @@ nautilus_window_slot_get_property (GObject    *object,
82f35c
 
82f35c
         case PROP_TOOLBAR_MENU_SECTIONS:
82f35c
         {
82f35c
-            g_value_set_pointer (value, nautilus_window_slot_get_toolbar_menu_sections (self));
82f35c
+            g_value_set_object (value, nautilus_window_slot_get_toolbar_menu_sections (self));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
+        case PROP_EXTENSIONS_BACKGROUND_MENU:
82f35c
+        {
82f35c
+            g_value_set_object (value, real_get_extensions_background_menu (self));
82f35c
+        }
82f35c
+        break;
82f35c
+
82f35c
+        case PROP_TEMPLATES_MENU:
82f35c
+        {
82f35c
+            g_value_set_object (value, real_get_templates_menu (self));
82f35c
         }
82f35c
         break;
82f35c
 
82f35c
@@ -2717,6 +2815,9 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
82f35c
 
82f35c
     if (priv->content_view != NULL)
82f35c
     {
82f35c
+        g_binding_unbind (priv->extensions_background_menu_binding);
82f35c
+        g_binding_unbind (priv->templates_menu_binding);
82f35c
+
82f35c
         widget = GTK_WIDGET (priv->content_view);
82f35c
         gtk_widget_destroy (widget);
82f35c
         g_object_unref (priv->content_view);
82f35c
@@ -2733,8 +2834,17 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
82f35c
         gtk_widget_set_vexpand (widget, TRUE);
82f35c
         gtk_widget_show (widget);
82f35c
 
82f35c
+        priv->extensions_background_menu_binding = g_object_bind_property (priv->content_view, "extensions-background-menu",
82f35c
+                                                                           self, "extensions-background-menu",
82f35c
+                                                                           G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
82f35c
+        priv->templates_menu_binding = g_object_bind_property (priv->content_view, "templates-menu",
82f35c
+                                                               self, "templates-menu",
82f35c
+                                                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
82f35c
+
82f35c
         g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
82f35c
         g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TOOLBAR_MENU_SECTIONS]);
82f35c
+        g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EXTENSIONS_BACKGROUND_MENU]);
82f35c
+        g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TEMPLATES_MENU]);
82f35c
     }
82f35c
 
82f35c
 done:
82f35c
@@ -2786,6 +2896,9 @@ nautilus_window_slot_dispose (GObject *object)
82f35c
 
82f35c
     nautilus_window_slot_remove_extra_location_widgets (self);
82f35c
 
82f35c
+    g_clear_pointer (&priv->extensions_background_menu_binding, g_binding_unbind);
82f35c
+    g_clear_pointer (&priv->templates_menu_binding, g_binding_unbind);
82f35c
+
82f35c
     if (priv->content_view)
82f35c
     {
82f35c
         gtk_widget_destroy (GTK_WIDGET (priv->content_view));
82f35c
@@ -2924,6 +3037,20 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
82f35c
                               "The menu sections to add to the toolbar menu for this slot",
82f35c
                               G_PARAM_READABLE);
82f35c
 
82f35c
+    properties[PROP_EXTENSIONS_BACKGROUND_MENU] =
82f35c
+        g_param_spec_object ("extensions-background-menu",
82f35c
+                             "Background menu of extensions",
82f35c
+                             "Proxy property from the view for the background menu for extensions",
82f35c
+                             G_TYPE_MENU,
82f35c
+                             G_PARAM_READWRITE);
82f35c
+
82f35c
+    properties[PROP_TEMPLATES_MENU] =
82f35c
+        g_param_spec_object ("templates-menu",
82f35c
+                             "Templates menu",
82f35c
+                             "Proxy property from the view for the templates menu",
82f35c
+                             G_TYPE_MENU,
82f35c
+                             G_PARAM_READWRITE);
82f35c
+
82f35c
     properties[PROP_LOCATION] =
82f35c
         g_param_spec_object ("location",
82f35c
                              "Current location visible on the slot",
82f35c
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
82f35c
index 573357d9b..9be645aa4 100644
82f35c
--- a/src/nautilus-window-slot.h
82f35c
+++ b/src/nautilus-window-slot.h
82f35c
@@ -105,6 +105,10 @@ GIcon*   nautilus_window_slot_get_icon                     (NautilusWindowSlot *
82f35c
 
82f35c
 NautilusToolbarMenuSections * nautilus_window_slot_get_toolbar_menu_sections (NautilusWindowSlot *slot);
82f35c
 
82f35c
+GMenu* nautilus_window_slot_get_templates_menu (NautilusWindowSlot *self);
82f35c
+
82f35c
+GMenu* nautilus_window_slot_get_extensions_background_menu (NautilusWindowSlot *self);
82f35c
+
82f35c
 gboolean nautilus_window_slot_get_active                   (NautilusWindowSlot *slot);
82f35c
 
82f35c
 void     nautilus_window_slot_set_active                   (NautilusWindowSlot *slot,
82f35c
diff --git a/src/resources/ui/nautilus-pathbar-context-menu.ui b/src/resources/ui/nautilus-pathbar-context-menu.ui
82f35c
index 11b68857d..403cf71f6 100644
82f35c
--- a/src/resources/ui/nautilus-pathbar-context-menu.ui
82f35c
+++ b/src/resources/ui/nautilus-pathbar-context-menu.ui
82f35c
@@ -1,23 +1,54 @@
82f35c
 
82f35c
+
82f35c
 <interface>
82f35c
-  <menu id="pathbar-menu">
82f35c
+  <menu id="current-view-menu">
82f35c
+    <item>
82f35c
+      <attribute name="label" translatable="yes">New _Folder</attribute>
82f35c
+      <attribute name="action">view.new-folder</attribute>
82f35c
+    </item>
82f35c
+    <submenu>
82f35c
+      <attribute name="id">templates-submenu</attribute>
82f35c
+      <attribute name="label" translatable="yes">New _Document</attribute>
82f35c
+      <attribute name="action">view.new-document</attribute>
82f35c
+      <attribute name="hidden-when">action-disabled</attribute>
82f35c
+    </submenu>
82f35c
+    <item>
82f35c
+      <attribute name="label" translatable="yes">Add to _Bookmarks</attribute>
82f35c
+      <attribute name="action">view.bookmark</attribute>
82f35c
+    </item>
82f35c
     <section>
82f35c
       <item>
82f35c
-        <attribute name="label" translatable="yes">Open In New _Tab</attribute>
82f35c
-        <attribute name="action">pathbar.open-item-new-tab</attribute>
82f35c
-        <attribute name="hidden-when">action-disabled</attribute>
82f35c
+        <attribute name="label" translatable="yes">_Paste</attribute>
82f35c
+        <attribute name="action">view.paste</attribute>
82f35c
       </item>
82f35c
       <item>
82f35c
-        <attribute name="label" translatable="yes">Open In New _Window</attribute>
82f35c
-        <attribute name="action">pathbar.open-item-new-window</attribute>
82f35c
-        <attribute name="hidden-when">action-disabled</attribute>
82f35c
+        <attribute name="label" translatable="yes">Select _All</attribute>
82f35c
+        <attribute name="action">view.select-all</attribute>
82f35c
       </item>
82f35c
     </section>
82f35c
+    <section>
82f35c
+      <attribute name="id">extensions</attribute>
82f35c
+    </section>
82f35c
     <section>
82f35c
       <item>
82f35c
         <attribute name="label" translatable="yes">P_roperties</attribute>
82f35c
-        <attribute name="action">pathbar.properties</attribute>
82f35c
+        <attribute name="action">view.current-directory-properties</attribute>
82f35c
+        <attribute name="hidden-when">action-disabled</attribute>
82f35c
       </item>
82f35c
     </section>
82f35c
   </menu>
82f35c
+  <menu id="button-menu">
82f35c
+    <item>
82f35c
+      <attribute name="label" translatable="yes">Open in New _Window</attribute>
82f35c
+      <attribute name="action">pathbar.open-item-new-window</attribute>
82f35c
+    </item>
82f35c
+    <item>
82f35c
+      <attribute name="label" translatable="yes">Open in New _Tab</attribute>
82f35c
+      <attribute name="action">pathbar.open-item-new-tab</attribute>
82f35c
+    </item>
82f35c
+    <item>
82f35c
+      <attribute name="label" translatable="yes">_Properties</attribute>
82f35c
+      <attribute name="action">pathbar.properties</attribute>
82f35c
+    </item>
82f35c
+  </menu>
82f35c
 </interface>
82f35c
-- 
82f35c
2.36.0
82f35c