[Xfce4-commits] <thunar:master> Add working directory parameter to thunar_file_execute().
Jannis Pohlmann
noreply at xfce.org
Sun Oct 24 23:36:01 CEST 2010
Updating branch refs/heads/master
to 6140f346f0d772d841c0c0a03d2cd26a1f4d6481 (commit)
from 64a79dd953388f3422bee879e2080dd9ebaf2cb8 (commit)
commit 6140f346f0d772d841c0c0a03d2cd26a1f4d6481
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Sun Oct 24 23:32:13 2010 +0200
Add working directory parameter to thunar_file_execute().
thunar/thunar-dnd.c | 5 +++--
thunar/thunar-file.c | 28 ++++++++++++++++++----------
thunar/thunar-file.h | 1 +
thunar/thunar-launcher.c | 5 ++++-
4 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/thunar/thunar-dnd.c b/thunar/thunar-dnd.c
index ee74b90..92259bc 100644
--- a/thunar/thunar-dnd.c
+++ b/thunar/thunar-dnd.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*-
* Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2010 Jannis Pohlmann <jannis at xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -246,7 +246,8 @@ thunar_dnd_perform (GtkWidget *widget,
}
else if (thunar_file_is_executable (file))
{
- succeed = thunar_file_execute (file, gtk_widget_get_screen (widget), file_list, &error);
+ /* TODO any chance to determine the working dir here? */
+ succeed = thunar_file_execute (file, NULL, gtk_widget_get_screen (widget), file_list, &error);
if (G_UNLIKELY (!succeed))
{
/* display an error to the user */
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 75b0a02..6ab7dfc 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -925,10 +925,12 @@ thunar_file_get_parent (const ThunarFile *file,
/**
* thunar_file_execute:
- * @file : a #ThunarFile instance.
- * @screen : a #GdkScreen.
- * @file_list : the list of #GFile<!---->s to supply to @file on execution.
- * @error : return location for errors or %NULL.
+ * @file : a #ThunarFile instance.
+ * @working_directory : the working directory used to resolve relative filenames
+ * in @file_list.
+ * @screen : a #GdkScreen.
+ * @file_list : the list of #GFile<!---->s to supply to @file on execution.
+ * @error : return location for errors or %NULL.
*
* Tries to execute @file on the specified @screen. If @file is executable
* and could have been spawned successfully, %TRUE is returned, else %FALSE
@@ -937,10 +939,11 @@ thunar_file_get_parent (const ThunarFile *file,
* Return value: %TRUE on success, else %FALSE.
**/
gboolean
-thunar_file_execute (ThunarFile *file,
- GdkScreen *screen,
- GList *file_list,
- GError **error)
+thunar_file_execute (ThunarFile *file,
+ GFile *working_directory,
+ GdkScreen *screen,
+ GList *file_list,
+ GError **error)
{
gboolean snotify = FALSE;
gboolean terminal;
@@ -1056,7 +1059,12 @@ thunar_file_execute (ThunarFile *file,
if (G_LIKELY (result))
{
/* determine the working directory */
- if (G_LIKELY (file_list != NULL))
+ if (G_LIKELY (working_directory != NULL))
+ {
+ /* copy the working directory provided to this method */
+ directory = g_file_get_path (working_directory);
+ }
+ else if (file_list != NULL)
{
/* use the directory of the first list item */
parent = g_file_get_parent (file_list->data);
@@ -1146,7 +1154,7 @@ thunar_file_launch (ThunarFile *file,
/* check if we should execute the file */
if (thunar_file_is_executable (file))
- return thunar_file_execute (file, screen, NULL, error);
+ return thunar_file_execute (file, NULL, screen, NULL, error);
/* determine the default application to open the file */
/* TODO We should probably add a cancellable argument to thunar_file_launch() */
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index d289402..d1a5704 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -139,6 +139,7 @@ ThunarFile *thunar_file_get_parent (const ThunarFile *file
GError **error);
gboolean thunar_file_execute (ThunarFile *file,
+ GFile *working_directory,
GdkScreen *screen,
GList *path_list,
GError **error);
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index 6b3a8f5..f479cf9 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -523,6 +523,7 @@ thunar_launcher_execute_files (ThunarLauncher *launcher,
{
GdkScreen *screen;
GError *error = NULL;
+ GFile *working_directory;
GList *lp;
/* determine the screen on which to run the file(s) */
@@ -531,7 +532,9 @@ thunar_launcher_execute_files (ThunarLauncher *launcher,
/* execute all selected files */
for (lp = files; lp != NULL; lp = lp->next)
{
- if (!thunar_file_execute (lp->data, screen, NULL, &error))
+ working_directory = thunar_file_get_file (launcher->current_directory);
+
+ if (!thunar_file_execute (lp->data, working_directory, screen, NULL, &error))
{
/* display an error message to the user */
thunar_dialogs_show_error (launcher->widget, error, _("Failed to execute file \"%s\""), thunar_file_get_display_name (lp->data));
More information about the Xfce4-commits
mailing list