gnome-scan r598 - in trunk: . doc/ref/tmpl lib modules



Author: bersace
Date: Tue May  6 15:14:19 2008
New Revision: 598
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=598&view=rev

Log:
Rewrote GnomeScanUnit, GnomeScanRectangle and unit conversion function
in Vala.



Added:
   trunk/lib/gnome-scan-common.vala
   trunk/lib/gnome-scan-option.vala
Modified:
   trunk/ChangeLog
   trunk/doc/ref/tmpl/gnome-scan-utils.sgml
   trunk/lib/Makefile.am
   trunk/lib/gnome-scan-types.c
   trunk/lib/gnome-scan-types.h
   trunk/lib/gnome-scan-utils.c
   trunk/lib/gnome-scan-utils.h
   trunk/modules/gsane-meta-param.c
   trunk/modules/gsane-scanner.c

Modified: trunk/doc/ref/tmpl/gnome-scan-utils.sgml
==============================================================================
--- trunk/doc/ref/tmpl/gnome-scan-utils.sgml	(original)
+++ trunk/doc/ref/tmpl/gnome-scan-utils.sgml	Tue May  6 15:14:19 2008
@@ -57,7 +57,7 @@
 
 @GNOME_SCAN_UNIT_NONE: 
 @GNOME_SCAN_UNIT_PIXEL: 
- GNOME_SCAN_UNIT_POINT: 
+ GNOME_SCAN_UNIT_POINTS: 
 @GNOME_SCAN_UNIT_MM: 
 @GNOME_SCAN_UNIT_BIT: 
 @GNOME_SCAN_UNIT_DPI: 

Modified: trunk/lib/Makefile.am
==============================================================================
--- trunk/lib/Makefile.am	(original)
+++ trunk/lib/Makefile.am	Tue May  6 15:14:19 2008
@@ -1,5 +1,6 @@
 INCLUDES = \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\"	\
+	-DGETTEXT_PACKAGE=\""@GETTEXT_PACKAGE@"\"	\
 	-DICON_DIR=\""@ICON_DIR@"\"
 
 AM_CFLAGS = \
@@ -12,6 +13,7 @@
 	$(srcdir)/gnome-scan-types.c
 
 BUILT_SOURCES = \
+	gnome-scan.vala.stamp \
 	$(BUILT_SOURCE)
 
 types_deps = \
@@ -23,19 +25,23 @@
 lib_LTLIBRARIES = \
 	lib SONAME@.la 
 
-lib SONAME@_la_VALASOURCES = \
+libgnomescan_la_VALASOURCES = \
+	gnome-scan-common.vala	\
 	$(NULL)
 
 lib SONAME@_la_VALAPKGADD = \
 	--pkg=glib-2.0	\
 	--pkg=gtk+-2.0	\
+	--pkg=gconf-2.0 \
+	--vapidir=. --pkg=config \
 	$(NULL)
 
 lib SONAME@_la_SOURCES = \
-	$(BUILT_SOURCES)	\
-	$(BUILT_HEADER)	\
-	$(lib SONAME@_la_VALASOURCES:.vala=.c)	\
-	$(lib SONAME@_la_VALASOURCES:.vala=.h)	\
+	gnome-scan.vala.stamp	\
+	$(BUILT_SOURCE) \
+	$(BUILT_HEADER) \
+	$(libgnomescan_la_VALASOURCES:.vala=.c)	\
+	$(libgnomescan_la_VALASOURCES:.vala=.h)	\
 	gnome-scan-settings.h          \
 	gnome-scan-settings.c          \
 	gnome-scan-plugin.h          \
@@ -104,6 +110,7 @@
 	gnome-scan.h	\
 	$(BUILT_HEADER)	\
 	gnome-scan-utils.h		\
+	gnome-scan-common.h		\
 	gnome-scan-settings.h          	\
 	gnome-scan-plugin.h          	\
 	gnome-scanner.h          	\

