예제 #1
0
static void
ephy_download_set_property (GObject      *object,
                            guint         property_id,
                            const GValue *value,
                            GParamSpec   *pspec)
{
  EphyDownload *download;
  download = EPHY_DOWNLOAD (object);

  switch (property_id) {
    case PROP_DESTINATION:
      ephy_download_set_destination_uri (download, g_value_get_string (value));
      break;
    case PROP_ACTION:
      ephy_download_set_action (download, g_value_get_enum (value));
      break;
    case PROP_WINDOW:
      ephy_download_set_window (download, g_value_get_object (value));
      break;
    case PROP_WIDGET:
      ephy_download_set_widget (download, g_value_get_object (value));
      break;
    case PROP_DOWNLOAD:
    case PROP_SOURCE:
    case PROP_START_TIME:
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }
}
예제 #2
0
static void
download_created_destination_cb (WebKitDownload *wk_download,
                                 const gchar *destination,
                                 EphyDownload *download)
{
  if (download->priv->destination)
    return;

  ephy_download_set_destination_uri (download, destination);
}
예제 #3
0
/**
 * ephy_download_set_auto_destination:
 * @download: an #EphyDownload
 *
 * Tells @download to automatically determine a destination for itself.
 **/
void
ephy_download_set_auto_destination (EphyDownload *download)
{
#ifdef HAVE_WEBKIT2
  /* In WebKit2 priv->destination == NULL means auto_destination */
#else
  char *dest;

  g_return_if_fail (EPHY_IS_DOWNLOAD (download));

  dest = define_destination_uri (download,
                                 webkit_download_get_suggested_filename (download->priv->download));
  ephy_download_set_destination_uri (download, dest);

  g_free (dest);
#endif
}
예제 #4
0
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);
}
예제 #5
0
static gboolean
download_decide_destination_cb (WebKitDownload *wk_download,
                                const gchar *suggested_filename,
                                EphyDownload *download)
{
  char *dest;

  if (download->priv->destination) {
    webkit_download_set_destination (wk_download, download->priv->destination);
    return TRUE;
  }

  dest = define_destination_uri (download, suggested_filename);
  if (!dest)
    return FALSE;

  ephy_download_set_destination_uri (download, dest);
  webkit_download_set_destination (wk_download, dest);
  g_free (dest);

  return TRUE;
}
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);
}