comparison gtk/gtkprefs.c @ 14354:01daacf7b771

[gaim-migrate @ 17060] Make gaim_url_fetch() cancelable and change Yahoo! to take advantage of the changes. Other stuff can be changed later, the important thing is that the API is there. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 27 Aug 2006 21:13:30 +0000
parents ab8a105eff62
children 333989477bcd
comparison
equal deleted inserted replaced
14353:33dc9f22b528 14354:01daacf7b771
524 if (theme_rowref != NULL) 524 if (theme_rowref != NULL)
525 gtk_tree_row_reference_free(theme_rowref); 525 gtk_tree_row_reference_free(theme_rowref);
526 } 526 }
527 527
528 static void 528 static void
529 theme_got_url(void *data, const char *themedata, size_t len) 529 theme_got_url(GaimUtilFetchUrlData *url_data, gpointer user_data,
530 const gchar *themedata, size_t len, const gchar *error_message)
530 { 531 {
531 FILE *f; 532 FILE *f;
532 gchar *path; 533 gchar *path;
533 534
534 if (len == 0) 535 if ((error_message != NULL) || (len == 0))
535 return; 536 return;
536 537
537 f = gaim_mkstemp(&path, TRUE); 538 f = gaim_mkstemp(&path, TRUE);
538 fwrite(themedata, len, 1, f); 539 fwrite(themedata, len, 1, f);
539 fclose(f); 540 fclose(f);
540 541
541 theme_install_theme(path, data); 542 theme_install_theme(path, user_data);
542 543
543 g_unlink(path); 544 g_unlink(path);
544 g_free(path); 545 g_free(path);
545 } 546 }
546 547
547 static void theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, 548 static void
548 guint info, guint t, gpointer data) { 549 theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
550 GtkSelectionData *sd, guint info, guint t, gpointer data)
551 {
549 gchar *name = (gchar *)sd->data; 552 gchar *name = (gchar *)sd->data;
550 553
551 if ((sd->length >= 0) && (sd->format == 8)) { 554 if ((sd->length >= 0) && (sd->format == 8)) {
552 /* Well, it looks like the drag event was cool. 555 /* Well, it looks like the drag event was cool.
553 * Let's do something with it */ 556 * Let's do something with it */
566 theme_install_theme(tmp, NULL); 569 theme_install_theme(tmp, NULL);
567 g_free(tmp); 570 g_free(tmp);
568 } else if (!g_ascii_strncasecmp(name, "http://", 7)) { 571 } else if (!g_ascii_strncasecmp(name, "http://", 7)) {
569 /* Oo, a web drag and drop. This is where things 572 /* Oo, a web drag and drop. This is where things
570 * will start to get interesting */ 573 * will start to get interesting */
571 gaim_url_fetch(name, TRUE, NULL, FALSE, theme_got_url, ".tgz"); 574 gaim_util_fetch_url(name, TRUE, NULL, FALSE, theme_got_url, ".tgz");
572 } else if (!g_ascii_strncasecmp(name, "https://", 8)) { 575 } else if (!g_ascii_strncasecmp(name, "https://", 8)) {
573 /* gaim_url_fetch() doesn't support HTTPS, but we want users 576 /* gaim_util_fetch_url() doesn't support HTTPS, but we want users
574 * to be able to drag and drop links from the SF trackers, so 577 * to be able to drag and drop links from the SF trackers, so
575 * we'll try it as an HTTP URL. */ 578 * we'll try it as an HTTP URL. */
576 char *tmp = g_strdup(name + 1); 579 char *tmp = g_strdup(name + 1);
577 tmp[0] = 'h'; 580 tmp[0] = 'h';
578 tmp[1] = 't'; 581 tmp[1] = 't';
579 tmp[2] = 't'; 582 tmp[2] = 't';
580 tmp[3] = 'p'; 583 tmp[3] = 'p';
581 gaim_url_fetch(tmp, TRUE, NULL, FALSE, theme_got_url, ".tgz"); 584 gaim_util_fetch_url(tmp, TRUE, NULL, FALSE, theme_got_url, ".tgz");
582 g_free(tmp); 585 g_free(tmp);
583 } 586 }
584 587
585 gtk_drag_finish(dc, TRUE, FALSE, t); 588 gtk_drag_finish(dc, TRUE, FALSE, t);
586 } 589 }