diff --git a/thunar/thunar-location-entry.c b/thunar/thunar-location-entry.c index 0893b03e95e54cde70e167c6cf8e974b40a8ea41..dd885944c8c06ebe6dfadabe5c407ca94465e2f2 100644 --- a/thunar/thunar-location-entry.c +++ b/thunar/thunar-location-entry.c @@ -312,18 +312,20 @@ thunar_location_entry_accept_focus (ThunarLocationEntry *location_entry, static void -thunar_location_entry_open_or_launch (ThunarLocationEntry *location_entry, - ThunarFile *file) +thunar_location_entry_open_or_highlight (ThunarLocationEntry *location_entry, + ThunarFile *file) { GError *error = NULL; _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry)); _thunar_return_if_fail (THUNAR_IS_FILE (file)); + GFile *gfile = thunar_file_get_file (file); + /* check if the file is mounted */ if (thunar_file_is_mounted (file)) { - /* check if we have a new directory or a file to launch */ + /* check if we have a new directory or a file to highlight */ if (thunar_file_is_directory (file)) { /* open the new directory */ @@ -331,14 +333,34 @@ thunar_location_entry_open_or_launch (ThunarLocationEntry *location_entry, } else { - /* try to launch the selected file */ - thunar_file_launch (file, location_entry->path_entry, NULL, &error); - - /* be sure to reset the current file of the path entry */ - if (G_LIKELY (location_entry->current_directory != NULL)) + /* check if the file has a parent to which we can navigate to */ + ThunarFile *parent = thunar_file_get_parent (file, &error); + if (parent != NULL) { - thunar_path_entry_set_current_file (THUNAR_PATH_ENTRY (location_entry->path_entry), - location_entry->current_directory); + // get the parent window first + GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (location_entry)); + + /* change to the parent directory */ + thunar_navigator_change_directory (THUNAR_NAVIGATOR (location_entry), parent); + + if (GTK_IS_WINDOW (window) && gtk_window_has_toplevel_focus (GTK_WINDOW (window)) == TRUE) + { + GList *selected = NULL; + + /* ensure gfile is not NULL and is a valid GFile before appending */ + if (gfile != NULL && G_IS_FILE (gfile)) + { + selected = g_list_append (selected, gfile); + + if (selected != NULL) + { + thunar_window_show_and_select_files (THUNAR_WINDOW (window), selected); + g_list_free (selected); + } + } + } + + g_object_unref (parent); } } } @@ -377,8 +399,8 @@ thunar_location_entry_poke_file_finish (ThunarBrowser *browser, if (error == NULL) { /* try to open or launch the target file */ - thunar_location_entry_open_or_launch (THUNAR_LOCATION_ENTRY (browser), - target_file); + thunar_location_entry_open_or_highlight (THUNAR_LOCATION_ENTRY (browser), + target_file); } else {