diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2004-01-19 22:06:41 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2004-01-19 22:06:41 +0800 |
commit | dd0b02c40b5d202794d03299f2d190833b63bb22 (patch) | |
tree | 4e8dc109ed36ca01584e1a7d39d5649cc6adbd6e /lib/eel-gconf-extensions.c | |
parent | eaba78e8dfd1cdad90bed57cc536cbfe40a9509e (diff) | |
download | gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.gz gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.bz2 gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.lz gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.xz gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.tar.zst gsoc2013-epiphany-dd0b02c40b5d202794d03299f2d190833b63bb22.zip |
Add a way to store paths.
2004-01-19 Marco Pesenti Gritti <marco@gnome.org>
* lib/eel-gconf-extensions.c: (tilde_compress),
(eel_gconf_set_path):
* lib/eel-gconf-extensions.h:
Add a way to store paths.
* embed/mozilla/ContentHandler.cpp:
* embed/mozilla/ContentHandler.h:
* embed/mozilla/MozDownload.cpp:
* embed/mozilla/MozDownload.h:
Actually save the file in downloads dir and then
open it. It doesnt seem to open it but it's prolly
a gnome-vfs bug.
* src/prefs-dialog.c: (get_download_button_label),
(download_path_response_cb):
Simplify the label logic using ~.
Diffstat (limited to 'lib/eel-gconf-extensions.c')
-rw-r--r-- | lib/eel-gconf-extensions.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/eel-gconf-extensions.c b/lib/eel-gconf-extensions.c index 7ec18f492..a60372d45 100644 --- a/lib/eel-gconf-extensions.c +++ b/lib/eel-gconf-extensions.c @@ -687,3 +687,65 @@ eel_gconf_get_float (const char *key) return result; } + +static char * +tilde_compress (const char *path) +{ + const char *home_dir = g_get_home_dir(); + int home_dir_l = strlen (home_dir); + int ntilde = 0; + const char *scan; + int path_l, result_l; + char *result, *scan2; + + if (path == NULL) + return NULL; + + path_l = strlen (path); + for (scan = path; scan != NULL; scan++) { + if (path_l - (scan - path) < home_dir_l) + break; + if (strncmp (scan, home_dir, home_dir_l) == 0) + ntilde++; + } + + if (ntilde == 0) + return g_strdup (path); + + result_l = strlen (path) + ntilde - (ntilde * home_dir_l); + result = g_new (char, result_l + 1); + + for (scan = path, scan2 = result; scan != NULL; scan2++) { + if (path_l - (scan - path) < home_dir_l) { + strcpy (scan2, scan); + scan2 += strlen (scan); + break; + } + if (strncmp (scan, home_dir, home_dir_l) == 0) { + *scan2 = '~'; + scan += home_dir_l; + } else { + *scan2 = *scan; + scan++; + } + } + *scan2 = 0; + + return result; +} + +void +eel_gconf_set_path (const char *key, + const char *value) +{ + char *tilde_path; + char *converted; + + converted = g_filename_to_utf8 (value, -1, NULL, NULL, NULL); + + tilde_path = tilde_compress (converted); + eel_gconf_set_string (key, tilde_path); + + g_free (tilde_path); + g_free (converted); +} |