Added: trunk/lib/gnome-scan-common.vala
==============================================================================
--- (empty file)
+++ trunk/lib/gnome-scan-common.vala	Tue May  6 15:14:19 2008
@@ -0,0 +1,175 @@
+using GLib;
+using Gtk;
+
+namespace Gnome {
+	namespace Scan {
+		public const double MM_PER_INCH	= 25.4;
+
+		public enum Unit {
+			NONE	= -1,
+			PIXEL	,//= Gtk.Unit.PIXEL,
+			POINTS	,//= Gtk.Unit.POINTS,
+			MM		,//= Gtk.Unit.MM,
+			BIT,
+			DPI,
+			PERCENT,
+			MICROSECOND
+		}
+
+		private void warn_unsupported_unit(Unit unit)
+		{
+			warning("Unit %i conversion not supported.", unit);
+		}
+
+		/**
+		 * gnome_scan_convert:
+		 * @val:	the value to convert
+		 * @from:	the current @val unit
+		 * @to:		the target unit fro @val
+		 * @res:	the resolution in dpi
+		 *
+		 * Convert @val from @from unit to @to at @res resolution. Useful for
+		 * preview area, #GnomeScanner, etc.
+		 **/
+		public double convert(double val,
+							  Unit from,
+							  Unit to,
+							  double res)
+		{
+			if (from == to)
+				return val;
+
+			switch(from) {
+			case Unit.NONE:
+			case Unit.BIT:
+			case Unit.PERCENT:
+			case Unit.MICROSECOND:
+			case Unit.DPI:
+				warn_unsupported_unit(from);
+				return val;
+			default:
+				switch (to) {
+				case Unit.NONE:
+				case Unit.BIT:
+				case Unit.PERCENT:
+				case Unit.MICROSECOND:
+				case Unit.DPI:
+					warn_unsupported_unit(to);
+					return val;
+				default:
+					return convert_from_mm (convert_to_mm (val, from, res),
+											to, res);
+				}
+			}
+		}
+
+		public double convert_from_mm(double val,
+									  Unit to,
+									  double res)
+		{
+			switch (to) {
+			case Unit.NONE:
+			case Unit.BIT:
+			case Unit.PERCENT:
+			case Unit.MICROSECOND:
+			case Unit.DPI:
+				warn_unsupported_unit(to);
+				return val;
+			case Unit.MM:
+				return val;
+			case Unit.PIXEL:
+				return val * (MM_PER_INCH / res);
+			}
+			return 0.;
+		}
+
+		public double convert_to_mm(double val,
+									Unit from,
+									double res)
+		{
+			switch (from) {
+			case Unit.NONE:
+			case Unit.BIT:
+			case Unit.PERCENT:
+			case Unit.MICROSECOND:
+			case Unit.DPI:
+				warn_unsupported_unit(from);
+				return val;
+			case Unit.MM:
+				return val;
+			case Unit.PIXEL:
+				return val / (MM_PER_INCH / res);
+			}
+			return 0.;
+		}
+
+		public struct Rectangle {
+			double	x;
+			double	y;
+			double	width;
+			double	height;
+
+			private	double max(double a, double b)
+			{
+				return a > b ? a : b;
+			}
+
+			public void	rotate(Rectangle	area,
+							   int		angle)
+			{
+				angle%= 360;
+	
+				switch (angle)
+				{
+				case 0:
+					break;
+				case 270:
+					this.width = this.height;
+					this.height = this.width;
+					this.x = this.y;
+					this.y = max(area.width - this.x - this.width, area.x);
+					break;
+				case 180:
+					this.x = max(area.width - this.x - this.width, area.x);
+					this.y = max(area.height - this.y - this.height, area.y);
+					break;
+				case 90:
+					this.width = this.height;
+					this.height = this.width;
+					this.y = this.x;
+					this.x = max(area.height - this.y - this.height, area.y);
+					break;
+				default:
+					warning("%i degree rotation is not supported", angle);
+					break;
+				}
+			}
+
+			public void convert(Unit	from,
+								Unit	to,
+								double	res)
+			{
+				convert_to_mm(from, res);
+				convert_from_mm(to, res);
+			}
+
+			public void	convert_to_mm(Unit	from,
+									  double	res)
+			{
+				this.x		= Gnome.Scan.convert_to_mm(this.x,		from, res);
+				this.y		= Gnome.Scan.convert_to_mm(this.y,		from, res);
+				this.width	= Gnome.Scan.convert_to_mm(this.width,	from, res);
+				this.height = Gnome.Scan.convert_to_mm(this.height,	from, res);
+			}
+
+			public void	convert_from_mm(Unit	to,
+										double	res)
+			{
+				this.x		= Gnome.Scan.convert_from_mm(this.x,		to, res);
+				this.y		= Gnome.Scan.convert_from_mm(this.y,		to, res);
+				this.width	= Gnome.Scan.convert_from_mm(this.width,	to, res);
+				this.height = Gnome.Scan.convert_from_mm(this.height,	to, res);
+			}
+		}
+	}
+}
\ No newline at end of file

Added: trunk/lib/gnome-scan-option.vala
==============================================================================
--- (empty file)
+++ trunk/lib/gnome-scan-option.vala	Tue May  6 15:14:19 2008
@@ -0,0 +1,206 @@
+using GLib;
+
+namespace Gnome {
+	namespace Scan {
+		public const Quark GROUP_SCANNER_FRONT	= Quark.from_string(N_("Scan Options"));
+		public const Quark GROUP_SINK_FRONT		= Quark.from_string(N_("Output Options"));
+		public const Quark GROUP_FORMAT			= Quark.from_string(N_("Format"));
+		public const Quark GROUP_HIDDEN			= Quark.from_string("$$HIDDEN$$");
+		public const Quark GROUP_PREVIEW		= Quark.from_string("$$PREVIEW");
+
+		public enum OptionFlags {
+			ACTIVE	= 1 << 0,
+			RANGE,
+			ENUM
+		}
+	}
+}
+
+public abstract class Gnome.Scan.Option : Object {
+	[Description(nick="Option name",
+				 blurb="Unique name of the option.")]
+	public string	name	{get; set construct;}
+	[Description(nick="Option title",
+				 blurb="Translated title of the option")]
+	public string	title	{get; set construct;}
+	[Description(nick="Description",
+				 blurb="Translated option description")]
+	public string	desc	{get; set construct;}
+	[Description(nick="Translation domaine")]
+	public string	domain	{get; set construct;}
+	[Description(nick="Option group")]
+	public Quark	group	{get; set construct;}
+	public Gnome.Scan.Unit	unit		{get; set construct; default = Unit.NONE;}
+	[Notify]
+		public OptionFlags	flags	{get; set construct;}
+	public int	index	{get; set construct; default = 0;}
+
+	public Value init_value();
+	public Value from_gconf_value(GConf.Value value);
+	public GConf.Value to_gconf_value(Value value);
+}
+
+public class Gnome.Scan.OptionInt : Gnome.Scan.Option {
+	public int 	default_value {get; set construct; default = 0;}
+	public int	min;
+	public int	max;
+	public int	step;
+	public SList<int>	values;
+
+	public OptionInt(string name,
+					 string title,
+					 string desc,
+					 string domain,
+					 Quark group,
+					 int index,
+					 int default_value,
+					 OptionFlags flags)
+	{
+		this.name	= name;
+		this.title	= title;
+		this.desc	= desc;
+		this.domain = domain;
+		this.group	= group;
+		this.index	= index;
+		this.default_value = default_value;
+		this.flags	= flags;
+	}
+
+	public void set_range(int min, int max, int step)
+	{
+		return_if_fail ((bool) (this.flags & OptionFlags.RANGE));
+
+		this.min = min;
+		this.max = max;
+		this.step = step;
+	}
+
+	public void set_enum(SList values)
+	{
+		return_if_fail ((bool) (this.flags & OptionFlags.ENUM));
+		this.values = values.copy();
+	}
+}
+
+public class Gnome.Scan.OptionDouble : Gnome.Scan.Option {
+	public double default_value {get; set construct; default = 0.;}
+	public double	min;
+	public double	max;
+	public double	step;
+	public SList	values;
+
+
+	public OptionDouble(string name,
+						string title,
+						string desc,
+						string domain,
+						Quark group,
+						int index,
+						double default_value,
+						OptionFlags flags)
+	{
+		this.name	= name;
+		this.title	= title;
+		this.desc	= desc;
+		this.domain = domain;
+		this.group	= group;
+		this.index	= index;
+		this.default_value = default_value;
+		this.flags	= flags;
+	}
+
+	public void set_range(double min, double max, double step)
+	{
+		return_if_fail ((bool) (this.flags & OptionFlags.RANGE));
+
+		this.min = min;
+		this.max = max;
+		this.step = step;
+	}
+
+	public void set_enum(SList values)
+	{
+		return_if_fail ((bool) (this.flags & OptionFlags.ENUM));
+		this.values = values.copy();
+	}
+}
+
+public class Gnome.Scan.OptionString : Gnome.Scan.Option {
+	public string default_value {get; set construct; default = null;}
+	public SList	values;
+
+	public OptionString(string name,
+						string title,
+						string desc,
+						string domain,
+						Quark group,
+						int index,
+						string default_value,
+						OptionFlags flags)
+	{
+		this.name	= name;
+		this.title	= title;
+		this.desc	= desc;
+		this.domain = domain;
+		this.group	= group;
+		this.index	= index;
+		this.default_value = default_value;
+		this.flags	= flags;
+	}
+
+	public void set_enum(SList values)
+	{
+		return_if_fail ((bool) (this.flags & OptionFlags.ENUM));
+		this.values = values.copy();
+	}
+}
+
+public class Gnome.Scan.OptionPaperSize : Gnome.Scan.Option {
+	[Notify]
+		public weak SList		paper_sizes		{set; get;}
+	public weak Gtk.PaperSize	default_value	{set construct; get;}
+
+	public OptionPaperSize(string name,
+						   string title,
+						   string desc,
+						   string domain,
+						   Quark group,
+						   int index,
+						   Gtk.PaperSize# default_value,
+						   SList# paper_sizes,
+						   OptionFlags flags)
+	{
+		this.name	= name;
+		this.title	= title;
+		this.desc	= desc;
+		this.domain = domain;
+		this.group	= group;
+		this.index	= index;
+		this.default_value = default_value;
+		this.paper_sizes = paper_sizes;
+		this.flags	= flags;
+	}
+}
+
+public class Gnome.Scan.OptionPageOrientation : Gnome.Scan.Option {
+	public Gtk.PageOrientation	default_value	{set construct; get;}
+
+	public OptionPageOrientation(string name,
+								 string title,
+								 string desc,
+								 string domain,
+								 Quark group,
+								 int index,
+								 Gtk.PageOrientation default_value,
+								 OptionFlags flags)
+	{
+		this.name	= name;
+		this.title	= title;
+		this.desc	= desc;
+		this.domain = domain;
+		this.group	= group;
+		this.index	= index;
+		this.default_value = default_value;
+		this.flags	= flags;
+	}
+}

