| 606 |
606 |
| 607 static void |
607 static void |
| 608 do_insert_image_cb(GtkWidget *widget, int response, PidginWebViewToolbar *toolbar) |
608 do_insert_image_cb(GtkWidget *widget, int response, PidginWebViewToolbar *toolbar) |
| 609 { |
609 { |
| 610 PidginWebViewToolbarPriv *priv = PIDGIN_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar); |
610 PidginWebViewToolbarPriv *priv = PIDGIN_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar); |
| 611 gchar *filename = NULL, *buf; |
611 gchar *filename = NULL; |
| 612 char *filedata; |
|
| 613 size_t size; |
|
| 614 GError *error = NULL; |
|
| 615 PurpleImage *img; |
612 PurpleImage *img; |
| 616 |
613 |
| 617 if (response == GTK_RESPONSE_ACCEPT) |
614 if (response == GTK_RESPONSE_ACCEPT) |
| 618 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
615 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
| 619 |
616 |
| 621 gtk_action_activate(priv->image); |
618 gtk_action_activate(priv->image); |
| 622 |
619 |
| 623 if (filename == NULL) |
620 if (filename == NULL) |
| 624 return; |
621 return; |
| 625 |
622 |
| 626 if (!g_file_get_contents(filename, &filedata, &size, &error)) { |
623 img = purple_image_new_from_file(filename, TRUE); |
| 627 purple_notify_error(NULL, NULL, error->message, NULL, NULL); |
|
| 628 |
|
| 629 g_error_free(error); |
|
| 630 g_free(filename); |
|
| 631 |
|
| 632 return; |
|
| 633 } |
|
| 634 |
|
| 635 img = purple_image_new_from_data(filedata, size); |
|
| 636 purple_image_set_friendly_filename(img, filename); |
|
| 637 |
624 |
| 638 if (!img) { |
625 if (!img) { |
| 639 buf = g_strdup_printf(_("Failed to store image: %s\n"), filename); |
626 gchar *buf = g_strdup_printf(_("Failed to store image: %s"), |
| |
627 filename); |
| |
628 |
| 640 purple_notify_error(NULL, NULL, buf, NULL, NULL); |
629 purple_notify_error(NULL, NULL, buf, NULL, NULL); |
| 641 |
630 |
| 642 g_free(buf); |
631 g_free(buf); |
| 643 g_free(filename); |
632 g_free(filename); |
| 644 |
633 |
| 761 if (width > 0) { |
750 if (width > 0) { |
| 762 total_width += width; |
751 total_width += width; |
| 763 continue; |
752 continue; |
| 764 } |
753 } |
| 765 |
754 |
| 766 pixbuf = pidgin_pixbuf_new_from_file( |
755 pixbuf = pidgin_pixbuf_from_image( |
| 767 purple_smiley_get_path(smiley)); |
756 purple_smiley_get_image(smiley)); |
| 768 pixbuf = pidgin_pixbuf_scale_down(pixbuf, |
757 pixbuf = pidgin_pixbuf_scale_down(pixbuf, |
| 769 24, 24, GDK_INTERP_BILINEAR, TRUE); |
758 24, 24, GDK_INTERP_BILINEAR, TRUE); |
| 770 |
759 |
| 771 if (pixbuf) |
760 if (pixbuf) |
| 772 width = gdk_pixbuf_get_width(pixbuf); |
761 width = gdk_pixbuf_get_width(pixbuf); |