diff --git a/data/org.gnome.Nautilus.desktop.in b/data/org.gnome.Nautilus.desktop.in index db3f9a198..6544b02be 100644 --- a/data/org.gnome.Nautilus.desktop.in +++ b/data/org.gnome.Nautilus.desktop.in @@ -11,7 +11,7 @@ Type=Application DBusActivatable=true StartupNotify=true Categories=GNOME;GTK;Utility;Core;FileManager; -MimeType=inode/directory; +MimeType=inode/directory; application/x-7z-compressed; application/x-7z-compressed-tar; application/x-bzip; application/x-bzip-compressed-tar; application/x-compress; application/x-compressed-tar; application/x-cpio; application/x-gzip; application/x-lha; application/x-lzip; application/x-lzip-compressed-tar; application/x-lzma; application/x-lzma-compressed-tar; application/x-tar; application/x-tarz; application/x-xar; application/x-xz; application/x-xz-compressed-tar; application/zip; application/gzip; application/bzip2; X-GNOME-UsesNotifications=true Actions=new-window; diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml index f093c3ccf..023035872 100644 --- a/data/org.gnome.nautilus.gschema.xml +++ b/data/org.gnome.nautilus.gschema.xml @@ -111,11 +111,6 @@ Whether to ask for confirmation when deleting files, or emptying the Trash If set to true, then Nautilus will ask for confirmation when you attempt to delete files, or empty the Trash. - - true - Whether to extract compressed files instead of opening them in another application - If set to true, then Nautilus will automatically extract compressed files instead of opening them in another application - 'local-only' diff --git a/src/nautilus-file-utilities.h b/src/nautilus-file-utilities.h index 98f823a70..da165cd73 100644 --- a/src/nautilus-file-utilities.h +++ b/src/nautilus-file-utilities.h @@ -26,6 +26,8 @@ #include #include +#define NAUTILUS_DESKTOP_ID "org.gnome.Nautilus.desktop" + /* These functions all return something something that needs to be * freed with g_free, is not NULL, and is guaranteed to exist. */ diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index d8d4326f7..10e4a0c4e 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -1237,53 +1237,15 @@ nautilus_files_view_activate_files (NautilusFilesView *view, g_list_free (files_to_activate); } -static void +void nautilus_files_view_activate_file (NautilusFilesView *view, NautilusFile *file, NautilusWindowOpenFlags flags) { - NautilusFilesViewPrivate *priv; - char *path; + g_autoptr (GList) files = NULL; - priv = nautilus_files_view_get_instance_private (view); - - if (nautilus_mime_file_extracts (file)) - { - GList *files = NULL; - - files = g_list_prepend (files, file); - - if (nautilus_files_view_supports_extract_here (view)) - { - g_autoptr (GFile) location = NULL; - g_autoptr (GFile) parent = NULL; - - location = nautilus_file_get_location (file); - /* Get a parent from a random file. We assume all files has a common parent. - * But don't assume the parent is the view location, since that's not the - * case in list view when expand-folder setting is set - */ - parent = g_file_get_parent (location); - extract_files (view, files, parent); - } - else - { - extract_files_to_chosen_location (view, files); - } - - g_list_free (files); - - return; - } - - path = get_view_directory (view); - nautilus_mime_activate_file (nautilus_files_view_get_containing_window (view), - priv->slot, - file, - path, - flags); - - g_free (path); + files = g_list_append (files, file); + nautilus_files_view_activate_files (view, files, flags, FALSE); } static void @@ -7344,6 +7306,23 @@ can_extract_all (GList *files) return TRUE; } +static gboolean +nautilus_handles_all_files_to_extract (GList *files) +{ + NautilusFile *file; + GList *l; + + for (l = files; l != NULL; l = l->next) + { + file = l->data; + if (!nautilus_mime_file_extracts (file)) + { + return FALSE; + } + } + return TRUE; +} + GActionGroup * nautilus_files_view_get_action_group (NautilusFilesView *view) { @@ -7377,6 +7356,7 @@ real_update_actions_state (NautilusFilesView *view) gboolean can_copy_files; gboolean can_paste_files_into; gboolean can_extract_files; + gboolean handles_all_files_to_extract; gboolean can_extract_here; gboolean item_opens_in_view; gboolean is_read_only; @@ -7390,7 +7370,6 @@ real_update_actions_state (NautilusFilesView *view) gboolean show_detect_media; gboolean settings_show_delete_permanently; gboolean settings_show_create_link; - gboolean settings_automatic_decompression; GDriveStartStopType start_stop_type; priv = nautilus_files_view_get_instance_private (view); @@ -7430,13 +7409,11 @@ real_update_actions_state (NautilusFilesView *view) can_extract_files = selection_count != 0 && can_extract_all (selection); can_extract_here = nautilus_files_view_supports_extract_here (view); + handles_all_files_to_extract = nautilus_handles_all_files_to_extract (selection); settings_show_delete_permanently = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY); settings_show_create_link = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SHOW_CREATE_LINK); - settings_automatic_decompression = g_settings_get_boolean (nautilus_preferences, - NAUTILUS_PREFERENCES_AUTOMATIC_DECOMPRESSION); - /* Right click actions */ /* Selection menu actions */ action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), @@ -7470,14 +7447,14 @@ real_update_actions_state (NautilusFilesView *view) "extract-here"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_extract_files && - !settings_automatic_decompression && + !handles_all_files_to_extract && can_extract_here); action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "extract-to"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_extract_files && - (!settings_automatic_decompression || + (!handles_all_files_to_extract || can_extract_here)); action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h index cc3340ae5..d2c5ce171 100644 --- a/src/nautilus-files-view.h +++ b/src/nautilus-files-view.h @@ -267,6 +267,9 @@ void nautilus_files_view_activate_files (Nautil GList *files, NautilusWindowOpenFlags flags, gboolean confirm_multiple); +void nautilus_files_view_activate_file (NautilusFilesView *view, + NautilusFile *file, + NautilusWindowOpenFlags flags); void nautilus_files_view_preview_files (NautilusFilesView *view, GList *files, GArray *locations); diff --git a/src/nautilus-global-preferences.h b/src/nautilus-global-preferences.h index f508f7d97..ce0b32c9d 100644 --- a/src/nautilus-global-preferences.h +++ b/src/nautilus-global-preferences.h @@ -32,9 +32,6 @@ G_BEGIN_DECLS /* Trash options */ #define NAUTILUS_PREFERENCES_CONFIRM_TRASH "confirm-trash" -/* Automatic decompression */ -#define NAUTILUS_PREFERENCES_AUTOMATIC_DECOMPRESSION "automatic-decompression" - /* Display */ #define NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES "show-hidden" diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c index ab69c6007..28f1da54a 100644 --- a/src/nautilus-mime-actions.c +++ b/src/nautilus-mime-actions.c @@ -37,6 +37,7 @@ #include "nautilus-file-attributes.h" #include "nautilus-file.h" +#include "nautilus-file-utilities.h" #include "nautilus-file-operations.h" #include "nautilus-metadata.h" #include "nautilus-program-choosing.h" @@ -709,11 +710,14 @@ get_activation_action (NautilusFile *file) { ActivationAction action; char *activation_uri; - gboolean can_extract; - can_extract = g_settings_get_boolean (nautilus_preferences, - NAUTILUS_PREFERENCES_AUTOMATIC_DECOMPRESSION); + gboolean handles_extract; + g_autoptr (GAppInfo) app_info = NULL; + const gchar* app_id; - if (can_extract && nautilus_file_is_archive (file)) + app_info = nautilus_mime_get_default_application_for_file (file); + app_id = g_app_info_get_id (app_info); + handles_extract = g_strcmp0 (app_id, NAUTILUS_DESKTOP_ID) == 0; + if (handles_extract && nautilus_file_is_archive (file)) { return ACTIVATION_ACTION_EXTRACT; } diff --git a/src/nautilus-preferences-window.c b/src/nautilus-preferences-window.c index 680254ff1..0e4a5a413 100644 --- a/src/nautilus-preferences-window.c +++ b/src/nautilus-preferences-window.c @@ -57,8 +57,6 @@ "use_tree_view_checkbutton" #define NAUTILUS_PREFERENCES_DIALOG_TRASH_CONFIRM_WIDGET \ "trash_confirm_checkbutton" -#define NAUTILUS_PREFERENCES_DIALOG_AUTOMATIC_DECOMPRESSION_WIDGET \ - "automatic_decompression_checkbutton" #define NAUTILUS_PREFERENCES_DIALOG_USE_NEW_VIEWS_WIDGET \ "use_new_views_checkbutton" #define NAUTILUS_PREFERENCES_FTS_DEFAULT_WIDGET \ @@ -493,9 +491,6 @@ static void nautilus_preferences_window_setup(GtkBuilder *builder, bind_builder_bool (builder, nautilus_preferences, NAUTILUS_PREFERENCES_DIALOG_TRASH_CONFIRM_WIDGET, NAUTILUS_PREFERENCES_CONFIRM_TRASH); - bind_builder_bool (builder, nautilus_preferences, - NAUTILUS_PREFERENCES_DIALOG_AUTOMATIC_DECOMPRESSION_WIDGET, - NAUTILUS_PREFERENCES_AUTOMATIC_DECOMPRESSION); bind_builder_bool (builder, nautilus_list_view_preferences, NAUTILUS_PREFERENCES_DIALOG_LIST_VIEW_USE_TREE_WIDGET, NAUTILUS_PREFERENCES_LIST_VIEW_USE_TREE); diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 765be41fb..17aa99986 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -118,6 +118,7 @@ typedef struct guint location_change_distance; char *pending_scroll_to; GList *pending_selection; + NautilusFile *pending_file_to_activate; NautilusFile *determine_view_file; GCancellable *mount_cancellable; GError *mount_error; @@ -985,6 +986,7 @@ static gboolean setup_view (NautilusWindowSlot *self, static void load_new_location (NautilusWindowSlot *slot, GFile *location, GList *selection, + NautilusFile *file_to_activate, gboolean tell_current_content_view, gboolean tell_new_content_view); @@ -1580,10 +1582,18 @@ handle_regular_file_if_needed (NautilusWindowSlot *self, } g_clear_object (&priv->pending_location); + g_clear_object (&priv->pending_file_to_activate); g_free (priv->pending_scroll_to); priv->pending_location = nautilus_file_get_parent_location (file); - priv->pending_selection = g_list_prepend (NULL, nautilus_file_ref (file)); + if (nautilus_file_is_archive (file)) + { + priv->pending_file_to_activate = nautilus_file_ref (file); + } + else + { + priv->pending_selection = g_list_prepend (NULL, nautilus_file_ref (file)); + } priv->determine_view_file = nautilus_file_ref (parent_file); priv->pending_scroll_to = nautilus_file_get_uri (file); @@ -1777,6 +1787,7 @@ setup_view (NautilusWindowSlot *self, load_new_location (self, priv->pending_location, priv->pending_selection, + priv->pending_file_to_activate, FALSE, TRUE); @@ -1792,6 +1803,7 @@ setup_view (NautilusWindowSlot *self, load_new_location (self, old_location, selection, + NULL, FALSE, TRUE); nautilus_file_list_free (selection); @@ -1815,6 +1827,7 @@ static void load_new_location (NautilusWindowSlot *self, GFile *location, GList *selection, + NautilusFile *file_to_activate, gboolean tell_current_content_view, gboolean tell_new_content_view) { @@ -1845,6 +1858,20 @@ load_new_location (NautilusWindowSlot *self, if (view) { nautilus_view_set_selection (view, selection); + if (file_to_activate != NULL) + { + g_autoptr (GAppInfo) app_info = NULL; + const gchar *app_id; + + g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view)); + app_info = nautilus_mime_get_default_application_for_file (file_to_activate); + app_id = g_app_info_get_id (app_info); + if (g_strcmp0 (app_id, NAUTILUS_DESKTOP_ID) == 0) + { + nautilus_files_view_activate_file (NAUTILUS_FILES_VIEW (view), + file_to_activate, 0); + } + } } nautilus_profile_end (NULL); @@ -1882,6 +1909,7 @@ free_location_change (NautilusWindowSlot *self) priv = nautilus_window_slot_get_instance_private (self); g_clear_object (&priv->pending_location); + g_clear_object (&priv->pending_file_to_activate); nautilus_file_list_free (priv->pending_selection); priv->pending_selection = NULL; @@ -2769,6 +2797,7 @@ nautilus_window_slot_dispose (GObject *object) nautilus_window_slot_set_viewed_file (self, NULL); g_clear_object (&priv->location); + g_clear_object (&priv->pending_file_to_activate); nautilus_file_list_free (priv->pending_selection); priv->pending_selection = NULL; @@ -3066,6 +3095,7 @@ nautilus_window_slot_stop_loading (NautilusWindowSlot *self) load_new_location (self, location, selection, + NULL, TRUE, FALSE); nautilus_file_list_free (selection); diff --git a/src/resources/ui/nautilus-preferences-window.ui b/src/resources/ui/nautilus-preferences-window.ui index 7bba44eaf..aeeb1f8c5 100644 --- a/src/resources/ui/nautilus-preferences-window.ui +++ b/src/resources/ui/nautilus-preferences-window.ui @@ -804,52 +804,6 @@ 3 - - - True - False - vertical - 6 - - - True - False - Compressed Files - 0 - - - - - - False - False - 0 - - - - - E_xtract the files on open - False - True - True - False - True - 0 - True - - - False - False - 2 - - - - - False - True - 4 - - 1