[Xfce4-commits] <thunar:master> Expand paths with ./ based on the current working directory (bug #3451).
Jannis Pohlmann
noreply at xfce.org
Sat Nov 13 16:44:01 CET 2010
Updating branch refs/heads/master
to cd913e51a2611e847a3dbff048195a22670bed49 (commit)
from 78a3cf854f68b3d8221210f2730b9c46ccb915f7 (commit)
commit cd913e51a2611e847a3dbff048195a22670bed49
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Sat Nov 13 16:40:17 2010 +0100
Expand paths with ./ based on the current working directory (bug #3451).
This involves a number of changes but it's an existing bug that was
reported first in 2007. Paths starting with '.' or './' are now resolved
based on the current working directory.
NEWS | 2 +
thunar/thunar-location-dialog.c | 48 +++++++++++----
thunar/thunar-location-dialog.h | 39 +++++++-----
thunar/thunar-location-entry.c | 31 ++++++----
thunar/thunar-path-entry.c | 62 +++++++++++++++----
thunar/thunar-path-entry.h | 38 +++++++-----
thunar/thunar-util.c | 127 ++++++++++++++++++++++++--------------
thunar/thunar-util.h | 30 +++++----
thunar/thunar-window.c | 30 +++++----
9 files changed, 259 insertions(+), 148 deletions(-)
diff --git a/NEWS b/NEWS
index dfe2a81..a5c02c2 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@
- Fix missing instruction to load the sendto model (bug #6762).
- Allow scrolling in the 'Open With' combo box of the file properties
dialog (bug #3055).
+- Expand filenames starting with './' based on the current working
+ directory instead of home (bug #3451).
1.1.4
=====
diff --git a/thunar/thunar-location-dialog.c b/thunar/thunar-location-dialog.c
index 6e58b91..7fde5f9 100644
--- a/thunar/thunar-location-dialog.c
+++ b/thunar/thunar-location-dialog.c
@@ -1,20 +1,22 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -123,6 +125,7 @@ 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));
}
@@ -141,7 +144,26 @@ thunar_location_dialog_set_selected_file (ThunarLocationDialog *location_dialog,
{
_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_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);
+}
diff --git a/thunar/thunar-location-dialog.h b/thunar/thunar-location-dialog.h
index bb8d17f..441e8a0 100644
--- a/thunar/thunar-location-dialog.h
+++ b/thunar/thunar-location-dialog.h
@@ -1,22 +1,25 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
+
#ifndef __THUNAR_LOCATION_DIALOG_H__
#define __THUNAR_LOCATION_DIALOG_H__
@@ -46,13 +49,15 @@ struct _ThunarLocationDialog
GtkWidget *entry;
};
-GType thunar_location_dialog_get_type (void) G_GNUC_CONST;
+GType thunar_location_dialog_get_type (void) G_GNUC_CONST;
-GtkWidget *thunar_location_dialog_new (void) G_GNUC_MALLOC;
+GtkWidget *thunar_location_dialog_new (void) G_GNUC_MALLOC;
-ThunarFile *thunar_location_dialog_get_selected_file (ThunarLocationDialog *location_dialog);
-void thunar_location_dialog_set_selected_file (ThunarLocationDialog *location_dialog,
- ThunarFile *selected_file);
+ThunarFile *thunar_location_dialog_get_selected_file (ThunarLocationDialog *location_dialog);
+void thunar_location_dialog_set_selected_file (ThunarLocationDialog *location_dialog,
+ ThunarFile *selected_file);
+void thunar_location_dialog_set_working_directory (ThunarLocationDialog *location_dialog,
+ ThunarFile *directory);
G_END_DECLS;
diff --git a/thunar/thunar-location-entry.c b/thunar/thunar-location-entry.c
index 51b3777..d64dbc0 100644
--- a/thunar/thunar-location-entry.c
+++ b/thunar/thunar-location-entry.c
@@ -1,21 +1,22 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -264,10 +265,14 @@ thunar_location_entry_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
+ ThunarLocationEntry *entry = THUNAR_LOCATION_ENTRY (object);
+
switch (prop_id)
{
case PROP_CURRENT_DIRECTORY:
thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (object), g_value_get_object (value));
+ thunar_path_entry_set_working_directory (THUNAR_PATH_ENTRY (entry->path_entry),
+ entry->current_directory);
break;
case PROP_SELECTED_FILES:
diff --git a/thunar/thunar-path-entry.c b/thunar/thunar-path-entry.c
index 06467d8..e0a241e 100644
--- a/thunar/thunar-path-entry.c
+++ b/thunar/thunar-path-entry.c
@@ -1,21 +1,22 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*
* The icon code is based on ideas from SexyIconEntry, which was written by
* Christian Hammond <chipx86 at chipx86.com>.
@@ -142,6 +143,7 @@ struct _ThunarPathEntry
ThunarIconFactory *icon_factory;
ThunarFile *current_folder;
ThunarFile *current_file;
+ GFile *working_directory;
GdkWindow *icon_area;
gint drag_button;
@@ -245,6 +247,7 @@ thunar_path_entry_init (ThunarPathEntry *path_entry)
ThunarListModel *store;
path_entry->check_completion_idle_id = -1;
+ path_entry->working_directory = NULL;
/* allocate a new entry completion for the given model */
completion = gtk_entry_completion_new ();
@@ -304,6 +307,10 @@ thunar_path_entry_finalize (GObject *object)
g_object_unref (G_OBJECT (path_entry->current_file));
}
+ /* release the working directory */
+ if (G_LIKELY (path_entry->working_directory != NULL))
+ g_object_unref (G_OBJECT (path_entry->working_directory));
+
/* drop the check_completion_idle source */
if (G_UNLIKELY (path_entry->check_completion_idle_id >= 0))
g_source_remove (path_entry->check_completion_idle_id);
@@ -1226,7 +1233,9 @@ thunar_path_entry_parse (ThunarPathEntry *path_entry,
_thunar_return_val_if_fail (file_part != NULL, FALSE);
/* expand the filename */
- filename = thunar_util_expand_filename (gtk_entry_get_text (GTK_ENTRY (path_entry)), error);
+ filename = thunar_util_expand_filename (gtk_entry_get_text (GTK_ENTRY (path_entry)),
+ path_entry->working_directory,
+ error);
if (G_UNLIKELY (filename == NULL))
return FALSE;
@@ -1411,3 +1420,28 @@ thunar_path_entry_set_current_file (ThunarPathEntry *path_entry,
gtk_widget_queue_draw (GTK_WIDGET (path_entry));
}
+
+
+/**
+ * thunar_path_entry_set_working_directory:
+ * @path_entry : a #ThunarPathEntry.
+ * @working_directory : a #ThunarFile or %NULL.
+ *
+ * Sets the #ThunarFile that should be used as the
+ * working directory for @path_entry.
+ **/
+void
+thunar_path_entry_set_working_directory (ThunarPathEntry *path_entry,
+ ThunarFile *working_directory)
+{
+ _thunar_return_if_fail (THUNAR_IS_PATH_ENTRY (path_entry));
+ _thunar_return_if_fail (working_directory == NULL || THUNAR_IS_FILE (working_directory));
+
+ if (G_LIKELY (path_entry->working_directory != NULL))
+ g_object_unref (path_entry->working_directory);
+
+ path_entry->working_directory = NULL;
+
+ if (THUNAR_IS_FILE (working_directory))
+ path_entry->working_directory = g_object_ref (thunar_file_get_file (working_directory));
+}
diff --git a/thunar/thunar-path-entry.h b/thunar/thunar-path-entry.h
index d3ce081..0baa21a 100644
--- a/thunar/thunar-path-entry.h
+++ b/thunar/thunar-path-entry.h
@@ -1,20 +1,22 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2010 Benedikt Meurer <benny 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifndef __THUNAR_PATH_ENTRY_H__
@@ -34,13 +36,15 @@ typedef struct _ThunarPathEntry ThunarPathEntry;
#define THUNAR_IS_PATH_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_PATH_ENTRY))
#define THUNAR_PATH_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_PATH_ENTRY, ThunarPathEntryClass))
-GType thunar_path_entry_get_type (void) G_GNUC_CONST;
+GType thunar_path_entry_get_type (void) G_GNUC_CONST;
-GtkWidget *thunar_path_entry_new (void);
+GtkWidget *thunar_path_entry_new (void);
-ThunarFile *thunar_path_entry_get_current_file (ThunarPathEntry *path_entry);
-void thunar_path_entry_set_current_file (ThunarPathEntry *path_entry,
- ThunarFile *current_file);
+ThunarFile *thunar_path_entry_get_current_file (ThunarPathEntry *path_entry);
+void thunar_path_entry_set_current_file (ThunarPathEntry *path_entry,
+ ThunarFile *current_file);
+void thunar_path_entry_set_working_directory (ThunarPathEntry *path_entry,
+ ThunarFile *directory);
G_END_DECLS;
diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c
index 20d7a89..b49a954 100644
--- a/thunar/thunar-util.c
+++ b/thunar/thunar-util.c
@@ -1,21 +1,22 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2006-2007 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -60,11 +61,13 @@
/**
* thunar_util_expand_filename:
- * @filename : a local filename.
- * @error : return location for errors or %NULL.
+ * @filename : a local filename.
+ * @working_directory : #GFile of the current working directory.
+ * @error : return location for errors or %NULL.
*
* Takes a user-typed @filename and expands a tilde at the
- * beginning of the @filename.
+ * beginning of the @filename. It also resolves paths prefixed with
+ * '.' using the current working directory.
*
* The caller is responsible to free the returned string using
* g_free() when no longer needed.
@@ -73,6 +76,7 @@
**/
gchar *
thunar_util_expand_filename (const gchar *filename,
+ GFile *working_directory,
GError **error)
{
struct passwd *passwd;
@@ -80,6 +84,8 @@ thunar_util_expand_filename (const gchar *filename,
const gchar *remainder;
const gchar *slash;
gchar *username;
+ gchar *pwd;
+ gchar *result = NULL;
g_return_val_if_fail (filename != NULL, NULL);
@@ -91,48 +97,75 @@ thunar_util_expand_filename (const gchar *filename,
}
/* check if we start with a '~' */
- if (G_LIKELY (*filename != '~'))
- return g_strdup (filename);
+ if (*filename == '~')
+ {
+ /* examine the remainder of the filename */
+ remainder = filename + 1;
- /* examine the remainder of the filename */
- remainder = filename + 1;
+ /* if we have only the slash, then we want the home dir */
+ if (G_UNLIKELY (*remainder == '\0'))
+ return g_strdup (xfce_get_homedir ());
- /* if we have only the slash, then we want the home dir */
- if (G_UNLIKELY (*remainder == '\0'))
- return g_strdup (xfce_get_homedir ());
+ /* lookup the slash */
+ for (slash = remainder; *slash != '\0' && *slash != G_DIR_SEPARATOR; ++slash);
- /* lookup the slash */
- for (slash = remainder; *slash != '\0' && *slash != G_DIR_SEPARATOR; ++slash)
- ;
+ /* check if a username was given after the '~' */
+ if (G_LIKELY (slash == remainder))
+ {
+ /* replace the tilde with the home dir */
+ replacement = xfce_get_homedir ();
+ }
+ else
+ {
+ /* lookup the pwd entry for the username */
+ username = g_strndup (remainder, slash - remainder);
+ passwd = getpwnam (username);
+ g_free (username);
- /* check if a username was given after the '~' */
- if (G_LIKELY (slash == remainder))
- {
- /* replace the tilde with the home dir */
- replacement = xfce_get_homedir ();
+ /* check if we have a valid entry */
+ if (G_UNLIKELY (passwd == NULL))
+ {
+ username = g_strndup (remainder, slash - remainder);
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_INVAL, _("Unknown user \"%s\""), username);
+ g_free (username);
+ return NULL;
+ }
+
+ /* use the homedir of the specified user */
+ replacement = passwd->pw_dir;
+ }
+
+ /* generate the filename */
+ return g_build_filename (replacement, slash, NULL);
}
- else
+ else if (*filename == '.')
{
- /* lookup the pwd entry for the username */
- username = g_strndup (remainder, slash - remainder);
- passwd = getpwnam (username);
- g_free (username);
-
- /* check if we have a valid entry */
- if (G_UNLIKELY (passwd == NULL))
+ /* examine the remainder of the filename */
+ remainder = filename + 1;
+
+ /* transform working directory into a filename string */
+ if (G_LIKELY (working_directory != NULL))
{
- username = g_strndup (remainder, slash - remainder);
- g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_INVAL, _("Unknown user \"%s\""), username);
- g_free (username);
- return NULL;
+ pwd = g_file_get_path (working_directory);
+
+ /* if we only have the slash then we want the working directory only */
+ if (G_UNLIKELY (*remainder == '\0'))
+ return pwd;
+
+ /* concatenate working directory and remainder */
+ result = g_build_filename (pwd, remainder, G_DIR_SEPARATOR_S, NULL);
+
+ /* free the working directory string */
+ g_free (pwd);
}
+ else
+ result = g_strdup (filename);
- /* use the homedir of the specified user */
- replacement = passwd->pw_dir;
+ /* return the resulting path string */
+ return result;
}
- /* generate the filename */
- return g_build_filename (replacement, slash, NULL);
+ return g_strdup (filename);
}
diff --git a/thunar/thunar-util.h b/thunar/thunar-util.h
index a28a1b4..779f936 100644
--- a/thunar/thunar-util.h
+++ b/thunar/thunar-util.h
@@ -1,21 +1,22 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2006-2007 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifndef __THUNAR_UTIL_H__
@@ -28,7 +29,8 @@ G_BEGIN_DECLS;
gboolean thunar_util_looks_like_an_uri (const gchar *string) G_GNUC_WARN_UNUSED_RESULT;
gchar *thunar_util_expand_filename (const gchar *filename,
- GError **error);
+ GFile *working_directory,
+ GError **error) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
gchar *thunar_util_humanize_file_time (guint64 file_time,
ThunarDateStyle date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 64e00ae..4735b3b 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -1,21 +1,22 @@
-/* $Id$ */
+/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2005-2007 Benedikt Meurer <benny 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * 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 Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -1529,7 +1530,10 @@ thunar_window_start_open_location (ThunarWindow *window,
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
- thunar_location_dialog_set_selected_file (THUNAR_LOCATION_DIALOG (dialog), thunar_window_get_current_directory (window));
+ thunar_location_dialog_set_working_directory (THUNAR_LOCATION_DIALOG (dialog),
+ thunar_window_get_current_directory (window));
+ thunar_location_dialog_set_selected_file (THUNAR_LOCATION_DIALOG (dialog),
+ thunar_window_get_current_directory (window));
/* setup the initial text (if any) */
if (G_UNLIKELY (initial_text != NULL))
More information about the Xfce4-commits
mailing list