static void async_get_favicon_cb (GObject *source, GAsyncResult *result, gpointer user_data) { GtkTreeIter iter; GtkTreePath *path; IconLoadData *data = (IconLoadData *) user_data; GdkPixbuf *favicon = webkit_favicon_database_get_favicon_pixbuf_finish (webkit_get_favicon_database (), result, NULL); if (favicon) { /* The completion model might have changed its contents */ if (gtk_tree_row_reference_valid (data->row_reference)) { path = gtk_tree_row_reference_get_path (data->row_reference); gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); gtk_tree_path_free (path); gtk_list_store_set (data->model, &iter, EPHY_HOSTS_STORE_COLUMN_FAVICON, favicon, -1); } g_object_unref (favicon); } g_object_unref (data->model); gtk_tree_row_reference_free (data->row_reference); g_slice_free (IconLoadData, data); }
static void icon_loaded_cb (GObject *source, GAsyncResult *result, gpointer user_data) { GtkTreeIter iter; GtkTreePath *path; IconLoadData *data = (IconLoadData *) user_data; WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source); GdkPixbuf *favicon = NULL; #ifdef HAVE_WEBKIT2 cairo_surface_t *icon_surface = webkit_favicon_database_get_favicon_finish (database, result, NULL); if (icon_surface) { favicon = ephy_pixbuf_get_from_surface_scaled (icon_surface, FAVICON_SIZE, FAVICON_SIZE); cairo_surface_destroy (icon_surface); } #else favicon = webkit_favicon_database_get_favicon_pixbuf_finish (database, result, NULL); #endif if (favicon) { /* The completion model might have changed its contents */ if (gtk_tree_row_reference_valid (data->row_reference)) { path = gtk_tree_row_reference_get_path (data->row_reference); gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model), &iter, path); gtk_list_store_set (data->model, &iter, EPHY_COMPLETION_FAVICON_COL, favicon, -1); g_object_unref (favicon); gtk_tree_path_free (path); } } g_object_unref (data->model); gtk_tree_row_reference_free (data->row_reference); g_slice_free (IconLoadData, data); }
static void faviconDatabaseGetInvalidFaviconCallback(GObject *sourceObject, GAsyncResult *result, void *userData) { gboolean *beenHere = (gboolean*)userData; GError *error = NULL; GdkPixbuf *icon = webkit_favicon_database_get_favicon_pixbuf_finish(WEBKIT_FAVICON_DATABASE(sourceObject), result, &error); g_assert(!icon); *beenHere = TRUE; g_main_loop_quit(loop); }
static void faviconDatabaseGetFaviconCancelledCallback(GObject *sourceObject, GAsyncResult *result, void *userData) { gboolean *beenHere = (gboolean*)userData; GError *error = NULL; GdkPixbuf *icon = webkit_favicon_database_get_favicon_pixbuf_finish(WEBKIT_FAVICON_DATABASE(sourceObject), result, &error); g_assert(!icon); g_assert(error && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)); *beenHere = TRUE; g_main_loop_quit(loop); }