]> Pileus Git - ~andy/gtk/commitdiff
Make a single tilde go to $HOME in the location entry. Patch from Yevgen
authorKjartan Maraas <kmaraas@gnome.org>
Thu, 11 Jan 2007 00:53:00 +0000 (00:53 +0000)
committerKjartan Maraas <kmaraas@src.gnome.org>
Thu, 11 Jan 2007 00:53:00 +0000 (00:53 +0000)
2007-01-11  Kjartan Maraas  <kmaraas@gnome.org>

* gtk/gtkfilesystemunix.c: (expand_tilde):
Make a single tilde go to $HOME in the location entry.
Patch from Yevgen Muntyan. Closes the gtk+ part of
bug #334168.

svn path=/trunk/; revision=17130

ChangeLog
gtk/gtkfilesystemunix.c

index 6d8033d7c6149436ecb0bc36472eca0f821de506..43cc6472b4cbb2ac257deecb6bbe0296fde8f2e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-01-11  Kjartan Maraas  <kmaraas@gnome.org>
+
+       * gtk/gtkfilesystemunix.c: (expand_tilde):
+       Make a single tilde go to $HOME in the location entry.
+       Patch from Yevgen Muntyan. Closes the gtk+ part of
+       bug #334168.
+
 2007-01-10  Behdad Esfahbod  <behdad@gnome.org>
 
        * gdk/gdkpango.c (gdk_draw_layout_with_colors):
index 3df49323159420e3d5a11161485f07619b8c518c..38a6cd064b72cfe18882fd8e2d02c360c8ebdb48 100644 (file)
@@ -1442,10 +1442,8 @@ expand_tilde (const char *filename)
   notilde = filename + 1;
 
   slash = strchr (notilde, G_DIR_SEPARATOR);
-  if (!slash)
-    return NULL;
 
-  if (slash == notilde)
+  if (slash == notilde || !*notilde)
     {
       home = g_get_home_dir ();
 
@@ -1457,7 +1455,11 @@ expand_tilde (const char *filename)
       char *username;
       struct passwd *passwd;
 
-      username = g_strndup (notilde, slash - notilde);
+      if (slash)
+        username = g_strndup (notilde, slash - notilde);
+      else
+        username = g_strdup (notilde);
+
       passwd = getpwnam (username);
       g_free (username);
 
@@ -1467,7 +1469,10 @@ expand_tilde (const char *filename)
       home = passwd->pw_dir;
     }
 
-  return g_build_filename (home, G_DIR_SEPARATOR_S, slash + 1, NULL);
+  if (slash)
+    return g_build_filename (home, G_DIR_SEPARATOR_S, slash + 1, NULL);
+  else
+    return g_strdup (home);
 }
 
 static gboolean