Mercurial > pidgin
comparison src/gtkconv.c @ 7078:acd2a66e59ed
[gaim-migrate @ 7643]
robot101 gave us images in notify_formatted windows. very cool. This lets what I committed earlier (which was support for images in jabber vcards) to work.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 30 Sep 2003 18:41:28 +0000 |
parents | 9946001989a3 |
children | 2cd3756a637b |
comparison
equal
deleted
inserted
replaced
7077:6d10bf28be0e | 7078:acd2a66e59ed |
---|---|
4342 gaim_prefs_get_bool("/gaim/gtk/conversations/im/hide_on_send"))))) { | 4342 gaim_prefs_get_bool("/gaim/gtk/conversations/im/hide_on_send"))))) { |
4343 | 4343 |
4344 gaim_window_show(win); | 4344 gaim_window_show(win); |
4345 } | 4345 } |
4346 | 4346 |
4347 if (flags & GAIM_MESSAGE_IMAGES) { | 4347 if (flags & GAIM_MESSAGE_IMAGES) |
4348 GData *attribs; | 4348 gaim_gtk_find_images(message, &images); |
4349 GdkPixbuf *broken; | |
4350 const char *tmp, *start, *end; | |
4351 | |
4352 broken = gtk_widget_render_icon(GTK_WIDGET(gtkconv->imhtml), | |
4353 GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_BUTTON, | |
4354 "gaim-missing-image"); | |
4355 | |
4356 tmp = message; | |
4357 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
4358 GaimStoredImage *image = NULL; | |
4359 GdkPixbufLoader *loader; | |
4360 GError *error = NULL; | |
4361 char *id = NULL; | |
4362 | |
4363 tmp = end + 1; | |
4364 | |
4365 id = g_datalist_get_data(&attribs, "id"); | |
4366 | |
4367 if (id) | |
4368 image = gaim_imgstore_get(atoi(id)); | |
4369 | |
4370 g_datalist_clear(&attribs); | |
4371 | |
4372 if (!image) { | |
4373 g_object_ref(G_OBJECT(broken)); | |
4374 images = g_slist_append(images, broken); | |
4375 continue; | |
4376 } | |
4377 | |
4378 loader = gdk_pixbuf_loader_new(); | |
4379 | |
4380 if (!gdk_pixbuf_loader_write(loader, image->data, image->size, &error)) { | |
4381 if (error) { | |
4382 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", | |
4383 "Failed to make pixbuf for IM Image: %s\n", | |
4384 error->message); | |
4385 g_error_free(error); | |
4386 } | |
4387 g_object_ref(G_OBJECT(broken)); | |
4388 images = g_slist_append(images, broken); | |
4389 } else { | |
4390 GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); | |
4391 if (pixbuf) { | |
4392 if (image->filename) | |
4393 g_object_set_data_full(G_OBJECT(pixbuf), "filename", | |
4394 g_strdup(image->filename), g_free); | |
4395 g_object_ref(G_OBJECT(pixbuf)); | |
4396 images = g_slist_append(images, pixbuf); | |
4397 } else { | |
4398 g_object_ref(G_OBJECT(broken)); | |
4399 images = g_slist_append(images, broken); | |
4400 } | |
4401 } | |
4402 | |
4403 gdk_pixbuf_loader_close(loader, NULL); | |
4404 } | |
4405 | |
4406 g_object_unref(G_OBJECT(broken)); | |
4407 } | |
4408 | 4349 |
4409 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ | 4350 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4410 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | 4351 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); |
4411 else | 4352 else |
4412 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | 4353 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); |
4673 | 4614 |
4674 if(sml_attrib) | 4615 if(sml_attrib) |
4675 g_free(sml_attrib); | 4616 g_free(sml_attrib); |
4676 | 4617 |
4677 if (images) { | 4618 if (images) { |
4678 GSList *tmp = images; | 4619 GSList *tmp; |
4679 GdkPixbuf *pixbuf; | 4620 |
4680 while (tmp) { | 4621 for (tmp = images; tmp; tmp = tmp->next) { |
4681 pixbuf = tmp->data; | 4622 GdkPixbuf *pixbuf = tmp->data; |
4682 g_object_unref(G_OBJECT(pixbuf)); | 4623 if(pixbuf) |
4683 tmp = tmp->next; | 4624 g_object_unref(pixbuf); |
4684 } | 4625 } |
4626 | |
4685 g_slist_free(images); | 4627 g_slist_free(images); |
4686 } | 4628 } |
4687 } | 4629 } |
4688 | 4630 |
4689 static void | 4631 static void |