Mercurial > pidgin
comparison src/gtkconv.c @ 4757:c4ebe1a8484b
[gaim-migrate @ 5074]
this fixes a bunch of little things, as well as a few big things, plugs a
few leaks, and makes the new buddy icon cache stuff much cooler. enjoy!
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 14 Mar 2003 01:14:24 +0000 |
parents | 54fbd9769677 |
children | c4c28874ecd3 |
comparison
equal
deleted
inserted
replaced
4756:85637881b342 | 4757:c4ebe1a8484b |
---|---|
1912 static void | 1912 static void |
1913 update_typing_icon(struct gaim_conversation *conv) | 1913 update_typing_icon(struct gaim_conversation *conv) |
1914 { | 1914 { |
1915 struct gaim_gtk_window *gtkwin; | 1915 struct gaim_gtk_window *gtkwin; |
1916 struct gaim_im *im = NULL; | 1916 struct gaim_im *im = NULL; |
1917 struct gaim_gtk_conversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1917 | 1918 |
1918 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | 1919 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); |
1919 | 1920 |
1920 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | 1921 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
1921 im = GAIM_IM(conv); | 1922 im = GAIM_IM(conv); |
1928 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); | 1929 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); |
1929 gtk_image_menu_item_set_image( | 1930 gtk_image_menu_item_set_image( |
1930 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | 1931 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), |
1931 gtk_image_new_from_stock(GAIM_STOCK_TYPING, | 1932 gtk_image_new_from_stock(GAIM_STOCK_TYPING, |
1932 GTK_ICON_SIZE_MENU)); | 1933 GTK_ICON_SIZE_MENU)); |
1933 gtk_tooltips_set_tip(gtk_tooltips_new(), gtkwin->menu.typing_icon, | 1934 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
1934 _("User is typing..."), NULL); | 1935 _("User is typing..."), NULL); |
1935 } else if(im && gaim_im_get_typing_state(im) == TYPED) { | 1936 } else if(im && gaim_im_get_typing_state(im) == TYPED) { |
1936 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); | 1937 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); |
1937 gtk_image_menu_item_set_image( | 1938 gtk_image_menu_item_set_image( |
1938 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | 1939 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), |
1939 gtk_image_new_from_stock(GAIM_STOCK_TYPED, | 1940 gtk_image_new_from_stock(GAIM_STOCK_TYPED, |
1940 GTK_ICON_SIZE_MENU)); | 1941 GTK_ICON_SIZE_MENU)); |
1941 gtk_tooltips_set_tip(gtk_tooltips_new(), gtkwin->menu.typing_icon, | 1942 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
1942 _("User has typed something and paused"), NULL); | 1943 _("User has typed something and paused"), NULL); |
1943 } | 1944 } |
1944 | 1945 |
1945 if(gtkwin->menu.typing_icon) { | 1946 if(gtkwin->menu.typing_icon) { |
1946 gtk_menu_item_set_right_justified( | 1947 gtk_menu_item_set_right_justified( |
4275 style = gtk_style_new(); | 4276 style = gtk_style_new(); |
4276 | 4277 |
4277 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | 4278 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) |
4278 gtk_widget_realize(gtkconv->tab_label); | 4279 gtk_widget_realize(gtkconv->tab_label); |
4279 | 4280 |
4281 pango_font_description_free(style->font_desc); | |
4280 style->font_desc = pango_font_description_copy( | 4282 style->font_desc = pango_font_description_copy( |
4281 gtk_widget_get_style(gtkconv->tab_label)->font_desc); | 4283 gtk_widget_get_style(gtkconv->tab_label)->font_desc); |
4282 | 4284 |
4283 if (im != NULL && gaim_im_get_typing_state(im) == TYPING) { | 4285 if (im != NULL && gaim_im_get_typing_state(im) == TYPING) { |
4284 style->fg[GTK_STATE_NORMAL].red = 0x4646; | 4286 style->fg[GTK_STATE_NORMAL].red = 0x4646; |
4613 | 4615 |
4614 char filename[256]; | 4616 char filename[256]; |
4615 FILE *file; | 4617 FILE *file; |
4616 GError *err = NULL; | 4618 GError *err = NULL; |
4617 | 4619 |
4620 struct buddy *buddy; | |
4621 | |
4618 void *data; | 4622 void *data; |
4619 int len, delay; | 4623 int len, delay; |
4620 | 4624 |
4621 GdkPixbuf *buf; | 4625 GdkPixbuf *buf; |
4622 | 4626 |
4641 return; | 4645 return; |
4642 | 4646 |
4643 if (gaim_conversation_get_gc(conv) == NULL) | 4647 if (gaim_conversation_get_gc(conv) == NULL) |
4644 return; | 4648 return; |
4645 | 4649 |
4646 data = get_icon_data(gaim_conversation_get_gc(conv), | 4650 if((buddy = gaim_find_buddy(gaim_conversation_get_account(conv), |
4647 normalize(gaim_conversation_get_name(conv)), | 4651 gaim_conversation_get_name(conv))) != NULL) { |
4648 &len); | 4652 char *file = gaim_buddy_get_setting(buddy, "buddy_icon"); |
4649 | 4653 if(file) { |
4650 if (!data) | 4654 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(file, &err); |
4651 return; | 4655 g_free(file); |
4652 | 4656 } |
4653 /* this is such an evil hack, i don't know why i'm even considering it. | 4657 } else { |
4654 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ | 4658 data = get_icon_data(gaim_conversation_get_gc(conv), |
4655 g_snprintf(filename, sizeof(filename), | 4659 normalize(gaim_conversation_get_name(conv)), |
4656 "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", | 4660 &len); |
4657 g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); | 4661 |
4658 | 4662 if (!data) |
4659 if (!(file = fopen(filename, "wb"))) | 4663 return; |
4660 return; | 4664 |
4661 | 4665 /* this is such an evil hack, i don't know why i'm even considering it. |
4662 fwrite(data, 1, len, file); | 4666 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ |
4663 fclose(file); | 4667 g_snprintf(filename, sizeof(filename), |
4664 | 4668 "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", |
4665 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err); | 4669 g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); |
4670 | |
4671 if (!(file = fopen(filename, "wb"))) | |
4672 return; | |
4673 | |
4674 fwrite(data, 1, len, file); | |
4675 fclose(file); | |
4676 | |
4677 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err); | |
4678 /* make sure we remove the file as soon as possible */ | |
4679 unlink(filename); | |
4680 } | |
4666 | 4681 |
4667 if (err) { | 4682 if (err) { |
4668 debug_printf("Buddy icon error: %s\n", err->message); | 4683 debug_printf("Buddy icon error: %s\n", err->message); |
4669 g_error_free(err); | 4684 g_error_free(err); |
4670 } | 4685 } |
4671 | 4686 |
4672 /* make sure we remove the file as soon as possible */ | |
4673 unlink(filename); | |
4674 | 4687 |
4675 if (!gtkconv->u.im->anim) | 4688 if (!gtkconv->u.im->anim) |
4676 return; | 4689 return; |
4677 | 4690 |
4678 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | 4691 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { |