summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-06-16 13:35:02 +0200
committerraveit65 <[email protected]>2016-07-02 10:50:56 +0200
commite983f64abd52242d96d9ed3825395f2e1f3dea5e (patch)
tree1db22130eda2f1d23818334a76a926e37b056f13
parentd829c648eb20daa6ad487768195e1379a2ddb135 (diff)
downloadcaja-e983f64abd52242d96d9ed3825395f2e1f3dea5e.tar.bz2
caja-e983f64abd52242d96d9ed3825395f2e1f3dea5e.tar.xz
GTK+-3 eel: rename GdkRGBA functions
-rw-r--r--eel/eel-background.c21
-rw-r--r--eel/eel-gdk-extensions.c78
-rw-r--r--eel/eel-gdk-extensions.h9
3 files changed, 81 insertions, 27 deletions
diff --git a/eel/eel-background.c b/eel/eel-background.c
index becd28f8..2e2b40cf 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -233,11 +233,19 @@ eel_bg_get_desktop_color (EelBackground *self)
use_gradient = FALSE;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ start_color = eel_gdk_rgb_to_color_spec (eel_gdk_rgba_to_rgb (&primary));
+
+ if (use_gradient)
+ {
+ end_color = eel_gdk_rgb_to_color_spec (eel_gdk_rgba_to_rgb (&secondary));
+#else
start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary));
if (use_gradient)
{
end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary));
+#endif
color_spec = eel_gradient_new (start_color, end_color, is_horizontal);
g_free (end_color);
}
@@ -270,7 +278,11 @@ set_image_properties (EelBackground *self)
}
else if (!eel_gradient_is_gradient (self->details->color))
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ eel_gdk_rgba_parse_with_white_default (&c, self->details->color);
+#else
eel_gdk_color_parse_with_white_default (self->details->color, &c);
+#endif
make_color_inactive (self, &c);
mate_bg_set_color (self->details->bg, MATE_BG_COLOR_SOLID, &c, NULL);
}
@@ -284,12 +296,21 @@ set_image_properties (EelBackground *self)
char *spec;
spec = eel_gradient_get_start_color_spec (self->details->color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ eel_gdk_rgba_parse_with_white_default (&c1, spec);
+ make_color_inactive (self, &c1);
+ g_free (spec);
+
+ spec = eel_gradient_get_end_color_spec (self->details->color);
+ eel_gdk_rgba_parse_with_white_default (&c2, spec);
+#else
eel_gdk_color_parse_with_white_default (spec, &c1);
make_color_inactive (self, &c1);
g_free (spec);
spec = eel_gradient_get_end_color_spec (self->details->color);
eel_gdk_color_parse_with_white_default (spec, &c2);
+#endif
make_color_inactive (self, &c2);
g_free (spec);
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index 878586ef..00697d4c 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -312,18 +312,18 @@ eel_gradient_set_bottom_color_spec (const char *gradient_spec,
return eel_gradient_set_edge_color (gradient_spec, bottom_color, FALSE, TRUE);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
/**
- * eel_gdk_color_parse_with_white_default
- * @color_spec: A color spec, or NULL.
+ * eel_gdk_rgba_parse_with_white_default
* @color: Pointer to place to put resulting color.
+ * @color_spec: A color spec, or NULL.
*
- * The same as gdk_color_parse, except sets the color to white if
+ * The same as gdk_rgba_parse, except sets the color to white if
* the spec. can't be parsed, instead of returning a boolean flag.
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
void
-eel_gdk_color_parse_with_white_default (const char *color_spec,
- GdkRGBA *color)
+eel_gdk_rgba_parse_with_white_default (GdkRGBA *color,
+ const char *color_spec)
{
gboolean got_color;
@@ -346,6 +346,14 @@ eel_gdk_color_parse_with_white_default (const char *color_spec,
}
}
#else
+/**
+ * eel_gdk_color_parse_with_white_default
+ * @color_spec: A color spec, or NULL.
+ * @color: Pointer to place to put resulting color.
+ *
+ * The same as gdk_color_parse, except sets the color to white if
+ * the spec. can't be parsed, instead of returning a boolean flag.
+ */
void
eel_gdk_color_parse_with_white_default (const char *color_spec,
GdkColor *color)
@@ -390,41 +398,50 @@ eel_rgb8_to_rgb (guchar r, guchar g, guchar b)
return eel_rgb16_to_rgb (r << 8, g << 8, b << 8);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
/**
- * eel_gdk_color_to_rgb
- * @color: A GdkColor style color.
+ * eel_gdk_rgba_to_rgb
+ * @color: A GdkRGBA style color.
* Returns: An rgb value.
*
- * Converts from a GdkColor stlye color to a gdk_rgb one.
+ * Converts from a GdkRGBA style color to a gdk_rgb one.
* Alpha gets set to fully opaque
*/
guint32
-#if GTK_CHECK_VERSION (3, 0, 0)
-eel_gdk_color_to_rgb (const GdkRGBA *color)
+eel_gdk_rgba_to_rgb (const GdkRGBA *color)
{
return eel_rgb16_to_rgb ((guint) (color->red * 65535),
(guint) (color->green * 65535),
(guint) (color->blue * 65535));
}
#else
+/**
+ * eel_gdk_color_to_rgb
+ * @color: A GdkColor style color.
+ * Returns: An rgb value.
+ *
+ * Converts from a GdkColor style color to a gdk_rgb one.
+ * Alpha gets set to fully opaque
+ */
+guint32
eel_gdk_color_to_rgb (const GdkColor *color)
{
return eel_rgb16_to_rgb (color->red, color->green, color->blue);
}
#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
/**
- * eel_gdk_rgb_to_color
+ * eel_gdk_rgb_to_rgba
* @color: a gdk_rgb style value.
*
- * Converts from a gdk_rgb value style to a GdkColor one.
+ * Converts from a gdk_rgb value style to a GdkRGBA one.
* The gdk_rgb color alpha channel is ignored.
*
- * Return value: A GdkColor structure version of the given RGB color.
+ * Return value: A GdkRGBA structure version of the given RGB color.
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA
-eel_gdk_rgb_to_color (guint32 color)
+eel_gdk_rgb_to_rgba (guint32 color)
{
GdkRGBA result;
@@ -432,6 +449,15 @@ eel_gdk_rgb_to_color (guint32 color)
result.green = ((color >> 8) & 0xFF) / 0xFF;
result.blue = (color & 0xff) / 0xFF;
#else
+/**
+ * eel_gdk_rgb_to_color
+ * @color: a gdk_rgb style value.
+ *
+ * Converts from a gdk_rgb value style to a GdkColor one.
+ * The gdk_rgb color alpha channel is ignored.
+ *
+ * Return value: A GdkColor structure version of the given RGB color.
+ */
GdkColor
eel_gdk_rgb_to_color (guint32 color)
{
@@ -461,13 +487,13 @@ eel_gdk_rgb_to_color_spec (const guint32 color)
return g_strdup_printf ("#%06X", (guint) (color & 0xFFFFFF));
}
+#if GTK_CHECK_VERSION(3,0,0)
/**
- * eel_gdk_color_is_dark:
+ * eel_gdk_rgba_is_dark:
*
* Return true if the given color is `dark'
*/
gboolean
-#if GTK_CHECK_VERSION(3,0,0)
eel_gdk_rgba_is_dark (const GdkRGBA *color)
{
int intensity;
@@ -476,6 +502,12 @@ eel_gdk_rgba_is_dark (const GdkRGBA *color)
+ (((int) (color->green) >> 8) * 150)
+ (((int) (color->blue) >> 8) * 28)) >> 8;
#else
+/**
+ * eel_gdk_color_is_dark:
+ *
+ * Return true if the given color is `dark'
+ */
+gboolean
eel_gdk_color_is_dark (GdkColor *color)
{
int intensity;
@@ -612,7 +644,7 @@ eel_make_color_inactive (GdkRGBA *color)
#if GTK_CHECK_VERSION(3,0,0)
static char *
-eel_gdk_color_as_hex_string (GdkRGBA color)
+eel_gdk_rgba_as_hex_string (GdkRGBA color)
{
return g_strdup_printf ("%04X%04X%04X",
(guint) (color.red * 65535),
@@ -625,8 +657,8 @@ eel_self_check_parse (const char *color_spec)
{
GdkRGBA color;
- eel_gdk_color_parse_with_white_default (color_spec, &color);
- return eel_gdk_color_as_hex_string (color);
+ eel_gdk_rgba_parse_with_white_default (&color, color_spec);
+ return eel_gdk_rgba_as_hex_string (color);
}
static char *
@@ -634,9 +666,9 @@ eel_self_check_gdk_rgb_to_color (guint32 color)
{
GdkRGBA result;
- result = eel_gdk_rgb_to_color (color);
+ result = eel_gdk_rgb_to_rgba (color);
- return eel_gdk_color_as_hex_string (result);
+ return eel_gdk_rgba_as_hex_string (result);
}
#else
static char *
diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h
index 1c74cff2..cd2ab757 100644
--- a/eel/eel-gdk-extensions.h
+++ b/eel/eel-gdk-extensions.h
@@ -102,10 +102,11 @@ char * eel_gradient_set_bottom_color_spec (const char
/* A version of parse_color that substitutes a default color instead of returning
a boolean to indicate it cannot be parsed.
*/
-void eel_gdk_color_parse_with_white_default (const char *color_spec,
#if GTK_CHECK_VERSION (3, 0, 0)
- GdkRGBA *parsed_color);
+void eel_gdk_rgba_parse_with_white_default (GdkRGBA *parsed_color,
+ const char *color_spec);
#else
+void eel_gdk_color_parse_with_white_default (const char *color_spec,
GdkColor *parsed_color);
#endif
guint32 eel_rgb16_to_rgb (gushort r,
@@ -115,8 +116,8 @@ guint32 eel_rgb8_to_rgb (guchar
guchar g,
guchar b);
#if GTK_CHECK_VERSION (3, 0, 0)
-guint32 eel_gdk_color_to_rgb (const GdkRGBA *color);
-GdkRGBA eel_gdk_rgb_to_color (guint32 color);
+guint32 eel_gdk_rgba_to_rgb (const GdkRGBA *color);
+GdkRGBA eel_gdk_rgb_to_rgba (guint32 color);
#else
guint32 eel_gdk_color_to_rgb (const GdkColor *color);
GdkColor eel_gdk_rgb_to_color (guint32 color);