| 702 if (gtalk_name && strcmp(gtalk_name, plugin->info->name) < 0) { |
702 if (gtalk_name && strcmp(gtalk_name, plugin->info->name) < 0) { |
| 703 char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
703 char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
| 704 "16", "google-talk.png", NULL); |
704 "16", "google-talk.png", NULL); |
| 705 GtkWidget *item; |
705 GtkWidget *item; |
| 706 |
706 |
| 707 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
707 pixbuf = pidgin_pixbuf_new_from_file(filename); |
| 708 g_free(filename); |
708 g_free(filename); |
| 709 |
709 |
| 710 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu), |
710 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu), |
| 711 item = aop_menu_item_new(sg, pixbuf, gtalk_name, "prpl-jabber", "protocol")); |
711 item = aop_menu_item_new(sg, pixbuf, gtalk_name, "prpl-jabber", "protocol")); |
| 712 g_object_set_data(G_OBJECT(item), "fakegoogle", GINT_TO_POINTER(1)); |
712 g_object_set_data(G_OBJECT(item), "fakegoogle", GINT_TO_POINTER(1)); |
| 721 if (facebook_name && strcmp(facebook_name, plugin->info->name) < 0) { |
721 if (facebook_name && strcmp(facebook_name, plugin->info->name) < 0) { |
| 722 char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
722 char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
| 723 "16", "facebook.png", NULL); |
723 "16", "facebook.png", NULL); |
| 724 GtkWidget *item; |
724 GtkWidget *item; |
| 725 |
725 |
| 726 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
726 pixbuf = pidgin_pixbuf_new_from_file(filename); |
| 727 g_free(filename); |
727 g_free(filename); |
| 728 |
728 |
| 729 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu), |
729 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu), |
| 730 item = aop_menu_item_new(sg, pixbuf, facebook_name, "prpl-jabber", "protocol")); |
730 item = aop_menu_item_new(sg, pixbuf, facebook_name, "prpl-jabber", "protocol")); |
| 731 g_object_set_data(G_OBJECT(item), "fakefacebook", GINT_TO_POINTER(1)); |
731 g_object_set_data(G_OBJECT(item), "fakefacebook", GINT_TO_POINTER(1)); |
| 3084 } |
3084 } |
| 3085 return FALSE; |
3085 return FALSE; |
| 3086 #endif |
3086 #endif |
| 3087 } |
3087 } |
| 3088 |
3088 |
| 3089 GdkPixbuf * pidgin_pixbuf_from_imgstore(PurpleStoredImage *image) |
3089 static GObject *pidgin_pixbuf_from_data_helper(const guchar *buf, gsize count, gboolean animated) |
| |
3090 { |
| |
3091 GObject *pixbuf; |
| |
3092 GdkPixbufLoader *loader; |
| |
3093 GError *error = NULL; |
| |
3094 |
| |
3095 loader = gdk_pixbuf_loader_new(); |
| |
3096 |
| |
3097 if (!gdk_pixbuf_loader_write(loader, buf, count, &error) || error) { |
| |
3098 purple_debug_warning("gtkutils", "gdk_pixbuf_loader_write() " |
| |
3099 "failed with size=%zu: %s\n", count, |
| |
3100 error ? error->message : "(no error message)"); |
| |
3101 if (error) |
| |
3102 g_error_free(error); |
| |
3103 g_object_unref(G_OBJECT(loader)); |
| |
3104 return NULL; |
| |
3105 } |
| |
3106 |
| |
3107 if (!gdk_pixbuf_loader_close(loader, &error) || error) { |
| |
3108 purple_debug_warning("gtkutils", "gdk_pixbuf_loader_close() " |
| |
3109 "failed for image of size %zu: %s\n", count, |
| |
3110 error ? error->message : "(no error message)"); |
| |
3111 if (error) |
| |
3112 g_error_free(error); |
| |
3113 g_object_unref(G_OBJECT(loader)); |
| |
3114 return NULL; |
| |
3115 } |
| |
3116 |
| |
3117 if (animated) |
| |
3118 pixbuf = G_OBJECT(gdk_pixbuf_loader_get_animation(loader)); |
| |
3119 else |
| |
3120 pixbuf = G_OBJECT(gdk_pixbuf_loader_get_pixbuf(loader)); |
| |
3121 if (!pixbuf) { |
| |
3122 purple_debug_warning("gtkutils", "%s() returned NULL for image " |
| |
3123 "of size %zu\n", |
| |
3124 animated ? "gdk_pixbuf_loader_get_animation" |
| |
3125 : "gdk_pixbuf_loader_get_pixbuf", count); |
| |
3126 g_object_unref(G_OBJECT(loader)); |
| |
3127 return NULL; |
| |
3128 } |
| |
3129 |
| |
3130 g_object_ref(pixbuf); |
| |
3131 g_object_unref(G_OBJECT(loader)); |
| |
3132 |
| |
3133 return pixbuf; |
| |
3134 } |
| |
3135 |
| |
3136 GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count) |
| |
3137 { |
| |
3138 return GDK_PIXBUF(pidgin_pixbuf_from_data_helper(buf, count, FALSE)); |
| |
3139 } |
| |
3140 |
| |
3141 GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count) |
| |
3142 { |
| |
3143 return GDK_PIXBUF_ANIMATION(pidgin_pixbuf_from_data_helper(buf, count, TRUE)); |
| |
3144 } |
| |
3145 |
| |
3146 GdkPixbuf *pidgin_pixbuf_from_imgstore(PurpleStoredImage *image) |
| |
3147 { |
| |
3148 return pidgin_pixbuf_from_data(purple_imgstore_get_data(image), |
| |
3149 purple_imgstore_get_size(image)); |
| |
3150 } |
| |
3151 |
| |
3152 GdkPixbuf *pidgin_pixbuf_new_from_file(const gchar *filename) |
| 3090 { |
3153 { |
| 3091 GdkPixbuf *pixbuf; |
3154 GdkPixbuf *pixbuf; |
| 3092 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
3155 GError *error = NULL; |
| 3093 gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(image), |
3156 |
| 3094 purple_imgstore_get_size(image), NULL); |
3157 pixbuf = gdk_pixbuf_new_from_file(filename, &error); |
| 3095 gdk_pixbuf_loader_close(loader, NULL); |
3158 if (!pixbuf || error) { |
| 3096 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
3159 purple_debug_warning("gtkutils", "gdk_pixbuf_new_from_file() " |
| 3097 if (pixbuf) |
3160 "returned %s for file %s: %s\n", |
| 3098 g_object_ref(pixbuf); |
3161 pixbuf ? "something" : "nothing", |
| 3099 g_object_unref(loader); |
3162 filename, |
| |
3163 error ? error->message : "(no error message)"); |
| |
3164 if (error) |
| |
3165 g_error_free(error); |
| |
3166 if (pixbuf) |
| |
3167 g_object_unref(G_OBJECT(pixbuf)); |
| |
3168 return NULL; |
| |
3169 } |
| |
3170 |
| |
3171 return pixbuf; |
| |
3172 } |
| |
3173 |
| |
3174 GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height) |
| |
3175 { |
| |
3176 GdkPixbuf *pixbuf; |
| |
3177 GError *error = NULL; |
| |
3178 |
| |
3179 pixbuf = gdk_pixbuf_new_from_file_at_size(filename, |
| |
3180 width, height, &error); |
| |
3181 if (!pixbuf || error) { |
| |
3182 purple_debug_warning("gtkutils", "gdk_pixbuf_new_from_file_at_size() " |
| |
3183 "returned %s for file %s: %s\n", |
| |
3184 pixbuf ? "something" : "nothing", |
| |
3185 filename, |
| |
3186 error ? error->message : "(no error message)"); |
| |
3187 if (error) |
| |
3188 g_error_free(error); |
| |
3189 if (pixbuf) |
| |
3190 g_object_unref(G_OBJECT(pixbuf)); |
| |
3191 return NULL; |
| |
3192 } |
| |
3193 |
| |
3194 return pixbuf; |
| |
3195 } |
| |
3196 |
| |
3197 GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio) |
| |
3198 { |
| |
3199 GdkPixbuf *pixbuf; |
| |
3200 GError *error = NULL; |
| |
3201 |
| |
3202 pixbuf = gdk_pixbuf_new_from_file_at_scale(filename, |
| |
3203 width, height, preserve_aspect_ratio, &error); |
| |
3204 if (!pixbuf || error) { |
| |
3205 purple_debug_warning("gtkutils", "gdk_pixbuf_new_from_file_at_scale() " |
| |
3206 "returned %s for file %s: %s\n", |
| |
3207 pixbuf ? "something" : "nothing", |
| |
3208 filename, |
| |
3209 error ? error->message : "(no error message)"); |
| |
3210 if (error) |
| |
3211 g_error_free(error); |
| |
3212 if (pixbuf) |
| |
3213 g_object_unref(G_OBJECT(pixbuf)); |
| |
3214 return NULL; |
| |
3215 } |
| |
3216 |
| 3100 return pixbuf; |
3217 return pixbuf; |
| 3101 } |
3218 } |
| 3102 |
3219 |
| 3103 static void url_copy(GtkWidget *w, gchar *url) |
3220 static void url_copy(GtkWidget *w, gchar *url) |
| 3104 { |
3221 { |