[Kazehakase-cvs] CVS update: kazehakase/src

Back to archive index

Kouhei Sutou kous****@users*****
Wed Oct 18 13:24:02 JST 2006


Index: kazehakase/src/kz-favicon.c
diff -u kazehakase/src/kz-favicon.c:1.36 kazehakase/src/kz-favicon.c:1.37
--- kazehakase/src/kz-favicon.c:1.36	Mon Oct 16 00:17:16 2006
+++ kazehakase/src/kz-favicon.c	Wed Oct 18 13:24:01 2006
@@ -30,6 +30,7 @@
 #include "kz-downloader.h"
 #include "utils.h"
 #include "glib-utils.h"
+#include <glib/gstdio.h>
 
 typedef struct _KzFaviconPrivate	KzFaviconPrivate;
 struct _KzFaviconPrivate
@@ -69,6 +70,9 @@
 static void cb_downloader_load_error    (KzDownloader *dl,
 					 downloader_info_t *info);
 
+static const gchar *kz_favicon_get_favicon_file_name (KzFavicon *kzfav,
+						      const gchar *uri);
+
 static GObjectClass *parent_class     = NULL;
 static KzFavicon    *kzfavicon_single = NULL;
 
@@ -316,13 +320,34 @@
 	return icon;
 }
 
+static const gchar *
+kz_favicon_get_favicon_file_name (KzFavicon *kzfav, const gchar *uri)
+{
+	KzFaviconPrivate *priv = KZ_FAVICON_GET_PRIVATE (kzfav);
+	gchar *hash_key;
+	const gchar *favicon_file_name;
+
+	if (!priv) return NULL;
+
+	hash_key = create_profile_key_from_uri(uri);
+	favicon_file_name = g_hash_table_lookup(priv->uri_hash, hash_key);
+	g_free(hash_key);
+
+	return favicon_file_name;
+}
+
+gboolean
+kz_favicon_is_loaded (KzFavicon *kzfav, const gchar *uri)
+{
+	return kz_favicon_get_favicon_file_name(kzfav, uri) ? TRUE : FALSE;
+}
+
 GdkPixbuf *
 kz_favicon_get_pixbuf (KzFavicon *kzfav, const gchar *uri, GtkIconSize size)
 {
 	GdkPixbuf *icon = NULL;
 	GdkPixbuf *pixbuf;
 	const gchar *favicon_file_name;
-	gchar *hash_key;
 	gint width, height;
 	KzFaviconPrivate *priv = KZ_FAVICON_GET_PRIVATE (kzfav);
 
@@ -331,10 +356,7 @@
 	if (uri == NULL)
 		return NULL;
 
-	hash_key = create_profile_key_from_uri(uri);
-	favicon_file_name = g_hash_table_lookup(priv->uri_hash, hash_key);
-	g_free(hash_key);
-
+	favicon_file_name = kz_favicon_get_favicon_file_name(kzfav, uri);
 	if (!favicon_file_name)
 		return NULL;
 
@@ -366,7 +388,6 @@
 {
 	gchar *favicon_filename;
 	gchar *favicon_file_location;
-	gchar *hash_key;
 	const gchar *old_value;
 	KzDownloader *dl;
 	KzFaviconPrivate *priv;
@@ -375,7 +396,6 @@
 	priv = KZ_FAVICON_GET_PRIVATE (kzfav);
 
 	if (!uri) return;
-	hash_key = create_profile_key_from_uri(document_uri);
 
 	favicon_filename = create_filename_from_uri(uri);
 	favicon_file_location = g_build_filename(g_get_home_dir(),
@@ -385,9 +405,7 @@
 					    	 NULL);
 	g_free(favicon_filename);
 	
-	old_value = g_hash_table_lookup(priv->uri_hash,
-					hash_key);
-	
+	old_value = kz_favicon_get_favicon_file_name(kzfav, document_uri);
 	if (old_value && !strcmp(old_value, favicon_file_location))
 	{
 		GQuark quark;
@@ -397,13 +415,12 @@
 			      kz_favicon_signals[READY_SIGNAL],
 			      quark,
 			      document_uri);
-		g_free(hash_key);
 		g_free(favicon_file_location);
 		return;
 	}
 
 	g_hash_table_insert(priv->uri_hash,
-			    g_strdup(hash_key),
+			    create_profile_key_from_uri(document_uri),
 			    g_strdup(favicon_file_location));
 
 	/* start download */
@@ -423,7 +440,6 @@
 		kz_downloader_to_buffer(dl);
 	}
 
-	g_free(hash_key);
 	g_free(favicon_file_location);
 }
 
Index: kazehakase/src/kz-favicon.h
diff -u kazehakase/src/kz-favicon.h:1.9 kazehakase/src/kz-favicon.h:1.10
--- kazehakase/src/kz-favicon.h:1.9	Tue Sep  6 12:30:19 2005
+++ kazehakase/src/kz-favicon.h	Wed Oct 18 13:24:01 2006
@@ -60,6 +60,9 @@
 				     const gchar *uri,
 				     GtkIconSize size);
 
+gboolean   kz_favicon_is_loaded     (KzFavicon *kzfav,
+				     const gchar *uri);
+
 void       kz_favicon_get_icon_from_uri (KzFavicon *kzfav, 
 					 const gchar *uri,
 					 const gchar *document_uri);


More information about the Kazehakase-cvs mailing list
Back to archive index