Mercurial > geeqie
comparison src/main.c @ 653:e06947d07086
Expand tilde with file: and view: remote parameters.
Now these are working:
geeqie -r file:~/dir
geeqie -r view:~user/file
author | zas_ |
---|---|
date | Tue, 13 May 2008 16:09:43 +0000 |
parents | 9bcfd6d7a902 |
children | 8268cbe682f1 |
comparison
equal
deleted
inserted
replaced
652:9bcfd6d7a902 | 653:e06947d07086 |
---|---|
43 | 43 |
44 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | 44 #include <gdk/gdkkeysyms.h> /* for keyboard values */ |
45 | 45 |
46 | 46 |
47 #include <math.h> | 47 #include <math.h> |
48 #ifdef G_OS_UNIX | |
49 #include <pwd.h> | |
50 #endif | |
48 | 51 |
49 | 52 |
50 static RemoteConnection *remote_connection = NULL; | 53 static RemoteConnection *remote_connection = NULL; |
51 | 54 |
52 | 55 |
78 text = conv_text; | 81 text = conv_text; |
79 } | 82 } |
80 | 83 |
81 return text; | 84 return text; |
82 } | 85 } |
86 | |
87 /* Borrowed from gtkfilesystemunix.c */ | |
88 gchar *expand_tilde(const gchar *filename) | |
89 { | |
90 #ifndef G_OS_UNIX | |
91 return g_strdup(filename); | |
92 #else | |
93 const char *notilde; | |
94 const char *slash; | |
95 const char *home; | |
96 | |
97 if (filename[0] != '~') | |
98 return g_strdup(filename); | |
99 | |
100 notilde = filename + 1; | |
101 slash = strchr(notilde, G_DIR_SEPARATOR); | |
102 if (slash == notilde || !*notilde) | |
103 { | |
104 home = g_get_home_dir(); | |
105 if (!home) | |
106 return g_strdup(filename); | |
107 } | |
108 else | |
109 { | |
110 gchar *username; | |
111 struct passwd *passwd; | |
112 | |
113 if (slash) | |
114 username = g_strndup(notilde, slash - notilde); | |
115 else | |
116 username = g_strdup(notilde); | |
117 | |
118 passwd = getpwnam(username); | |
119 g_free(username); | |
120 | |
121 if (!passwd) | |
122 return g_strdup(filename); | |
123 | |
124 home = passwd->pw_dir; | |
125 } | |
126 | |
127 if (slash) | |
128 return g_build_filename(home, G_DIR_SEPARATOR_S, slash + 1, NULL); | |
129 else | |
130 return g_build_filename(home, G_DIR_SEPARATOR_S, NULL); | |
131 #endif | |
132 } | |
133 | |
83 | 134 |
84 /* | 135 /* |
85 *----------------------------------------------------------------------------- | 136 *----------------------------------------------------------------------------- |
86 * keyboard functions | 137 * keyboard functions |
87 *----------------------------------------------------------------------------- | 138 *----------------------------------------------------------------------------- |