[nautilus/wip/antoniof/menu-reorganization: 54/56] 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: 54/56] files-view: Reorganize context menus
- Date: Sun, 7 Aug 2022 00:36:06 +0000 (UTC)
commit 8622a2d60ea2a9666d94e6256edca3327a94ad89
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 | 43 ++--
.../ui/nautilus-files-view-context-menus.ui | 218 +++++++++------------
2 files changed, 122 insertions(+), 139 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index dde7e746f..a08338f46 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -7707,10 +7707,8 @@ real_update_actions_state (NautilusFilesView *view)
!settings_show_create_link);
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"send-email");
- /* Show the email action is there's a default email client or if we are
- * in a sandbox, you can't check the app info so always show */
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- (app_info_mailto != NULL || nautilus_application_is_sandboxed ()));
+ app_info_mailto != NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"copy-to");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
@@ -8036,7 +8034,7 @@ update_selection_menu (NautilusFilesView *view,
else if (show_extract)
{
item_label = nautilus_files_view_supports_extract_here (view) ?
- g_strdup (_("Extract Here")) :
+ g_strdup (_("Extract")) :
g_strdup (_("Extract to…"));
}
else
@@ -8044,17 +8042,39 @@ 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);
+
+ g_object_unref (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);
}
+ /* The "Open" submenu should be hidden if the item doesn't open in the view. */
object = gtk_builder_get_object (builder, "open-with-application-section");
- g_menu_prepend_item (G_MENU (object), menu_item);
+ i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (object),
+ "nautilus-menu-item",
+ "open_in_view_submenu");
+ nautilus_g_menu_replace_string_in_item (G_MENU (object), i,
+ "hidden-when",
+ (!item_opens_in_view) ? "action-missing" : NULL);
g_free (item_label);
- g_object_unref (menu_item);
/* Drives */
for (l = selection; l != NULL && (show_mount || show_unmount
@@ -8181,10 +8201,11 @@ update_selection_menu (NautilusFilesView *view,
nautilus_gmenu_set_from_model (G_MENU (object), priv->scripts_menu);
}
- i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (priv->selection_menu_model),
+ 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",
"scripts-submenu");
- nautilus_g_menu_replace_string_in_item (priv->selection_menu_model, i,
+ nautilus_g_menu_replace_string_in_item (G_MENU (object), i,
"hidden-when",
(!show_scripts) ? "action-missing" : NULL);
}
diff --git a/src/resources/ui/nautilus-files-view-context-menus.ui
b/src/resources/ui/nautilus-files-view-context-menus.ui
index ca011272e..6e3fd7f10 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>
@@ -12,54 +12,30 @@
<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>
+ <attribute name="label" translatable="yes">Open _With…</attribute>
+ <attribute name="action">view.open-current-directory-with-other-application</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="label" translatable="yes">Open in Consol_e</attribute>
+ <attribute name="action">view.current-directory-console</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>
</item>
</section>
<section id="background-extensions-section"/>
- <section>
- <item>
- <attribute name="label" translatable="yes">Open in Consol_e</attribute>
- <attribute name="action">view.current-directory-console</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </item>
- </section>
<section>
<item>
<attribute name="label" translatable="yes">P_roperties</attribute>
@@ -72,46 +48,78 @@
<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="action">view.open-with-other-application</attribute>
+ <attribute name="label" translatable="yes">_Extract</attribute>
+ <attribute name="action">view.extract-here</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
- </section>
- <submenu>
- <attribute name="label" translatable="yes">_Scripts</attribute>
- <attribute name="nautilus-menu-item">scripts-submenu</attribute>
- <section id="scripts-submenu-section"/>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Open Scripts Folder</attribute>
- <attribute name="action">view.open-scripts-folder</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
- </item>
- </section>
- </submenu>
- <section>
<item>
- <attribute name="label" translatable="yes">_Open Item Location</attribute>
- <attribute name="action">view.open-item-location</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>
<item>
- <attribute name="label" translatable="yes">Open In New _Tab</attribute>
- <attribute name="action">view.open-item-new-tab</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">Open In New _Window</attribute>
- <attribute name="action">view.open-item-new-window</attribute>
+ <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>
<item>
- <attribute name="label" translatable="yes">_Run as a Program</attribute>
- <attribute name="action">view.run-in-terminal</attribute>
+ <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>
+ <item>
+ <attribute name="label" translatable="yes">Open in Consol_e</attribute>
+ <attribute name="action">view.console</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
+ </section>
+ </link>
+ </item>
+ <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>
+ <submenu>
+ <attribute name="label" translatable="yes">_Scripts</attribute>
+ <attribute name="nautilus-menu-item">scripts-submenu</attribute>
+ <section id="scripts-submenu-section"/>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Open Scripts Folder</attribute>
+ <attribute name="action">view.open-scripts-folder</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ </item>
+ </section>
+ </submenu>
</section>
<section id="drive-section">
<item>
@@ -154,18 +162,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>
@@ -177,100 +173,66 @@
</section>
<section>
<item>
- <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">_Delete from Trash</attribute>
- <attribute name="action">view.delete-from-trash</attribute>
- <attribute name="hidden-when">action-disabled</attribute>
+ <attribute name="label" translatable="yes">Rena_me…</attribute>
+ <attribute name="action">view.rename</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">_Delete Permanently…</attribute>
- <attribute name="action">view.delete-permanently-menu-item</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>
<item>
- <attribute name="label" translatable="yes">_Delete Permanently…</attribute>
- <attribute name="action">view.permanent-delete-permanently-menu-item</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">_Restore From Trash</attribute>
- <attribute name="action">view.restore-from-trash</attribute>
+ <attribute name="label" translatable="yes">C_ompress…</attribute>
+ <attribute name="action">view.compress</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="label" translatable="yes">Set as Background…</attribute>
<attribute name="action">view.set-as-wallpaper</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>
- </item>
- </section>
- <section>
- <item>
- <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">E_xtract to…</attribute>
- <attribute name="action">view.extract-to</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>
<item>
- <attribute name="label" translatable="yes">C_ompress…</attribute>
- <attribute name="action">view.compress</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>
- </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 from Trash</attribute>
+ <attribute name="action">view.delete-from-trash</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.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">_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="Unmarks a file as starred
(starred)">Unstar</attribute>
- <attribute name="action">view.unstar</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>
- </section>
- <section>
<item>
- <attribute name="label" translatable="yes">Open in Consol_e</attribute>
- <attribute name="action">view.console</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]