void getFaviconForPageURIAndWaitUntilReady(const char* pageURI) { if (m_favicon) { cairo_surface_destroy(m_favicon); m_favicon = 0; } WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); webkit_favicon_database_get_favicon(database, pageURI, 0, getFaviconCallback, this); g_main_loop_run(m_mainLoop); }
static void set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row) { GtkTreeIter iter; GtkTreePath *path; IconLoadData *data; WebKitFaviconDatabase* database; #ifndef HAVE_WEBKIT2 GdkPixbuf *favicon; database = webkit_get_favicon_database (); #else database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ()); #endif gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, position, EPHY_COMPLETION_TEXT_COL, row->title ? row->title : "", EPHY_COMPLETION_URL_COL, row->location, EPHY_COMPLETION_ACTION_COL, row->location, EPHY_COMPLETION_KEYWORDS_COL, row->keywords ? row->keywords : "", EPHY_COMPLETION_EXTRA_COL, row->is_bookmark, EPHY_COMPLETION_RELEVANCE_COL, row->relevance, -1); #ifndef HAVE_WEBKIT2 /* We try first with the try_get_favicon_pixbuf() because if the icon is in the DB it's faster than the async version. */ favicon = webkit_favicon_database_try_get_favicon_pixbuf (database, row->location, FAVICON_SIZE, FAVICON_SIZE); if (favicon) { gtk_list_store_set (GTK_LIST_STORE (model), &iter, EPHY_COMPLETION_FAVICON_COL, favicon, -1); g_object_unref (favicon); return; } #endif data = g_slice_new (IconLoadData); data->model = GTK_LIST_STORE (g_object_ref(model)); path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter); data->row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), path); gtk_tree_path_free (path); #ifdef HAVE_WEBKIT2 webkit_favicon_database_get_favicon (database, row->location, NULL, icon_loaded_cb, data); #else webkit_favicon_database_get_favicon_pixbuf (database, row->location, FAVICON_SIZE, FAVICON_SIZE, NULL, icon_loaded_cb, data); #endif }
static void icon_changed_cb (WebKitFaviconDatabase *database, const char *page_uri, #ifdef HAVE_WEBKIT2 const char *favicon_uri, #endif GtkTreeModel *model) { GtkTreeIter iter; int cmp; char *host_address; gboolean done, valid; SoupURI *uri; valid = gtk_tree_model_get_iter_first (model, &iter); /* If the page_uri has a path, this icon is not for a host, so it can be skipped. */ uri = soup_uri_new (page_uri); done = strcmp (soup_uri_get_path (uri), "/") != 0; soup_uri_free (uri); while (valid && !done) { gtk_tree_model_get (model, &iter, EPHY_HOSTS_STORE_COLUMN_ADDRESS, &host_address, -1); cmp = g_strcmp0 (host_address, page_uri); g_free (host_address); if (cmp == 0) { #ifdef HAVE_WEBKIT2 IconLoadData *data; GtkTreePath *path; data = g_slice_new (IconLoadData); data->model = GTK_LIST_STORE (g_object_ref (model)); path = gtk_tree_model_get_path (model, &iter); data->row_reference = gtk_tree_row_reference_new (model, path); gtk_tree_path_free (path); webkit_favicon_database_get_favicon (database, page_uri, 0, async_update_favicon_icon, data); #else GdkPixbuf *favicon = webkit_favicon_database_try_get_favicon_pixbuf (database, page_uri, FAVICON_SIZE, FAVICON_SIZE); if (favicon) { gtk_list_store_set (GTK_LIST_STORE (model), &iter, EPHY_HOSTS_STORE_COLUMN_FAVICON, favicon, -1); g_object_unref (favicon); } #endif } valid = gtk_tree_model_iter_next (model, &iter); /* Since the list is sorted alphanumerically, if the result of the comparison is > 0, there is no point in searching any further. */ done = cmp >= 0; } }
void ephy_hosts_store_add_hosts (EphyHostsStore *store, GList *hosts) { EphyHistoryHost *host; GtkTreeIter treeiter; GtkTreePath *path; GList *iter; GdkPixbuf *favicon; IconLoadData *data; WebKitFaviconDatabase *database; #ifdef HAVE_WEBKIT2 database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ()); #else database = webkit_get_favicon_database (); #endif for (iter = hosts; iter != NULL; iter = iter->next) { host = (EphyHistoryHost *)iter->data; #ifdef HAVE_WEBKIT2 /* Flag favicon to NULL to reuse some code later on */ favicon = NULL; #else favicon = webkit_favicon_database_try_get_favicon_pixbuf (database, host->url, FAVICON_SIZE, FAVICON_SIZE); #endif gtk_list_store_insert_with_values (GTK_LIST_STORE (store), &treeiter, G_MAXINT, EPHY_HOSTS_STORE_COLUMN_ID, host->id, EPHY_HOSTS_STORE_COLUMN_TITLE, host->title, EPHY_HOSTS_STORE_COLUMN_ADDRESS, host->url, EPHY_HOSTS_STORE_COLUMN_VISIT_COUNT, host->visit_count, #ifndef HAVE_WEBKIT2 EPHY_HOSTS_STORE_COLUMN_FAVICON, favicon, #endif -1); if (favicon) g_object_unref (favicon); else { data = g_slice_new (IconLoadData); data->model = GTK_LIST_STORE (g_object_ref (store)); path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &treeiter); data->row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path); gtk_tree_path_free (path); #ifdef HAVE_WEBKIT2 webkit_favicon_database_get_favicon (database, host->url, NULL, async_update_favicon_icon, data); #else webkit_favicon_database_get_favicon_pixbuf (database, host->url, FAVICON_SIZE, FAVICON_SIZE, NULL, async_update_favicon_icon, data); #endif } } }