[metacity] theme: move gradient code to libmetacity
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] theme: move gradient code to libmetacity
- Date: Thu, 28 Jan 2016 09:20:49 +0000 (UTC)
commit 6d57bcf0458aed702197896c1ac7cb3b9f2ed943
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Jan 27 23:56:04 2016 +0200
theme: move gradient code to libmetacity
libmetacity/Makefile.am | 2 +
src/ui/gradient.c => libmetacity/meta-gradient.c | 184 ++++++++++++----------
src/ui/gradient.h => libmetacity/meta-gradient.h | 22 +--
src/Makefile.am | 4 +-
src/ui/testgradient.c | 2 +-
src/ui/theme-private.h | 2 +-
src/ui/theme.c | 1 -
7 files changed, 111 insertions(+), 106 deletions(-)
---
diff --git a/libmetacity/Makefile.am b/libmetacity/Makefile.am
index f2a3e7f..e768c3d 100644
--- a/libmetacity/Makefile.am
+++ b/libmetacity/Makefile.am
@@ -8,6 +8,8 @@ libmetacity_la_SOURCES = \
meta-color-private.h \
meta-color-spec.c \
meta-color-spec.h \
+ meta-gradient.c \
+ meta-gradient.h \
meta-hsla.c \
meta-hsla.h \
meta-theme.c \
diff --git a/src/ui/gradient.c b/libmetacity/meta-gradient.c
similarity index 83%
rename from src/ui/gradient.c
rename to libmetacity/meta-gradient.c
index a1e7584..cef707d 100644
--- a/src/ui/gradient.c
+++ b/libmetacity/meta-gradient.c
@@ -27,17 +27,18 @@
#include <string.h>
-#include "gradient.h"
+#include "meta-gradient.h"
-/* Used as the destroy notification function for gdk_pixbuf_new() */
static void
-free_buffer (guchar *pixels, gpointer data)
+free_buffer (guchar *pixels,
+ gpointer data)
{
g_free (pixels);
}
static GdkPixbuf*
-blank_pixbuf (int width, int height)
+blank_pixbuf (int width,
+ int height)
{
guchar *buf;
int rowstride;
@@ -72,7 +73,8 @@ blank_pixbuf (int width, int height)
*----------------------------------------------------------------------
*/
static GdkPixbuf*
-meta_gradient_create_horizontal (int width, int height,
+meta_gradient_create_horizontal (int width,
+ int height,
const GdkRGBA *from,
const GdkRGBA *to)
{
@@ -145,8 +147,9 @@ meta_gradient_create_horizontal (int width, int height,
* None
*----------------------------------------------------------------------
*/
-static GdkPixbuf*
-meta_gradient_create_vertical (int width, int height,
+static GdkPixbuf *
+meta_gradient_create_vertical (int width,
+ int height,
const GdkRGBA *from,
const GdkRGBA *to)
{
@@ -206,7 +209,6 @@ meta_gradient_create_vertical (int width, int height,
return pixbuf;
}
-
/*
*----------------------------------------------------------------------
* meta_gradient_create_diagonal--
@@ -220,10 +222,9 @@ meta_gradient_create_vertical (int width, int height,
* None
*----------------------------------------------------------------------
*/
-
-
-static GdkPixbuf*
-meta_gradient_create_diagonal (int width, int height,
+static GdkPixbuf *
+meta_gradient_create_diagonal (int width,
+ int height,
const GdkRGBA *from,
const GdkRGBA *to)
{
@@ -269,11 +270,11 @@ meta_gradient_create_diagonal (int width, int height,
return pixbuf;
}
-
-static GdkPixbuf*
-meta_gradient_create_multi_horizontal (int width, int height,
+static GdkPixbuf *
+meta_gradient_create_multi_horizontal (int width,
+ int height,
const GdkRGBA *colors,
- int count)
+ int count)
{
int i, j, k;
long r, g, b, a, dr, dg, db, da;
@@ -348,10 +349,11 @@ meta_gradient_create_multi_horizontal (int width, int height,
return pixbuf;
}
-static GdkPixbuf*
-meta_gradient_create_multi_vertical (int width, int height,
+static GdkPixbuf *
+meta_gradient_create_multi_vertical (int width,
+ int height,
const GdkRGBA *colors,
- int count)
+ int count)
{
int i, j, k;
long r, g, b, a, dr, dg, db, da;
@@ -443,11 +445,11 @@ meta_gradient_create_multi_vertical (int width, int height,
return pixbuf;
}
-
-static GdkPixbuf*
-meta_gradient_create_multi_diagonal (int width, int height,
+static GdkPixbuf *
+meta_gradient_create_multi_diagonal (int width,
+ int height,
const GdkRGBA *colors,
- int count)
+ int count)
{
GdkPixbuf *pixbuf, *tmp;
float a, offset;
@@ -661,31 +663,29 @@ meta_gradient_add_alpha_horizontal (GdkPixbuf *pixbuf,
*
* Returns: (transfer full): A new linear gradient
*/
-GdkPixbuf*
-meta_gradient_create_simple (int width,
- int height,
- const GdkRGBA *from,
- const GdkRGBA *to,
- MetaGradientType style)
+GdkPixbuf *
+meta_gradient_create_simple (int width,
+ int height,
+ const GdkRGBA *from,
+ const GdkRGBA *to,
+ MetaGradientType style)
{
switch (style)
{
- case META_GRADIENT_HORIZONTAL:
- return meta_gradient_create_horizontal (width, height,
- from, to);
- case META_GRADIENT_VERTICAL:
- return meta_gradient_create_vertical (width, height,
- from, to);
-
- case META_GRADIENT_DIAGONAL:
- return meta_gradient_create_diagonal (width, height,
- from, to);
- case META_GRADIENT_LAST:
- break;
-
- default:
- break;
+ case META_GRADIENT_HORIZONTAL:
+ return meta_gradient_create_horizontal (width, height, from, to);
+ case META_GRADIENT_VERTICAL:
+ return meta_gradient_create_vertical (width, height, from, to);
+
+ case META_GRADIENT_DIAGONAL:
+ return meta_gradient_create_diagonal (width, height, from, to);
+ case META_GRADIENT_LAST:
+ break;
+
+ default:
+ break;
}
+
g_assert_not_reached ();
return NULL;
}
@@ -700,30 +700,30 @@ meta_gradient_create_simple (int width,
*
* Returns: (transfer full): A new multi-step linear gradient
*/
-GdkPixbuf*
-meta_gradient_create_multi (int width,
- int height,
- const GdkRGBA *colors,
- int n_colors,
- MetaGradientType style)
+GdkPixbuf *
+meta_gradient_create_multi (int width,
+ int height,
+ const GdkRGBA *colors,
+ int n_colors,
+ MetaGradientType style)
{
if (n_colors > 2)
{
switch (style)
{
- case META_GRADIENT_HORIZONTAL:
- return meta_gradient_create_multi_horizontal (width, height, colors, n_colors);
- case META_GRADIENT_VERTICAL:
- return meta_gradient_create_multi_vertical (width, height, colors, n_colors);
- case META_GRADIENT_DIAGONAL:
- return meta_gradient_create_multi_diagonal (width, height, colors, n_colors);
- case META_GRADIENT_LAST:
- g_assert_not_reached ();
- break;
- default:
- g_assert_not_reached ();
- break;
+ case META_GRADIENT_HORIZONTAL:
+ return meta_gradient_create_multi_horizontal (width, height, colors, n_colors);
+ case META_GRADIENT_VERTICAL:
+ return meta_gradient_create_multi_vertical (width, height, colors, n_colors);
+ case META_GRADIENT_DIAGONAL:
+ return meta_gradient_create_multi_diagonal (width, height, colors, n_colors);
+ case META_GRADIENT_LAST:
+ g_assert_not_reached ();
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
else if (n_colors > 1)
@@ -755,12 +755,12 @@ meta_gradient_create_multi (int width,
* WindowMaker had it.
*/
GdkPixbuf*
-meta_gradient_create_interwoven (int width,
- int height,
- const GdkRGBA colors1[2],
- int thickness1,
- const GdkRGBA colors2[2],
- int thickness2)
+meta_gradient_create_interwoven (int width,
+ int height,
+ const GdkRGBA colors1[2],
+ int thickness1,
+ const GdkRGBA colors2[2],
+ int thickness2)
{
int i, j, k, l, ll;
@@ -849,11 +849,21 @@ meta_gradient_create_interwoven (int width,
return pixbuf;
}
+/**
+ * meta_gradient_add_alpha:
+ * @pixbuf:
+ * @alphas:
+ * @n_alphas:
+ * @type:
+ *
+ * Generate an alpha gradient and multiply it with the existing alpha
+ * channel of the given pixbuf.
+ */
void
-meta_gradient_add_alpha (GdkPixbuf *pixbuf,
- const guchar *alphas,
- int n_alphas,
- MetaGradientType type)
+meta_gradient_add_alpha (GdkPixbuf *pixbuf,
+ const guchar *alphas,
+ int n_alphas,
+ MetaGradientType type)
{
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
g_return_if_fail (gdk_pixbuf_get_has_alpha (pixbuf));
@@ -861,24 +871,24 @@ meta_gradient_add_alpha (GdkPixbuf *pixbuf,
switch (type)
{
- case META_GRADIENT_HORIZONTAL:
- meta_gradient_add_alpha_horizontal (pixbuf, alphas, n_alphas);
- break;
+ case META_GRADIENT_HORIZONTAL:
+ meta_gradient_add_alpha_horizontal (pixbuf, alphas, n_alphas);
+ break;
- case META_GRADIENT_VERTICAL:
- g_printerr ("metacity: vertical alpha channel gradient not implemented yet\n");
- break;
+ case META_GRADIENT_VERTICAL:
+ g_printerr ("metacity: vertical alpha channel gradient not implemented yet\n");
+ break;
- case META_GRADIENT_DIAGONAL:
- g_printerr ("metacity: diagonal alpha channel gradient not implemented yet\n");
- break;
+ case META_GRADIENT_DIAGONAL:
+ g_printerr ("metacity: diagonal alpha channel gradient not implemented yet\n");
+ break;
- case META_GRADIENT_LAST:
- g_assert_not_reached ();
- break;
+ case META_GRADIENT_LAST:
+ g_assert_not_reached ();
+ break;
- default:
- g_assert_not_reached ();
- break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
diff --git a/src/ui/gradient.h b/libmetacity/meta-gradient.h
similarity index 81%
rename from src/ui/gradient.h
rename to libmetacity/meta-gradient.h
index 78ca942..7d7588b 100644
--- a/src/ui/gradient.h
+++ b/libmetacity/meta-gradient.h
@@ -38,31 +38,27 @@ typedef enum
META_GRADIENT_LAST
} MetaGradientType;
-GdkPixbuf* meta_gradient_create_simple (int width,
+GdkPixbuf *meta_gradient_create_simple (int width,
int height,
const GdkRGBA *from,
const GdkRGBA *to,
MetaGradientType style);
-GdkPixbuf* meta_gradient_create_multi (int width,
+
+GdkPixbuf *meta_gradient_create_multi (int width,
int height,
const GdkRGBA *colors,
int n_colors,
MetaGradientType style);
-GdkPixbuf* meta_gradient_create_interwoven (int width,
+
+GdkPixbuf *meta_gradient_create_interwoven (int width,
int height,
const GdkRGBA colors1[2],
int thickness1,
const GdkRGBA colors2[2],
int thickness2);
-
-/* Generate an alpha gradient and multiply it with the existing alpha
- * channel of the given pixbuf
- */
-void meta_gradient_add_alpha (GdkPixbuf *pixbuf,
- const guchar *alphas,
- int n_alphas,
- MetaGradientType type);
-
-
+void meta_gradient_add_alpha (GdkPixbuf *pixbuf,
+ const guchar *alphas,
+ int n_alphas,
+ MetaGradientType type);
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 5cc4e97..07bf747 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -113,8 +113,6 @@ libmetacity_private_la_CFLAGS =
libmetacity_private_la_SOURCES = \
core/boxes.c \
include/boxes.h \
- ui/gradient.c \
- ui/gradient.h \
core/util.c \
include/util.h \
include/common.h \
@@ -151,7 +149,7 @@ metacity_LDADD= METACITY_LIBS@ libmetacity-private.la
metacity_theme_viewer_LDADD= @METACITY_LIBS@ libmetacity-private.la
testboxes_SOURCES=include/util.h core/util.c include/boxes.h core/boxes.c core/testboxes.c
-testgradient_SOURCES=ui/gradient.h ui/gradient.c ui/testgradient.c
+testgradient_SOURCES=../libmetacity/meta-gradient.h ../libmetacity/meta-gradient.c ui/testgradient.c
testasyncgetprop_SOURCES=core/async-getprop.h core/async-getprop.c core/testasyncgetprop.c
noinst_PROGRAMS=testboxes testgradient testasyncgetprop
diff --git a/src/ui/testgradient.c b/src/ui/testgradient.c
index 3c06192..59f3cb3 100644
--- a/src/ui/testgradient.c
+++ b/src/ui/testgradient.c
@@ -18,8 +18,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>. */
-#include "gradient.h"
#include <gtk/gtk.h>
+#include <libmetacity/meta-gradient.h>
typedef void (* RenderGradientFunc) (cairo_t *cr,
int width,
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index de73200..05649fc 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -19,9 +19,9 @@
#define META_THEME_PRIVATE_H
#include <libmetacity/meta-color-spec.h>
+#include <libmetacity/meta-gradient.h>
#include "boxes.h"
-#include "gradient.h"
#include "theme.h"
G_BEGIN_DECLS
diff --git a/src/ui/theme.c b/src/ui/theme.c
index db630ec..540d09d 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -53,7 +53,6 @@
#include <config.h>
#include "theme-private.h"
#include "util.h"
-#include "gradient.h"
#include <gtk/gtk.h>
#include <libmetacity/meta-color.h>
#include <string.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]