pidgin/pidginavatar.c

changeset 42979
d9f973ac3afd
parent 42723
3761ba966eed
child 43072
a59a119b74f5
equal deleted inserted replaced
42978:bf58b98751aa 42979:d9f973ac3afd
54 static void 54 static void
55 pidgin_avatar_update(PidginAvatar *avatar) { 55 pidgin_avatar_update(PidginAvatar *avatar) {
56 PurpleAvatar *purple_avatar = NULL; 56 PurpleAvatar *purple_avatar = NULL;
57 GdkPixbufAnimation *animation = NULL; 57 GdkPixbufAnimation *animation = NULL;
58 GdkPixbuf *pixbuf = NULL; 58 GdkPixbuf *pixbuf = NULL;
59 GdkTexture *texture = NULL;
59 60
60 if(PURPLE_IS_CONTACT_INFO(avatar->info)) { 61 if(PURPLE_IS_CONTACT_INFO(avatar->info)) {
61 purple_avatar = purple_contact_info_get_avatar(avatar->info); 62 purple_avatar = purple_contact_info_get_avatar(avatar->info);
62 } else if(PURPLE_IS_CONVERSATION(avatar->conversation)) { 63 } else if(PURPLE_IS_CONVERSATION(avatar->conversation)) {
63 purple_avatar = purple_conversation_get_avatar(avatar->conversation); 64 purple_avatar = purple_conversation_get_avatar(avatar->conversation);
76 } else { 77 } else {
77 pixbuf = gdk_pixbuf_animation_get_static_image(avatar->animation); 78 pixbuf = gdk_pixbuf_animation_get_static_image(avatar->animation);
78 } 79 }
79 } 80 }
80 81
81 gtk_picture_set_pixbuf(GTK_PICTURE(avatar->icon), pixbuf); 82 texture = gdk_texture_new_for_pixbuf(pixbuf);
82 83 gtk_picture_set_paintable(GTK_PICTURE(avatar->icon),
84 GDK_PAINTABLE(texture));
85
86 g_clear_object(&texture);
83 g_clear_object(&animation); 87 g_clear_object(&animation);
84 } 88 }
85 89
86 /****************************************************************************** 90 /******************************************************************************
87 * Actions 91 * Actions
229 static void 233 static void
230 pidgin_avatar_init(PidginAvatar *avatar) { 234 pidgin_avatar_init(PidginAvatar *avatar) {
231 GSimpleActionGroup *group = NULL; 235 GSimpleActionGroup *group = NULL;
232 236
233 gtk_widget_init_template(GTK_WIDGET(avatar)); 237 gtk_widget_init_template(GTK_WIDGET(avatar));
234
235 gtk_picture_set_content_fit(GTK_PICTURE(avatar->icon),
236 GTK_CONTENT_FIT_SCALE_DOWN);
237 238
238 /* Now setup our actions. */ 239 /* Now setup our actions. */
239 group = g_simple_action_group_new(); 240 group = g_simple_action_group_new();
240 g_action_map_add_action_entries(G_ACTION_MAP(group), actions, 241 g_action_map_add_action_entries(G_ACTION_MAP(group), actions,
241 G_N_ELEMENTS(actions), avatar); 242 G_N_ELEMENTS(actions), avatar);
317 g_return_if_fail(PIDGIN_IS_AVATAR(avatar)); 318 g_return_if_fail(PIDGIN_IS_AVATAR(avatar));
318 319
319 avatar->animate = animate; 320 avatar->animate = animate;
320 321
321 if(GDK_IS_PIXBUF_ANIMATION(avatar->animation)) { 322 if(GDK_IS_PIXBUF_ANIMATION(avatar->animation)) {
323 GdkTexture *texture = NULL;
324
322 if(avatar->animate && 325 if(avatar->animate &&
323 !gdk_pixbuf_animation_is_static_image(avatar->animation)) { 326 !gdk_pixbuf_animation_is_static_image(avatar->animation)) {
324 gtk_picture_set_pixbuf(GTK_PICTURE(avatar->icon), 327 texture = gdk_texture_new_for_pixbuf(GDK_PIXBUF(avatar->animation));
325 GDK_PIXBUF(avatar->animation));
326 } else { 328 } else {
327 GdkPixbuf *frame = NULL; 329 GdkPixbuf *frame = NULL;
328 330
329 frame = gdk_pixbuf_animation_get_static_image(avatar->animation); 331 frame = gdk_pixbuf_animation_get_static_image(avatar->animation);
330 332
331 gtk_picture_set_pixbuf(GTK_PICTURE(avatar->icon), frame); 333 texture = gdk_texture_new_for_pixbuf(frame);
332 } 334 }
335
336 gtk_picture_set_paintable(GTK_PICTURE(avatar->icon),
337 GDK_PAINTABLE(texture));
338 g_object_unref(texture);
333 } 339 }
334 } 340 }
335 341
336 gboolean 342 gboolean
337 pidgin_avatar_get_animate(PidginAvatar *avatar) { 343 pidgin_avatar_get_animate(PidginAvatar *avatar) {

mercurial