Move midori_view_get_memory into WebKit guards

This commit is contained in:
Christian Dywan 2012-09-05 18:21:53 +02:00
parent 3717185834
commit a6744f64ee

View file

@ -130,7 +130,6 @@ struct _MidoriView
KatzeItem* item; KatzeItem* item;
gint scrollh, scrollv; gint scrollh, scrollv;
gboolean back_forward_set; gboolean back_forward_set;
GHashTable* memory;
GtkWidget* scrolled_window; GtkWidget* scrolled_window;
#if GTK_CHECK_VERSION (3, 2, 0) #if GTK_CHECK_VERSION (3, 2, 0)
@ -758,6 +757,23 @@ midori_view_unset_icon (MidoriView* view)
} }
#if !WEBKIT_CHECK_VERSION (1, 8, 0) #if !WEBKIT_CHECK_VERSION (1, 8, 0)
static void
katze_net_object_maybe_unref (gpointer object)
{
if (object)
g_object_unref (object);
}
static GHashTable*
midori_view_get_memory (void)
{
static GHashTable* memory = NULL;
if (!memory)
memory = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, katze_net_object_maybe_unref);
return (memory);
}
static gboolean static gboolean
katze_net_icon_status_cb (KatzeNetRequest* request, katze_net_icon_status_cb (KatzeNetRequest* request,
MidoriView* view) MidoriView* view)
@ -819,7 +835,7 @@ katze_net_icon_transfer_cb (KatzeNetRequest* request,
return; return;
} }
g_hash_table_insert (view->memory, g_strdup (view->icon_uri), pixbuf); g_hash_table_insert (midori_view_get_memory (), g_strdup (view->icon_uri), pixbuf);
settings = gtk_widget_get_settings (view->web_view); settings = gtk_widget_get_settings (view->web_view);
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &icon_width, &icon_height); gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height, GDK_INTERP_BILINEAR); pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height, GDK_INTERP_BILINEAR);
@ -865,7 +881,7 @@ _midori_web_view_load_icon (MidoriView* view)
view->icon_uri = g_strdup_printf ("%s/favicon.ico", view->uri); view->icon_uri = g_strdup_printf ("%s/favicon.ico", view->uri);
} }
if (g_hash_table_lookup_extended (view->memory, if (g_hash_table_lookup_extended (midori_view_get_memory (),
view->icon_uri, NULL, (gpointer)&pixbuf)) view->icon_uri, NULL, (gpointer)&pixbuf))
{ {
g_warn_if_fail (pixbuf != NULL); g_warn_if_fail (pixbuf != NULL);
@ -874,7 +890,7 @@ _midori_web_view_load_icon (MidoriView* view)
else if ((icon_file = katze_net_get_cached_path (NULL, view->icon_uri, "icons")) && else if ((icon_file = katze_net_get_cached_path (NULL, view->icon_uri, "icons")) &&
(pixbuf = gdk_pixbuf_new_from_file (icon_file, NULL))) (pixbuf = gdk_pixbuf_new_from_file (icon_file, NULL)))
{ {
g_hash_table_insert (view->memory, g_hash_table_insert (midori_view_get_memory (),
g_strdup (view->icon_uri), g_object_ref (pixbuf)); g_strdup (view->icon_uri), g_object_ref (pixbuf));
} }
else if (!view->special) else if (!view->special)
@ -3427,23 +3443,6 @@ midori_view_notify_vadjustment_cb (MidoriView* view,
G_CALLBACK (midori_view_vadjustment_notify_value_cb), view); G_CALLBACK (midori_view_vadjustment_notify_value_cb), view);
} }
static void
katze_net_object_maybe_unref (gpointer object)
{
if (object)
g_object_unref (object);
}
static GHashTable* midori_view_get_memory (void)
{
static GHashTable* memory = NULL;
if (!memory)
memory = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, katze_net_object_maybe_unref);
return g_hash_table_ref (memory);
}
static void static void
midori_view_init (MidoriView* view) midori_view_init (MidoriView* view)
{ {
@ -3453,7 +3452,6 @@ midori_view_init (MidoriView* view)
view->mime_type = NULL; view->mime_type = NULL;
view->icon = NULL; view->icon = NULL;
view->icon_uri = NULL; view->icon_uri = NULL;
view->memory = midori_view_get_memory ();
view->progress = 0.0; view->progress = 0.0;
view->load_status = MIDORI_LOAD_FINISHED; view->load_status = MIDORI_LOAD_FINISHED;
view->minimized = FALSE; view->minimized = FALSE;
@ -3534,12 +3532,6 @@ midori_view_finalize (GObject* object)
katze_object_assign (view->icon, NULL); katze_object_assign (view->icon, NULL);
katze_assign (view->icon_uri, NULL); katze_assign (view->icon_uri, NULL);
if (view->memory)
{
g_hash_table_unref (view->memory);
view->memory = NULL;
}
katze_assign (view->statusbar_text, NULL); katze_assign (view->statusbar_text, NULL);
katze_assign (view->link_uri, NULL); katze_assign (view->link_uri, NULL);
katze_assign (view->selected_text, NULL); katze_assign (view->selected_text, NULL);