Commit 4cffc059 authored by Robert Stefanic's avatar Robert Stefanic Committed by Alexander Schwinn
Browse files

Support for variables like $HOME in address bar (Bug #12165)

Appending a path to the variable is as well supported.
parent bd19aaaa
Loading
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -270,6 +270,7 @@ thunar_util_expand_filename (const gchar *filename,
  const gchar   *slash;
  gchar         *username;
  gchar         *pwd;
  gchar         *variable;
  gchar         *result = NULL;

  g_return_val_if_fail (filename != NULL, NULL);
@@ -320,6 +321,25 @@ thunar_util_expand_filename (const gchar *filename,
          replacement = passwd->pw_dir;
        }

      /* generate the filename */
      return g_build_filename (replacement, slash, NULL);
    }
  else if (*filename == '$')
    {
      /* examine the remainder of the variable and filename */
      remainder = filename + 1;

      /* lookup the slash at the end of the variable */
      for (slash = remainder; *slash != '\0' && *slash != G_DIR_SEPARATOR; ++slash);

      /* get the variable for replacement */
      variable = g_strndup (remainder, slash - remainder);
      replacement = g_getenv (variable);
      g_free (variable);

      if (replacement == NULL)
        return NULL;

      /* generate the filename */
      return g_build_filename (replacement, slash, NULL);
    }