Modified: trunk/lib/gnome-scan-types.c
==============================================================================
--- trunk/lib/gnome-scan-types.c	(original)
+++ trunk/lib/gnome-scan-types.c	Tue May  6 15:14:19 2008
@@ -51,32 +51,6 @@
   return type;
 }
 
-/* Enumerations from "gnome-scan-utils.h" */
-#include "gnome-scan-utils.h"
-
-GType
-gs_param_unit_get_type (void)
-{
-  static GType type = 0;
-  static const GEnumValue _gs_param_unit_values[] = {
-  { GNOME_SCAN_UNIT_NONE, "GNOME_SCAN_UNIT_NONE", "gnome-scan-unit-none" },
-  { GNOME_SCAN_UNIT_PIXEL, "GNOME_SCAN_UNIT_PIXEL", "gnome-scan-unit-pixel" },
-  { GNOME_SCAN_UNIT_POINT, "GNOME_SCAN_UNIT_POINT", "gnome-scan-unit-point" },
-  { GNOME_SCAN_UNIT_MM, "GNOME_SCAN_UNIT_MM", "gnome-scan-unit-mm" },
-  { GNOME_SCAN_UNIT_BIT, "GNOME_SCAN_UNIT_BIT", "gnome-scan-unit-bit" },
-  { GNOME_SCAN_UNIT_DPI, "GNOME_SCAN_UNIT_DPI", "gnome-scan-unit-dpi" },
-  { GNOME_SCAN_UNIT_PERCENT, "GNOME_SCAN_UNIT_PERCENT", "gnome-scan-unit-percent" },
-  { GNOME_SCAN_UNIT_MICROSECOND, "GNOME_SCAN_UNIT_MICROSECOND", "gnome-scan-unit-microsecond" },
-  { 0, NULL, NULL }
-};
-
-  if (type == 0) {
-    type = g_enum_register_static ("GnomeScanUnit", _gs_param_unit_values);
-  }
-
-  return type;
-}
-
 
 /* Generated data ends here */
 

