aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--widgets/e-table/e-cell-toggle.c105
-rw-r--r--widgets/shortcut-bar/e-icon-bar.c9
-rw-r--r--widgets/table/e-cell-toggle.c105
4 files changed, 110 insertions, 122 deletions
diff --git a/ChangeLog b/ChangeLog
index d269f8368e..74b3e458fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2000-04-11 Larry Ewing <lewing@helixcode.com>
+
+ * widgets/e-table/e-cell-toggle.c (etog_draw): update for new
+ gdk-pixbuf. Added a disabled chuck of code to do alpha blending
+ on pixmaps.
+
+ * widgets/shortcut-bar/e-icon-bar.c (flatten_alpha): update for
+ new gdk-pixbuf.
+
2000-04-11 Christopher James Lahey <clahey@helixcode.com>
* widgets/e-text/e-text.c: Moved some logic a bit. Minor changes.
@@ -9,8 +18,8 @@
(tooltip_event): Forward clicks on the tooltip onto the text item.
(_do_tooltip): Correct the origin co-ordinates to the items co-ords.
(e_text_point): Return 0 when the mouse is on the item.
- (_do_tooltip): Make the tooltip obey the parent items line_wrap and max_
- lines.
+ (_do_tooltip): Make the tooltip obey the parent items
+ line_wrap and max_lines.
00-04-11 Chris Toshok <toshok@helixcode.com>
diff --git a/widgets/e-table/e-cell-toggle.c b/widgets/e-table/e-cell-toggle.c
index 996d1d72fd..aa07a5c3b8 100644
--- a/widgets/e-table/e-cell-toggle.c
+++ b/widgets/e-table/e-cell-toggle.c
@@ -90,10 +90,10 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
GdkPixbuf *image;
- ArtPixBuf *art;
+ GdkPixbuf *flat;
int x, y, width, height;
const int value = GPOINTER_TO_INT (
- e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+ e_table_model_value_at (ecell_view->e_table_model, model_col, row));
if (value >= toggle->n_states){
g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
@@ -107,72 +107,61 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
gdk_draw_rectangle (drawable, GTK_WIDGET (toggle_view->canvas)->style->white_gc, TRUE, x1, y1, x2 - x1, y2 - y1);
image = toggle->images [value];
- art = image->art_pixbuf;
- if ((x2 - x1) < art->width){
+ if ((x2 - x1) < gdk_pixbuf_get_width (image)){
x = x1;
width = x2 - x1;
} else {
- x = x1 + ((x2 - x1) - art->width) / 2;
- width = art->width;
+ x = x1 + ((x2 - x1) - gdk_pixbuf_get_width (image)) / 2;
+ width = gdk_pixbuf_get_width (image);
}
- if ((y2 - y1) < art->height){
+ if ((y2 - y1) < gdk_pixbuf_get_height (image)){
y = y1;
height = y2 - y1;
} else {
- y = y1 + ((y2 - y1) - art->height) / 2;
- height = art->height;
+ y = y1 + ((y2 - y1) - gdk_pixbuf_get_height (image)) / 2;
+ height = gdk_pixbuf_get_height (image);
}
-
- if (image->art_pixbuf->has_alpha){
- GdkColor background;
- guchar *buffer;
- int alpha, ix, iy;
-
- buffer = g_malloc (art->rowstride * art->height * 3);
-
- background.red = 255;
- background.green = 255;
- background.blue = 255;
-
- for (iy = 0; iy < art->height; iy++){
- unsigned char *dest;
- unsigned char *src;
+#if 0 /* do alpha */
+ if (gdk_pixbuf_get_has_alpha (image)) {
+ flat = gdk_pixbuf_composite_color_simple (
+ image,
+ gdk_pixbuf_get_width (image),
+ gdk_pixbuf_get_height (image),
+ GDK_INTERP_NEAREST,
+ 255,
+ 32,
+ 0xffffff, 0xffffff);
- dest = buffer + (iy * art->rowstride);
- src = art->pixels + (iy * art->rowstride);
-
- for (ix = 0; ix < art->width; ix++){
- alpha = src [3];
- if (alpha == 0){
- *dest++ = background.red;
- *dest++ = background.green;
- *dest++ = background.blue;
- src += 3;
- } else if (alpha == 255){
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = *src++;
- } else {
- *dest++ = (background.red + ((*src++ - background.red) * alpha + 0x80)) >> 8;
- *dest++ = (background.green + ((*src++ - background.green) * alpha + 0x80)) >> 8;
- *dest++ = (background.blue + ((*src++ - background.blue) * alpha + 0x80)) >> 8;
- }
- src++;
- }
- }
-
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, buffer, art->rowstride, 0, 0);
-
- g_free (buffer);
- } else
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, art->pixels, art->rowstride, 0, 0);
+ gdk_pixbuf_render_to_drawable (flat, drawable,
+ toggle_view->gc,
+ 0, 0,
+ x, y,
+ width, height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ gdk_pixbuf_unref (flat);
+ } else {
+ gdk_pixbuf_render_to_drawable (image, drawable,
+ toggle_view->gc,
+ 0, 0,
+ x, y,
+ width, height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ }
+#else
+ gdk_pixbuf_render_to_drawable_alpha (image, drawable,
+ 0, 0,
+ x, y,
+ width, height,
+ GDK_PIXBUF_ALPHA_BILEVEL,
+ 128,
+ GDK_RGB_DITHER_NORMAL,
+ x, y);
+#endif
}
static void
@@ -283,8 +272,8 @@ e_cell_toggle_construct (ECellToggle *etog, int border, int n_states, GdkPixbuf
etog->images [i] = images [i];
gdk_pixbuf_ref (images [i]);
- if (images [i]->art_pixbuf->height > max_height)
- max_height = images [i]->art_pixbuf->height;
+ if (gdk_pixbuf_get_height (images [i]) > max_height)
+ max_height = gdk_pixbuf_get_height (images [i]);
}
etog->height = max_height;
diff --git a/widgets/shortcut-bar/e-icon-bar.c b/widgets/shortcut-bar/e-icon-bar.c
index e325ef0327..bce54320bc 100644
--- a/widgets/shortcut-bar/e-icon-bar.c
+++ b/widgets/shortcut-bar/e-icon-bar.c
@@ -525,14 +525,15 @@ e_icon_bar_set_view_type (EIconBar *icon_bar,
static GdkPixbuf *
flatten_alpha (GdkPixbuf *image, guint rgb)
{
- if (!image || !image->art_pixbuf->has_alpha)
+ if (!image || !gdk_pixbuf_get_has_alpha (image))
return NULL;
+
return gdk_pixbuf_composite_color_simple (
image,
- image->art_pixbuf->width,
- image->art_pixbuf->height,
- ART_FILTER_NEAREST,
+ gdk_pixbuf_get_width (image),
+ gdk_pixbuf_get_height (image),
+ GDK_INTERP_NEAREST,
255,
32,
rgb, ~rgb);
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
index 996d1d72fd..aa07a5c3b8 100644
--- a/widgets/table/e-cell-toggle.c
+++ b/widgets/table/e-cell-toggle.c
@@ -90,10 +90,10 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
GdkPixbuf *image;
- ArtPixBuf *art;
+ GdkPixbuf *flat;
int x, y, width, height;
const int value = GPOINTER_TO_INT (
- e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+ e_table_model_value_at (ecell_view->e_table_model, model_col, row));
if (value >= toggle->n_states){
g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
@@ -107,72 +107,61 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
gdk_draw_rectangle (drawable, GTK_WIDGET (toggle_view->canvas)->style->white_gc, TRUE, x1, y1, x2 - x1, y2 - y1);
image = toggle->images [value];
- art = image->art_pixbuf;
- if ((x2 - x1) < art->width){
+ if ((x2 - x1) < gdk_pixbuf_get_width (image)){
x = x1;
width = x2 - x1;
} else {
- x = x1 + ((x2 - x1) - art->width) / 2;
- width = art->width;
+ x = x1 + ((x2 - x1) - gdk_pixbuf_get_width (image)) / 2;
+ width = gdk_pixbuf_get_width (image);
}
- if ((y2 - y1) < art->height){
+ if ((y2 - y1) < gdk_pixbuf_get_height (image)){
y = y1;
height = y2 - y1;
} else {
- y = y1 + ((y2 - y1) - art->height) / 2;
- height = art->height;
+ y = y1 + ((y2 - y1) - gdk_pixbuf_get_height (image)) / 2;
+ height = gdk_pixbuf_get_height (image);
}
-
- if (image->art_pixbuf->has_alpha){
- GdkColor background;
- guchar *buffer;
- int alpha, ix, iy;
-
- buffer = g_malloc (art->rowstride * art->height * 3);
-
- background.red = 255;
- background.green = 255;
- background.blue = 255;
-
- for (iy = 0; iy < art->height; iy++){
- unsigned char *dest;
- unsigned char *src;
+#if 0 /* do alpha */
+ if (gdk_pixbuf_get_has_alpha (image)) {
+ flat = gdk_pixbuf_composite_color_simple (
+ image,
+ gdk_pixbuf_get_width (image),
+ gdk_pixbuf_get_height (image),
+ GDK_INTERP_NEAREST,
+ 255,
+ 32,
+ 0xffffff, 0xffffff);
- dest = buffer + (iy * art->rowstride);
- src = art->pixels + (iy * art->rowstride);
-
- for (ix = 0; ix < art->width; ix++){
- alpha = src [3];
- if (alpha == 0){
- *dest++ = background.red;
- *dest++ = background.green;
- *dest++ = background.blue;
- src += 3;
- } else if (alpha == 255){
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = *src++;
- } else {
- *dest++ = (background.red + ((*src++ - background.red) * alpha + 0x80)) >> 8;
- *dest++ = (background.green + ((*src++ - background.green) * alpha + 0x80)) >> 8;
- *dest++ = (background.blue + ((*src++ - background.blue) * alpha + 0x80)) >> 8;
- }
- src++;
- }
- }
-
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, buffer, art->rowstride, 0, 0);
-
- g_free (buffer);
- } else
- gdk_draw_rgb_image_dithalign (
- drawable, toggle_view->gc, x, y, width, height,
- GDK_RGB_DITHER_NORMAL, art->pixels, art->rowstride, 0, 0);
+ gdk_pixbuf_render_to_drawable (flat, drawable,
+ toggle_view->gc,
+ 0, 0,
+ x, y,
+ width, height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ gdk_pixbuf_unref (flat);
+ } else {
+ gdk_pixbuf_render_to_drawable (image, drawable,
+ toggle_view->gc,
+ 0, 0,
+ x, y,
+ width, height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ }
+#else
+ gdk_pixbuf_render_to_drawable_alpha (image, drawable,
+ 0, 0,
+ x, y,
+ width, height,
+ GDK_PIXBUF_ALPHA_BILEVEL,
+ 128,
+ GDK_RGB_DITHER_NORMAL,
+ x, y);
+#endif
}
static void
@@ -283,8 +272,8 @@ e_cell_toggle_construct (ECellToggle *etog, int border, int n_states, GdkPixbuf
etog->images [i] = images [i];
gdk_pixbuf_ref (images [i]);
- if (images [i]->art_pixbuf->height > max_height)
- max_height = images [i]->art_pixbuf->height;
+ if (gdk_pixbuf_get_height (images [i]) > max_height)
+ max_height = gdk_pixbuf_get_height (images [i]);
}
etog->height = max_height;