From eb6b2cdb2e89e41759cf3b1cd136cfca42e6e42b Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 26 Oct 2003 10:45:56 +0000 Subject: Port to new gtk+ file chooser. 2003-10-26 Christian Persch Port to new gtk+ file chooser. * data/epiphany.schemas.in: * lib/ephy-prefs.h: Add key for remembering upload path. * embed /Makefile.am: * embed/downloader-view.c: * embed/ephy-embed-persist.c: (ephy_embed_persist_get_type), (ephy_embed_persist_set_dest), (ephy_embed_persist_set_embed), (ephy_embed_persist_set_fc_title), (ephy_embed_persist_set_fc_parent), (ephy_embed_persist_set_flags), (ephy_embed_persist_set_max_size), (ephy_embed_persist_set_persist_key), (ephy_embed_persist_set_source), (ephy_embed_persist_get_dest), (ephy_embed_persist_get_embed), (ephy_embed_persist_get_fc_title), (ephy_embed_persist_get_fc_parent), (ephy_embed_persist_get_flags), (ephy_embed_persist_get_max_size), (ephy_embed_persist_get_persist_key), (ephy_embed_persist_get_source), (ephy_embed_persist_set_property), (ephy_embed_persist_get_property), (ephy_embed_persist_init), (ephy_embed_persist_finalize), (ephy_embed_persist_class_init), (ephy_embed_persist_cancel), (ephy_embed_persist_save), (ephy_embed_persist_new): * embed/ephy-embed-persist.h: * embed/ephy-embed-popup-control.c: (save_url), (save_property_url), (background_download_completed), (embed_popup_set_image_as_background_cmd), (embed_popup_copy_image_location_cmd): * src/popup-commands.c: (save_property_url), (background_download_completed), (popup_cmd_set_image_as_background): * src/window-commands.c: (open_response_cb), (window_cmd_file_open), (window_cmd_file_save_as): * src/window-commands.h: * embed/ephy-favicon-cache.c: (ephy_favicon_cache_get_type), (ephy_favicon_cache_new), (icon_is_obsolete), (icons_added_cb), (remove_obsolete_icons), (ephy_favicon_cache_init), (favicon_download_completed_cb), (ephy_favicon_cache_download), (ephy_favicon_cache_get): * embed/mozilla/MozDownload.cpp: * embed/mozilla/EphyHeaderSniffer.cpp: * embed/mozilla/mozilla-embed-persist.cpp: * embed/mozilla/mozilla-embed-single.cpp: * src/popup-commands.c: (save_property_url), (background_download_completed), (popup_cmd_set_image_as_background): * src/window-commands.c: (open_response_cb), (window_cmd_file_open), (window_cmd_file_save_as): * src/window-commands.h: Simplify EphyEmbedPersist implementation. Augment it with properties for showing a file chooser to select persist destination. Port all callers to new interfaces. * embed/ephy-embed-single.c: (ephy_embed_single_remove_passwords): * embed/ephy-embed-single.h: * embed/ephy-embed-utils.c: * embed/ephy-embed-utils.h: Obsolete and removed. * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: Misc cleanups. * embed/mozilla/FilePicker.cpp: * embed/mozilla/FilePicker.h: Port to new file chooser class. * embed/mozilla/Makefile.am: * lib/Makefile.am: * lib/ephy-file-chooser.c: (ephy_file_chooser_get_type), (current_folder_changed_cb), (ephy_file_chooser_init), (ephy_file_chooser_finalize), (ephy_file_chooser_set_persist_key), (ephy_file_chooser_set_property), (ephy_file_chooser_get_property), (ephy_file_chooser_class_init), (ephy_file_chooser_new): * lib/ephy-file-chooser.h: * src/bookmarks/ephy-bookmarks-editor.c: (import_from_file_response_cb), (import_dialog_response_cb): New file chooser wrapper class; ported file chooser callers to it. --- embed/ephy-favicon-cache.c | 67 +++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 37 deletions(-) (limited to 'embed/ephy-favicon-cache.c') diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c index da598a9e2..f0c3a0022 100644 --- a/embed/ephy-favicon-cache.c +++ b/embed/ephy-favicon-cache.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2002 Jorn Baayen + * Copyright (C) 2003 Marco Pesenti Gritti * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,8 +85,8 @@ ephy_favicon_cache_get_type (void) }; ephy_favicon_cache_type = g_type_register_static (G_TYPE_OBJECT, - "EphyFaviconCache", - &our_info, 0); + "EphyFaviconCache", + &our_info, 0); } return ephy_favicon_cache_type; @@ -117,11 +118,7 @@ ephy_favicon_cache_class_init (EphyFaviconCacheClass *klass) EphyFaviconCache * ephy_favicon_cache_new (void) { - EphyFaviconCache *cache; - - cache = EPHY_FAVICON_CACHE (g_object_new (EPHY_TYPE_FAVICON_CACHE, NULL)); - - return cache; + return EPHY_FAVICON_CACHE (g_object_new (EPHY_TYPE_FAVICON_CACHE, NULL)); } static gboolean @@ -133,8 +130,8 @@ icon_is_obsolete (EphyNode *node, GDate *now) last_visit = ephy_node_get_property_int (node, EPHY_NODE_FAVICON_PROP_LAST_USED); - g_date_clear (&date, 1); - g_date_set_time (&date, last_visit); + g_date_clear (&date, 1); + g_date_set_time (&date, last_visit); return (g_date_days_between (&date, now) >= EPHY_FAVICON_CACHE_OBSOLETE_DAYS); @@ -142,8 +139,8 @@ icon_is_obsolete (EphyNode *node, GDate *now) static void icons_added_cb (EphyNode *node, - EphyNode *child, - EphyFaviconCache *eb) + EphyNode *child, + EphyFaviconCache *eb) { g_static_rw_lock_writer_lock (eb->priv->icons_hash_lock); @@ -176,8 +173,8 @@ remove_obsolete_icons (EphyFaviconCache *eb) GDate current_date; now = time (NULL); - g_date_clear (¤t_date, 1); - g_date_set_time (¤t_date, time (NULL)); + g_date_clear (¤t_date, 1); + g_date_set_time (¤t_date, time (NULL)); children = ephy_node_get_children (eb->priv->icons); ephy_node_thaw (eb->priv->icons); @@ -245,8 +242,8 @@ ephy_favicon_cache_init (EphyFaviconCache *cache) cache->priv->db = db; cache->priv->xml_file = g_build_filename (ephy_dot_dir (), - "ephy-favicon-cache.xml", - NULL); + "ephy-favicon-cache.xml", + NULL); cache->priv->directory = g_build_filename (ephy_dot_dir (), "favicon_cache/", @@ -261,11 +258,11 @@ ephy_favicon_cache_init (EphyFaviconCache *cache) } cache->priv->icons_hash = g_hash_table_new (g_str_hash, - g_str_equal); + g_str_equal); cache->priv->icons_hash_lock = g_new0 (GStaticRWLock, 1); g_static_rw_lock_init (cache->priv->icons_hash_lock); cache->priv->downloads_hash = g_hash_table_new_full (g_str_hash, - g_str_equal, + g_str_equal, g_free, NULL); @@ -273,13 +270,13 @@ ephy_favicon_cache_init (EphyFaviconCache *cache) cache->priv->icons = ephy_node_new_with_id (db, ICONS_NODE_ID); ephy_node_ref (cache->priv->icons); ephy_node_signal_connect_object (cache->priv->icons, - EPHY_NODE_CHILD_ADDED, - (EphyNodeCallback) icons_added_cb, - G_OBJECT (cache)); + EPHY_NODE_CHILD_ADDED, + (EphyNodeCallback) icons_added_cb, + G_OBJECT (cache)); ephy_node_signal_connect_object (cache->priv->icons, - EPHY_NODE_CHILD_REMOVED, - (EphyNodeCallback) icons_removed_cb, - G_OBJECT (cache)); + EPHY_NODE_CHILD_REMOVED, + (EphyNodeCallback) icons_removed_cb, + G_OBJECT (cache)); ephy_node_db_load_from_file (cache->priv->db, cache->priv->xml_file, EPHY_FAVICON_CACHE_XML_ROOT, @@ -356,17 +353,16 @@ static void favicon_download_completed_cb (EphyEmbedPersist *persist, EphyFaviconCache *cache) { - char *url; + const char *url; - url = g_strdup ((char *) g_object_get_data (G_OBJECT (persist), "url")); + url = ephy_embed_persist_get_source (persist); g_return_if_fail (url != NULL); g_hash_table_remove (cache->priv->downloads_hash, url); - g_object_unref (persist); g_signal_emit (G_OBJECT (cache), ephy_favicon_cache_signals[CHANGED], 0, url); - g_free (url); + g_object_unref (persist); } static void @@ -387,17 +383,14 @@ ephy_favicon_cache_download (EphyFaviconCache *cache, persist = ephy_embed_persist_new (NULL); + ephy_embed_persist_set_dest (persist, dest); + ephy_embed_persist_set_flags + (persist, EMBED_PERSIST_BYPASSCACHE | EMBED_PERSIST_NO_VIEW); ephy_embed_persist_set_max_size (persist, 100); - ephy_embed_persist_set_flags (persist, EMBED_PERSIST_BYPASSCACHE | - EMBED_PERSIST_NO_VIEW); - ephy_embed_persist_set_source (persist, favicon_url); - ephy_embed_persist_set_dest (persist, dest); + ephy_embed_persist_set_source (persist, favicon_url); g_free (dest); - g_object_set_data_full (G_OBJECT (persist), "url", - g_strdup (favicon_url), g_free); - g_signal_connect (G_OBJECT (persist), "completed", G_CALLBACK (favicon_download_completed_cb), @@ -437,13 +430,13 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, url); ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_URL, - &value); + &value); g_value_unset (&value); g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, filename); ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_FILENAME, - &value); + &value); g_value_unset (&value); ephy_node_add_child (cache->priv->icons, icon); @@ -456,7 +449,7 @@ ephy_favicon_cache_get (EphyFaviconCache *cache, g_value_init (&value, G_TYPE_INT); g_value_set_int (&value, now); ephy_node_set_property (icon, EPHY_NODE_FAVICON_PROP_LAST_USED, - &value); + &value); g_value_unset (&value); if (g_hash_table_lookup (cache->priv->downloads_hash, url) != NULL) -- cgit v1.2.3