aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-01-19 22:06:41 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-01-19 22:06:41 +0800
commitdd0b02c40b5d202794d03299f2d190833b63bb22 (patch)
tree4e8dc109ed36ca01584e1a7d39d5649cc6adbd6e /lib
parenteaba78e8dfd1cdad90bed57cc536cbfe40a9509e (diff)
downloadgsoc2013-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')
-rw-r--r--lib/eel-gconf-extensions.c62
-rw-r--r--lib/eel-gconf-extensions.h2
2 files changed, 64 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);
+}
diff --git a/lib/eel-gconf-extensions.h b/lib/eel-gconf-extensions.h
index 13196d7ee..4bc6167ef 100644
--- a/lib/eel-gconf-extensions.h
+++ b/lib/eel-gconf-extensions.h
@@ -72,6 +72,8 @@ void eel_gconf_value_set_string_list (GConfValue *value,
void eel_gconf_set_float (const char *key,
gfloat float_value);
gfloat eel_gconf_get_float (const char *key);
+void eel_gconf_set_path (const char *key,
+ const char *value);
G_END_DECLS