Commit 86e47f46 authored by Christian Neumair's avatar Christian Neumair Committed by Christian Neumair

Get script file name as script parameter relative to current view

2008-08-31  Christian Neumair  <cneumair@gnome.org>

	* src/file-manager/fm-directory-view.c
	(get_file_names_as_parameter_array), (run_script_callback):
	Get script file name as script parameter relative to current
	view directory. Fixes #320215.

svn path=/trunk/; revision=14545
parent c310aa1f
2008-08-31 Christian Neumair <cneumair@gnome.org>
* src/file-manager/fm-directory-view.c
(get_file_names_as_parameter_array), (run_script_callback):
Get script file name as script parameter relative to current
view directory. Fixes #320215.
2008-08-30 Christian Neumair <cneumair@gnome.org>
* src/file-manager/fm-icon-view.c (fm_icon_view_set_property):
......
......@@ -4781,16 +4781,24 @@ change_to_view_directory (FMDirectoryView *view)
}
static char **
get_file_names_as_parameter_array (GList *selection)
get_file_names_as_parameter_array (GList *selection,
NautilusDirectory *model)
{
NautilusFile *file;
char *name;
char **parameters;
GList *node;
GFile *file_location;
GFile *model_location;
int i;
if (model == NULL) {
return NULL;
}
parameters = g_new (char *, g_list_length (selection) + 1);
model_location = nautilus_directory_get_location (model);
for (node = selection, i = 0; node != NULL; node = node->next, i++) {
file = NAUTILUS_FILE (node->data);
......@@ -4800,15 +4808,16 @@ get_file_names_as_parameter_array (GList *selection)
return NULL;
}
/* TODO get name with respect to base directory,
* which may be different from file's parent directory
* in list view with nested subdirectories.
*/
name = nautilus_file_get_name (NAUTILUS_FILE (node->data));
parameters[i] = name;
file_location = nautilus_file_get_location (NAUTILUS_FILE (node->data));
parameters[i] = g_file_get_relative_path (model_location, file_location);
if (parameters[i] == NULL) {
parameters[i] = g_file_get_path (file_location);
}
g_object_unref (file_location);
}
g_object_unref (model_location);
parameters[i] = NULL;
return parameters;
}
......@@ -4959,7 +4968,8 @@ run_script_callback (GtkAction *action, gpointer callback_data)
selected_files = fm_directory_view_get_selection (launch_parameters->directory_view);
set_script_environment_variables (launch_parameters->directory_view, selected_files);
parameters = get_file_names_as_parameter_array (selected_files);
parameters = get_file_names_as_parameter_array (selected_files,
launch_parameters->directory_view->details->model);
screen = gtk_widget_get_screen (GTK_WIDGET (launch_parameters->directory_view));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment