summaryrefslogtreecommitdiff
path: root/src/ui/gradient.c
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-10-15 15:39:12 +0300
committermonsta <[email protected]>2016-10-15 15:39:12 +0300
commit40e26ed6d0e9ef84522ad0723f630bd7d796beec (patch)
tree67374984e9b7d2c60525976a008889775f7de4f3 /src/ui/gradient.c
parent3b69fd200912e27ce64caf3bf5d4338aab73177b (diff)
downloadmarco-40e26ed6d0e9ef84522ad0723f630bd7d796beec.tar.bz2
marco-40e26ed6d0e9ef84522ad0723f630bd7d796beec.tar.xz
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
Diffstat (limited to 'src/ui/gradient.c')
-rw-r--r--src/ui/gradient.c177
1 files changed, 5 insertions, 172 deletions
diff --git a/src/ui/gradient.c b/src/ui/gradient.c
index dfdb2fa1..550017e1 100644
--- a/src/ui/gradient.c
+++ b/src/ui/gradient.c
@@ -26,12 +26,11 @@
#include "util.h"
#include <string.h>
-#include <gtk/gtk.h>
+#include <gdk/gdk.h>
/* This is all Alfredo's and Dan's usual very nice WindowMaker code,
* slightly GTK-ized
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkPixbuf* meta_gradient_create_horizontal (int width,
int height,
const GdkRGBA *from,
@@ -56,32 +55,6 @@ static GdkPixbuf* meta_gradient_create_multi_diagonal (int width,
int height,
const GdkRGBA *colors,
int count);
-#else
-static GdkPixbuf* meta_gradient_create_horizontal (int width,
- int height,
- const GdkColor *from,
- const GdkColor *to);
-static GdkPixbuf* meta_gradient_create_vertical (int width,
- int height,
- const GdkColor *from,
- const GdkColor *to);
-static GdkPixbuf* meta_gradient_create_diagonal (int width,
- int height,
- const GdkColor *from,
- const GdkColor *to);
-static GdkPixbuf* meta_gradient_create_multi_horizontal (int width,
- int height,
- const GdkColor *colors,
- int count);
-static GdkPixbuf* meta_gradient_create_multi_vertical (int width,
- int height,
- const GdkColor *colors,
- int count);
-static GdkPixbuf* meta_gradient_create_multi_diagonal (int width,
- int height,
- const GdkColor *colors,
- int count);
-#endif
/* Used as the destroy notification function for gdk_pixbuf_new() */
@@ -116,21 +89,12 @@ blank_pixbuf (int width, int height, gboolean no_padding)
free_buffer, NULL);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf*
meta_gradient_create_simple (int width,
int height,
const GdkRGBA *from,
const GdkRGBA *to,
MetaGradientType style)
-#else
-GdkPixbuf*
-meta_gradient_create_simple (int width,
- int height,
- const GdkColor *from,
- const GdkColor *to,
- MetaGradientType style)
-#endif
{
switch (style)
{
@@ -151,23 +115,13 @@ meta_gradient_create_simple (int width,
return NULL;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf*
meta_gradient_create_multi (int width,
int height,
const GdkRGBA *colors,
int n_colors,
MetaGradientType style)
-#else
-GdkPixbuf*
-meta_gradient_create_multi (int width,
- int height,
- const GdkColor *colors,
- int n_colors,
- MetaGradientType style)
-#endif
{
-
if (n_colors > 2)
{
switch (style)
@@ -202,7 +156,6 @@ meta_gradient_create_multi (int width,
* are alternated. I'm not sure what it's good for, just copied since
* WindowMaker had it.
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf*
meta_gradient_create_interwoven (int width,
int height,
@@ -210,17 +163,7 @@ meta_gradient_create_interwoven (int width,
int thickness1,
const GdkRGBA colors2[2],
int thickness2)
-#else
-GdkPixbuf*
-meta_gradient_create_interwoven (int width,
- int height,
- const GdkColor colors1[2],
- int thickness1,
- const GdkColor colors2[2],
- int thickness2)
-#endif
{
-
int i, j, k, l, ll;
long r1, g1, b1, dr1, dg1, db1;
long r2, g2, b2, dr2, dg2, db2;
@@ -236,7 +179,6 @@ meta_gradient_create_interwoven (int width,
pixels = gdk_pixbuf_get_pixels (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
-#if GTK_CHECK_VERSION (3, 0, 0)
r1 = (long)(colors1[0].red*0xffffff);
g1 = (long)(colors1[0].green*0xffffff);
b1 = (long)(colors1[0].blue*0xffffff);
@@ -252,23 +194,6 @@ meta_gradient_create_interwoven (int width,
dr2 = ((colors2[1].red-colors2[0].red)*0xffffff)/(int)height;
dg2 = ((colors2[1].green-colors2[0].green)*0xffffff)/(int)height;
db2 = ((colors2[1].blue-colors2[0].blue)*0xffffff)/(int)height;
-#else
- r1 = colors1[0].red<<8;
- g1 = colors1[0].green<<8;
- b1 = colors1[0].blue<<8;
-
- r2 = colors2[0].red<<8;
- g2 = colors2[0].green<<8;
- b2 = colors2[0].blue<<8;
-
- dr1 = ((colors1[1].red-colors1[0].red)<<8)/(int)height;
- dg1 = ((colors1[1].green-colors1[0].green)<<8)/(int)height;
- db1 = ((colors1[1].blue-colors1[0].blue)<<8)/(int)height;
-
- dr2 = ((colors2[1].red-colors2[0].red)<<8)/(int)height;
- dg2 = ((colors2[1].green-colors2[0].green)<<8)/(int)height;
- db2 = ((colors2[1].blue-colors2[0].blue)<<8)/(int)height;
-#endif
for (i=0,k=0,l=0,ll=thickness1; i<height; i++)
{
@@ -330,17 +255,10 @@ meta_gradient_create_interwoven (int width,
* None
*----------------------------------------------------------------------
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkPixbuf*
meta_gradient_create_horizontal (int width, int height,
const GdkRGBA *from,
const GdkRGBA *to)
-#else
-static GdkPixbuf*
-meta_gradient_create_horizontal (int width, int height,
- const GdkColor *from,
- const GdkColor *to)
-#endif
{
int i;
long r, g, b, dr, dg, db;
@@ -359,21 +277,12 @@ meta_gradient_create_horizontal (int width, int height,
ptr = pixels;
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
-#if GTK_CHECK_VERSION (3, 0, 0)
r0 = (guchar) (from->red * 0xff);
g0 = (guchar) (from->green * 0xff);
b0 = (guchar) (from->blue * 0xff);
rf = (guchar) (to->red * 0xff);
gf = (guchar) (to->green * 0xff);
bf = (guchar) (to->blue * 0xff);
-#else
- r0 = (guchar) (from->red / 256.0);
- g0 = (guchar) (from->green / 256.0);
- b0 = (guchar) (from->blue / 256.0);
- rf = (guchar) (to->red / 256.0);
- gf = (guchar) (to->green / 256.0);
- bf = (guchar) (to->blue / 256.0);
-#endif
r = r0 << 16;
g = g0 << 16;
@@ -414,17 +323,10 @@ meta_gradient_create_horizontal (int width, int height,
* None
*----------------------------------------------------------------------
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkPixbuf*
meta_gradient_create_vertical (int width, int height,
const GdkRGBA *from,
const GdkRGBA *to)
-#else
-static GdkPixbuf*
-meta_gradient_create_vertical (int width, int height,
- const GdkColor *from,
- const GdkColor *to)
-#endif
{
int i, j;
long r, g, b, dr, dg, db;
@@ -442,21 +344,12 @@ meta_gradient_create_vertical (int width, int height,
pixels = gdk_pixbuf_get_pixels (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
-#if GTK_CHECK_VERSION (3, 0, 0)
r0 = (guchar) (from->red * 0xff);
g0 = (guchar) (from->green * 0xff);
b0 = (guchar) (from->blue * 0xff);
rf = (guchar) (to->red * 0xff);
gf = (guchar) (to->green * 0xff);
bf = (guchar) (to->blue * 0xff);
-#else
- r0 = (guchar) (from->red / 256.0);
- g0 = (guchar) (from->green / 256.0);
- b0 = (guchar) (from->blue / 256.0);
- rf = (guchar) (to->red / 256.0);
- gf = (guchar) (to->green / 256.0);
- bf = (guchar) (to->blue / 256.0);
-#endif
r = r0<<16;
g = g0<<16;
@@ -500,17 +393,10 @@ meta_gradient_create_vertical (int width, int height,
*----------------------------------------------------------------------
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkPixbuf*
meta_gradient_create_diagonal (int width, int height,
const GdkRGBA *from,
const GdkRGBA *to)
-#else
-static GdkPixbuf*
-meta_gradient_create_diagonal (int width, int height,
- const GdkColor *from,
- const GdkColor *to)
-#endif
{
GdkPixbuf *pixbuf, *tmp;
int j;
@@ -554,17 +440,10 @@ meta_gradient_create_diagonal (int width, int height,
return pixbuf;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkPixbuf*
meta_gradient_create_multi_horizontal (int width, int height,
const GdkRGBA *colors,
int count)
-#else
-static GdkPixbuf*
-meta_gradient_create_multi_horizontal (int width, int height,
- const GdkColor *colors,
- int count)
-#endif
{
int i, j, k;
long r, g, b, dr, dg, db;
@@ -594,28 +473,17 @@ meta_gradient_create_multi_horizontal (int width, int height,
k = 0;
-#if GTK_CHECK_VERSION (3, 0, 0)
r = (long)(colors[0].red * 0xffffff);
g = (long)(colors[0].green * 0xffffff);
b = (long)(colors[0].blue * 0xffffff);
-#else
- r = colors[0].red << 8;
- g = colors[0].green << 8;
- b = colors[0].blue << 8;
-#endif
/* render the first line */
for (i=1; i<count; i++)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
dr = (int)((colors[i].red - colors[i-1].red) *0xffffff)/(int)width2;
dg = (int)((colors[i].green - colors[i-1].green)*0xffffff)/(int)width2;
db = (int)((colors[i].blue - colors[i-1].blue) *0xffffff)/(int)width2;
-#else
- dr = ((int)(colors[i].red - colors[i-1].red) <<8)/(int)width2;
- dg = ((int)(colors[i].green - colors[i-1].green)<<8)/(int)width2;
- db = ((int)(colors[i].blue - colors[i-1].blue) <<8)/(int)width2;
-#endif
+
for (j=0; j<width2; j++)
{
*ptr++ = (unsigned char)(r>>16);
@@ -626,16 +494,12 @@ meta_gradient_create_multi_horizontal (int width, int height,
b += db;
k++;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
+
r = (long)(colors[i].red * 0xffffff);
g = (long)(colors[i].green * 0xffffff);
b = (long)(colors[i].blue * 0xffffff);
-#else
- r = colors[i].red << 8;
- g = colors[i].green << 8;
- b = colors[i].blue << 8;
-#endif
}
+
for (j=k; j<width; j++)
{
*ptr++ = (unsigned char)(r>>16);
@@ -651,17 +515,10 @@ meta_gradient_create_multi_horizontal (int width, int height,
return pixbuf;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkPixbuf*
meta_gradient_create_multi_vertical (int width, int height,
const GdkRGBA *colors,
int count)
-#else
-static GdkPixbuf*
-meta_gradient_create_multi_vertical (int width, int height,
- const GdkColor *colors,
- int count)
-#endif
{
int i, j, k;
long r, g, b, dr, dg, db;
@@ -691,27 +548,15 @@ meta_gradient_create_multi_vertical (int width, int height,
k = 0;
-#if GTK_CHECK_VERSION (3, 0, 0)
r = (long)(colors[0].red * 0xffffff);
g = (long)(colors[0].green * 0xffffff);
b = (long)(colors[0].blue * 0xffffff);
-#else
- r = colors[0].red << 8;
- g = colors[0].green << 8;
- b = colors[0].blue << 8;
-#endif
for (i=1; i<count; i++)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
dr = (int)((colors[i].red - colors[i-1].red) *0xffffff)/(int)height2;
dg = (int)((colors[i].green - colors[i-1].green)*0xffffff)/(int)height2;
db = (int)((colors[i].blue - colors[i-1].blue) *0xffffff)/(int)height2;
-#else
- dr = ((int)(colors[i].red - colors[i-1].red) <<8)/(int)height2;
- dg = ((int)(colors[i].green - colors[i-1].green)<<8)/(int)height2;
- db = ((int)(colors[i].blue - colors[i-1].blue) <<8)/(int)height2;
-#endif
for (j=0; j<height2; j++)
{
@@ -730,15 +575,10 @@ meta_gradient_create_multi_vertical (int width, int height,
b += db;
k++;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
+
r = (long)(colors[i].red * 0xffffff);
g = (long)(colors[i].green * 0xffffff);
b = (long)(colors[i].blue * 0xffffff);
-#else
- r = colors[i].red << 8;
- g = colors[i].green << 8;
- b = colors[i].blue << 8;
-#endif
}
if (k<height)
@@ -765,17 +605,10 @@ meta_gradient_create_multi_vertical (int width, int height,
return pixbuf;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkPixbuf*
meta_gradient_create_multi_diagonal (int width, int height,
const GdkRGBA *colors,
int count)
-#else
-static GdkPixbuf*
-meta_gradient_create_multi_diagonal (int width, int height,
- const GdkColor *colors,
- int count)
-#endif
{
GdkPixbuf *pixbuf, *tmp;
float a, offset;