[nautilus] sidebar: Restore "Empty Trash..." menu item
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] sidebar: Restore "Empty Trash..." menu item
- Date: Mon, 2 May 2022 10:22:23 +0000 (UTC)
commit 28dd7fd304bda0e529723bfbf14836e54413981f
Author: Corey Berla <corey berla me>
Date: Mon Apr 25 12:34:12 2022 -0700
sidebar: Restore "Empty Trash..." menu item
Also add Properties menu item to the Trash row context menu too.
src/gtk/nautilusgtkplacessidebar.c | 30 +++++++++++++++++++++++++++++-
src/nautilus-window.c | 35 -----------------------------------
2 files changed, 29 insertions(+), 36 deletions(-)
---
diff --git a/src/gtk/nautilusgtkplacessidebar.c b/src/gtk/nautilusgtkplacessidebar.c
index f258f9076..a0a329967 100644
--- a/src/gtk/nautilusgtkplacessidebar.c
+++ b/src/gtk/nautilusgtkplacessidebar.c
@@ -36,6 +36,7 @@
#include "gdk/gdkkeysyms.h"
#include "nautilusgtkbookmarksmanagerprivate.h"
#include "nautilus-file.h"
+#include "nautilus-file-operations.h"
#include "nautilus-properties-window.h"
#include "nautilus-trash-monitor.h"
#pragma GCC diagnostic ignored "-Wshadow"
@@ -2433,6 +2434,15 @@ properties_cb (GSimpleAction *action,
nautilus_file_list_free (list);
}
+static void
+empty_trash_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+{
+ NautilusGtkPlacesSidebar *sidebar = data;
+ nautilus_file_operations_empty_trash (GTK_WIDGET (sidebar), TRUE, NULL);
+}
+
static void
remove_bookmark (NautilusGtkSidebarRow *row)
{
@@ -3104,6 +3114,7 @@ static GActionEntry entries[] = {
{ "start", start_shortcut_cb, NULL, NULL, NULL },
{ "stop", stop_shortcut_cb, NULL, NULL, NULL },
{ "properties", properties_cb, NULL, NULL, NULL },
+ { "empty-trash", empty_trash_cb, NULL, NULL, NULL },
};
static void
@@ -3188,6 +3199,8 @@ create_row_popover (NautilusGtkPlacesSidebar *sidebar,
g_autofree gchar *uri = NULL;
g_autoptr (GFile) file = NULL;
gboolean show_properties;
+ g_autoptr (GFile) trash = NULL;
+ gboolean is_trash;
g_object_get (row,
"place-type", &type,
@@ -3201,11 +3214,14 @@ create_row_popover (NautilusGtkPlacesSidebar *sidebar,
if (uri != NULL)
{
file = g_file_new_for_uri (uri);
- show_properties = (g_file_is_native (file) || mount != NULL);
+ trash = g_file_new_for_uri("trash:///");
+ is_trash = g_file_equal (trash, file);
+ show_properties = (g_file_is_native (file) || is_trash || mount != NULL);
}
else
{
show_properties = FALSE;
+ is_trash = FALSE;
}
#ifdef HAVE_CLOUDPROVIDERS
@@ -3227,6 +3243,8 @@ create_row_popover (NautilusGtkPlacesSidebar *sidebar,
type == NAUTILUS_GTK_PLACES_XDG_DIR));
action = g_action_map_lookup_action (G_ACTION_MAP (sidebar->row_actions), "open");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !gtk_list_box_row_is_selected (GTK_LIST_BOX_ROW
(row)));
+ action = g_action_map_lookup_action (G_ACTION_MAP (sidebar->row_actions), "empty-trash");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !nautilus_trash_monitor_is_empty());
menu = g_menu_new ();
section = g_menu_new ();
@@ -3274,6 +3292,16 @@ create_row_popover (NautilusGtkPlacesSidebar *sidebar,
g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
g_object_unref (section);
+ if (is_trash) {
+ section = g_menu_new ();
+ item = g_menu_item_new (_("Empty Trash"), "row.empty-trash");
+ g_menu_append_item (section, item);
+ g_object_unref (item);
+
+ g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
+ g_object_unref (section);
+ }
+
section = g_menu_new ();
if (volume != NULL && mount == NULL &&
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index c47a8b770..b1c4f6a14 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -53,7 +53,6 @@
#include "nautilus-clipboard.h"
#include "nautilus-dnd.h"
#include "nautilus-enums.h"
-#include "nautilus-file-operations.h"
#include "nautilus-file-undo-manager.h"
#include "nautilus-file-utilities.h"
#include "nautilus-global-preferences.h"
@@ -1092,17 +1091,6 @@ places_sidebar_drag_perform_drop_cb (NautilusGtkPlacesSidebar *sidebar,
}
#endif
-/* Callback used in the "empty trash" menu item from the places sidebar */
-static void
-action_empty_trash (GSimpleAction *action,
- GVariant *variant,
- gpointer user_data)
-{
- NautilusWindow *window = NAUTILUS_WINDOW (user_data);
-
- nautilus_file_operations_empty_trash (GTK_WIDGET (window), TRUE, NULL);
-}
-
static gboolean
check_have_gnome_disks (void)
{
@@ -1219,34 +1207,12 @@ places_sidebar_populate_popup_cb (NautilusGtkPlacesSidebar *sidebar,
gpointer user_data)
{
NautilusWindow *window = NAUTILUS_WINDOW (user_data);
- GFile *trash;
GtkWidget *menu_item;
GAction *action;
g_clear_object (&window->selected_file);
g_clear_object (&window->selected_volume);
- if (selected_file)
- {
- trash = g_file_new_for_uri ("trash:///");
- if (g_file_equal (trash, selected_file))
- {
- add_menu_separator (menu);
-
- menu_item = gtk_model_button_new ();
- gtk_actionable_set_action_name (GTK_ACTIONABLE (menu_item),
- "win.empty-trash");
- g_object_set (menu_item, "text", _("Empty _Trash…"), NULL);
- gtk_box_append (GTK_BOX (menu), menu_item);
- gtk_widget_show (menu_item);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (window),
- "empty-trash");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- !nautilus_trash_monitor_is_empty ());
- }
- g_object_unref (trash);
- }
if (selected_volume)
{
if (should_show_format_command (selected_volume))
@@ -1840,7 +1806,6 @@ const GActionEntry win_entries[] =
{ "prompt-root-location", action_prompt_for_location_root },
{ "prompt-home-location", action_prompt_for_location_home },
{ "go-to-tab", NULL, "i", "0", action_go_to_tab },
- { "empty-trash", action_empty_trash },
{ "format", action_format },
{ "restore-tab", action_restore_tab },
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]