comparison src/gtkutils.c @ 8962:4ff4c34b7500

[gaim-migrate @ 9736] IM Image, WYSIWYG. It's still somewhat buggy, although the worse problems are with oscar's direct connect. We could always yank oscar's im image flag if we think it will cause too many bug reports. I made the GaimImgstore struct opque. I modified oscar's sending function to parse im images better, and everything seems to work. I made it write some errors to the conversation if you try to send an image and you aren't direct connected. That's just a hack until you can set formatting flags on a per conversation bases. There's a scrolling bug I haven't tracked down. I think it may exist normally and this just causes it better. It's worth noting jabber also uses this for pics in profiles, although I never did find a test case. Hopefully some other stuff can use this soon too, maybe Yahoo! pics in profiles or something. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 17 May 2004 06:47:20 +0000
parents b875f5d57b81
children b24967757d46
comparison
equal deleted inserted replaced
8961:92e061a1db10 8962:4ff4c34b7500
68 url_clicked_cb(GtkWidget *w, const char *uri) 68 url_clicked_cb(GtkWidget *w, const char *uri)
69 { 69 {
70 g_idle_add(url_clicked_idle_cb, g_strdup(uri)); 70 g_idle_add(url_clicked_idle_cb, g_strdup(uri));
71 } 71 }
72 72
73 GtkIMHtmlFuncs gtkimhtml_cbs = {
74 (GtkIMHtmlGetImageFunc)gaim_imgstore_get,
75 (GtkIMHtmlGetImageDataFunc)gaim_imgstore_get_data,
76 (GtkIMHtmlGetImageSizeFunc)gaim_imgstore_get_size,
77 (GtkIMHtmlGetImageFilenameFunc)gaim_imgstore_get_filename,
78 gaim_imgstore_ref,
79 gaim_imgstore_unref,
80 };
81
73 void 82 void
74 gaim_setup_imhtml(GtkWidget *imhtml) 83 gaim_setup_imhtml(GtkWidget *imhtml)
75 { 84 {
76 g_return_if_fail(imhtml != NULL); 85 g_return_if_fail(imhtml != NULL);
77 g_return_if_fail(GTK_IS_IMHTML(imhtml)); 86 g_return_if_fail(GTK_IS_IMHTML(imhtml));
78 87
79 g_signal_connect(G_OBJECT(imhtml), "url_clicked", 88 g_signal_connect(G_OBJECT(imhtml), "url_clicked",
80 G_CALLBACK(url_clicked_cb), NULL); 89 G_CALLBACK(url_clicked_cb), NULL);
81 90
82 smiley_themeize(imhtml); 91 smiley_themeize(imhtml);
92
93 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs);
83 } 94 }
84 95
85 void 96 void
86 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) 97 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
87 { 98 {
919 strcpy(buf, tmp); 930 strcpy(buf, tmp);
920 } 931 }
921 932
922 g_free(tmp); 933 g_free(tmp);
923 return buf; 934 return buf;
924 }
925
926 void
927 gaim_gtk_find_images(const char *message, GSList **list)
928 {
929 GData *attribs;
930 const char *tmp, *start, *end;
931
932 g_return_if_fail(message != NULL);
933 g_return_if_fail( list != NULL);
934
935 tmp = message;
936 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) {
937 GaimStoredImage *image = NULL;
938 GdkPixbufLoader *loader = NULL;
939 GdkPixbuf *pixbuf = NULL;
940 GError *error = NULL;
941 char *id = g_datalist_get_data(&attribs, "id");
942
943 tmp = end + 1;
944
945 if (id)
946 image = gaim_imgstore_get(atoi(id));
947
948 g_datalist_clear(&attribs);
949
950 if (!image) {
951 *list = g_slist_append(*list, NULL);
952 continue;
953 }
954
955 loader = gdk_pixbuf_loader_new();
956
957 if (gdk_pixbuf_loader_write(loader, image->data, image->size, &error)
958 && (pixbuf = gdk_pixbuf_loader_get_pixbuf(loader))) {
959
960 if (image->filename)
961 g_object_set_data_full(G_OBJECT(pixbuf), "filename",
962 g_strdup(image->filename), g_free);
963 g_object_ref(G_OBJECT(pixbuf));
964 *list = g_slist_append(*list, pixbuf);
965 } else {
966 if (error) {
967 gaim_debug(GAIM_DEBUG_ERROR, "gtkutils",
968 "Failed to make pixbuf from image store: %s\n",
969 error->message);
970 g_error_free(error);
971 } else {
972 gaim_debug(GAIM_DEBUG_ERROR, "gtkutils",
973 "Failed to make pixbuf from image store: unknown reason\n");
974 }
975 *list = g_slist_append(*list, NULL);
976 }
977
978 gdk_pixbuf_loader_close(loader, NULL);
979 }
980 } 935 }
981 936
982 void 937 void
983 gaim_gtk_setup_gtkspell(GtkTextView *textview) 938 gaim_gtk_setup_gtkspell(GtkTextView *textview)
984 { 939 {