aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog27
-rw-r--r--embed/ephy-embed-popup-control.c8
-rw-r--r--embed/ephy-favicon-cache.c48
-rw-r--r--embed/mozilla/EphyHeaderSniffer.cpp4
-rw-r--r--embed/mozilla/FilePicker.cpp3
-rw-r--r--embed/mozilla/MozDownload.cpp36
-rw-r--r--lib/ephy-file-chooser.c13
-rw-r--r--lib/ephy-file-helpers.c10
-rw-r--r--src/popup-commands.c6
-rw-r--r--src/prefs-dialog.c22
10 files changed, 124 insertions, 53 deletions
diff --git a/ChangeLog b/ChangeLog
index 7137c6ea5..8d31acefe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2004-02-12 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/ephy-embed-popup-control.c: (save_url),
+ (embed_popup_set_image_as_background_cmd):
+ * embed/ephy-favicon-cache.c: (ephy_favicon_cache_get_type),
+ (ephy_favicon_cache_class_init), (favicon_name_build),
+ (favicon_download_completed_cb), (ephy_favicon_cache_get):
+ * embed/mozilla/FilePicker.cpp:
+ * embed/mozilla/MozDownload.cpp:
+ * lib/ephy-file-chooser.c: (ephy_file_chooser_set_persist_key):
+ * lib/ephy-file-helpers.c: (ephy_file_downloads_dir):
+ * src/popup-commands.c: (popup_cmd_set_image_as_background):
+ * src/prefs-dialog.c: (get_download_button_label),
+ (download_path_response_cb):
+
+ Fix numerous places where we weren't properly converting between UTF-8
+ and filename encoding.
+
+ * embed/ephy-favicon-cache.c:
+
+ Bump favicon cache xml version.
+
+ * embed/mozilla/EphyHeaderSniffer.cpp:
+
+ Fix mem leak, and use CONF_STATE_SAVE_DIR instead of the download dir
+ key for directory persistence.
+
2004-02-12 Marco Pesenti Gritti <marco@gnome.org>
* data/glade/prefs-dialog.glade:
diff --git a/embed/ephy-embed-popup-control.c b/embed/ephy-embed-popup-control.c
index ce24abb2e..3a771120f 100644
--- a/embed/ephy-embed-popup-control.c
+++ b/embed/ephy-embed-popup-control.c
@@ -501,7 +501,7 @@ save_url (EphyEmbedPopupControl *popup,
ephy_embed_persist_set_flags
(persist, ask_dest ? EMBED_PERSIST_ASK_DESTINATION : 0);
ephy_embed_persist_set_persist_key
- (persist, CONF_STATE_DOWNLOAD_DIR);
+ (persist, CONF_STATE_SAVE_DIR);
ephy_embed_persist_set_source (persist, location);
ephy_embed_persist_save (persist);
@@ -591,7 +591,7 @@ embed_popup_set_image_as_background_cmd (BonoboUIComponent *uic,
{
EphyEmbedEvent *info;
const char *location;
- char *dest, *base;
+ char *dest, *base, *base_converted;
const GValue *value;
EphyEmbedPersist *persist;
@@ -603,7 +603,8 @@ embed_popup_set_image_as_background_cmd (BonoboUIComponent *uic,
(ephy_embed_factory_new_object ("EphyEmbedPersist"));
base = g_path_get_basename (location);
- dest = g_build_filename (ephy_dot_dir (), base, NULL);
+ base_converted = g_filename_from_utf8 (base, -1, NULL, NULL, NULL);
+ dest = g_build_filename (ephy_dot_dir (), base_converted, NULL);
ephy_embed_persist_set_dest (persist, dest);
ephy_embed_persist_set_flags (persist, EMBED_PERSIST_NO_VIEW);
@@ -617,6 +618,7 @@ embed_popup_set_image_as_background_cmd (BonoboUIComponent *uic,
g_free (dest);
g_free (base);
+ g_free (base_converted);
}
static void
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c
index 222f67f5b..c83471dee 100644
--- a/embed/ephy-favicon-cache.c
+++ b/embed/ephy-favicon-cache.c
@@ -19,6 +19,10 @@
* $Id$
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <libgnomevfs/gnome-vfs-ops.h>
#include <string.h>
#include <time.h>
@@ -33,13 +37,13 @@
#include "ephy-debug.h"
#define EPHY_FAVICON_CACHE_XML_ROOT "ephy_favicons_cache"
-#define EPHY_FAVICON_CACHE_XML_VERSION "1.0"
+#define EPHY_FAVICON_CACHE_XML_VERSION "1.1"
#define EPHY_FAVICON_CACHE_OBSOLETE_DAYS 30
static void ephy_favicon_cache_class_init (EphyFaviconCacheClass *klass);
-static void ephy_favicon_cache_init (EphyFaviconCache *ma);
-static void ephy_favicon_cache_finalize (GObject *object);
+static void ephy_favicon_cache_init (EphyFaviconCache *ma);
+static void ephy_favicon_cache_finalize (GObject *object);
#define EPHY_FAVICON_CACHE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_FAVICON_CACHE, EphyFaviconCachePrivate))
@@ -59,16 +63,16 @@ enum
LAST_SIGNAL
};
-static guint ephy_favicon_cache_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL;
GType
ephy_favicon_cache_get_type (void)
{
- static GType ephy_favicon_cache_type = 0;
+ static GType type = 0;
- if (ephy_favicon_cache_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info =
{
@@ -83,12 +87,12 @@ ephy_favicon_cache_get_type (void)
(GInstanceInitFunc) ephy_favicon_cache_init
};
- ephy_favicon_cache_type = g_type_register_static (G_TYPE_OBJECT,
- "EphyFaviconCache",
- &our_info, 0);
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "EphyFaviconCache",
+ &our_info, 0);
}
- return ephy_favicon_cache_type;
+ return type;
}
static void
@@ -100,7 +104,7 @@ ephy_favicon_cache_class_init (EphyFaviconCacheClass *klass)
object_class->finalize = ephy_favicon_cache_finalize;
- ephy_favicon_cache_signals[CHANGED] =
+ signals[CHANGED] =
g_signal_new ("changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
@@ -298,15 +302,21 @@ ephy_favicon_cache_finalize (GObject *object)
static char *
favicon_name_build (const char *url)
{
- char *res;
- char *slashpos;
+ char *result, *slashpos;
+
+ result = g_filename_from_utf8 (url, -1, NULL, NULL, NULL);
- res = g_strdup (url);
+ if (result == NULL)
+ {
+ return NULL;
+ }
- while ((slashpos = strstr (res, "/")) != NULL)
+ while ((slashpos = strstr (result, "/")) != NULL)
+ {
*slashpos = '_';
+ }
- return res;
+ return result;
}
static void
@@ -320,7 +330,7 @@ favicon_download_completed_cb (EphyEmbedPersist *persist,
g_hash_table_remove (cache->priv->downloads_hash, url);
- g_signal_emit (G_OBJECT (cache), ephy_favicon_cache_signals[CHANGED], 0, url);
+ g_signal_emit (G_OBJECT (cache), signals[CHANGED], 0, url);
g_object_unref (persist);
}
@@ -383,6 +393,10 @@ ephy_favicon_cache_get (EphyFaviconCache *cache,
char *filename;
filename = favicon_name_build (url);
+ if (filename == NULL)
+ {
+ return NULL;
+ }
icon = ephy_node_new (cache->priv->db);
g_value_init (&value, G_TYPE_STRING);
diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp
index abf0ba931..a37c9164c 100644
--- a/embed/mozilla/EphyHeaderSniffer.cpp
+++ b/embed/mozilla/EphyHeaderSniffer.cpp
@@ -216,6 +216,8 @@ filechooser_response_cb (EphyFileChooser *dialog, gint response, EphyHeaderSniff
sniffer->InitiateDownload (destFile);
}
}
+
+ g_free (filename);
}
// FIXME how to inform user of failed save ?
@@ -314,7 +316,7 @@ nsresult EphyHeaderSniffer::PerformSave (nsIURI* inOriginalURI)
dialog = ephy_file_chooser_new (title ? title: _("Save"),
GTK_WIDGET (window),
GTK_FILE_CHOOSER_ACTION_SAVE,
- key ? key : CONF_STATE_DOWNLOAD_DIR);
+ key ? key : CONF_STATE_SAVE_DIR);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
NS_ConvertUCS2toUTF8 (defaultFileName).get());
diff --git a/embed/mozilla/FilePicker.cpp b/embed/mozilla/FilePicker.cpp
index 71685c958..ee1dda489 100644
--- a/embed/mozilla/FilePicker.cpp
+++ b/embed/mozilla/FilePicker.cpp
@@ -202,7 +202,8 @@ NS_IMETHODIMP GFilePicker::GetDefaultString(PRUnichar **aDefaultString)
if (filename != NULL)
{
converted = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
-
+
+ /* FIXME: when can depend on moz >= 1.6, use CopyUTF8toUCS2 here */
*aDefaultString = ToNewUnicode (NS_ConvertUTF8toUCS2 (converted));
g_free (filename);
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index b8c0f1833..4be00f301 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -540,28 +540,46 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
static char*
GetFilePath (const char *filename)
{
- char *path, *download_dir, *expanded, *tmp;
+ char *path = NULL;
+ char *download_dir, *converted_dp, *expanded, *tmp;
download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
if (!download_dir)
{
/* Emergency download destination */
- download_dir = g_strdup (g_get_home_dir ());
+ /* FIXME !! prefs-dialog.c::get_download_button_label()
+ * claims that fallback for key == NULL is the
+ * downloads dir, not the home dir !
+ */
+ return g_build_filename (g_get_home_dir (), filename, NULL);
}
- else if (g_utf8_collate (download_dir, "Downloads") == 0)
+
+ if (g_utf8_collate (download_dir, "Downloads") == 0)
{
- tmp = ephy_file_downloads_dir ();
g_free (download_dir);
- download_dir = tmp;
- }
- expanded = gnome_vfs_expand_initial_tilde (download_dir);
- path = g_build_filename (expanded, filename, NULL);
- g_free (expanded);
+ return g_build_filename (ephy_file_downloads_dir (),
+ filename, NULL);
+ }
+ converted_dp = g_filename_from_utf8 (download_dir, -1, NULL, NULL, NULL);
g_free (download_dir);
+ if (converted_dp)
+ {
+ expanded = gnome_vfs_expand_initial_tilde (converted_dp);
+ path = g_build_filename (expanded, filename, NULL);
+
+ g_free (expanded);
+ g_free (converted_dp);
+ }
+ else
+ {
+ /* Fallback, see FIXME above too */
+ path = g_build_filename (g_get_home_dir (), filename, NULL);
+ }
+
return path;
}
diff --git a/lib/ephy-file-chooser.c b/lib/ephy-file-chooser.c
index 6a59bff5a..15e57b7b9 100644
--- a/lib/ephy-file-chooser.c
+++ b/lib/ephy-file-chooser.c
@@ -24,6 +24,7 @@
#endif
#include "ephy-file-chooser.h"
+#include "ephy-file-helpers.h"
#include "eel-gconf-extensions.h"
#include "ephy-state.h"
#include "ephy-debug.h"
@@ -132,22 +133,22 @@ ephy_file_chooser_set_persist_key (EphyFileChooser *dialog, const char *key)
converted = g_filename_from_utf8
(dir, -1, NULL, NULL, NULL);
- expanded = gnome_vfs_expand_initial_tilde (converted);
-
- if (expanded != NULL)
+ if (converted != NULL)
{
+ expanded = gnome_vfs_expand_initial_tilde (converted);
+
gtk_file_chooser_set_current_folder
(GTK_FILE_CHOOSER (dialog), expanded);
+
+ g_free (expanded);
+ g_free (converted);
}
- g_free (expanded);
- g_free (converted);
g_free (dir);
}
g_signal_connect (dialog, "current-folder-changed",
G_CALLBACK (current_folder_changed_cb), dialog);
-
}
const char *
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 1c316f8f4..dd69fdb60 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -66,12 +66,18 @@ char *
ephy_file_downloads_dir (void)
{
const char *translated_folder;
+ char *converted, *downloads_dir;
/* The name of the default downloads folder */
translated_folder = _("Downloads");
- return g_build_filename (g_get_home_dir (), "Desktop",
- translated_folder, NULL);
+ converted = g_filename_from_utf8 (translated_folder, -1, NULL,
+ NULL, NULL);
+ downloads_dir = g_build_filename (g_get_home_dir (), "Desktop",
+ converted, NULL);
+ g_free (converted);
+
+ return downloads_dir;
}
char *
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 8839e1935..6a2280b82 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -374,7 +374,7 @@ popup_cmd_set_image_as_background (GtkAction *action,
{
EphyEmbedEvent *info;
const char *location;
- char *dest, *base;
+ char *dest, *base, *base_converted;
const GValue *value;
EphyEmbedPersist *persist;
EphyEmbed *embed;
@@ -390,7 +390,8 @@ popup_cmd_set_image_as_background (GtkAction *action,
(ephy_embed_factory_new_object ("EphyEmbedPersist"));
base = g_path_get_basename (location);
- dest = g_build_filename (ephy_dot_dir (), base, NULL);
+ base_converted = g_filename_from_utf8 (base, -1, NULL, NULL, NULL);
+ dest = g_build_filename (ephy_dot_dir (), base_converted, NULL);
ephy_embed_persist_set_embed (persist, embed);
ephy_embed_persist_set_dest (persist, dest);
@@ -405,6 +406,7 @@ popup_cmd_set_image_as_background (GtkAction *action,
g_free (dest);
g_free (base);
+ g_free (base_converted);
}
void
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 762b29b46..9b0a228a4 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -1086,18 +1086,20 @@ create_language_section (EphyDialog *dialog)
static char*
get_download_button_label ()
{
- char *key, *label, *downloads_path;
+ char *key, *label, *downloads_path, *converted_dp;
key = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
+
downloads_path = ephy_file_downloads_dir ();
+ converted_dp = g_filename_to_utf8 (downloads_path, -1, NULL, NULL, NULL);
- /* fallback to default downloads directory */
- if (key == NULL)
+ if (key == NULL ||
+ g_utf8_collate (key, converted_dp) == 0 ||
+ g_utf8_collate (key, "Downloads") == 0)
{
- key = ephy_file_downloads_dir ();
+ label = g_strdup (_("Downloads"));
}
-
- if (g_utf8_collate (key, "~/Desktop") == 0)
+ else if (g_utf8_collate (key, "~/Desktop") == 0)
{
label = g_strdup (_("Desktop"));
}
@@ -1109,17 +1111,13 @@ get_download_button_label ()
* filechooser */
label = g_strdup (_("Home"));
}
- else if (g_utf8_collate (key, downloads_path) == 0 ||
- g_utf8_collate (key, "Downloads") == 0)
- {
- label = g_strdup (_("Downloads"));
- }
else
{
label = g_strdup (key);
}
g_free (downloads_path);
+ g_free (converted_dp);
g_free (key);
return label;
@@ -1296,7 +1294,7 @@ download_path_response_cb (GtkDialog *fc, gint response, EphyDialog *dialog)
char *label;
eel_gconf_set_path (CONF_STATE_DOWNLOAD_DIR, dir);
-
+
button = ephy_dialog_get_control (dialog, properties[DOWNLOAD_PATH_BUTTON_PROP].id);
label = get_download_button_label ();
ephy_ellipsizing_label_set_text ((EphyEllipsizingLabel*) GTK_BIN (button)->child,