static void thunar_history_go_forward (ThunarHistory *history, guint n) { _thunar_return_if_fail (THUNAR_IS_HISTORY (history)); _thunar_return_if_fail (n > 0); /* go forward up to n steps */ for (; n > 0 && history->forward_list != NULL; --n) { /* prepend the previous current directory to the "back" list */ if (G_LIKELY (history->current_directory != NULL)) history->back_list = g_list_prepend (history->back_list, history->current_directory); /* remove the first directory from the "forward" list and make it the current directory */ history->current_directory = history->forward_list->data; history->forward_list = g_list_delete_link (history->forward_list, history->forward_list); } /* tell the other modules to change the current directory */ if (G_LIKELY (history->current_directory != NULL)) thunar_navigator_change_directory (THUNAR_NAVIGATOR (history), history->current_directory); /* update the sensitivity of the actions */ gtk_action_set_sensitive (history->action_back, (history->back_list != NULL)); gtk_action_set_sensitive (history->action_forward, (history->forward_list != NULL)); }
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); } } }
static void thunar_location_entry_item_activated (GtkWidget *item, ThunarLocationEntry *location_entry) { ThunarVfsVolume *volume; ThunarFile *file; GtkWidget *window; GError *error = NULL; _thunar_return_if_fail (GTK_IS_MENU_ITEM (item)); _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry)); /* determine the toplevel window */ window = gtk_widget_get_toplevel (GTK_WIDGET (location_entry)); /* check if the item corresponds to a volume */ volume = g_object_get_data (G_OBJECT (item), "thunar-vfs-volume"); if (G_UNLIKELY (volume != NULL)) { /* check if the volume isn't already mounted */ if (G_LIKELY (!thunar_vfs_volume_is_mounted (volume))) { /* try to mount the volume */ if (!thunar_vfs_volume_mount (volume, window, &error)) { /* display an error dialog to inform the user */ thunar_dialogs_show_error (window, error, _("Failed to mount \"%s\""), thunar_vfs_volume_get_name (volume)); g_error_free (error); return; } } /* try to determine the mount point of the volume */ file = thunar_file_get_for_path (thunar_vfs_volume_get_mount_point (volume), &error); if (G_UNLIKELY (file == NULL)) { /* display an error dialog to inform the user */ thunar_dialogs_show_error (window, error, _("Failed to determine the mount point for %s"), thunar_vfs_volume_get_name (volume)); g_error_free (error); return; } } else { /* determine the file from the item */ file = g_object_get_data (G_OBJECT (item), "thunar-file"); if (G_LIKELY (file != NULL)) g_object_ref (G_OBJECT (file)); } /* check if we have a file object now */ if (G_LIKELY (file != NULL)) { /* make sure that this is actually a directory */ if (thunar_file_is_directory (file)) { /* open the new directory */ thunar_navigator_change_directory (THUNAR_NAVIGATOR (location_entry), file); } /* cleanup */ g_object_unref (G_OBJECT (file)); } }