[evolution] Embed e_hsv_tweak() directly in e-table-item.c.



commit 8494cbd4f1b3ad4a3d738df03170f945afce237b
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jun 1 09:27:12 2011 -0400

    Embed e_hsv_tweak() directly in e-table-item.c.
    
    ETableItem is the last user of e_hsv_tweak().
    This allows us to remove widgets/misc/e-hsv-utils.[ch].

 COPYING                            |    1 -
 widgets/misc/Makefile.am           |    2 -
 widgets/misc/e-canvas-background.c |    1 -
 widgets/misc/e-hsv-utils.c         |   72 ------------------------------------
 widgets/misc/e-hsv-utils.h         |   38 -------------------
 widgets/table/e-cell-toggle.c      |    1 -
 widgets/table/e-table-item.c       |   44 +++++++++++++++++++++-
 7 files changed, 43 insertions(+), 116 deletions(-)
---
diff --git a/COPYING b/COPYING
index ff4f32b..262c783 100644
--- a/COPYING
+++ b/COPYING
@@ -16,7 +16,6 @@ LGPLv2 only
 LGPLv2+
         e-util/gconf-bridge.[ch]
         widgets/misc/e-icon-entry.[ch]
-        widgets/misc/e-hsv-utils.[ch]
         widgets/text/e-text.[ch]
         widgets/table/e-cell-tree.[ch]
         widgets/misc/e-dateedit.[ch]
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 05a5967..fdcd541 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -36,7 +36,6 @@ widgetsinclude_HEADERS =			\
 	e-dateedit.h				\
 	e-focus-tracker.h			\
 	e-hinted-entry.h			\
-	e-hsv-utils.h				\
 	e-image-chooser.h			\
 	e-import-assistant.h			\
 	e-map.h					\
@@ -115,7 +114,6 @@ libemiscwidgets_la_SOURCES =			\
 	e-dateedit.c				\
 	e-focus-tracker.c			\
 	e-hinted-entry.c			\
-	e-hsv-utils.c				\
 	e-image-chooser.c			\
 	e-import-assistant.c			\
 	e-map.c					\
diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c
index 10cddb4..dc41577 100644
--- a/widgets/misc/e-canvas-background.c
+++ b/widgets/misc/e-canvas-background.c
@@ -37,7 +37,6 @@
 #include "e-util/e-util.h"
 #include "misc/e-canvas.h"
 #include "misc/e-canvas-utils.h"
-#include "misc/e-hsv-utils.h"
 
 #include "e-canvas-background.h"
 
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
index 8583446..06b26c5 100644
--- a/widgets/table/e-cell-toggle.c
+++ b/widgets/table/e-cell-toggle.c
@@ -35,7 +35,6 @@
 #include "gal-a11y-e-cell-toggle.h"
 #include "gal-a11y-e-cell-registry.h"
 #include "e-util/e-util.h"
-#include "misc/e-hsv-utils.h"
 
 #include "e-cell-toggle.h"
 #include "e-table-item.h"
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 4b4299f..ac46df2 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -44,7 +44,6 @@
 #include "e-util/e-util.h"
 #include "misc/e-canvas.h"
 #include "misc/e-canvas-utils.h"
-#include "misc/e-hsv-utils.h"
 
 #include "e-cell.h"
 #include "e-table-item.h"
@@ -122,6 +121,49 @@ static void e_table_item_redraw_row (ETableItem *eti, gint row);
 #define ETI_MULTIPLE_ROW_HEIGHT(eti,row) ((eti)->height_cache && (eti)->height_cache[(row)] != -1 ? (eti)->height_cache[(row)] : eti_row_height((eti),(row)))
 #define ETI_ROW_HEIGHT(eti,row) ((eti)->uniform_row_height ? ETI_SINGLE_ROW_HEIGHT ((eti)) : ETI_MULTIPLE_ROW_HEIGHT((eti),(row)))
 
+/* tweak_hsv is a really tweaky function. it modifies its first argument, which
+   should be the color you want tweaked. delta_h, delta_s and delta_v specify
+   how much you want their respective channels modified (and in what direction).
+   if it can't do the specified modification, it does it in the oppositon direction */
+static void
+e_hsv_tweak (GdkColor *color,
+             gdouble delta_h,
+             gdouble delta_s,
+             gdouble delta_v)
+{
+	gdouble h, s, v, r, g, b;
+
+	r = color->red   / 65535.0f;
+	g = color->green / 65535.0f;
+	b = color->blue  / 65535.0f;
+
+	gtk_rgb_to_hsv (r, g, b, &h, &s, &v);
+
+	if (h + delta_h < 0) {
+		h -= delta_h;
+	} else {
+		h += delta_h;
+	}
+
+	if (s + delta_s < 0) {
+		s -= delta_s;
+	} else {
+		s += delta_s;
+	}
+
+	if (v + delta_v < 0) {
+		v -= delta_v;
+	} else {
+		v += delta_v;
+	}
+
+	gtk_hsv_to_rgb (h, s, v, &r, &g, &b);
+
+	color->red   = r * 65535.0f;
+	color->green = g * 65535.0f;
+	color->blue  = b * 65535.0f;
+}
+
 inline static gint
 model_to_view_row (ETableItem *eti, gint row)
 {



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