コード例 #1
0
ファイル: ephy-download-test.c プロジェクト: jdapena/epiphany
static void
fixture_setup (Fixture *fixture, gconstpointer data)
{
  char *tmp_filename;
  char *dest_file;

  tmp_filename = ephy_file_tmp_filename ("ephy-download-XXXXXX", NULL);
  dest_file = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL);

  fixture->source = get_uri_for_path ("/default");
  fixture->download = ephy_download_new_for_uri (fixture->source);
  fixture->destination = g_filename_to_uri (dest_file, NULL, NULL);
  fixture->loop = g_main_loop_new (NULL, TRUE);

  ephy_download_set_destination_uri (fixture->download, fixture->destination);

  g_free (tmp_filename);
  g_free (dest_file);
}
コード例 #2
0
static void
ephy_greasemonkey_extension_install_cb (GtkAction *action,
					EphyWindow *window)
{
	EphyEmbed *embed;
	EphyDownload *download;
	WindowData *data;
	const char *url;
	char *filename;

	data = (WindowData *) g_object_get_data (G_OBJECT (window),
						 WINDOW_DATA_KEY);
	g_return_if_fail (data != NULL);

	url = data->last_clicked_url;
	g_return_if_fail (url != NULL);

	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
	g_return_if_fail (embed != NULL);

	LOG ("Installing script at '%s'", url);

	download = ephy_download_new_for_uri (url);

	filename = script_name_build (url);
	ephy_download_set_destination_uri (download, filename);
	g_free (filename);

	g_signal_connect (download, "completed",
			  G_CALLBACK (save_source_completed_cb), window);
	g_signal_connect (download, "error",
			  G_CALLBACK (save_source_error_cb), window);

	data->pending_downloads = g_list_prepend (data->pending_downloads,
						  download);

	ephy_download_start (download);
}