aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-corba-icon-utils.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-02-22 10:18:05 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-02-22 10:18:05 +0800
commitea9489d8944c6c4a7095e92a47991df421140a4b (patch)
tree474af4ad21bc7bcd8684bd6151b6b16408e067dc /shell/e-shell-corba-icon-utils.c
parent5416d54dcfb902d7c84e8d16585a68822f54db0f (diff)
downloadgsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar.gz
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar.bz2
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar.lz
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar.xz
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar.zst
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.zip
Set the icons for all the "New..." menu items from the specified one in
* e-shell-user-creatable-items-handler.c (ensure_menu_items): Set the icons for all the "New..." menu items from the specified one in the type definitions. * e-activity-handler.c (create_gdk_pixbuf_from_corba_icon): Removed. (impl_operationStarted): Just use `e_new_gdk_pixbuf_from_corba_icon()'. * e-shell-corba-icon-utils.c (e_new_gdk_pixbuf_from_corba_icon): New. svn path=/trunk/; revision=15786
Diffstat (limited to 'shell/e-shell-corba-icon-utils.c')
-rw-r--r--shell/e-shell-corba-icon-utils.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/shell/e-shell-corba-icon-utils.c b/shell/e-shell-corba-icon-utils.c
index 53ce1ecc81..0174213ecc 100644
--- a/shell/e-shell-corba-icon-utils.c
+++ b/shell/e-shell-corba-icon-utils.c
@@ -140,3 +140,69 @@ e_new_corba_animated_icon_from_pixbuf_array (GdkPixbuf **pixbuf_array)
return animated_icon;
}
+
+
+/**
+ * e_new_gdk_pixbuf_from_corba_icon:
+ * @icon: A CORBA Evolution::Icon.
+ * @scaled_width: Width of the GdkPixbuf to obtain.
+ * @scaled_height: Width of the GdkPixbuf to obtain.
+ *
+ * If @scaled_width or @scaled_height is -1, do not scale.
+ *
+ * Create a GdkPixbuf for the specified CORBA @icon.
+ *
+ * Return value: The newly created GdkPixbuf.
+ **/
+GdkPixbuf *
+e_new_gdk_pixbuf_from_corba_icon (const GNOME_Evolution_Icon *icon,
+ int scaled_width,
+ int scaled_height)
+{
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *scaled_pixbuf;
+ unsigned char *p;
+ int src_offset;
+ int i, j;
+ int rowstride;
+ int total_width;
+
+ g_return_val_if_fail (icon != NULL, NULL);
+
+ if (scaled_width == -1)
+ scaled_width = icon->width;
+
+ if (scaled_height == -1)
+ scaled_height = icon->height;
+
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, icon->hasAlpha, 8, icon->width, icon->height);
+
+ if (icon->hasAlpha)
+ total_width = 4 * icon->width;
+ else
+ total_width = 3 * icon->width;
+
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ src_offset = 0;
+ p = gdk_pixbuf_get_pixels (pixbuf);
+
+ for (i = 0; i < icon->height; i++) {
+ for (j = 0; j < total_width; j++)
+ p[j] = icon->rgbaData._buffer[src_offset ++];
+ p += rowstride;
+ }
+
+ if (icon->width == scaled_width && icon->height == scaled_height)
+ return pixbuf;
+
+ scaled_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, icon->hasAlpha, 8, scaled_width, scaled_height);
+ gdk_pixbuf_scale (pixbuf, scaled_pixbuf,
+ 0, 0, scaled_width, scaled_height,
+ 0, 0, (double) scaled_width / icon->width, (double) scaled_height / icon->height,
+ GDK_INTERP_HYPER);
+
+ gdk_pixbuf_unref (pixbuf);
+
+ return scaled_pixbuf;
+}
+