Modified: trunk/lib/gnome-scan-types.h
==============================================================================
--- trunk/lib/gnome-scan-types.h	(original)
+++ trunk/lib/gnome-scan-types.h	Tue May  6 15:14:19 2008
@@ -31,10 +31,6 @@
 #define GNOME_TYPE_SCANNER_STATUS	(gnome_scanner_status_get_type ())
 GType	gnome_scanner_status_get_type (void)	G_GNUC_CONST;
 
-/* Enumerations from "gnome-scan-utils.h" */
-#define GNOME_TYPE_SCAN_UNIT	(gs_param_unit_get_type ())
-GType	gs_param_unit_get_type (void)	G_GNUC_CONST;
-
 
 G_END_DECLS
 

Modified: trunk/lib/gnome-scan-utils.c
==============================================================================
--- trunk/lib/gnome-scan-utils.c	(original)
+++ trunk/lib/gnome-scan-utils.c	Tue May  6 15:14:19 2008
@@ -28,8 +28,6 @@
 #include "gnome-scan-utils.h"
 #include "gnome-scan-types.h"
 
-#define	GNOME_SCAN_WARN_UNSUPPORTED_UNIT(unit)	g_warning("%s: Unsupported unit %s.", __FUNCTION__, gnome_scan_enum_get_nick_from_value (GNOME_TYPE_SCAN_UNIT, unit))
-
 const gchar*
 gnome_scan_enum_get_nick_from_value (GType type, guint value)
 {
@@ -42,163 +40,3 @@
 	
 	return g_strdup (val->value_nick);
 }
