[nautilus/wip/antoniof/menu-reorganization: 3/3] files-view: Reorganize context menus
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/menu-reorganization: 3/3] files-view: Reorganize context menus
- Date: Tue, 2 Aug 2022 19:22:32 +0000 (UTC)
commit 93d0062508f9a6dba23abee6351c3845b916ae7b
Author: António Fernandes <antoniof gnome org>
Date: Tue Aug 2 20:21:46 2022 +0100
files-view: Reorganize context menus
Resolves https://gitlab.gnome.org/GNOME/nautilus/-/issues/2207
src/nautilus-files-view.c | 31 +++-
.../ui/nautilus-files-view-context-menus.ui | 192 +++++++++------------
2 files changed, 105 insertions(+), 118 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 2f3ec45a1..b4b93564e 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -7987,14 +7987,35 @@ update_selection_menu (NautilusFilesView *view,
item_label = g_strdup (_("Open"));
}
- menu_item = g_menu_item_new (item_label, "view.open-with-default-application");
- if (app_icon != NULL)
+ /* The action already exists in the submenu if item opens in view */
+ if (!item_opens_in_view)
{
- g_menu_item_set_icon (menu_item, app_icon);
+ menu_item = g_menu_item_new (item_label, "view.open-with-default-application");
+ if (app_icon != NULL)
+ {
+ g_menu_item_set_icon (menu_item, app_icon);
+ }
+
+ object = gtk_builder_get_object (builder, "open-with-application-section");
+ g_menu_prepend_item (G_MENU (object), menu_item);
+ }
+ else
+ {
+ object = gtk_builder_get_object (builder, "open-with-application-section");
+ i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (object),
+ "nautilus-menu-item",
+ "open_with_in_main_menu");
+
+ g_menu_remove (G_MENU (object), i);
}
- object = gtk_builder_get_object (builder, "open-with-application-section");
- g_menu_prepend_item (G_MENU (object), menu_item);
+ /* The "Open" submenu should be hidden if the item doesn't open in the view. */
+ i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (priv->selection_menu_model),
+ "nautilus-menu-item",
+ "open_in_view_submenu");
+ nautilus_g_menu_replace_string_in_item (priv->selection_menu_model, i,
+ "hidden-when",
+ (!item_opens_in_view) ? "action-missing" : NULL);
g_free (item_label);
g_object_unref (menu_item);
diff --git a/src/resources/ui/nautilus-files-view-context-menus.ui
b/src/resources/ui/nautilus-files-view-context-menus.ui
index e6735ee3a..9d7c1c46d 100644
--- a/src/resources/ui/nautilus-files-view-context-menus.ui
+++ b/src/resources/ui/nautilus-files-view-context-menus.ui
@@ -3,7 +3,7 @@
<requires lib="gtk" version="4.0"/>
<menu id="background-menu">
<item>
- <attribute name="label" translatable="yes">New _Folder</attribute>
+ <attribute name="label" translatable="yes">New _Folder…</attribute>
<attribute name="action">view.new-folder</attribute>
</item>
<item>
@@ -11,42 +11,16 @@
<attribute name="nautilus-menu-item">templates-submenu</attribute>
<link name="submenu" id="templates-submenu"/>
</item>
- <item>
- <attribute name="label" translatable="yes">Add to _Bookmarks</attribute>
- <attribute name="action">win.bookmark-current-location</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">R_eload</attribute>
- <attribute name="action">win.reload</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">St_op</attribute>
- <attribute name="action">win.stop</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </item>
<section>
<item>
- <attribute name="label" translatable="yes">_Open With Other Application</attribute>
- <attribute name="action">view.open-current-directory-with-other-application</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Copy Location</attribute>
- <attribute name="action">view.copy-current-location</attribute>
+ <attribute name="label" translatable="yes">_Paste</attribute>
+ <attribute name="action">view.paste</attribute>
</item>
- </section>
- <section>
<item>
- <attribute name="label" translatable="yes">Create _Link</attribute>
+ <attribute name="label" translatable="yes">Paste as _Link</attribute>
<attribute name="action">view.create-link</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
- </section>
- <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>
@@ -65,9 +39,52 @@
<section id="new-folder-with-selection-section"/>
<section id="open-with-application-section">
<item>
- <attribute name="label" translatable="yes">Open With Other _Application</attribute>
+ <attribute name="label" translatable="yes">Open _With…</attribute>
<attribute name="action">view.open-with-other-application</attribute>
<attribute name="hidden-when">action-disabled</attribute>
+ <attribute name="nautilus-menu-item">open_with_in_main_menu</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Run as a Program</attribute>
+ <attribute name="action">view.run-in-terminal</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
+ </section>
+ <item>
+ <attribute name="label" translatable="yes">_Open</attribute>
+ <attribute name="nautilus-menu-item">open_in_view_submenu</attribute>
+ <link name="submenu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Open</attribute>
+ <attribute name="action">view.open-with-default-application</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>
+ <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>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Open _With…</attribute>
+ <attribute name="action">view.open-with-other-application</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
+ </section>
+ </link>
+ </item>
+ <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>
</section>
<submenu>
@@ -82,30 +99,6 @@
</item>
</section>
</submenu>
- <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 _Tab</attribute>
- <attribute name="action">view.open-item-new-tab</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>
- </section>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Run as a Program</attribute>
- <attribute name="action">view.run-in-terminal</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </item>
- </section>
<section id="drive-section">
<item>
<attribute name="label" translatable="yes">_Mount</attribute>
@@ -147,18 +140,6 @@
<attribute name="label" translatable="yes">_Copy</attribute>
<attribute name="action">view.copy</attribute>
</item>
- <item>
- <attribute name="label" translatable="yes">Create _Link</attribute>
- <attribute name="action">view.create-link-in-place</attribute>
- <attribute name="hidden-when">action-disabled</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>
@@ -167,96 +148,81 @@
<attribute name="label" translatable="yes">Copy to…</attribute>
<attribute name="action">view.copy-to</attribute>
</item>
- </section>
- <section>
<item>
- <attribute name="label" translatable="yes">Mo_ve to Trash</attribute>
- <attribute name="action">view.move-to-trash</attribute>
+ <attribute name="label" translatable="yes">Create _Link</attribute>
+ <attribute name="action">view.create-link-in-place</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">_Delete from Trash</attribute>
- <attribute name="action">view.delete-from-trash</attribute>
+ <attribute name="label" translatable="yes" comments="Translators: This is the transitive verb
meaning 'to send via email' (e.g. 'email this document to Angela).">Email…</attribute>
+ <attribute name="action">view.send-email</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
+ </section>
+ <section>
<item>
- <attribute name="label" translatable="yes">_Delete Permanently…</attribute>
- <attribute name="action">view.delete-permanently-menu-item</attribute>
+ <attribute name="label" translatable="yes">Set As Wallpaper</attribute>
+ <attribute name="action">view.set-as-wallpaper</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">_Delete Permanently…</attribute>
- <attribute name="action">view.permanent-delete-permanently-menu-item</attribute>
+ <attribute name="label" translatable="yes">_Extract Here</attribute>
+ <attribute name="action">view.extract-here</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">_Restore From Trash</attribute>
- <attribute name="action">view.restore-from-trash</attribute>
+ <attribute name="label" translatable="yes">E_xtract to…</attribute>
+ <attribute name="action">view.extract-to</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
- </section>
- <section>
<item>
- <attribute name="label" translatable="yes">Rena_me…</attribute>
- <attribute name="action">view.rename</attribute>
- </item>
- </section>
- <section>
- <item>
- <attribute name="label" translatable="yes">Set As Wallpaper</attribute>
- <attribute name="action">view.set-as-wallpaper</attribute>
+ <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">_Remove from Recent</attribute>
- <attribute name="action">view.remove-from-recent</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
+ <attribute name="label" translatable="yes">Rena_me…</attribute>
+ <attribute name="action">view.rename</attribute>
</item>
- </section>
- <section>
<item>
- <attribute name="label" translatable="yes">_Extract Here</attribute>
- <attribute name="action">view.extract-here</attribute>
+ <attribute name="label" translatable="yes">C_ompress…</attribute>
+ <attribute name="action">view.compress</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">E_xtract to…</attribute>
- <attribute name="action">view.extract-to</attribute>
+ <attribute name="label" translatable="yes">Mo_ve to Trash</attribute>
+ <attribute name="action">view.move-to-trash</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">C_ompress…</attribute>
- <attribute name="action">view.compress</attribute>
+ <attribute name="label" translatable="yes">_Delete from Trash</attribute>
+ <attribute name="action">view.delete-from-trash</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
- </section>
- <section>
<item>
- <attribute name="label" translatable="yes" comments="Translators: This is the transitive verb
meaning 'to send via email' (e.g. 'email this document to Angela).">Email…</attribute>
- <attribute name="action">view.send-email</attribute>
+ <attribute name="label" translatable="yes">_Delete Permanently…</attribute>
+ <attribute name="action">view.delete-permanently-menu-item</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
- </section>
- <section id="selection-extensions-section"/>
- <section>
<item>
- <attribute name="label" translatable="yes">Tags</attribute>
- <attribute name="action">view.edit-tags</attribute>
+ <attribute name="label" translatable="yes">_Delete Permanently…</attribute>
+ <attribute name="action">view.permanent-delete-permanently-menu-item</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
- <attribute name="label" translatable="yes" context="menu item" comments="Marks a file as starred
(starred)">Star</attribute>
- <attribute name="action">view.star</attribute>
+ <attribute name="label" translatable="yes">_Restore From Trash</attribute>
+ <attribute name="action">view.restore-from-trash</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
- <attribute name="label" translatable="yes" context="menu item" comments="Unmarks a file as starred
(starred)">Unstar</attribute>
- <attribute name="action">view.unstar</attribute>
+ <attribute name="label" translatable="yes">_Remove from Recent</attribute>
+ <attribute name="action">view.remove-from-recent</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
</section>
+ <section id="selection-extensions-section"/>
<section>
<item>
<attribute name="label" translatable="yes">P_roperties</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]