summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSachin Daluja <30343-sachindaluja@users.noreply.gitlab.gnome.org>2020-02-05 21:55:59 -0500
committerAntónio Fernandes <antoniof@gnome.org>2020-03-22 11:58:40 +0000
commit88e830833ff429e09e0860016be6e053863feaed (patch)
tree77cc5c7ba54a7339ce37f2814dd5a9e88a438e3d
parent9cda09c75747a41b0a38dd9f821b429e053dc652 (diff)
downloadnautilus-88e830833ff429e09e0860016be6e053863feaed.tar.gz
pathbar: Build current location menu from the background context menu
The current location menu in the pathbar has been introduced as an alternative to the background context menu. But we have been building them from separate resources. As a result, we have have had menu items in one menu but missing in the other, and the ordering of items and sections has been insonsistent. To ensure consistency, build the current location menu from the same resource as the the background context menu. This also introduces the "Create Link" action to the current location menu, which was missing.
-rw-r--r--src/nautilus-pathbar.c33
-rw-r--r--src/resources/ui/nautilus-pathbar-context-menu.ui32
2 files changed, 26 insertions, 39 deletions
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 5e1fa3021..58242fbb8 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -209,17 +209,36 @@ static void
nautilus_path_bar_init (NautilusPathBar *self)
{
GtkBuilder *builder;
+ g_autoptr (GError) error = NULL;
- /* Context menu */
- builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-pathbar-context-menu.ui");
- self->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "current-view-menu")));
- self->extensions_section = g_object_ref (G_MENU (gtk_builder_get_object (builder, "extensions-section")));
- self->templates_submenu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "templates-submenu")));
+ builder = gtk_builder_new();
+
+ /* Add context menu for pathbar buttons */
+ gtk_builder_add_from_resource (builder,
+ "/org/gnome/nautilus/ui/nautilus-pathbar-context-menu.ui",
+ &error);
+ if (error != NULL)
+ {
+ g_error ("Failed to add pathbar-context-menu.ui: %s", error->message);
+ }
self->button_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "button-menu")));
- self->current_view_menu_popover = g_object_ref_sink (GTK_POPOVER (gtk_popover_new_from_model (NULL,
- G_MENU_MODEL (self->current_view_menu))));
self->button_menu_popover = g_object_ref_sink (GTK_POPOVER (gtk_popover_new_from_model (NULL,
G_MENU_MODEL (self->button_menu))));
+
+ /* Add current location menu, which matches the view's background context menu */
+ gtk_builder_add_from_resource (builder,
+ "/org/gnome/nautilus/ui/nautilus-files-view-context-menus.ui",
+ &error);
+ if (error != NULL)
+ {
+ g_error ("failed to add files-view-context-menus.ui: %s", error->message);
+ }
+ self->current_view_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "background-menu")));
+ self->extensions_section = g_object_ref (G_MENU (gtk_builder_get_object (builder, "background-extensions-section")));
+ self->templates_submenu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "templates-submenu")));
+ self->current_view_menu_popover = g_object_ref_sink (GTK_POPOVER (gtk_popover_new_from_model (NULL,
+ G_MENU_MODEL (self->current_view_menu))));
+
g_object_unref (builder);
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
diff --git a/src/resources/ui/nautilus-pathbar-context-menu.ui b/src/resources/ui/nautilus-pathbar-context-menu.ui
index 2a253ba06..696921e3c 100644
--- a/src/resources/ui/nautilus-pathbar-context-menu.ui
+++ b/src/resources/ui/nautilus-pathbar-context-menu.ui
@@ -1,38 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
- <menu id="current-view-menu">
- <item>
- <attribute name="label" translatable="yes">New _Folder…</attribute>
- <attribute name="action">view.new-folder</attribute>
- </item>
- <submenu id="templates-submenu">
- <attribute name="label" translatable="yes">New _Document</attribute>
- <attribute name="action">view.new-document</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </submenu>
- <item>
- <attribute name="label" translatable="yes">Add to _Bookmarks</attribute>
- <attribute name="action">win.bookmark-current-location</attribute>
- </item>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Paste</attribute>
- <attribute name="action">view.paste</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Select _All</attribute>
- <attribute name="action">view.select-all</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">P_roperties</attribute>
- <attribute name="action">view.current-directory-properties</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </item>
- </section>
- <section id="extensions-section">
- </section>
- </menu>
<menu id="button-menu">
<item>
<attribute name="label" translatable="yes">Open in New _Window</attribute>