static void thunar_location_entry_activate (GtkWidget *path_entry, ThunarLocationEntry *location_entry) { ThunarFile *file; GError *error = NULL; _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry)); _thunar_return_if_fail (location_entry->path_entry == path_entry); /* determine the current file from the path entry */ file = thunar_path_entry_get_current_file (THUNAR_PATH_ENTRY (path_entry)); if (G_LIKELY (file != NULL)) { /* check if we have a new directory or a file to launch */ if (thunar_file_is_directory (file)) { /* open the new directory */ thunar_navigator_change_directory (THUNAR_NAVIGATOR (location_entry), file); } else { /* try to launch the selected file */ if (!thunar_file_launch (file, path_entry, &error)) { thunar_dialogs_show_error (path_entry, error, _("Failed to launch \"%s\""), thunar_file_get_display_name (file)); g_error_free (error); } /* be sure to reset the current file of the path entry */ if (G_LIKELY (location_entry->current_directory != NULL)) thunar_path_entry_set_current_file (THUNAR_PATH_ENTRY (path_entry), location_entry->current_directory); } } }
/** * thunar_location_dialog_get_selected_file: * @location_dialog : a #ThunarLocationDialog. * * Returns the file selected for the @dialog or * %NULL if the file entered is not valid. * * Return value: the selected #ThunarFile or %NULL. **/ ThunarFile* thunar_location_dialog_get_selected_file (ThunarLocationDialog *location_dialog) { _thunar_return_val_if_fail (THUNAR_IS_LOCATION_DIALOG (location_dialog), NULL); return thunar_path_entry_get_current_file (THUNAR_PATH_ENTRY (location_dialog->entry)); }
/** * thunar_location_dialog_set_selected_file: * @location_dialog : a #ThunarLocationDialog. * @selected_file : a #ThunarFile or %NULL. * * Sets the file for @location_dialog to @selected_file. **/ void thunar_location_dialog_set_selected_file (ThunarLocationDialog *location_dialog, ThunarFile *selected_file) { _thunar_return_if_fail (THUNAR_IS_LOCATION_DIALOG (location_dialog)); _thunar_return_if_fail (selected_file == NULL || THUNAR_IS_FILE (selected_file)); thunar_path_entry_set_current_file (THUNAR_PATH_ENTRY (location_dialog->entry), selected_file); }
/** * thunar_location_dialog_set_working_directory: * @location_dialog : a #ThunarLocationDialog. * @directory : a #ThunarFile or %NULL. * * Sets the working directory of @location_dialog to @directory. **/ void thunar_location_dialog_set_working_directory (ThunarLocationDialog *location_dialog, ThunarFile *directory) { _thunar_return_if_fail (THUNAR_IS_LOCATION_DIALOG (location_dialog)); _thunar_return_if_fail (directory == NULL || THUNAR_IS_FILE (directory)); thunar_path_entry_set_working_directory (THUNAR_PATH_ENTRY (location_dialog->entry), directory); }
static gboolean thunar_location_entry_reset (ThunarLocationEntry *location_entry) { /* just reset the path entry to our current directory... */ thunar_path_entry_set_current_file (THUNAR_PATH_ENTRY (location_entry->path_entry), location_entry->current_directory); /* ...and select the whole text again */ gtk_editable_select_region (GTK_EDITABLE (location_entry->path_entry), 0, -1); return TRUE; }