[nautilus] [eel] remove unused eel_gradient code



commit 802e1967cdf301a50b8403cfe820097561c60033
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Nov 1 03:35:02 2010 +0100

    [eel] remove unused eel_gradient code

 eel/eel-gdk-extensions.c |  341 ----------------------------------------------
 eel/eel-gdk-extensions.h |   25 ----
 2 files changed, 0 insertions(+), 366 deletions(-)
---
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index 2dc66c3..4fa7973 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -37,267 +37,6 @@
 #include <stdlib.h>
 #include <pango/pango.h>
 
-#define GRADIENT_BAND_SIZE 4
-
-/**
- * eel_gradient_new
- * @start_color: Color for the top or left.
- * @end_color: Color for the bottom or right.
- * @is_horizontal: Direction of the gradient.
- *
- * Create a string that combines the start and end colors along
- * with the direction of the gradient in a standard format.
- */
-char *
-eel_gradient_new (const char *start_color,
-		       const char *end_color,
-		       gboolean is_horizontal)
-{
-	/* Handle the special case where the start and end colors are identical.
-	   Handle the special case where the end color is an empty string.
-	*/
-	if (eel_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0') {
-		return g_strdup (start_color);
-	}
-
-	/* Handle the special case where the start color is an empty string. */
-	if (start_color == NULL || start_color[0] == '\0') {
-		return g_strdup (end_color);
-	}
-	
-	/* Handle the general case. */
-	return g_strconcat (start_color, "-", end_color, is_horizontal ? ":h" : NULL, NULL);
-}
-
-/**
- * eel_gradient_is_gradient
- * @gradient_spec: A gradient spec. string.
- *
- * Return true if the spec. specifies a gradient instead of a solid color.
- */
-gboolean
-eel_gradient_is_gradient (const char *gradient_spec)
-{
-	return eel_strchr (gradient_spec, '-') != NULL;
-}
-
-/**
- * eel_gradient_is_horizontal
- * @gradient_spec: A gradient spec. string.
- *
- * Return true if the spec. specifies a horizontal gradient.
- */
-gboolean
-eel_gradient_is_horizontal (const char *gradient_spec)
-{
-	size_t length;
-
-	length = eel_strlen (gradient_spec);
-	return length >= 2 && gradient_spec[length - 2] == ':' && gradient_spec[length - 1] == 'h';
-}
-
-static char *
-eel_gradient_strip_trailing_direction_if_any (const char *gradient_spec)
-{
-	size_t length;
-
-	length = eel_strlen (gradient_spec);
-	if (length >= 2 && gradient_spec[length - 2] == ':'
-	    && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h')) {
-		length -= 2;
-	}
-
-	return g_strndup (gradient_spec, length);
-}
-
-/* For parsing n-point gradients. Successive calls should pass the next_spec value
- * set by the previous call as their first argument - to continue parsing where the
- * previous call left off.
- */
-char *
-eel_gradient_parse_one_color_spec (const char *spec, int *percent, const char **next_spec)
-{
-	char *result;
-	const char *rgb_end_ptr;
-	const char *percent_ptr;
-	const char *separator_ptr;
-	
-	percent_ptr   = eel_strchr (spec, '%');
-	separator_ptr = eel_strchr (spec, '-');
-
-	if (percent_ptr != NULL && (separator_ptr == NULL || percent_ptr < separator_ptr)) {
-		if (percent != NULL) {
-			*percent = (int) strtol (percent_ptr + 1, NULL, 10);
-		}
-		rgb_end_ptr = percent_ptr;
-	} else {
-		if (percent != NULL) {
-			*percent = 100;
-		}
-		rgb_end_ptr = separator_ptr;
-	}
-		
-	if (rgb_end_ptr != NULL) {
-		result = g_strndup (spec, rgb_end_ptr - spec);
-	} else {
-		result = eel_gradient_strip_trailing_direction_if_any (spec);
-	}
-
-	/* It's important not to use spec after setting *next_spec because it's
-	 * likely that *next_spec == spec. 
-	 */
-	if (next_spec != NULL) {
-		*next_spec = (separator_ptr != NULL) ? separator_ptr + 1 : NULL;
-	}
-
-	return result;
-}
-
-/* FIXME bugzilla.eazel.com 5076:
- * anyone using eel_gradient_get_start_color_spec or
- * eel_gradient_get_end_color_spec is assuming the gradient
- * is 2 colors which is questionable.
- * 
- * Callers should be rewritten and these fns eliminated.
- */
- 
-/**
- * eel_gradient_get_start_color_spec
- * @gradient_spec: A gradient spec. string.
- *
- * Return the start color.
- * This may be the entire gradient_spec if it's a solid color.
- */
-char *
-eel_gradient_get_start_color_spec (const char *gradient_spec)
-{
-	return eel_gradient_parse_one_color_spec (gradient_spec, NULL, NULL);
-}
-
-/**
- * eel_gradient_get_end_color_spec
- * @gradient_spec: A gradient spec. string.
- *
- * Return the end color.
- * This may be the entire gradient_spec if it's a solid color.
- */
-char *
-eel_gradient_get_end_color_spec (const char *gradient_spec)
-{
-	char* color = NULL;
-
-	do {
-		g_free (color);
-		color = eel_gradient_parse_one_color_spec (gradient_spec, NULL, &gradient_spec);
-	} while (gradient_spec != NULL);
-
-	return color;
-}
-
-/* Do the work shared by all the set_color_spec functions below. */
-static char *
-eel_gradient_set_edge_color (const char *gradient_spec,
-				  const char *edge_color,
-				  gboolean is_horizontal,
-				  gboolean change_end)
-{
-	char *opposite_color;
-	char *result;
-
-	g_assert (edge_color != NULL);
-
-	/* Get the color from the existing gradient spec. for the opposite
-	   edge. This will parse away all the stuff we don't want from the
-	   old gradient spec.
-	*/
-	opposite_color = change_end
-		? eel_gradient_get_start_color_spec (gradient_spec)
-		: eel_gradient_get_end_color_spec (gradient_spec);
-
-	/* Create a new gradient spec. The eel_gradient_new function handles
-	   some special cases, so we don't have to bother with them here.
-	*/
-	result = eel_gradient_new (change_end ? opposite_color : edge_color,
-					change_end ? edge_color : opposite_color,
-					is_horizontal);
-
-	g_free (opposite_color);
-
-	return result;
-}
-
-/**
- * eel_gradient_set_left_color_spec
- * @gradient_spec: A gradient spec. string.
- * @left_color: Color spec. to replace left color with.
- *
- * Changes the left color to what's passed in.
- * This creates a horizontal gradient.
- */
-char *
-eel_gradient_set_left_color_spec (const char *gradient_spec,
-				       const char *left_color)
-{
-	g_return_val_if_fail (gradient_spec != NULL, NULL);
-	g_return_val_if_fail (left_color != NULL, NULL);
-
-	return eel_gradient_set_edge_color (gradient_spec, left_color, TRUE, FALSE);
-}
-
-/**
- * eel_gradient_set_top_color_spec
- * @gradient_spec: A gradient spec. string.
- * @top_color: Color spec. to replace top color with.
- *
- * Changes the top color to what's passed in.
- * This creates a vertical gradient.
- */
-char *
-eel_gradient_set_top_color_spec (const char *gradient_spec,
-				      const char *top_color)
-{
-	g_return_val_if_fail (gradient_spec != NULL, NULL);
-	g_return_val_if_fail (top_color != NULL, NULL);
-
-	return eel_gradient_set_edge_color (gradient_spec, top_color, FALSE, FALSE);
-}
-
-/**
- * eel_gradient_set_right_color_spec
- * @gradient_spec: A gradient spec. string.
- * @right_color: Color spec. to replace right color with.
- *
- * Changes the right color to what's passed in.
- * This creates a horizontal gradient.
- */
-char *
-eel_gradient_set_right_color_spec (const char *gradient_spec,
-					const char *right_color)
-{
-	g_return_val_if_fail (gradient_spec != NULL, NULL);
-	g_return_val_if_fail (right_color != NULL, NULL);
-
-	return eel_gradient_set_edge_color (gradient_spec, right_color, TRUE, TRUE);
-}
-
-/**
- * eel_gradient_set_bottom_color_spec
- * @gradient_spec: A gradient spec. string.
- * @bottom_color: Color spec. to replace bottom color with.
- *
- * Changes the bottom color to what's passed in.
- * This creates a vertical gradient.
- */
-char *
-eel_gradient_set_bottom_color_spec (const char *gradient_spec,
-					 const char *bottom_color)
-{
-	g_return_val_if_fail (gradient_spec != NULL, NULL);
-	g_return_val_if_fail (bottom_color != NULL, NULL);
-
-	return eel_gradient_set_edge_color (gradient_spec, bottom_color, FALSE, TRUE);
-}
-
 /**
  * eel_gdk_color_parse_with_white_default
  * @color_spec: A color spec, or NULL.
@@ -535,86 +274,6 @@ eel_self_check_gdk_rgb_to_color (guint32 color)
 void
 eel_self_check_gdk_extensions (void)
 {
-	/* eel_gradient_new */
-	EEL_CHECK_STRING_RESULT (eel_gradient_new ("", "", FALSE), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "b", FALSE), "a-b");
-	EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "b", TRUE), "a-b:h");
-	EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "a", FALSE), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "a", TRUE), "a");
-
-	/* eel_gradient_is_gradient */
-	EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient (""), FALSE);
-	EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("-"), TRUE);
-	EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("a"), FALSE);
-	EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("a-b"), TRUE);
-	EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("a-b:h"), TRUE);
-
-	/* eel_gradient_get_start_color_spec */
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec (""), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("-"), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a-b"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a-"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("-b"), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:h"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:v"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:c"), "a:c");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:-b"), "a:");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:-b:v"), "a:");
-
-	/* eel_gradient_get_end_color_spec */
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec (""), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("-"), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a-b"), "b");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a-"), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("-b"), "b");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:h"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:v"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:c"), "a:c");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:-b"), "b");
-	EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:-b:v"), "b");
-
-	/* eel_gradient_set_left_color_spec */
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("", ""), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a", ""), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a", "b"), "b-a:h");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a-c:v", "b"), "b-c:h");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a-c:v", "c"), "c");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a:-b:v", "d"), "d-b:h");
-
-	/* eel_gradient_set_top_color_spec */
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("", ""), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a", ""), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a", "b"), "b-a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a-c:v", "b"), "b-c");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a-c:v", "c"), "c");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a:-b:h", "d"), "d-b");
-
-	/* eel_gradient_set_right_color_spec */
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("", ""), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a", ""), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a", "b"), "a-b:h");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a-c:v", "b"), "a-b:h");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a-c:v", "c"), "a-c:h");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a:-b:v", "d"), "a:-d:h");
-
-	/* eel_gradient_set_bottom_color_spec */
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("", ""), "");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a", ""), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a", "a"), "a");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a", "b"), "a-b");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a-c:v", "b"), "a-b");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a-c:v", "c"), "a-c");
-	EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a:-b:h", "d"), "a:-d");
-
 	/* eel_gdk_color_parse_with_white_default */
 	EEL_CHECK_STRING_RESULT (eel_self_check_parse (""), "FFFFFFFFFFFF");
 	EEL_CHECK_STRING_RESULT (eel_self_check_parse ("a"), "FFFFFFFFFFFF");
diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h
index b135264..70b1005 100644
--- a/eel/eel-gdk-extensions.h
+++ b/eel/eel-gdk-extensions.h
@@ -69,31 +69,6 @@ typedef enum {
 	EEL_GDK_Y_NEGATIVE   = 0x20
 } EelGdkGeometryFlags;
 
-/* A gradient spec. is a string that contains a specifier for either a
-   color or a gradient. If the string has a "-" in it, then it's a gradient.
-   The gradient is vertical by default and the spec. can end with ":v" to indicate that.
-   If the gradient ends with ":h", the gradient is horizontal.
-*/
-char *              eel_gradient_new                       (const char          *start_color,
-							    const char          *end_color,
-							    gboolean             is_horizontal);
-char *              eel_gradient_parse_one_color_spec      (const char          *spec,
-							    int                 *percent,
-							    const char         **next_spec);
-gboolean            eel_gradient_is_gradient               (const char          *gradient_spec);
-char *              eel_gradient_get_start_color_spec      (const char          *gradient_spec);
-char *              eel_gradient_get_end_color_spec        (const char          *gradient_spec);
-gboolean            eel_gradient_is_horizontal             (const char          *gradient_spec);
-char *              eel_gradient_set_left_color_spec       (const char          *gradient_spec,
-							    const char          *left_color);
-char *              eel_gradient_set_top_color_spec        (const char          *gradient_spec,
-							    const char          *top_color);
-char *              eel_gradient_set_right_color_spec      (const char          *gradient_spec,
-							    const char          *right_color);
-char *              eel_gradient_set_bottom_color_spec     (const char          *gradient_spec,
-							    const char          *bottom_color);
-
-
 /* A version of parse_color that substitutes a default color instead of returning
    a boolean to indicate it cannot be parsed.
 */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]