-
-/**
- * gnome_scan_convert:
- * @val:	the value to convert
- * @from:	the current @val unit
- * @to:		the target unit fro @val
- * @res:	the resolution in dpi
- *
- * Convert @val from @from unit to @to at @res resolution. Useful for
- * preview area, #GnomeScanner, etc.
- **/
-gdouble
-gnome_scan_convert (gdouble val,
-					GnomeScanUnit from,
-					GnomeScanUnit to,
-					gdouble res)
-{
-	if (from == to)
-		return val;
-	
-	switch (from) {
-	case GNOME_SCAN_UNIT_NONE:
-	case GNOME_SCAN_UNIT_BIT:
-	case GNOME_SCAN_UNIT_PERCENT:
-	case GNOME_SCAN_UNIT_MICROSECOND:
-	case GNOME_SCAN_UNIT_DPI:
-		GNOME_SCAN_WARN_UNSUPPORTED_UNIT(from);
-		return val;
-	default:
-		switch (to) {
-		case GNOME_SCAN_UNIT_NONE:
-		case GNOME_SCAN_UNIT_BIT:
-		case GNOME_SCAN_UNIT_PERCENT:
-		case GNOME_SCAN_UNIT_MICROSECOND:
-		case GNOME_SCAN_UNIT_DPI:
-			GNOME_SCAN_WARN_UNSUPPORTED_UNIT(from);
-			return val;
-		default:
-			return gnome_scan_convert_from_mm (gnome_scan_convert_to_mm (val, from, res),
-											   to, res);
-		}
-	}
-}
-
-
-gdouble
-gnome_scan_convert_to_mm (gdouble val,
-						  GnomeScanUnit unit,
-						  gdouble res)
-{
-	switch (unit) {
-	case GNOME_SCAN_UNIT_NONE:
-	case GNOME_SCAN_UNIT_BIT:
-	case GNOME_SCAN_UNIT_PERCENT:
-	case GNOME_SCAN_UNIT_MICROSECOND:
-	case GNOME_SCAN_UNIT_DPI:
-		GNOME_SCAN_WARN_UNSUPPORTED_UNIT(unit);
-		return val;
-	case GNOME_SCAN_UNIT_MM:
-		return val;
-	case GNOME_SCAN_UNIT_PIXEL:
-		return val * (MM_PER_INCH / res);
-	}
-}
-
-gdouble
-gnome_scan_convert_from_mm (gdouble val,
-							GnomeScanUnit unit,
-							gdouble res)
-{
-	switch (unit) {
-	case GNOME_SCAN_UNIT_NONE:
-	case GNOME_SCAN_UNIT_BIT:
-	case GNOME_SCAN_UNIT_PERCENT:
-	case GNOME_SCAN_UNIT_MICROSECOND:
-	case GNOME_SCAN_UNIT_DPI:
-		GNOME_SCAN_WARN_UNSUPPORTED_UNIT(unit);
-		return val;
-	case GNOME_SCAN_UNIT_MM:
-		return val;
-	case GNOME_SCAN_UNIT_PIXEL:
-		return val / (MM_PER_INCH / res);
-	}
-}
-
-GnomeScanRectangle*
-gnome_scan_rectangle_convert (GnomeScanRectangle *r,
-							  GnomeScanUnit from,
-							  GnomeScanUnit to,
-							  gdouble res)
-{
-	return gnome_scan_rectangle_convert_from_mm (gnome_scan_rectangle_convert_to_mm (r, from, res),
-												 to, res);
-}
-
-GnomeScanRectangle*
-gnome_scan_rectangle_convert_to_mm (GnomeScanRectangle *r,
-									GnomeScanUnit unit,
-									gdouble res)
-{
-	GnomeScanRectangle*rect = g_new0 (GnomeScanRectangle, 1);
-#define conv(var)	rect->var = gnome_scan_convert_to_mm (r->var, unit, res)
-	conv(x);
-	conv(y);
-	conv(width);
-	conv(height);
-#undef	conv
-	return rect;
-}
-
-GnomeScanRectangle*
-gnome_scan_rectangle_convert_from_mm (GnomeScanRectangle *r,
-									  GnomeScanUnit unit,
-									  gdouble res)
-{
-	GnomeScanRectangle*rect = g_new0 (GnomeScanRectangle, 1);
-#define conv(var)	rect->var = gnome_scan_convert_from_mm (r->var, unit, res)
-	conv(x);
-	conv(y);
-	conv(width);
-	conv(height);
-#undef	conv
-	return rect;
-}
-
-GnomeScanRectangle*
-gnome_scan_rectangle_rotate(GnomeScanRectangle *r,
-							GnomeScanRectangle *a,
-							guint angle)
-{
-	GnomeScanRectangle *res = g_memdup(r, sizeof(GnomeScanRectangle));
-	angle%= 360;
-	
-	switch (angle)
-		{
-		case 0:
-			break;
-		case 270:
-			res->width = r->height;
-			res->height = r->width;
-			res->x = r->y;
-			res->y = MAX(a->width - r->x - r->width, a->x);
-			break;
-		case 180:
-			res->x = MAX(a->width - r->x - r->width, a->x);
-			res->y = MAX(a->height - r->y - r->height, a->y);
-			break;
-		case 90:
-			res->width = r->height;
-			res->height = r->width;
-			res->y = r->x;
-			res->x = MAX(a->height - r->y - r->height, a->y);
-			break;
-		default:
-			g_warning("%s: %i degree rotation is not supported",
-					  __FUNCTION__, angle);
-			break;
-		}
-	return res;
-}

Modified: trunk/lib/gnome-scan-utils.h
==============================================================================
--- trunk/lib/gnome-scan-utils.h	(original)
+++ trunk/lib/gnome-scan-utils.h	Tue May  6 15:14:19 2008
@@ -26,6 +26,7 @@
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
+#include <gnome-scan-common.h>
 
 G_BEGIN_DECLS
 
@@ -86,66 +87,9 @@
 	gdouble y;
 };
 
-typedef struct _GnomeScanRectangle GnomeScanRectangle;
-struct _GnomeScanRectangle
-{
-	gdouble x;
-	gdouble y;
-	gdouble width;
-	gdouble height;
-};
-
-/**
- * GnomeScanUnit:
- **/
-typedef enum /*< underscore_name=gnome_scan_unit,prefix=GNOME_SCAN_UNIT >*/
-	{
-		GNOME_SCAN_UNIT_NONE=-1,
-		GNOME_SCAN_UNIT_PIXEL=GTK_UNIT_PIXEL,
-		GNOME_SCAN_UNIT_POINT=GTK_UNIT_POINTS,
-		GNOME_SCAN_UNIT_MM=GTK_UNIT_MM,
-		GNOME_SCAN_UNIT_BIT,
-		GNOME_SCAN_UNIT_DPI,
-		GNOME_SCAN_UNIT_PERCENT,
-		GNOME_SCAN_UNIT_MICROSECOND
-	} GnomeScanUnit;
-
 const gchar*
 gnome_scan_enum_get_nick_from_value (GType type, guint value);
 
