static void getFaviconCallback(GObject* sourceObject, GAsyncResult* result, void* data) { FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data); WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); test->m_favicon = webkit_favicon_database_get_favicon_finish(database, result, &test->m_error.outPtr()); test->quitMainLoop(); }
static void ephy_hosts_store_init (EphyHostsStore *self) { GType types[EPHY_HOSTS_STORE_N_COLUMNS]; types[EPHY_HOSTS_STORE_COLUMN_ID] = G_TYPE_INT; types[EPHY_HOSTS_STORE_COLUMN_TITLE] = G_TYPE_STRING; types[EPHY_HOSTS_STORE_COLUMN_ADDRESS] = G_TYPE_STRING; types[EPHY_HOSTS_STORE_COLUMN_VISIT_COUNT] = G_TYPE_INT; types[EPHY_HOSTS_STORE_COLUMN_FAVICON] = GDK_TYPE_PIXBUF; gtk_list_store_set_column_types (GTK_LIST_STORE (self), EPHY_HOSTS_STORE_N_COLUMNS, types); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self), EPHY_HOSTS_STORE_COLUMN_ADDRESS, GTK_SORT_ASCENDING); #ifdef HAVE_WEBKIT2 g_signal_connect (webkit_web_context_get_favicon_database (webkit_web_context_get_default ()), "favicon-changed", G_CALLBACK (icon_changed_cb), self); #else g_signal_connect (webkit_get_favicon_database (), "icon-loaded", G_CALLBACK (icon_changed_cb), self); #endif }
~FaviconDatabaseTest() { if (m_favicon) cairo_surface_destroy(m_favicon); WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); g_signal_handlers_disconnect_matched(database, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); }
FaviconDatabaseTest() : m_webContext(webkit_web_context_get_default()) , m_favicon(0) , m_faviconNotificationReceived(false) { WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); g_signal_connect(database, "favicon-changed", G_CALLBACK(faviconChangedCallback), this); }
static void testGetFaviconURI(FaviconDatabaseTest* test) { WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); CString baseURI = kServer->getURIForPath("/foo"); GUniquePtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, baseURI.data())); ASSERT_CMP_CSTRING(iconURI.get(), ==, kServer->getURIForPath("/icon/favicon.ico")); }
static void testClearDatabase(FaviconDatabaseTest* test) { WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); webkit_favicon_database_clear(database); GUniquePtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, kServer->getURIForPath("/foo").data())); g_assert(!iconURI); }
void afterAll() { delete kServer; // Delete the temporary files after the IconDatabase has been // closed, that is, once WebKitFaviconDatabase is being destroyed. WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(webkit_web_context_get_default()); g_object_weak_ref(G_OBJECT(database), webkitFaviconDatabaseFinalizedCallback, 0); }
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 ephy_hosts_store_finalize (GObject *object) { EphyHostsStore *store = EPHY_HOSTS_STORE (object); WebKitFaviconDatabase *database; #ifdef HAVE_WEBKIT2 database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ()); #else database = webkit_get_favicon_database (); #endif g_signal_handlers_disconnect_by_func (database, icon_changed_cb, store); G_OBJECT_CLASS (ephy_hosts_store_parent_class)->finalize (object); }
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 } } }