diff options
author | Gene Z. Ragan <gzr@eazel.com> | 2000-08-28 18:27:13 +0000 |
---|---|---|
committer | Gene Ragan <gzr@src.gnome.org> | 2000-08-28 18:27:13 +0000 |
commit | 64e331759b45493999fa5c6668c20c26e1bb5cc0 (patch) | |
tree | e10a9ca910fa32b6af3311b617159b74d9307a0f /src | |
parent | 5655cd8ef1e894ef49467030bcfcd61f314824c1 (diff) | |
download | nautilus-64e331759b45493999fa5c6668c20c26e1bb5cc0.tar.gz |
Fixed bug #1942, Trash icon on desktop has "Move to Trash" in right-click
2000-08-28 Gene Z. Ragan <gzr@eazel.com>
Fixed bug #1942, Trash icon on desktop has "Move to Trash" in
right-click menu.
* libnautilus-extensions/nautilus-link.c:
(nautilus_link_is_home_link), (nautilus_link_is_trash_link),
(nautilus_link_can_accept_drag):
Rename path argument to uri. The funciton can accrept
a URI.
* libnautilus-extensions/nautilus-link.h:
* src/file-manager/fm-directory-view.c: (trash_link_is_in_files),
(fm_directory_trash_link_in_selection),
(fm_directory_view_real_create_selection_context_menu_items):
New functions to identify if a Trash link is in the selection.
Diffstat (limited to 'src')
-rw-r--r-- | src/file-manager/fm-directory-view.c | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 3f9a2906a..ca395b8dc 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -1913,6 +1913,42 @@ fm_directory_all_selected_items_in_trash (FMDirectoryView *view) } static gboolean +trash_link_is_in_files (GList *files) +{ + GList *node; + char *uri; + + /* Result is ambiguous if called on NULL, so disallow. */ + g_return_val_if_fail (files != NULL, FALSE); + + for (node = files; node != NULL; node = node->next) { + if (nautilus_file_is_nautilus_link (NAUTILUS_FILE (node->data))) { + uri = nautilus_file_get_uri (NAUTILUS_FILE (node->data)); + if (nautilus_link_is_trash_link (uri)) { + g_free (uri); + return TRUE; + } + g_free (uri); + } + } + + return FALSE; +} + +static gboolean +fm_directory_trash_link_in_selection (FMDirectoryView *view) +{ + GList *selection; + gboolean result; + + selection = fm_directory_view_get_selection (view); + result = (selection == NULL) ? FALSE : trash_link_is_in_files (selection); + nautilus_file_list_free (selection); + + return result; +} + +static gboolean fm_directory_view_can_move_file_to_trash (FMDirectoryView *view, NautilusFile *file) { /* Return TRUE if we can get a trash directory on the same volume as this file. */ @@ -2674,15 +2710,18 @@ fm_directory_view_real_create_selection_context_menu_items (FMDirectoryView *vie gtk_widget_show (menu_item); gtk_menu_append (menu, menu_item); - /* Trash menu item handled specially. See comment above reset_bonobo_trash_delete_menu. */ - if (!fm_directory_all_selected_items_in_trash (view)) { - append_gtk_menu_item_with_view (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_TRASH, - trash_callback, files); - } else { - append_gtk_menu_item_with_view (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_DELETE, - trash_callback, files); + /* Don't add item if Trash icon is in selection */ + if (!fm_directory_trash_link_in_selection (view)) { + /* Trash menu item handled specially. See comment above reset_bonobo_trash_delete_menu. */ + if (!fm_directory_all_selected_items_in_trash (view)) { + append_gtk_menu_item_with_view (view, menu, files, + FM_DIRECTORY_VIEW_MENU_PATH_TRASH, + trash_callback, files); + } else { + append_gtk_menu_item_with_view (view, menu, files, + FM_DIRECTORY_VIEW_MENU_PATH_DELETE, + trash_callback, files); + } } append_gtk_menu_item_with_view (view, menu, files, FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE, |