-gdouble gnome_scan_convert							(gdouble val,
-													 GnomeScanUnit from,
-													 GnomeScanUnit to,
-													 gdouble res);
-
-gdouble gnome_scan_convert_to_mm					(gdouble val,
-													 GnomeScanUnit unit,
-													 gdouble res);
-
-gdouble gnome_scan_convert_from_mm					(gdouble val,
-													 GnomeScanUnit unit,
-													 gdouble res);
-
-GnomeScanRectangle*
-gnome_scan_rectangle_convert 			(GnomeScanRectangle *r,
-										 GnomeScanUnit from,
-										 GnomeScanUnit to,
-										 gdouble res);
-GnomeScanRectangle*
-gnome_scan_rectangle_convert_to_mm		(GnomeScanRectangle *r,
-										 GnomeScanUnit unit,
-										 gdouble res);
-
-GnomeScanRectangle*
-gnome_scan_rectangle_convert_from_mm	(GnomeScanRectangle *r,
-										 GnomeScanUnit unit,
-										 gdouble res);
-
-GnomeScanRectangle*
-gnome_scan_rectangle_rotate (GnomeScanRectangle *r,
-							 GnomeScanRectangle *a,
-							 guint angle);
-
 #define gs_debug_rect(r) g_debug(G_STRLOC ": " #r " = %ix%i+%i+%i", (r)->width, (r)->height, (r)->x, (r)->y)
 #define gs_debug_gsrect(r) g_debug(G_STRLOC ": " #r " = %.2fx%.2f+%.2f+%.2f", (r)->width, (r)->height, (r)->x, (r)->y)
 

Modified: trunk/modules/gsane-meta-param.c
==============================================================================
--- trunk/modules/gsane-meta-param.c	(original)
+++ trunk/modules/gsane-meta-param.c	Tue May  6 15:14:19 2008
@@ -407,7 +407,7 @@
 	g_value_init (real, G_TYPE_DOUBLE);
 	g_value_init (trans, G_PARAM_SPEC_VALUE_TYPE (mpps->tl_x));
 	g_param_value_set_default (mpps->tl_x, trans);
-	GnomeScanRectangle *r, *u; /* rotation, unit */
+	GnomeScanRectangle *r; /* rotation */
 	guint unit = gs_param_spec_get_unit (mpps->tl_x);
 	
 	
@@ -420,16 +420,16 @@
 	g_free(v);															\
 	var = g_value_get_double(real);
 	
-	r = gnome_scan_rectangle_rotate (&mpps->roi, &mpps->area, mpps->rotation);
-	u = gnome_scan_rectangle_convert_from_mm (r, unit, mpps->resolution);
-	g_free(r);
-	
-	set_opt(tl_x, u->x);
-	set_opt(tl_y, u->y);
-	set_opt(br_x, u->x + u->width);
-	set_opt(br_y, u->y + u->height);
+	r = g_memdup(&mpps->roi, sizeof(GnomeScanRectangle));
+	gnome_scan_rectangle_rotate (r, &mpps->area, mpps->rotation);
+	gnome_scan_rectangle_convert_from_mm (r, unit, mpps->resolution);
+	
+	set_opt(tl_x, r->x);
+	set_opt(tl_y, r->y);
+	set_opt(br_x, r->x + r->width);
+	set_opt(br_y, r->y + r->height);
 	
-	g_free(u);  
+	g_free(r);
 	
 	g_value_unset (trans);
 	g_free (trans);

Modified: trunk/modules/gsane-scanner.c
==============================================================================
--- trunk/modules/gsane-scanner.c	(original)
+++ trunk/modules/gsane-scanner.c	Tue May  6 15:14:19 2008
@@ -806,7 +806,7 @@
 		break;
 	}
 	
-	enumclass = g_type_class_ref (GNOME_TYPE_SCAN_UNIT);
+	enumclass = g_type_class_ref (GNOME_SCAN_TYPE_UNIT);
 	enumvalue = g_enum_get_value (enumclass, unit);
 	g_type_class_unref (enumclass);
 	



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